Skip to content
API referenceUpload a context source

Upload a context source

POST/v1/context-sources

Upload a context source.

Send the document as multipart/form-data: Markdown (.md), HTML (.html) or a born-digital PDF (.pdf; scanned pages are not supported). The gateway parses it into sections, scans every section for prompt injection and secrets, and stores the parsed text and the section outline encrypted with the organization's key. The uploaded file itself is not kept. Returns 201 with the source in status PENDING (its section summaries are written next, paid for by index_virtual_key), or QUARANTINED when the scan found something; a quarantined source cannot be used until a workspace admin releases it.

Indexing runs in the background: a short summary of every section is written by index_model, each an ordinary request on index_virtual_key (billed to it, subject to its limits, and listed in the logs with operation type context_index), and the source becomes READY. A temporary failure is retried; a permanent one (the key is disabled or out of credit, the model is not allowed) makes the source FAILED, with the reason in status_detail, until it is reindexed.

Requires an organization admin key, or a workspace admin key for workspace_id, and a plan that includes context sources (402 otherwise). Returns 400 for an unsupported or unreadable file, an index key that is not a usable key of the workspace, or a model outside the key's model allowlist, and 413 when the file is larger than 15 MB or the document longer than about 1.5 million tokens.

Authorization

  • AuthorizationBearer va_

    A platform API key (va_...), created under Settings > API keys. Scoped to an organization or one workspace, with an admin or member role. Used by the management API.

Request body multipart/form-data

  • filestring<binary>required

    the file to upload

  • organizationstringrequired

    The organization's identifier (slug).

  • workspace_idstringrequired

    The workspace the source belongs to (UUID).

  • namestringrequired

    A name for the source, at most 200 characters.

  • index_virtual_keystringrequired

    The virtual key (vk-...) of the workspace that pays for the section summaries.

  • index_modelstring

    The model that writes the section summaries, called on index_virtual_key. Default gpt-6-luna; choose another when the key cannot reach OpenAI.

  • retention_daysstring

    Days after which the source is deleted automatically (1 to 3650). Absent: kept until deleted.

Responses

201application/json

Created

  • slugstring

    The source's identifier (ctx-...).

  • organizationstring

    The organization's identifier (slug).

  • workspace_idstring<uuid>

    The workspace the source belongs to (UUID).

  • namestring

    The name given at upload.

  • formatenum<string>

    MARKDOWN, HTML or PDF.

    One of "MARKDOWN", "HTML", "PDF"

  • filenamestring

    The uploaded file's name.

  • size_bytesinteger<int64>

    Size of the uploaded file in bytes.

  • page_countinteger<int32>

    Number of pages (PDF only).

  • statusenum<string>

    PENDING, INDEXING, READY, QUARANTINED or FAILED.

    One of "PENDING", "INDEXING", "READY", "QUARANTINED", "FAILED"

  • status_detailstring

    Why the source is quarantined or failed; absent otherwise.

  • scan_findingsobject[]

    What the upload scan found (quarantined sources). Never the matched text.

    Child attributes
    • check_typestring

      The check that fired: tool_output_injection (instructions aimed at a model) or secrets_present (keys, tokens).

    • descriptionstring

      What the check reported, without the matched text.

    • section_idstring

      The section where it was found.

  • index_virtual_keystring

    The virtual key that pays for this source's section summaries.

  • index_modelstring

    The model that writes this source's section summaries, called on index_virtual_key.

  • index_attemptsinteger<int32>

    Failed indexing attempts since the last success. While the source is PENDING after a temporary failure (a rate limit, a provider outage) it is retried with a growing delay; after too many it becomes FAILED.

  • expires_atstring<date-time>

    When the source is deleted automatically (its retention), as an ISO 8601 timestamp. Absent: kept until deleted.

  • section_countinteger<int32>

    Number of sections (groups not counted).

  • token_countinteger<int32>

    Approximate size of the whole document's text in tokens.

  • summarystring

    One sentence on what the document is; absent until indexed.

  • summary_edited_bystring

    Who replaced the generated one-sentence summary with their own; absent when it is the generated one.

  • summary_edited_atstring<date-time>

    When the source's summary was edited.

  • sectionsobject[]

    The outline (every section and group, in reading order). Returned when getting one source, not in lists.

    Child attributes
    • section_idstring

      The section's id within the source (n12, or g3 for a group).

    • parent_idstring

      The id of the section or group this one sits under; absent at the top level.

    • kindenum<string>

      SECTION or GROUP.

      One of "SECTION", "GROUP"

    • depthinteger<int32>

      Nesting depth, 0 at the top level.

    • titlestring

      The section's heading (several headings joined with " / " when short sections were merged).

    • summarystring

      A short summary of what the section contains; absent until the source is indexed, and for groups.

    • summary_edited_bystring

      Who replaced the generated summary with their own; absent when the summary is the generated one.

    • summary_edited_atstring<date-time>

      When the summary was edited. Reindexing keeps an edited summary.

    • page_frominteger<int32>

      First page the section covers (PDF only).

    • page_tointeger<int32>

      Last page the section covers (PDF only).

    • tokensinteger<int32>

      Approximate size of the section's text in tokens.

  • released_bystring

    Who released the source from quarantine; absent if never quarantined.

  • released_atstring<date-time>

    When the source was released from quarantine.

  • indexed_atstring<date-time>

    When indexing finished.

  • created_bystring

    Who uploaded the source.

  • created_atstring<date-time>

    When the source was uploaded.

  • updated_atstring<date-time>

    When the source last changed.

NVIDIA Inception Program member

VectorAxis is built by GK Labs, a member of NVIDIA Inception.