Docu-Analyzer
The DocuAnalyzer API uploads document files for content analysis and returns various types of results (XML, MD, JSON) as a Zip file.
After analysis, you can also automatically assign the resulting document to a specific project. Use the GET /projects/summary API to retrieve your project IDs.
All API requests require API key authentication.
Authentication
All API requests must include an API key in the HTTP header. The API key follows Bearer token authentication.
| Header | Value |
|---|---|
Authorization |
Bearer {API_KEY} |
Replace {API_KEY} with your actual issued API key in the request.
Endpoint
`POST /analyze`
Uploads a document file and processes the entire asynchronous flow of conversion, status check, and result retrieval in one request, returning the final result (ZIP).
You can select the desired result file format using the outputFormats parameter. The default value is json.
Request Examples
cURL
# Basic usage (default: json)
curl -X POST 'https://synapfoundry.ai/api/v1/docu-analyzer/analyze' \
-H 'Authorization: Bearer {API_KEY}' \
-F 'file=@{FILE_PATH}' \
-o result.zip
# Select specific format (xml)
curl -X POST 'https://synapfoundry.ai/api/v1/docu-analyzer/analyze?outputFormats=xml' \
-H 'Authorization: Bearer {API_KEY}' \
-F 'file=@{FILE_PATH}' \
-o result.zip
# Select multiple formats (xml, json, md)
curl -X POST 'https://synapfoundry.ai/api/v1/docu-analyzer/analyze?outputFormats=xml&outputFormats=json&outputFormats=md' \
-H 'Authorization: Bearer {API_KEY}' \
-F 'file=@{FILE_PATH}' \
-o result.zip
# Assign document to a specific project after analysis
curl -X POST 'https://synapfoundry.ai/api/v1/docu-analyzer/analyze' \
-H 'Authorization: Bearer {API_KEY}' \
-F 'file=@{FILE_PATH}' \
-F 'projectId={PROJECT_ID}' \
-o result.zipPython
import requests
api_key = "{API_KEY}"
file_path = "/path/to/your/file.ext"
url = "https://synapfoundry.ai/api/v1/docu-analyzer/analyze"
headers = { "Authorization": f"Bearer {api_key}" }
# Optional: Add outputFormats parameter
params = { "outputFormats": ["xml", "json"] }
with open(file_path, "rb") as file:
files = { "file": file }
# Optional: Add projectId to assign the document to a project after analysis
data = { "projectId": "{PROJECT_ID}" }
response = requests.post(url, headers=headers, files=files, data=data, params=params)
with open("result.zip", "wb") as f:
f.write(response.content)Node.js
const axios = require('axios');
const fs = require('fs');
const FormData = require('form-data');
const apiKey = "{API_KEY}";
const filePath = "/path/to/your/file.ext";
// Optional: Add outputFormats parameter
const url = 'https://synapfoundry.ai/api/v1/docu-analyzer/analyze?outputFormats=xml&outputFormats=json';
const form = new FormData();
form.append('file', fs.createReadStream(filePath));
// Optional: Add projectId to assign the document to a project after analysis
form.append('projectId', '{PROJECT_ID}');
const headers = {
...form.getHeaders(),
'Authorization': `Bearer ${apiKey}`,
};
axios.post(url, form, {
headers: headers,
responseType: 'stream'
}).then(response => {
response.data.pipe(fs.createWriteStream('result.zip'));
}).catch(error => {
console.error('Error:', error.response?.data || error.message);
});Headers
| Parameter | Type | Description |
|---|---|---|
| Authorization | string |
Bearer token for API request authentication. Must be provided in the format Bearer {API_KEY}. |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| outputFormats | string[] |
No | Result file format (multiple selections allowed). Allowed values: xml, json, md. Default is json. |
Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| file | file |
Yes | The document file to be analyzed. |
| projectId | string |
No | The external ID of the project to assign the document to after analysis. Use the id value retrieved from GET /projects/summary. |
Success Responses
| Status Code | Media Type | Description |
|---|---|---|
| 200 OK | application/zip |
When analysis is successful and one or more result files exist, returns a ZIP file. |
Error Responses
| Status Code | Message | Description |
|---|---|---|
400 Bad Request |
The 'file' field is missing in the request body (form-data). |
Returned when the file field containing file data cannot be found in a multipart/form-data request. |
400 Bad Request |
The format '{format}' you entered is not supported. (Supported formats: xml, md, json) |
Returned when an invalid format is passed in the outputFormats parameter. |
400 Bad Request |
projectId cannot be empty. |
Returned when the projectId field is provided as an empty string. |
404 Not Found |
Project not found |
Returned when no project matching the given projectId is found, or you do not own that project. |
402 Payment Required |
Insufficient credits to perform document analysis. |
Returned when the remaining credits in the account are less than required for document analysis. |
413 Payload Too Large |
The uploaded file exceeds the server limit of 100MB. |
Returned when the size of a single uploaded file exceeds the maximum size (100MB) allowed by the server. |
415 Unsupported Media Type |
Unsupported file format. |
Returned when the format of the uploaded file is not supported by the server. |
500 Internal Server Error |
Failed to process the request due to an internal server error. Please try again later. If the problem persists, please contact the administrator. |
Returned when request processing fails due to an unexpected internal server issue. |
`GET /projects/summary`
Returns the external ID (id) and name (name) of projects owned by the authenticated API key client.
Use the id values from this response as the projectId parameter in POST /analyze.
Request Examples
cURL
curl -X GET 'https://synapfoundry.ai/api/v1/projects/summary' \
-H 'Authorization: Bearer {API_KEY}'Python
import requests
api_key = "{API_KEY}"
url = "https://synapfoundry.ai/api/v1/projects/summary"
headers = { "Authorization": f"Bearer {api_key}" }
response = requests.get(url, headers=headers)
projects = response.json()Node.js
const axios = require('axios');
const apiKey = "{API_KEY}";
const url = 'https://synapfoundry.ai/api/v1/projects/summary';
axios.get(url, {
headers: { 'Authorization': `Bearer ${apiKey}` }
}).then(response => {
console.log(response.data);
}).catch(error => {
console.error('Error:', error.response?.data || error.message);
});Headers
| Parameter | Type | Description |
|---|---|---|
| Authorization | string |
Bearer token for API request authentication. Must be provided in the format Bearer {API_KEY}. |
Success Responses
| Status Code | Media Type | Description |
|---|---|---|
| 200 OK | application/json |
Returns the list of owned projects. |
Response Example
[
{
"id": "Ab1Cd2Ef3G",
"name": "My Project"
},
{
"id": "Xy9Zw8Vt7U",
"name": "Analysis Project"
}
]Response Fields
| Field | Type | Description |
|---|---|---|
| id | string |
The external identifier of the project (10-character alphanumeric string). Use this value as projectId in POST /analyze. |
| name | string |
The name of the project. |
Error Responses
| Status Code | Message | Description |
|---|---|---|
401 Unauthorized |
- | Returned when the request is made with an invalid or expired API key. |
500 Internal Server Error |
Failed to process the request due to an internal server error. |
Returned when request processing fails due to an unexpected internal server issue. |