The Docpier Intelligent Document Processing (IDP) API enables automated document processing, workspace management, and feedback submission for agents and users. It supports various document types (invoices, credit notes, contracts, etc.) with a normalized JSON structure, ensuring compliance with the Swiss Federal Act on Data Protection (nFADP).
API Base URL
| Environment | Base URL | Description |
|---|---|---|
| Production | https://idp.docpier.com/api/v1 | Live environment for production use. |
| Stage | https://idp-stage.docpier.com/api/v1 | Integration environment. |
Token URL
| Environment | Base URL | Description |
|---|---|---|
| Production | https://auth.docpier.com/realms/idp/protocol/openid-connect/token | Live environment for production use. |
| Stage | https://auth-stage.docpier.com/realms/idp/protocol/openid-connect/token | Integration environment. |
Contact
support@docpier.comto obtain stage credentials.
The API uses Semantic Versioning (MAJOR.MINOR.PATCH):
There is only major version visible (/v1) on the URL path https://.../api/v1
Changelog: https://docpier.com/changelog
The API uses OAuth 2.0 managed by Docpier’s identity provider.
https://auth.docpier.com/realms/idp/protocol/openid-connect/tokenidp.capture — Read and write workspace data.Request an access token using HTTP POST with:
grant_type=client_credentialsclient_id=<<your_client_id>>client_secret=<<your_client_secret>>scope=idp.captureHere’s a full example how to request a client credentials token for Docpier using curl:
curl -X POST https://auth.docpier.com/realms/idp/protocol/openid-connect/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=<<your_client_id>>" \
-d "client_secret=<<your_client_secret>>" \
-d "scope=idp.capture"
The response will include an access_token that can be used in the Authorization header for subsequent API requests.
{
"access_token": "eyJhbGciOi...",
"expires_in": 300,
"token_type": "Bearer",
"scope": "idp.capture"
}
Authorization: Bearer <<access_token>>
Best Practice: Cache tokens, refresh before expiry, store credentials securely.
Upload the PDF as multipart/form-data using the file form field.
curl -X POST 'https://idp.docpier.com/api/v1/workspaces/<<WORKSPACE_ID>>/documents' \
-H 'Authorization: Bearer <<access_token>>' \
-F 'file=@/.../invoice_123.pdf;type=application/pdf'
Notes:
application/jsonapplication/pdfimage/jpeg, image/jpgimage/pngimage/tiffDocpier API responses can be returned as JSON (default) or XML, using standard HTTP content negotiation via the Accept header.
application/jsonAccept: application/xmlContent-Type:
Content-Type: application/jsonContent-Type: application/xmlGET /workspaces/{workspaceId}/documents/{documentId}
Authorization: Bearer <token>
Accept: application/json
GET /workspaces/{workspaceId}/documents/{documentId}
Authorization: Bearer <token>
Accept: application/xml
<documentResponse>
<documentId>01HXYZ987654321FEDCBA</documentId>
<workspaceId>04HXYZ123456789ABCDEF</workspaceId>
<status>COMPLETED</status>
<documentType>INVOICE</documentType>
<!-- ...other fields depending on the document schema... -->
</documentResponse>
Accept is omitted, Docpier returns JSON.The API provides pagination mechanism for clients to query of large amount of data efficiently.
page — The page number (zero-based). Default: 0.size — The number of items per page. Default: 20, Maximum: 100.sort — Optional. Sorting criteria in the format: property,(asc|desc).GET /user/workspaces/ws_abcdef123/documents?page=0&size=10&sort=uploadTime,desc
Authorization: Bearer <token>
{
"content": [ ... ],
"pageable": {
"pageNumber": 0,
"pageSize": 10
},
"totalElements": 123,
"totalPages": 13,
"last": false,
"first": true,
"numberOfElements": 10
}
All errors return standard HTTP status codes with consistent JSON error format.
{
"code": "INVALID_FILE",
"message": "The uploaded file is not a valid PDF."
}
| Code | Meaning |
|---|---|
| 200 | OK |
| 201 | Created |
| 202 | Accepted |
| 400 | Bad Request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
| 413 | Payload Too Large |
| 415 | Unsupported Media Type |
| 429 | Too Many Requests |
| 500 | Internal Server Error |
| Code | Description |
|---|---|
| INVALID_FILE | Invalid file format or corrupted |
| INVALID_TOKEN | Invalid or expired token |
| FORBIDDEN_ACCESS | Insufficient permissions |
| NOT_FOUND | Resource not found |
| RATE_LIMIT_EXCEEDED | Too many requests |
| PROCESSING_FAILED | Processing error |
Best Practice: Implement retry logic with exponential backoff for 429 and 500 errors.
application/json (default)application/pdf, image/jp[e]g, image/png, image/tiffContact support@docpier.com to receive:
client_idclient_secretworkspace_idUse https://idp-stage.docpier.com/api/v1 to integrate your flow.
POST /v1/worspaces/{workspace_id}/documents — Upload documentGET /v1/worspaces/{workspace_id}/documents/{documentId} — Get processed data (poll the result)PATCH /v1/worspaces/{workspace_id}/documents/{documentId}/feedback — Submit feedback| Environment | Limit |
|---|---|
| Production | 100 requests/minute |
| Stage | 20 requests/minute |
X-Rate-Limit-RemainingnFADP object.sequenceDiagram
participant Client as Agent Client
participant API as Docpier IDP API Server
participant Auth as OAuth Provider
participant WebhookReceiver as Client's Webhook Endpoint
Client->>Auth: Request Access Token (Client Credentials)
Auth-->>Client: Return access_token
Client->>API: POST /documents (file upload with Authorization: Bearer <token>)
API-->>Client: 202 Accepted {documentId, processingInfo}
Note over API: Document Processing in Progress...
API->>WebhookReceiver: POST /your-webhook-url (DocumentReadyNotification, {documentId, status: "COMPLETED"})
WebhookReceiver-->>API: 200 OK (Webhook Acknowledged)
Client->>API: GET /documents/{documentId} (Authorization: Bearer <token>)
API-->>Client: 200 OK {items: [...], status: "COMPLETED"}
Client->>API: PATCH /documents/{documentId}/feedback (JSON body with feedback, Authorization: Bearer <token>)
API-->>Client: 200 OK (Feedback successfully received)
This section explains the possible values for all enum fields across the API data models, providing clarity on the expected and accepted values.
documentTypeUsed in: CoreDocument
| Value | Description |
|---|---|
INVOICE | The document is identified as a commercial invoice (Rechnung). |
REMINDER | The document is identified as a payment reminder (Mahnung). |
RECEIPT | The document is identified as a payment receipt (Beeleg). |
ACCOUNT_STATEMENT | The document is identified as a bank account statement (Kontoauszug). |
CREDIT_NOTE | The document is identified as a credit note (Gutschrift). |
SALARY_STATEMENT | The document is identified as a salary statement (Lohnausweis). |
PAY_SLIP | The document is identified as a pay slip (Lohnabrechnung). |
TAX_CERTIFICATE | The document is identified as a tax certificate (Steuerbescheinigung). |
INSURANCE_POLICY | The document is identified as an insurance policy (Versicherungspolice). |
POLICY_ADJUSTMENT | The document is identified as a policy adjustment. The document records a modification, correction, or endorsement to an existing insurance policy |
WARRANTY_POLICY | The document is identified as a warranty policy (Garantieschein). |
CONTRACT | The document is identified as a contract (Vertrag). |
CREDITCARD_STATEMENT | The document is identified as a credit card statement (Kreditkartenauszug). |
UNKNOWN | The document type could not be identified or fully structured by Docpier. |
The GET /documents/{documentId} endpoint returns processed documents in a normalized JSON structure. Each extracted field corresponds to a defined schema property and includes a confidence score (a float between 0.0 and 1.0) indicating the accuracy of the extraction for that specific field.
The top-level response is an array of detected documents, where each document conforms to one of the specific schemas (e.g., Invoice, Credit Note, Account Statement, or UnknownDocument).
support@docpier.comdocumentId and error codes for faster resolution).