SteveAI API Docs
The SteveAI API is a RESTful API that allows you to pass document images and retrieve document data in JSON format.
Endpoint
POST /api/documents/list
Request Body
- documentIds: An array of document IDs specifying the documents to be retrieved.
- type: The type of the documents to be returned.
Default is "document". Valid types are:
- form_w2
- form_1095_a
- receipt
- pay_stub
- invoice
- utility_bill
- bank_statement
- page: The page number of the results to be returned. Default is 1.
Headers
- Authorization: API key for authentication.
Response
- 200 OK: The request was successful, and the document list is returned.
- 404 Not Found: No documents found with the provided IDs.
- 401 Unauthorized: The request lacks valid authentication credentials.
- 500 Internal Server Error: An error occurred during processing.
Example Response
{
"page": 1,
"perPage": 50,
"totalItems": 1,
"totalPages": 1,
"items": [
{
"collectionId": "atbvlpzbwm07ahj",
"collectionName": "documents",
"created": "2024-05-06 20:20:00.940Z",
"deleted_at": "",
"document_date": "",
"establishment_name": "THE HOME DEPOT",
"id": "248go9wck66eux7",
"image_uri": "s3://test-raw-documents-bucket/a3de0e54-3264-4a8c-8b03-23685e79c848",
"industry": "Retail",
"json": {
"industry": "Retail",
"establishment_name": "THE HOME DEPOT",
"total_amount": 33.48,
"date": "04/09/24",
"processed_at": "2024-05-06T15:19:57-05:00",
"s3_uri": "s3://test-raw-documents-bucket/a3de0e54-3264-4a8c-8b03-23685e79c848",
"user_id": "ntbjbdw5qtyiuxw",
"organization_id": "44yl8trbin9hkuw",
"status": "success",
"items": [
{"name": "WATERMEILD <A>", "price": 7.48},
{"name": "SEED WATERMEILD EPOXY PUTTY <A>", "price": 2.05},
{"name": "GORILLA PATCH & SEAL WHITE 4 X 10", "price": 14.97},
{"name": "GORILLA GLUE 4 OZ", "price": 6.48}
]
},
"organization_id": "44yl8trbin9hkuw",
"processed_at": "2024-05-06 20:19:57.000Z",
"status": "success",
"team_id": "",
"updated": "2024-05-06 20:20:00.940Z",
"user_id": "ntbjbdw5qtyiuxw",
"uuid": "3e7992a8-b655-4feb-a6e2-e7aa33a14f1b",
"expand": {}
}
]
}
Errors
- 401 Unauthorized: If the provided API key is invalid or missing.
- 404 Not Found: If no document is found with the provided ID.
- 500 Internal Server Error: If an error occurs during the processing pipeline.
Notes
- Ensure that the document IDs provided are correct to retrieve the correct document data.
Endpoint
GET /api/documents/:id
Request Parameters
- id: The unique identifier of the document to be retrieved.
Headers
- Authorization: API key for authentication.
Response
- 200 OK: The request was successful, and the document data is returned.
- 404 Not Found: No document found with the provided ID.
- 401 Unauthorized: The request lacks valid authentication credentials.
- 500 Internal Server Error: An error occurred during processing.
Example Response
{
"document": {
"id": "RECORD_ID",
"collectionId": "ge8cu104curgiyy",
"collectionName": "documents",
"created": "2022-01-01 01:00:00.123Z",
"updated": "2022-01-01 23:59:59.456Z",
"uuid": "test",
"establishment_name": "test",
"industry": "test",
"document_date": "2022-01-01 10:00:00.123Z",
"processed_at": "2022-01-01 10:00:00.123Z",
"user_id": "test",
"team_id": "test",
"organization_id": "test",
"image_uri": "test",
"json": "{
"industry": "Grocery store, Starbucks, Laundry cleaning and closet",
"establishment_name": "Austin Arboretum",
"total_amount": 45.22,
"date": "03/06/2024",
"processed_at": "2024-05-06T20:58:18Z",
"s3_uri": "s3://some-bucket/f40895fc-3d45-4769-9603-8b0d2ab56fe4",
"user_id": "hqpzer8kr97ovuz",
"organization_id": "h4soa4jfjrztt6h",
"status": "success",
"items": [
{
"name": "GROCERY",
"price": 35.49
},
{
"name": "LAUNDRY CLEANING AND CLOSET",
"price": 8.99
},
{
"name": "DRANO",
"price": 0
}
]
}",
"deleted_at": "",
"status": "waiting"
}
}
Errors
- 401 Unauthorized: If the provided API key is invalid or missing.
- 404 Not Found: If no document is found with the provided ID.
- 500 Internal Server Error: If an error occurs during the processing pipeline.
Notes
- Ensure that the ID provided is correct to retrieve the correct document data.
Endpoint
POST /api/documents/process
Request Body Format
This is a multipart/form-data POST request. The request body should include the following fields:
- document: An image file of the document to be processed. This should be included as a file upload.
- endpoint_url: A string specifying the URL of the webhook to which the processed data will be sent.
- endpoint_body: A JSON-formatted string that specifies the custom body to be included in the webhook request.
Headers
- Authorization: API key for authentication.
Response
- 200 OK: The request was successful, and the document processing pipeline has been initiated and the new document ID is returned.
- 401 Unauthorized: The request lacks valid authentication credentials.
- 500 Internal Server Error: An error occurred during processing.
Example Response
{ "ok": true, "documentId": "123" }
Errors
- 401 Unauthorized: If the provided API key is invalid or missing.
- 500 Internal Server Error: If an error occurs during the processing pipeline.
Notes
- If the uploaded file is in HEIC format, it will be converted to JPEG format before processing.
- The processed data will be sent to the provided webhook URL with the custom body specified by the user.
To upload a document image, ensure you set the content type encoding to multipart form. Below is an example successful CURL request:
curl -XPOST \
-H "Authorization: YOUR_API_KEY" \
-F "document=@YOUR_IMAGE_PATH" \
-F "endpoint_url=YOUR_WEBHOOK_URL" \
-F "endpoint_body=YOUR_WEBHOOK_JSON_BODY" \
"https://beta.steveai.io/api/documents/process"
Webhook Payload Example
When the processing pipeline is complete, the following JSON representation of the document is sent to the webhook:
{
"document": {
"id": "RECORD_ID",
"collectionId": "ge8cu104curgiyy",
"collectionName": "documents",
"created": "2022-01-01 01:00:00.123Z",
"updated": "2022-01-01 23:59:59.456Z",
"uuid": "test",
"establishment_name": "test",
"industry": "test",
"document_date": "2022-01-01 10:00:00.123Z",
"processed_at": "2022-01-01 10:00:00.123Z",
"user_id": "test",
"team_id": "test",
"organization_id": "test",
"image_uri": "test",
"json": "{
"industry": "Grocery store, Starbucks, Laundry cleaning and closet",
"establishment_name": "Austin Arboretum",
"total_amount": 45.22,
"date": "03/06/2024",
"processed_at": "2024-05-06T20:58:18Z",
"s3_uri": "s3://prod-raw-documents-bucket/f40895fc-3d45-4769-9603-8b0d2ab56fe4",
"user_id": "hqpzer8kr97ovuz",
"organization_id": "h4soa4jfjrztt6h",
"status": "success",
"items": [
{
"name": "GROCERY",
"price": 35.49
},
{
"name": "LAUNDRY CLEANING AND CLOSET",
"price": 8.99
},
{
"name": "DRANO",
"price": 0
}
]
}",
"deleted_at": "",
"status": "waiting"
},
"endpoint_body": {
"custom_field": "custom_value"
}
}
Field Descriptions
- document: A JSON object containing details about the processed document.
- industry: The sector or industry associated with the document.
- establishment_name: The name of the establishment from which the document was issued.
- total_amount: The total monetary amount listed on the document.
- date: The date when the transaction on the document took place.
- processed_at: The timestamp indicating when the document was processed by the system.
- s3_uri: The Amazon S3 URI where the document image is stored.
- status: The processing status of the document, 'success' or 'failed'.
- items: An array of items purchased, each item is a JSON object containing the item's name and price.
- endpoint_body: A JSON object that was sent to the webhook URL. It contains custom data specified by the user.
Endpoint
POST /api/documents/bulk-process
Request Body Format
This is a multipart/form-data POST request. The request body should include the following fields:
- documents: An array of image files to be processed. These should be included as file uploads. We currently support a maximum of 10 files at a combined total size of 25MB per bulk process request.
- endpoint_url: A string specifying the URL of the webhook to which the processed data will be sent.
- endpoint_body: A JSON-formatted string that specifies the custom body to be included in the webhook request.
Headers
- Authorization: API key for authentication.
Response
- 200 OK: The request was successful, and the document processing pipeline has been initiated. The IDs of the processed documents are returned.
- 401 Unauthorized: The request lacks valid authentication credentials.
- 402 Payment Required: The account is delinquent.
- 400 Bad Request: No files were uploaded, or the file limit was exceeded.
- 500 Internal Server Error: An error occurred during processing.
Example Response
{
"ok": true,
"documentIds": [
"bcd123efg456",
"hij789klm012"
]
}
Errors
- 401 Unauthorized: If the provided API key is invalid or missing.
- 402 Payment Required: If the account is delinquent.
- 400 Bad Request: If no files are uploaded or the maximum file limit is exceeded.
- 500 Internal Server Error: If an error occurs during the processing pipeline.
Notes
- Ensure that the uploaded files are valid images and adhere to the maximum file limit of 25.
- The processed data will be sent to the provided webhook URL with the custom body specified by the user.