Skip to content

Rest API

Create or update a document

POST
/api/v1/ai/training/documents
curl --request POST \
--url https://api.unless.com/api/v1/ai/training/documents \
--header 'Content-Type: application/json' \
--header 'x-account-id: example' \
--header 'x-api-key: example' \
--header 'x-user-email: example' \
--header 'x-website-id: example' \
--data '{ "document": { "trainingDataId": "example", "websiteId": "example", "title": "example", "body": "example", "segmentId": "example", "restrictedAudiences": [ "example" ] } }'

Add a document to the knowledge base, or update one by passing its trainingDataId. A document is a title with a markdown body. Unless trains the AI on it and adds it to the content library.

Use cases

  • Fill a knowledge gap: Write down the answer to a question the AI could not answer
  • Add internal knowledge: Add a policy, procedure or how-to that is not on a website or in a file
  • Correct a document: Update the title or body of a document created earlier

Notes

  • Omit document.trainingDataId to create a new document, pass it to update that document. Documents show up as sources of type faq in the get training data endpoint
  • document.websiteId must match the x-website-id header
  • The body is markdown: use headings, lists, tables and links to structure longer documents
  • The title and body together may be at most 20000 characters
  • Ingestion runs asynchronously, poll the get training data endpoint to follow progress
x-api-key
required
string

Your API key from account settings.

x-user-email
required
string

The email address of your user.

x-account-id
required
string

The ID of your account. You can find this in the account settings.

x-website-id
required
string

The ID of the workspace you want to use.

Media typeapplication/json
object
document
required
object
trainingDataId

ID of an existing document to update. Omit to create a new document.

string
websiteId
required

Must match the x-website-id header.

string
title
required

Title of the document. Used as its name in the dashboard and as its title in AI sources.

string
>= 1 characters <= 20000 characters
body
required

Content of the document in markdown.

string
>= 1 characters <= 20000 characters
segmentId

Segment to train the document into. Omit to keep the current segment, null for the global knowledge base.

string
nullable
restrictedAudiences

Audience IDs that may use this document. An empty list removes the restriction, omit to keep the current one.

Array<string>

Example generated

{
"document": {
"trainingDataId": "example",
"websiteId": "example",
"title": "example",
"body": "example",
"segmentId": "example",
"restrictedAudiences": [
"example"
]
}
}

The document was saved and ingestion was started.

Media typeapplication/json
object
message
string
trainingDataId
string

Example

{
"message": "Document upserted",
"trainingDataId": "3f2b8c1e-5d4a-4e7b-9c0f-1a2b3c4d5e6f"
}

Invalid document, too long, or the trainingDataId is not a document in this workspace.

Unauthorized - invalid API key.