> For the complete documentation index, see [llms.txt](https://docs.usepylon.com/pylon-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.usepylon.com/pylon-docs/developer/api/api-reference/training-data.md).

# Training Data

Use Training Data to connect external knowledge sources that power Pylon’s AI.

For UI setup and behavior, see [Training Data](/pylon-docs/platform/training-data.md).

{% hint style="info" %}
This API Reference section renders from our OpenAPI spec.

If you don’t see any endpoints below, they may not be published in the spec yet.
{% endhint %}

### Endpoints

## List all training data configurations

> Returns all training data configurations for the organization.\
> \
> \*\*Rate limit:\*\* 60 requests per minute

```json
{"openapi":"3.0.3","info":{"title":"Pylon API.","version":"1.0.0"},"servers":[{"url":"https://api.usepylon.com"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"description":"Authorization: Bearer <token>","scheme":"bearer","type":"http"}},"responses":{"ListTrainingDataResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListTrainingDataResponseBody"}}},"description":""},"BadRequestApiResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorApiResponseBody"}}},"description":"The request was invalid or could not be completed."},"InternalServerErrorApiResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorApiResponseBody"}}},"description":"An unexpected internal error occurred."}},"schemas":{"ListTrainingDataResponseBody":{"properties":{"data":{"items":{"$ref":"#/components/schemas/TrainingData"},"type":"array"},"request_id":{"type":"string"}},"type":"object"},"TrainingData":{"properties":{"created_at":{"type":"string"},"documents":{"items":{"$ref":"#/components/schemas/TrainingDataDocument"},"type":"array"},"exclude_from_kb_search":{"type":"boolean"},"id":{"type":"string"},"name":{"type":"string"},"scrape_status":{"$ref":"#/components/schemas/TrainingDataScrapeStatus"},"type":{"type":"string"},"updated_at":{"type":"string"},"visibility":{"enum":["everyone","user_only","ai_agent_only"],"type":"string"}},"type":"object"},"TrainingDataDocument":{"properties":{"external_id":{"type":"string"},"file_name":{"type":"string"},"file_size":{"format":"int64","type":"integer"},"file_type":{"type":"string"},"id":{"type":"string"},"s3_key":{"type":"string"}},"type":"object"},"TrainingDataScrapeStatus":{"properties":{"last_scraped_at":{"type":"string"},"pages_scraped":{"format":"int64","type":"integer"},"status":{"type":"string"},"total_pages":{"format":"int64","type":"integer"}},"type":"object"},"ErrorApiResponseBody":{"properties":{"errors":{"description":"The list of errors.","items":{"type":"string"},"type":"array"},"exists_id":{"description":"The ID of the object that already exists if this is a duplicate object error.","type":"string"},"request_id":{"description":"The request ID for tracking.","type":"string"}},"type":"object"}}},"paths":{"/training-data":{"get":{"description":"Returns all training data configurations for the organization.\n\n**Rate limit:** 60 requests per minute","operationId":"ListTrainingData","responses":{"200":{"$ref":"#/components/responses/ListTrainingDataResponse"},"400":{"$ref":"#/components/responses/BadRequestApiResponse"},"500":{"$ref":"#/components/responses/InternalServerErrorApiResponse"}},"summary":"List all training data configurations","tags":["training-data"]}}}}
```

## Create a training data configuration

> Creates a new training data configuration for the organization.\
> \
> \*\*Rate limit:\*\* 10 requests per minute

```json
{"openapi":"3.0.3","info":{"title":"Pylon API.","version":"1.0.0"},"servers":[{"url":"https://api.usepylon.com"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"description":"Authorization: Bearer <token>","scheme":"bearer","type":"http"}},"schemas":{"CreateTrainingDataRequestBody":{"properties":{"training_data_name":{"description":"The name of the training data container.","type":"string"},"visibility":{"default":"everyone","description":"The visibility of the training data. Defaults to \"everyone\".\nValid values: \"everyone\", \"user_only\", \"ai_agent_only\"","enum":["everyone","user_only","ai_agent_only"],"type":"string"}},"type":"object"},"CreateTrainingDataResponseBody":{"properties":{"data":{"$ref":"#/components/schemas/TrainingData"},"request_id":{"type":"string"}},"type":"object"},"TrainingData":{"properties":{"created_at":{"type":"string"},"documents":{"items":{"$ref":"#/components/schemas/TrainingDataDocument"},"type":"array"},"exclude_from_kb_search":{"type":"boolean"},"id":{"type":"string"},"name":{"type":"string"},"scrape_status":{"$ref":"#/components/schemas/TrainingDataScrapeStatus"},"type":{"type":"string"},"updated_at":{"type":"string"},"visibility":{"enum":["everyone","user_only","ai_agent_only"],"type":"string"}},"type":"object"},"TrainingDataDocument":{"properties":{"external_id":{"type":"string"},"file_name":{"type":"string"},"file_size":{"format":"int64","type":"integer"},"file_type":{"type":"string"},"id":{"type":"string"},"s3_key":{"type":"string"}},"type":"object"},"TrainingDataScrapeStatus":{"properties":{"last_scraped_at":{"type":"string"},"pages_scraped":{"format":"int64","type":"integer"},"status":{"type":"string"},"total_pages":{"format":"int64","type":"integer"}},"type":"object"},"ErrorApiResponseBody":{"properties":{"errors":{"description":"The list of errors.","items":{"type":"string"},"type":"array"},"exists_id":{"description":"The ID of the object that already exists if this is a duplicate object error.","type":"string"},"request_id":{"description":"The request ID for tracking.","type":"string"}},"type":"object"}},"responses":{"CreateTrainingDataResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTrainingDataResponseBody"}}},"description":""},"BadRequestApiResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorApiResponseBody"}}},"description":"The request was invalid or could not be completed."},"InternalServerErrorApiResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorApiResponseBody"}}},"description":"An unexpected internal error occurred."}}},"paths":{"/training-data":{"post":{"description":"Creates a new training data configuration for the organization.\n\n**Rate limit:** 10 requests per minute","operationId":"CreateTrainingData","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTrainingDataRequestBody"}}}},"responses":{"200":{"$ref":"#/components/responses/CreateTrainingDataResponse"},"400":{"$ref":"#/components/responses/BadRequestApiResponse"},"500":{"$ref":"#/components/responses/InternalServerErrorApiResponse"}},"summary":"Create a training data configuration","tags":["training-data"]}}}}
```

## Get a training data configuration by its ID

> Returns a single training data configuration by ID.\
> \
> \*\*Rate limit:\*\* 60 requests per minute

```json
{"openapi":"3.0.3","info":{"title":"Pylon API.","version":"1.0.0"},"servers":[{"url":"https://api.usepylon.com"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"description":"Authorization: Bearer <token>","scheme":"bearer","type":"http"}},"responses":{"GetTrainingDataResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetTrainingDataResponseBody"}}},"description":""},"BadRequestApiResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorApiResponseBody"}}},"description":"The request was invalid or could not be completed."},"ErrorApiResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorApiResponseBody"}}},"description":""}},"schemas":{"GetTrainingDataResponseBody":{"properties":{"data":{"$ref":"#/components/schemas/TrainingData"},"request_id":{"type":"string"}},"type":"object"},"TrainingData":{"properties":{"created_at":{"type":"string"},"documents":{"items":{"$ref":"#/components/schemas/TrainingDataDocument"},"type":"array"},"exclude_from_kb_search":{"type":"boolean"},"id":{"type":"string"},"name":{"type":"string"},"scrape_status":{"$ref":"#/components/schemas/TrainingDataScrapeStatus"},"type":{"type":"string"},"updated_at":{"type":"string"},"visibility":{"enum":["everyone","user_only","ai_agent_only"],"type":"string"}},"type":"object"},"TrainingDataDocument":{"properties":{"external_id":{"type":"string"},"file_name":{"type":"string"},"file_size":{"format":"int64","type":"integer"},"file_type":{"type":"string"},"id":{"type":"string"},"s3_key":{"type":"string"}},"type":"object"},"TrainingDataScrapeStatus":{"properties":{"last_scraped_at":{"type":"string"},"pages_scraped":{"format":"int64","type":"integer"},"status":{"type":"string"},"total_pages":{"format":"int64","type":"integer"}},"type":"object"},"ErrorApiResponseBody":{"properties":{"errors":{"description":"The list of errors.","items":{"type":"string"},"type":"array"},"exists_id":{"description":"The ID of the object that already exists if this is a duplicate object error.","type":"string"},"request_id":{"description":"The request ID for tracking.","type":"string"}},"type":"object"}}},"paths":{"/training-data/{id}":{"get":{"description":"Returns a single training data configuration by ID.\n\n**Rate limit:** 60 requests per minute","operationId":"GetTrainingData","parameters":[{"description":"The ID of the training data.","in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"$ref":"#/components/responses/GetTrainingDataResponse"},"400":{"$ref":"#/components/responses/BadRequestApiResponse"},"404":{"$ref":"#/components/responses/ErrorApiResponse"}},"summary":"Get a training data configuration by its ID","tags":["training-data"]}}}}
```

## Upload files as training data

> Uploads one or more files to a training data configuration.\
> \
> \*\*Rate limit:\*\* 10 requests per minute

```json
{"openapi":"3.0.3","info":{"title":"Pylon API.","version":"1.0.0"},"servers":[{"url":"https://api.usepylon.com"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"description":"Authorization: Bearer <token>","scheme":"bearer","type":"http"}},"responses":{"TrainingDataUploadResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrainingDataUploadResponseBody"}}},"description":"","headers":{"Body":{"schema":{}}}},"BadRequestApiResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorApiResponseBody"}}},"description":"The request was invalid or could not be completed."},"InternalServerErrorApiResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorApiResponseBody"}}},"description":"An unexpected internal error occurred."}},"schemas":{"TrainingDataUploadResponseBody":{"properties":{"data":{"$ref":"#/components/schemas/TrainingData"},"request_id":{"type":"string"}},"type":"object"},"TrainingData":{"properties":{"created_at":{"type":"string"},"documents":{"items":{"$ref":"#/components/schemas/TrainingDataDocument"},"type":"array"},"exclude_from_kb_search":{"type":"boolean"},"id":{"type":"string"},"name":{"type":"string"},"scrape_status":{"$ref":"#/components/schemas/TrainingDataScrapeStatus"},"type":{"type":"string"},"updated_at":{"type":"string"},"visibility":{"enum":["everyone","user_only","ai_agent_only"],"type":"string"}},"type":"object"},"TrainingDataDocument":{"properties":{"external_id":{"type":"string"},"file_name":{"type":"string"},"file_size":{"format":"int64","type":"integer"},"file_type":{"type":"string"},"id":{"type":"string"},"s3_key":{"type":"string"}},"type":"object"},"TrainingDataScrapeStatus":{"properties":{"last_scraped_at":{"type":"string"},"pages_scraped":{"format":"int64","type":"integer"},"status":{"type":"string"},"total_pages":{"format":"int64","type":"integer"}},"type":"object"},"ErrorApiResponseBody":{"properties":{"errors":{"description":"The list of errors.","items":{"type":"string"},"type":"array"},"exists_id":{"description":"The ID of the object that already exists if this is a duplicate object error.","type":"string"},"request_id":{"description":"The request ID for tracking.","type":"string"}},"type":"object"}}},"paths":{"/training-data/upload":{"post":{"description":"Uploads one or more files to a training data configuration.\n\n**Rate limit:** 10 requests per minute","operationId":"UploadTrainingDataFiles","requestBody":{"content":{"multipart/form-data":{"schema":{"properties":{"external_ids":{"description":"External IDs for idempotent operations. Must match the number of files if provided.\nUsed for duplicate detection and updates.","items":{"type":"string"},"type":"array"},"file_names":{"description":"Custom names for the uploaded files. Must match the number of files if provided.\nIf not provided, original filenames will be used.","items":{"type":"string"},"type":"array"},"files":{"description":"The files to upload (minimum 1, maximum 10).\nSupported types: PDF, plain text, markdown, CSV, JSON, and images (JPEG, PNG, GIF, WebP).\nMaximum size: 50MB per file, 100MB total.","items":{"type":"string"},"type":"array"},"training_data_id":{"description":"The ID of an existing training data container to upload files to.\nRequired if not creating new training data.","type":"string"},"training_data_name":{"description":"The name of a new training data container.\nRequired when creating new training data (if training_data_id is not provided).","type":"string"},"visibility":{"default":"everyone","description":"Visibility of the training data. Defaults to \"everyone\".\nValid values: \"everyone\", \"user_only\", \"ai_agent_only\"","enum":["everyone","user_only","ai_agent_only"],"type":"string"}},"required":["files"],"type":"object"}}}},"responses":{"200":{"$ref":"#/components/responses/TrainingDataUploadResponse"},"400":{"$ref":"#/components/responses/BadRequestApiResponse"},"500":{"$ref":"#/components/responses/InternalServerErrorApiResponse"}},"summary":"Upload files as training data","tags":["training-data"]}}}}
```

## Upload text content as training data

> Uploads plain text content as a training data document.\
> \
> \*\*Rate limit:\*\* 10 requests per minute

```json
{"openapi":"3.0.3","info":{"title":"Pylon API.","version":"1.0.0"},"servers":[{"url":"https://api.usepylon.com"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"description":"Authorization: Bearer <token>","scheme":"bearer","type":"http"}},"schemas":{"UploadTrainingDataFileContentRequestBody":{"properties":{"content":{"description":"The text content to upload.","type":"string"},"external_id":{"description":"External ID for idempotent operations (optional).","type":"string"},"file_name":{"description":"The name for the uploaded file.","type":"string"},"training_data_id":{"description":"The ID of an existing training data container to upload to (optional).","type":"string"},"training_data_name":{"description":"The name of a new training data container (required if training_data_id not provided).","type":"string"},"visibility":{"default":"everyone","description":"Visibility of the training data. Defaults to \"everyone\".","enum":["everyone","user_only","ai_agent_only"],"type":"string"}},"type":"object"},"TrainingDataUploadResponseBody":{"properties":{"data":{"$ref":"#/components/schemas/TrainingData"},"request_id":{"type":"string"}},"type":"object"},"TrainingData":{"properties":{"created_at":{"type":"string"},"documents":{"items":{"$ref":"#/components/schemas/TrainingDataDocument"},"type":"array"},"exclude_from_kb_search":{"type":"boolean"},"id":{"type":"string"},"name":{"type":"string"},"scrape_status":{"$ref":"#/components/schemas/TrainingDataScrapeStatus"},"type":{"type":"string"},"updated_at":{"type":"string"},"visibility":{"enum":["everyone","user_only","ai_agent_only"],"type":"string"}},"type":"object"},"TrainingDataDocument":{"properties":{"external_id":{"type":"string"},"file_name":{"type":"string"},"file_size":{"format":"int64","type":"integer"},"file_type":{"type":"string"},"id":{"type":"string"},"s3_key":{"type":"string"}},"type":"object"},"TrainingDataScrapeStatus":{"properties":{"last_scraped_at":{"type":"string"},"pages_scraped":{"format":"int64","type":"integer"},"status":{"type":"string"},"total_pages":{"format":"int64","type":"integer"}},"type":"object"},"ErrorApiResponseBody":{"properties":{"errors":{"description":"The list of errors.","items":{"type":"string"},"type":"array"},"exists_id":{"description":"The ID of the object that already exists if this is a duplicate object error.","type":"string"},"request_id":{"description":"The request ID for tracking.","type":"string"}},"type":"object"}},"responses":{"UploadTrainingDataFileContentResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrainingDataUploadResponseBody"}}},"description":""},"BadRequestApiResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorApiResponseBody"}}},"description":"The request was invalid or could not be completed."},"InternalServerErrorApiResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorApiResponseBody"}}},"description":"An unexpected internal error occurred."}}},"paths":{"/training-data/upload-content":{"post":{"description":"Uploads plain text content as a training data document.\n\n**Rate limit:** 10 requests per minute","operationId":"UploadTrainingDataFileContent","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UploadTrainingDataFileContentRequestBody"}}}},"responses":{"200":{"$ref":"#/components/responses/UploadTrainingDataFileContentResponse"},"400":{"$ref":"#/components/responses/BadRequestApiResponse"},"500":{"$ref":"#/components/responses/InternalServerErrorApiResponse"}},"summary":"Upload text content as training data","tags":["training-data"]}}}}
```

## Delete training data documents

> Removes documents from a training data configuration by document ID or external ID.\
> \
> \*\*Rate limit:\*\* 10 requests per minute

```json
{"openapi":"3.0.3","info":{"title":"Pylon API.","version":"1.0.0"},"servers":[{"url":"https://api.usepylon.com"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"description":"Authorization: Bearer <token>","scheme":"bearer","type":"http"}},"responses":{"DeleteTrainingDataDocumentsResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteTrainingDataDocumentsResponseBody"}}},"description":""},"BadRequestApiResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorApiResponseBody"}}},"description":"The request was invalid or could not be completed."},"ErrorApiResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorApiResponseBody"}}},"description":""},"InternalServerErrorApiResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorApiResponseBody"}}},"description":"An unexpected internal error occurred."}},"schemas":{"DeleteTrainingDataDocumentsResponseBody":{"properties":{"deleted_count":{"format":"int64","type":"integer"},"request_id":{"type":"string"}},"type":"object"},"ErrorApiResponseBody":{"properties":{"errors":{"description":"The list of errors.","items":{"type":"string"},"type":"array"},"exists_id":{"description":"The ID of the object that already exists if this is a duplicate object error.","type":"string"},"request_id":{"description":"The request ID for tracking.","type":"string"}},"type":"object"}}},"paths":{"/training-data/{id}/documents":{"delete":{"description":"Removes documents from a training data configuration by document ID or external ID.\n\n**Rate limit:** 10 requests per minute","operationId":"DeleteTrainingDataDocuments","parameters":[{"description":"The ID of the training data.","in":"path","name":"id","required":true,"schema":{"type":"string"}},{"description":"Document IDs to delete.","in":"query","name":"document_ids","schema":{"items":{"type":"string"},"type":"array"}},{"description":"External IDs to delete.","in":"query","name":"external_ids","schema":{"items":{"type":"string"},"type":"array"}}],"responses":{"200":{"$ref":"#/components/responses/DeleteTrainingDataDocumentsResponse"},"400":{"$ref":"#/components/responses/BadRequestApiResponse"},"404":{"$ref":"#/components/responses/ErrorApiResponse"},"500":{"$ref":"#/components/responses/InternalServerErrorApiResponse"}},"summary":"Delete training data documents","tags":["training-data"]}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.usepylon.com/pylon-docs/developer/api/api-reference/training-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
