Documents

Upload

GA
POST

Upload a document to be indexed and used for search.

Note: Uses a base url of https://documents.vellum.ai.

This is a multipart/form-data request. The contents field should be a file upload. It also expects a JSON body with the following fields:

  • add_to_index_names: list[str] - Optionally include the names of all indexes that you’d like this document to be included in
  • external_id: str | None - Optionally include an external ID for this document. This is useful if you want to re-upload the same document later when its contents change and would like it to be re-indexed.
  • label: str - A human-friendly name for this document. Typically the filename.
  • keywords: list[str] | None - Optionally include a list of keywords that’ll be associated with this document. Used when performing keyword searches.
  • metadata: dict[str, Any] - A stringified JSON object containing any metadata associated with the document that you’d like to filter upon later.

Request

This endpoint expects a multipart form containing a file.
add_to_index_nameslist of stringsOptional
Optionally include the names of all indexes that you'd like this document to be included in
external_idstringOptional
Optionally include an external ID for this document. This is useful if you want to re-upload the same document later when its contents change and would like it to be re-indexed.
labelstringRequired
A human-friendly name for this document. Typically the filename.
contentsfile
keywordslist of stringsOptional
Optionally include a list of keywords that'll be associated with this document. Used when performing keyword searches.
metadatastringOptional
A stringified JSON object containing any metadata associated with the document that you'd like to filter upon later.

Response

This endpoint returns an object
document_id
string
The ID of the newly created document.
POST
1curl -X POST https://documents.vellum.ai/v1/upload-document \
2 -H "X_API_KEY: <apiKey>" \
3 -H "Content-Type: multipart/form-data" \
4 -F label="label" \
5 -F contents=@<file1>
200Successful
1{
2 "document_id": "document_id"
3}