Skip to main content

Agent Documents API Documentation

GET: Retrieve Documents​

Description​

This route is used to retrieve a list of documents for a specific Agent.

Method​

GET

URL Parameters​

  • AgentId (string): The ID of the Agent to retrieve documents for.

Query Parameters​

  • sort (string): The field by which to sort the documents.
  • page (number): The page number of the results.
  • limit (number): The number of items per page.

Response​

  • Returns a JSON response with the list of documents or an error message.

Status Codes​

  • 200 OK: Documents retrieved successfully.
  • 500 Internal Server Error: Error listing documents.

Throws​

  • An error if request validation or document retrieval fails.

Example cURL​

curl --location 'https://app.ai12z.net/api/Agents/{AgentId}/documents' \
--header 'Authorization: Bearer <YOUR_KEY>' \
--data-urlencode 'sort=name' \
--data-urlencode 'page=1' \
--data-urlencode 'limit=10'

GET: Retrieve Document By Id​

Description​

This route is used to retrieve a document for a specific id.

Method​

GET

URL Parameters​

  • AgentId (string): The ID of the Agent to retrieve documents for.
  • id (string): The ID of the document to retrieve.

Response​

  • Returns a JSON response with the document or an error message.

Status Codes​

  • 200 OK: Document retrieved successfully.
  • 500 Internal Server Error: Error listing documents.

Throws​

  • An error if request validation or document retrieval fails.

Example cURL​

curl --location 'https://app.ai12z.net/api/Agents/{AgentId}/documents/{id}' \
--header 'Authorization: Bearer <YOUR_KEY>'

DELETE: Delete a Document​

Description​

This route is used to delete a specific document.

Method​

DELETE

Request Body​

Example request body:

{
"id": "document ID"
}

Response​

  • Returns the result of the document deletion.

Status Codes​

  • 200 OK: Document deleted successfully.
  • 500 Internal Server Error: Error during deletion.

Throws​

  • An error if request validation, body parsing, or document deletion fails.

Example cURL​

curl --location --request DELETE 'https://app.ai12z.net/api/Agents/{AgentId}/documents' \
--header 'Authorization: Bearer <YOUR_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": "document ID"
}'

POST: Ingest a website​

Description​

This route allows ingesting of a website. It is a two steps process.

1. Create histogram / sitemap​

Method​

POST

URL Parameters​
  • AgentId (string): The ID of the Agent to which the document will be attached.
Request Body​
  • Example request body:
{
"name": "Smple Website Demo",
"url": "https://ai12z.com/",
"description": "This is a description",
"type": "sitemap"
}
Response​
  • Returns the document metadata.
Status Codes​
  • 200 OK: Document added successfully.
  • 500 Internal Server Error: Error processing the request.
Throws​
  • An error if the request validation or add document fails.
Example cURL​
curl --location 'https://app.ai12z.net/api/Agents/{AgentId}/documents' \
--header 'Authorization: Bearer <YOUR_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"name": "Smple Website Demo",
"url": "https://ai12z.com/",
"description": "This is a description",
"type": "sitemap"
}'

2. Ingest histogram / sitemap​

Before continue with this step check to see if document previous step is sucess. You can use the get document by id to get the ingest status.

Method​

PUT

URL Parameters​
  • AgentId (string): The ID of the Agent to which the document will be attached.
Request Body​
  • Example request body:
{
"type": "application/website"
}
Response​
  • Returns the document metadata.
Status Codes​
  • 200 OK: Document added successfully.
  • 500 Internal Server Error: Error processing the request.
Throws​
  • An error if the request validation or add document fails.
Example cURL​
curl --location --request PUT 'https://app.ai12z.net/api/Agents/{AgentId}/documents' \
--header 'Authorization: Bearer <YOUR_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"type": "application/website"
}'

POST: Ingest a file / html by URL​

Description​

This route allows adding a new document type url to a Agent.

Method​

POST

URL Parameters​

  • AgentId (string): The ID of the Agent to which the document will be attached.

Request Body​

  • Example request body:
{
"name": "Sample Url",
"url": "https://gdlp01.c-wss.com/gds/5/0300003415/02/ef85f18usm-im3-eng.pdf",
"description": "A sample url",
"type": "application/link"
}

Response​

  • Returns the uploaded document metadata.

Status Codes​

  • 200 OK: Document uploaded successfully.
  • 400 Bad Request: No file received.
  • 500 Internal Server Error: Error processing the request.

Throws​

  • An error if the request validation or file upload fails.

Example cURL​

curl --location 'https://app.ai12z.net/api/Agents/{AgentId}/documents' \
--header 'Authorization: Bearer <YOUR_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sample Url",
"url": "https://gdlp01.c-wss.com/gds/5/0300003415/02/ef85f18usm-im3-eng.pdf",
"description": "A sample url",
"type": "application/link"
}'

POST: Ingest an uploaded file​

Description​

This route allows uploading a new document to a Agent.

Method​

POST

URL Parameters​

  • AgentId (string): The ID of the Agent to which the document will be attached.

Request Body​

  • When adding a file:

    • Form-data:
      • file (File): The document to upload (e.g., .pdf, .docx).
      • description (Text): A description of the document.
  • Example request body:

{
"file": "example.pdf",
"description": "This is a file document"
}

Response​

  • Returns the uploaded document metadata.

Status Codes​

  • 200 OK: Document uploaded successfully.
  • 400 Bad Request: No file received.
  • 500 Internal Server Error: Error processing the request.

Throws​

  • An error if the request validation or file upload fails.

Example cURL​

curl --location 'https://app.ai12z.net/api/Agents/{AgentId}/documents' \
--header 'Authorization: Bearer <YOUR_KEY>' \
--header 'Content-Type: multipart/form-data' \
--form 'file=@"/path/to/document.pdf"' \
--form 'description="This is a file document"'

PUT: Update a Document​

Description​

This route is used to update an existing document.

Method​

PUT

Request Body​

Example request body:

{
"id": "Document ID",
"description": "Updated description of the document"
}

Response​

  • Returns the updated document metadata.

Status Codes​

  • 200 OK: Document updated successfully.
  • 500 Internal Server Error: Error updating the document.

Throws​

  • An error if request validation or document update fails.

Example cURL​

curl --location --request PUT 'https://app.ai12z.net/api/Agents/{AgentId}/documents' \
--header 'Authorization: Bearer <YOUR_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": "Document ID",
"description": "Updated description"
}'