Upsert document

Inserts a document into the specified external source if it doesn't contain a document with the specified doc_id; updates the specified document otherwise.
Note: This operation is only valid for external sources of type CUSTOM. Attempts to perform it in other types of external sources are rejected with a 400 Bad Request error.

The request returns 204 No Content as soon as the document is accepted for processing. Use GET /knowledge-management/external-sources/{external_source_id}/documents/{doc_id}/status to follow its processing.

Request formats

  • application/json: the document is sent inline in content, as HTML (default) or Markdown
    (content_type).

  • multipart/form-data: part document (JSON, same fields as the JSON body) is required and
    must be sent once. Optional part file uploads a native file instead of inline content.
    Exactly one of document.content or file must be provided. content_type is ignored when a
    file part is sent. Accepted file formats: PDF, DOCX, PPTX, XLSX, plain text, Markdown and
    CSV, detected from the file content. For text files, the filename extension only selects
    Markdown (.md) or CSV (.csv); any other text file is treated as plain text. HTML is not
    accepted as a file (send it inline instead). Files larger than 10 MiB are
    rejected with 400 Bad Request; request bodies larger than the maximum accepted request body
    size are rejected with 413 Payload Too Large.

Images (applies only when image processing is enabled for the knowledge base)

  • Applies only when image processing is enabled for the knowledge base: images referenced from
    the content can come from data: URIs, from multipart images parts (referenced by
    filename from HTML <img src> or Markdown ![](...)), or from https URLs.

  • Applies only when image processing is enabled for the knowledge base: supported formats are
    png, jpeg, gif and webp; SVG is rejected. Each image may be up to 10 MiB and 16 megapixels,
    and at most 20 images are processed per document.

  • Applies only when image processing is enabled for the knowledge base: images part filenames
    must be unique and must not contain /, \ or ..; images parts cannot be combined with
    a file part. Sending images parts when image processing is disabled is rejected with
    400 Bad Request.

  • Applies only when image processing is enabled for the knowledge base: invalid inline or
    uploaded images are rejected with 400 Bad Request and a message of the form
    Image <n>: <reason>. Failures to download images from https URLs are not fatal; the
    document is still processed.

  • Applies only when image processing is enabled for the knowledge base: Markdown content larger
    than 64 KB that contains data: URI images or references multipart images parts is
    rejected with 400 Bad Request; images referenced only by https URLs are processed
    asynchronously and do not trigger this limit.

Rate limiting
Requests may be rate limited by the API gateway or by the service. A rate-limited request is rejected with 429 Too Many Requests and a Retry-After header with the number of seconds to wait before retrying.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

Scope

km-external-sources:write

Path Params
string
required
length between 36 and 36

The external source id.

string
required
length between 1 and 255

The document id.

Body Params

Document to be created or updated.

A document to upsert in an external source.

string
required
length between 1 and 2048
\S+

The URL of the document. Must be an absolute http or https URL with a host and without credentials.

string
required
length between 1 and 1000
\S+

The title of the document.

string
required
length ≥ 1
\S+

The content of the document, as HTML (including HTML tags) or Markdown according to content_type. Up to 5 MB. Required in application/json requests; in multipart/form-data requests exactly one of content or the file part must be provided. When image processing is enabled for the knowledge base, images can be referenced from the content (applies only when image processing is enabled for the knowledge base).

string
enum
length between 4 and 8
Defaults to html

The format of content. Defaults to html when absent. Any other value is rejected with 400 Bad Request (code 1040200). Ignored when a file part is sent.

Allowed:
date-time
required
length ≥ 20

The creation date of the document.

date-time
length ≥ 20

The last update date of the document. Must not be before created_at.

metadata
object

The metadata of the document. At most 100 keys, keys up to 256 characters and a serialized size up to 64 KiB.

Headers
string
enum
Defaults to application/json

Generated from available request content types

Allowed:
Responses
204

Document successfully created/updated.

413

Payload Too Large - the request body exceeds the maximum accepted size. The response has no body.

Language
Credentials
OAuth2
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json