Skip to content

Rest API

Ingest a training data source

POST
/api/v1/ai/training/data
curl --request POST \
--url https://api.unless.com/api/v1/ai/training/data \
--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 '{ "trainingData": { "trainingDataId": "example", "accountId": "example", "websiteId": "example", "type": "example", "method": "single", "url": "example", "name": "example", "question": "example", "answer": "example", "isPublic": true, "include": [ "example" ], "exclude": [ "example" ], "schedule": "Daily" }, "skipRetrain": true }'

Create a new training data source, or update an existing one by passing its trainingDataId. Creating a source of type url starts a website ingestion: Unless crawls the site and trains the AI on its content.

Use cases

  • Ingest a website: Create a url source pointing at the website you want the AI to learn from
  • Rescan: Update an existing source to change its URL filters or schedule and trigger a retrain

Notes

  • Omit trainingData.trainingDataId to create a new source, pass it to update that source
  • trainingData.accountId and trainingData.websiteId must match the x-account-id and x-website-id headers
  • For website ingestion use type: url with method set to all (crawl the whole site), single (one page) or sitemap
  • To add or edit a document (a title with a markdown body), use the upsert document endpoint instead
  • 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
trainingData
required
object
trainingDataId

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

string
accountId
required

Must match the x-account-id header.

string
websiteId
required

Must match the x-website-id header.

string
type
required

Kind of source. Use url for website ingestion, other values include faq (a document), pdf, docx, md and csv.

string
method
required

How to crawl a url source. all follows links from the entry point, single ingests one page, sitemap reads the sitemap.

string
Allowed values: single all sitemap
url

Entry point URL for a url source.

string
name

Display name of the source.

string
question

The title of a faq (document) source. Required when creating one.

string
answer

The markdown body of a faq (document) source. Required when creating one.

string
isPublic
required

Whether content from this source may be shown to anonymous visitors.

boolean
include

Path prefixes to include while crawling.

Array<string>
exclude

Path prefixes to exclude while crawling.

Array<string>
schedule

How often the source is rescanned.

string
Allowed values: Daily Weekly Monthly Never
skipRetrain

Skip retraining after saving, only store the source configuration.

boolean

The source was saved and ingestion was started.

Media typeapplication/json
object
message
string

Example

{
"message": "Training data upserted"
}

Unauthorized - invalid API key.