What is a Client Secret?
The Client ID and Client Secret are secure credentials that allow external applications to interact with our platform APIs. You can use them to Upload documents and Extract structured data using a selected template.
Step 1: How to Generate a Client Secret
-
Go to the Sidebar
- Navigate to Client Secret from the left-side menu.
-
Click “Generate Client Secret”
- You will see a button labeled Generate Client Secret. Click it to create a new set of credentials.
-
Copy Immediately - The credentials will be shown only once:
- Client ID
- Client Secret
- Generated Timestamp
-
Download Credentials (Recommended)
- Click the Download button to store your credentials in a JSON file securely.
- Once saved, these credentials can be reused for API access.
Step 2: How to Use the Credentials in API Requests
Add Headers to Every Request:
X-Client-Id: your-client-id
X-Client-Secret: your-client-secret
- Replace your-client-id and your-client-secret with the values you generated.
Step 3: API Endpoints Available
Extracted Data API
- Method: GET
- Endpoint: https://papex.sholas.io/api/v1/extracted
Use this to fetch extracted data for previously uploaded files.
Step 4: Process PDF with Template
- Method: POST
- Endpoint: https://papex.sholas.io/api/v1/process
Use this to process a PDF using a specific template name. You must send:
- File (PDF)
- Template name in the request body
Security Guidelines
-
One-Time Visibility
The client secret is shown only once. Store it securely.
-
Use Secure Storage
Do not hardcode or expose your credentials in frontend code or public spaces.
-
Regenerate If Needed
If credentials are compromised, regenerate a new set and delete the old one.
-
Important: If you lose the secret, you must generate a new one. It cannot be retrieved later.
API Integration Code Samples
- Python
- Java
- .Net
- Node.js
import requests
# Replace with your actual credentials
CLIENT_ID = 'your-client-id'
CLIENT_SECRET = 'your-client-secret'
BASE_URL = 'https://papex.sholas.io/v1'
HEADERS = {
'X-Client-Id': CLIENT_ID,
'X-Client-Secret': CLIENT_SECRET
}
def process_document(file_path, prompt_type='invoice', split_by_page=True):
"""
Upload a document and process it using a template.
"""
with open(file_path, 'rb') as f:
files = {
'file': (file_path, f, 'application/octet-stream')
}
data = {
'promptType': prompt_type,
'splitByPage': str(split_by_page).lower() # 'true' or 'false'
}
response = requests.post(
f'{BASE_URL}/process',
headers=HEADERS,
files=files,
data=data
)
print(" Process Document Response:")
print(response.status_code, response.text)
def get_extracted_data():
"""
Fetch all previously extracted document data.
"""
response = requests.get(f'{BASE_URL}/extracted', headers=HEADERS)
print("
Extracted Data Response:")
print(response.status_code, response.text)
def list_templates():
"""
List all available AI extraction templates.
"""
response = requests.get(f'{BASE_URL}/prompts', headers=HEADERS)
print("
List Templates Response:")
print(response.status_code, response.text)
if __name__ == "__main__":
# Run the integrations
process_document('document.pdf', prompt_type='invoice', split_by_page=True)
get_extracted_data()
list_templates()
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files;
public class PapexAPI {
private static final String CLIENT_ID = "your-client-id";
private static final String CLIENT_SECRET = "your-client-secret";
public static void main(String[] args) throws IOException {
processDocument("document.pdf");
getExtractedData();
listTemplates();
}
// 1. Upload and process document
public static void processDocument(String filePath) throws IOException {
String boundary = "Boundary-" + System.currentTimeMillis();
URL url = new URL("https://papex.sholas.io/v1/process");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("X-Client-Id", CLIENT_ID);
conn.setRequestProperty("X-Client-Secret", CLIENT_SECRET);
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
conn.setDoOutput(true);
OutputStream output = conn.getOutputStream();
PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, "UTF-8"), true);
File file = new File(filePath);
// File part
writer.append("--").append(boundary).append("
");
writer.append("Content-Disposition: form-data; name="file"; filename="").append(file.getName()).append(""
");
writer.append("Content-Type: application/pdf
");
writer.flush();
Files.copy(file.toPath(), output);
output.flush();
writer.append("
");
// Prompt type
writer.append("--").append(boundary).append("
");
writer.append("Content-Disposition: form-data; name="promptType"
");
writer.append("invoice
");
// splitByPage
writer.append("--").append(boundary).append("
");
writer.append("Content-Disposition: form-data; name="splitByPage"
");
writer.append("true
");
writer.append("--").append(boundary).append("--
");
writer.close();
printResponse(conn);
}
// 2. Get previously extracted data
public static void getExtractedData() throws IOException {
URL url = new URL("https://papex.sholas.io/v1/extracted");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("X-Client-Id", CLIENT_ID);
conn.setRequestProperty("X-Client-Secret", CLIENT_SECRET);
printResponse(conn);
}
// 3. List all templates
public static void listTemplates() throws IOException {
URL url = new URL("https://papex.sholas.io/v1/prompts");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("X-Client-Id", CLIENT_ID);
conn.setRequestProperty("X-Client-Secret", CLIENT_SECRET);
printResponse(conn);
}
// Helper function to print response
private static void printResponse(HttpURLConnection conn) throws IOException {
int status = conn.getResponseCode();
BufferedReader reader = new BufferedReader(new InputStreamReader(
status >= 400 ? conn.getErrorStream() : conn.getInputStream()
));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
reader.close();
}
}
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class PapexAPI
{
private static readonly string clientId = "your-client-id";
private static readonly string clientSecret = "your-client-secret";
private static readonly string baseUrl = "https://papex.sholas.io/v1";
static async Task Main(string[] args)
{
await ProcessDocument("document.pdf");
await GetExtractedData();
await ListTemplates();
}
// 1. Process document with template
static async Task ProcessDocument(string filePath)
{
using var client = new HttpClient();
using var form = new MultipartFormDataContent();
// Headers
client.DefaultRequestHeaders.Add("X-Client-Id", clientId);
client.DefaultRequestHeaders.Add("X-Client-Secret", clientSecret);
// File
var fileStream = File.OpenRead(filePath);
var fileContent = new StreamContent(fileStream);
fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/octet-stream");
form.Add(fileContent, "file", Path.GetFileName(filePath));
// Other form fields
form.Add(new StringContent("invoice"), "promptType");
form.Add(new StringContent("true"), "splitByPage");
// Send request
var response = await client.PostAsync($"{baseUrl}/process", form);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(" Process Document Response:");
Console.WriteLine(result);
}
// 2. Get all extracted data
static async Task GetExtractedData()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Client-Id", clientId);
client.DefaultRequestHeaders.Add("X-Client-Secret", clientSecret);
var response = await client.GetAsync($"{baseUrl}/extracted");
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine("
📥 Extracted Data Response:");
Console.WriteLine(result);
}
// 3. List all templates
static async Task ListTemplates()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Client-Id", clientId);
client.DefaultRequestHeaders.Add("X-Client-Secret", clientSecret);
var response = await client.GetAsync($"{baseUrl}/prompts");
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine("
Templates List Response:");
Console.WriteLine(result);
}
}
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
// Replace these with your actual credentials
const CLIENT_ID = 'your-client-id';
const CLIENT_SECRET = 'your-client-secret';
const BASE_URL = 'https://papex.sholas.io/v1';
const HEADERS = {
'X-Client-Id': CLIENT_ID,
'X-Client-Secret': CLIENT_SECRET,
};
// 1. Process Document
async function processDocument(filePath, promptType = 'invoice', splitByPage = true) {
try {
const form = new FormData();
form.append('file', fs.createReadStream(filePath));
form.append('promptType', promptType);
form.append('splitByPage', splitByPage.toString());
const response = await axios.post(`${BASE_URL}/process`, form, {
headers: {
...HEADERS,
...form.getHeaders()
}
});
console.log("Process Document Response:");
console.log(response.data);
} catch (error) {
console.error("Error in processDocument:", error.response?.data || error.message);
}
}
// 2. Get Extracted Data
async function getExtractedData() {
try {
const response = await axios.get(`${BASE_URL}/extracted`, { headers: HEADERS });
console.log("Extracted Data Response:");
console.log(response.data);
} catch (error) {
console.error("Error in getExtractedData:", error.response?.data || error.message);
}
}
// 3. List Templates
async function listTemplates() {
try {
const response = await axios.get(`${BASE_URL}/prompts`, { headers: HEADERS });
console.log("List Templates Response:");
console.log(response.data);
} catch (error) {
console.error("Error in listTemplates:", error.response?.data || error.message);
}
}
// Run the functions
(async () => {
await processDocument('document.pdf');
await getExtractedData();
await listTemplates();
})();