Airgentic Help
Use the Document Ingestion API to upload documents to an Airgentic service from an external system. Uploaded documents can be optionally indexed for search and/or handed off to a customer-defined processor script for further handling.
This is the programmatic equivalent of the Upload Documents screen.
You need:
The API key must be passed in the api-key request header.
Use the following endpoint:
POST https://admin.airgentic.com/api/accounts/{account_id}/services/{service_id}/document-ingestions
The request body must be multipart/form-data.
| Parameter | Required | Description |
|---|---|---|
account_id |
Yes | Your Airgentic account ID |
service_id |
Yes | The service ID the document belongs to |
| Header | Required | Description |
|---|---|---|
api-key |
Yes | The Document Ingestion API key from the Security screen |
Content-Type |
Yes | Must be multipart/form-data |
| Field | Required | Description |
|---|---|---|
file |
Yes | The document binary. Up to 500 MB |
filename |
Yes | The filename to store the document as. Used as-is when saving to disk and indexing |
mime_type |
Yes | One of: text/csv, application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, text/html |
visibility |
Yes | Either public (anyone who clicks a citation link can view the file) or private (only authenticated users of a Secure Service can view it) |
index |
No | true to also start a search-index build that includes the new document, false (default) to only store the file |
processor_id |
No | Name of a customer-defined Python script to run after the file is saved. See Processor Scripts below |
visibility controls where the file is stored — public files are saved to the same location as the Public Documents tab on the Upload Documents screen, private files are saved to the Secure Documents location.
curl -X POST \
-H "api-key: <API Key>" \
-F "file=@/path/to/fitment.csv" \
-F "filename=fitment.csv" \
-F "mime_type=text/csv" \
-F "visibility=private" \
-F "index=false" \
-F "processor_id=fitment_ingestor" \
"https://admin.airgentic.com/api/accounts/<account ID>/services/<service ID>/document-ingestions"
To upload a public PDF and rebuild the search index for the service:
curl -X POST \
-H "api-key: <API Key>" \
-F "file=@/path/to/handbook.pdf" \
-F "filename=handbook.pdf" \
-F "mime_type=application/pdf" \
-F "visibility=public" \
-F "index=true" \
"https://admin.airgentic.com/api/accounts/<account ID>/services/<service ID>/document-ingestions"
On success the API returns 201 Created with a JSON body describing the ingestion job:
{
"ingestion_id": "8b4d6c57-8b5a-4b1d-a442-6a85e7e3958c",
"account_id": "your-account",
"service_id": "your-service",
"processor_id": "fitment_ingestor",
"processor_invoked": true,
"filename": "fitment.csv",
"mime_type": "text/csv",
"visibility": "private",
"indexed": false,
"file_size_bytes": 14238,
"status": "completed"
}
| Field | Description |
|---|---|
ingestion_id |
Unique ID for this ingestion job. Useful when correlating logs |
account_id |
Account the document was uploaded to |
service_id |
Service the document was uploaded to |
processor_id |
The processor script name supplied in the request, or null if none |
processor_invoked |
true when a processor script was located and a subprocess was spawned to run it. Always false when processor_id was omitted |
filename |
The filename the document was stored as |
mime_type |
The MIME type that was accepted |
visibility |
public or private, matching the request |
indexed |
true when an indexing job was requested |
file_size_bytes |
Number of bytes received and written to disk |
status |
completed (file stored), processing / queued (indexing in progress), or failed (file stored but indexing did not start) |
The optional processor_id field lets you trigger a customer-defined Python script after the file has been saved to disk. This is useful for transforming the upload into a different format, loading rows into another system, or enriching it before downstream use.
text
conf/<account_id>/<service_id>/<processor_id>.py
For example, processor_id=fitment_ingestor maps to conf/centuryyuasa/centurybatteries/fitment_ingestor.py.
```python
import sys
def main(document_path: str) -> None:
print(f"Got document: {document_path}")
if name == "main":
main(sys.argv[1])
```
.py extension) in the processor_id form field.processor_invoked: true only confirms that the subprocess was started, not that it has finished.processor_id must contain only letters, digits, and underscores (^[A-Za-z0-9_]+$)..py file must already exist in the service's config directory before the upload is sent. If it does not, the request fails with 404 Not Found and the document is not saved.| Status | Meaning |
|---|---|
400 Bad Request |
A required form field is missing, visibility is not public/private, processor_id contains invalid characters, or the multipart body is malformed |
401 Unauthorized |
The api-key header is missing or invalid |
403 Forbidden |
The Document Ingestion API is not enabled for this service (no key has been generated) |
404 Not Found |
The account, service, or named processor script could not be found |
413 Payload Too Large |
The uploaded file exceeds the 500 MB limit |
415 Unsupported Media Type |
The mime_type is not one of the allowed types |
500 Internal Server Error |
Airgentic could not save the file or create the ingestion job |
ingestion_id is the canonical reference for that job.index=true triggers the same indexing pipeline used by the Upload Documents screen. Indexing runs asynchronously — status: "processing" in the response means the indexing job has been queued, not that it has finished.