API Token

Enter your API token to test the endpoints. This token will be used for all examples on this page.

API Reference

Welcome to the DocumentFlow API Reference. This page provides detailed information about our API endpoints, request/response formats, and example usage.

Base URL

All API requests should be made to:

https://api.documentflow.com/v1

Authentication

To authenticate requests, include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Endpoints

POST
/v1/documents/process

Submit a document for processing.

Parameters

Name
Type
Required
Description
urlstring
Yes
The URL of the document to process
typestring
Yes
The type of document (e.g., 'invoice', 'receipt')

Response

Code Examples


const response = await fetch('https://api.documentflow.com/v1/documents/process', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer ' + apiToken,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    url: 'https://example.com/invoice.pdf',
    type: 'invoice',
  }),
});

const data = await response.json();
console.log(data);
return data;
            
GET
/v1/documents/{id}

Retrieve the current status and results of a processed document.

Parameters

Name
Type
Required
Description
idstring
Yes
The ID of the document to retrieve

Response

Code Examples


const response = await fetch('https://api.documentflow.com/v1/documents/doc_123456', {
  headers: {
    'Authorization': 'Bearer ' + apiToken,
  },
});

const data = await response.json();
console.log(data);
return data;
            
GET
/v1/documents

List all documents.

Parameters

Name
Type
Required
Description
limitnumber
No
Number of documents to return (default: 10, max: 100)
offsetnumber
No
Number of documents to skip (default: 0)

Response

Code Examples


const response = await fetch('https://api.documentflow.com/v1/documents?limit=2', {
  headers: {
    'Authorization': 'Bearer ' + apiToken,
  },
});

const data = await response.json();
console.log(data);
return data;
            
POST
/v1/webhooks

Create a new webhook endpoint.

Parameters

Name
Type
Required
Description
urlstring
Yes
The URL of the webhook endpoint
eventsarray
Yes
Array of event types to subscribe to

Response

Code Examples


const response = await fetch('https://api.documentflow.com/v1/webhooks', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer ' + apiToken,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    url: 'https://example.com/webhook',
    events: ['document.processed', 'document.failed'],
  }),
});

const data = await response.json();
console.log(data);
return data;
            
GET
/v1/webhooks

List all webhook endpoints.

Response

Code Examples


const response = await fetch('https://api.documentflow.com/v1/webhooks', {
  headers: {
    'Authorization': 'Bearer ' + apiToken,
  },
});

const data = await response.json();
console.log(data);
return data;
            
DELETE
/v1/webhooks/{id}

Delete a webhook endpoint.

Parameters

Name
Type
Required
Description
idstring
Yes
The ID of the webhook to delete

Response

Code Examples


const response = await fetch('https://api.documentflow.com/v1/webhooks/webhook_123456', {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer ' + apiToken,
  },
});

if (response.status === 204) {
  console.log('Webhook deleted successfully');
  return { success: true };
} else {
  const errorData = await response.json();
  console.error('Error deleting webhook:', errorData);
  return errorData;
}