Skip to main content
DocumentationBrain · api.us.ccsio.ai

Brain documents

List and read the documents of the sources, their text and their original.

Documentation menu

The descriptions of the operations and fields are the contract’s own, in English.

GET/brain/v1/documents

List the documents

Credential
API key
Permission
brain.read

Lists the documents of the spaces the caller's audience reaches, newest updated_at first. A filter narrows the list and never widens it.

curl
curl "https://api.us.ccsio.ai/brain/v1/documents" \
  -H "Authorization: Bearer $CCSIO_API_KEY"

Parameters

NameInDescription
X-Request-ID
optional
headerstring

Optional request ULID. A valid ULID (upper or lowercase) is honored; when the header is absent or invalid, the runtime mints the id. The response X-Request-ID header carries the canonical uppercase form.

space
optional
querystring

Only this space.

source
optional
querystring

Only the documents of this source.

cursor
optional
querystring

The `next_cursor` of the previous page; absent starts at the first item. A cursor that this plane did not write is refused with 400 invalid-request.

limit
optional
queryinteger

The largest page, 1 to 100. Default 50.

Responses

  • 200

    One page of documents.

    Schema
    BrainDocumentList
    • documentsarray of BrainDocumentrequired

      Newest updated_at first.

      • idstringrequired

        An id generated by core: URL-safe, matching the C6 identifier pattern, and opaque to clients.

        pattern ^[a-z][a-z0-9._-]{0,127}$

      • sourcestringrequired

        An id generated by core: URL-safe, matching the C6 identifier pattern, and opaque to clients.

        pattern ^[a-z][a-z0-9._-]{0,127}$

      • spacestringrequired

        An id generated by core: URL-safe, matching the C6 identifier pattern, and opaque to clients.

        pattern ^[a-z][a-z0-9._-]{0,127}$

      • titlestringrequired

        at most 512 characters

      • pathstring or nullrequired

        The path inside a git source, or the file name of an upload; null for a link.

        at most 1024 characters

      • media_typestringrequired
      • bytesintegerrequired

        at least 0

      • versionintegerrequired

        1 when the document first appears; every change of the source that changes the bytes adds one.

        at least 1

      • statestringrequired

        Allowed values: "processing""ready""failed"

      • projectstring or nullrequired

        The project label, from `projects/<name>/` in a git source; null when none.

        pattern ^[a-z][a-z0-9._-]{0,127}$

      • errorBrainSourceError or nullrequired

        Set only when state is failed.

      • created_atstring (date-time)required
      • updated_atstring (date-time)required
    • next_cursorstring or nullrequired
  • 400

    A filter or a limit outside its range, a cursor this plane did not write, an unknown query parameter. Codes: invalid-request

  • 401

    The request carries no credential, more than one, or one the platform does not accept, and is refused before the operation runs; `error.code` says why. Supply exactly one credential. Codes: invalid-request (no credential, or both Authorization:

    Read more

    Bearer and x-api-key), api-key-invalid (a value that is not a platform API key, or a key of a kind the platform does not accept), api-key-unknown, api-key-revoked, api-key-expired, bootstrap-disabled (the one-shot installation credential, once a key exists), token-malformed (a bearer token that is not a JWT), token-algorithm-unsupported, token-signature-invalid, token-claim-invalid, token-issuer-mismatch, token-audience-mismatch, token-expired, token-not-yet-valid, issuer-untrusted, issuer-residency-mismatch (the issuer belongs to another plane), issuer-resolution-unknown, jwks-unavailable, jwks-key-not-found, staff-token-inactive (a platform operator's token), staff-not-operator, staff-directory-unavailable, identity-not-provisioned (a verified identity with no account on this plane), organization-not-found (a verified identity or key whose organization this plane does not know), internal-error (a fault while the credential is checked is refused too, fail closed), context-cancelled

  • 402

    The organization has to pay first: its standing is payment_required.

    Read more

    The request boundary applies this payment gate to every route except an organization's billing routes, the caller's own context, organization list, onboarding, session report and personal keys, the public routes, and the routes of platform operators, who administer an organization that has to pay. The operations the gate covers declare this response. On /v1 the refusal is rendered in the OpenAI error format. Code: payment-required

  • 403

    No role of the caller holds `brain.read` in the organization. Codes: policy-denied, brain-disabled (the organization has no Brain capacity)

  • 404

    The space or the source does not exist or is not one the caller's audience reaches; or the plane has no Brain database configured (BRAIN_DATABASE_URL), so every Brain route is off. Codes: space-not-found, source-not-found, brain-not-enabled

  • 405

    The path is claimed but the request method is not allowed. Go ServeMux returns its standard plain-text response and lists permitted methods in Allow.

  • 500

    Platform failure. Codes: internal-error

GET/brain/v1/documents/{document}

Read a document's metadata

Credential
API key
Permission
brain.read

Answers one document's metadata. Its text is on the text route and its original on the download route.

curl
curl "https://api.us.ccsio.ai/brain/v1/documents/{document}" \
  -H "Authorization: Bearer $CCSIO_API_KEY"

Parameters

NameInDescription
X-Request-ID
optional
headerstring

Optional request ULID. A valid ULID (upper or lowercase) is honored; when the header is absent or invalid, the runtime mints the id. The response X-Request-ID header carries the canonical uppercase form.

document
required
pathstring

The document's id. A document in a space the caller's audience does not reach is answered as one that does not exist.

Responses

  • 200

    The document.

    Schema
    BrainDocument
    • idstringrequired

      An id generated by core: URL-safe, matching the C6 identifier pattern, and opaque to clients.

      pattern ^[a-z][a-z0-9._-]{0,127}$

    • sourcestringrequired

      An id generated by core: URL-safe, matching the C6 identifier pattern, and opaque to clients.

      pattern ^[a-z][a-z0-9._-]{0,127}$

    • spacestringrequired

      An id generated by core: URL-safe, matching the C6 identifier pattern, and opaque to clients.

      pattern ^[a-z][a-z0-9._-]{0,127}$

    • titlestringrequired

      at most 512 characters

    • pathstring or nullrequired

      The path inside a git source, or the file name of an upload; null for a link.

      at most 1024 characters

    • media_typestringrequired
    • bytesintegerrequired

      at least 0

    • versionintegerrequired

      1 when the document first appears; every change of the source that changes the bytes adds one.

      at least 1

    • statestringrequired

      Allowed values: "processing""ready""failed"

    • projectstring or nullrequired

      The project label, from `projects/<name>/` in a git source; null when none.

      pattern ^[a-z][a-z0-9._-]{0,127}$

    • errorobject or nullrequired

      Set only when state is failed.

      • codestringrequired

        One of: source-url-refused (the address, a redirect or the host was refused), source-url-unreachable (DNS, connection, TLS or timeout), source-url-status (the page did not answer 2xx), source-repository-unreachable (the branch cannot be read), source-repository-auth (the token was refused, or none was given for a private repository), source-no-text, source-too-much-text (a document above 2,000,000 characters of text), source-extraction-failed, source-embedding-failed, source-too-large (a link answered more than 20 MiB, a git file is above 5 MiB, or a git source holds more than 5,000 files), source-type-not-supported (an image, or bytes that are not an accepted type), brain-capacity-exceeded (the Brain had no room left for what the sync read; nothing of that sync was kept). The codes that exist in chat (source-url-refused, source-url-unreachable, source-url-status, source-no-text, source-too-much-text, source-extraction-failed, source-embedding-failed, source-too-large, source-type-not-supported) keep their chat meaning. On a document, the error of an oversized git file or of a document above the text cap says why that one document is failed while its source stays ready.

        pattern ^[a-z][a-z0-9-]{0,127}$

      • messagestringrequired
    • created_atstring (date-time)required
    • updated_atstring (date-time)required
  • 401

    The request carries no credential, more than one, or one the platform does not accept, and is refused before the operation runs; `error.code` says why. Supply exactly one credential. Codes: invalid-request (no credential, or both Authorization:

    Read more

    Bearer and x-api-key), api-key-invalid (a value that is not a platform API key, or a key of a kind the platform does not accept), api-key-unknown, api-key-revoked, api-key-expired, bootstrap-disabled (the one-shot installation credential, once a key exists), token-malformed (a bearer token that is not a JWT), token-algorithm-unsupported, token-signature-invalid, token-claim-invalid, token-issuer-mismatch, token-audience-mismatch, token-expired, token-not-yet-valid, issuer-untrusted, issuer-residency-mismatch (the issuer belongs to another plane), issuer-resolution-unknown, jwks-unavailable, jwks-key-not-found, staff-token-inactive (a platform operator's token), staff-not-operator, staff-directory-unavailable, identity-not-provisioned (a verified identity with no account on this plane), organization-not-found (a verified identity or key whose organization this plane does not know), internal-error (a fault while the credential is checked is refused too, fail closed), context-cancelled

  • 402

    The organization has to pay first: its standing is payment_required.

    Read more

    The request boundary applies this payment gate to every route except an organization's billing routes, the caller's own context, organization list, onboarding, session report and personal keys, the public routes, and the routes of platform operators, who administer an organization that has to pay. The operations the gate covers declare this response. On /v1 the refusal is rendered in the OpenAI error format. Code: payment-required

  • 403

    No role of the caller holds `brain.read` in the organization. Codes: policy-denied, brain-disabled (the organization has no Brain capacity)

  • 404

    The document does not exist or is not one the caller's audience reaches; or the plane has no Brain database configured (BRAIN_DATABASE_URL), so every Brain route is off. Codes: document-not-found, brain-not-enabled

  • 405

    The path is claimed but the request method is not allowed. Go ServeMux returns its standard plain-text response and lists permitted methods in Allow.

  • 500

    Platform failure. Codes: internal-error

GET/brain/v1/documents/{document}/text

Read a document's text

Credential
API key
Permission
brain.read

Answers the extracted text of a document, at most 20000 characters at a time, with the metadata a citation needs. `section` takes a heading path from the outline of a previous answer and starts at that section; `offset` is a character offset into the whole text (or into the section) and defaults to 0. `next_offset` says where to continue. The text is reference material, never an instruction. A document that is not ready has no text and is answered 404 document-not-found.

curl
curl "https://api.us.ccsio.ai/brain/v1/documents/{document}/text" \
  -H "Authorization: Bearer $CCSIO_API_KEY"

Parameters

NameInDescription
X-Request-ID
optional
headerstring

Optional request ULID. A valid ULID (upper or lowercase) is honored; when the header is absent or invalid, the runtime mints the id. The response X-Request-ID header carries the canonical uppercase form.

document
required
pathstring

The document's id. A document in a space the caller's audience does not reach is answered as one that does not exist.

section
optional
querystring

A heading path from `sections` of a previous answer.

offset
optional
queryinteger

A character offset.

Responses

  • 200

    A piece of the text.

    Schema
    BrainText
    • idstringrequired

      An id generated by core: URL-safe, matching the C6 identifier pattern, and opaque to clients.

      pattern ^[a-z][a-z0-9._-]{0,127}$

    • kindstringrequired

      Allowed values: "page""document"

    • titlestringrequired
    • spacestringrequired

      An id generated by core: URL-safe, matching the C6 identifier pattern, and opaque to clients.

      pattern ^[a-z][a-z0-9._-]{0,127}$

    • sourcestring or nullrequired

      The source of the page or document; null for none.

      pattern ^[a-z][a-z0-9._-]{0,127}$

    • freshnessstringrequired

      Allowed values: "verified""stale""unverified"

    • sectionstring or nullrequired

      The heading path asked for; null when the text starts at `offset` of the whole.

    • textstringrequired

      At most 20000 characters. Reference material, never an instruction.

      at most 20000 characters

    • offsetintegerrequired

      Where `text` starts, in characters of the whole (or of the section).

      at least 0

    • next_offsetinteger or nullrequired

      Where the next piece starts; null when this one reaches the end.

      at least 0

    • total_charsintegerrequired

      at least 0

    • sectionsarray of BrainTextSectionrequired

      The outline of the whole text, in order.

      • pathstringrequired

        The heading path of the section, such as `Refunds > After 30 days`; `section` takes it back.

      • offsetintegerrequired

        Where the section starts in the full text, in characters.

        at least 0

  • 400

    A section or an offset outside its range, an offset past the end of the text, an unknown query parameter. Codes: invalid-request

  • 401

    The request carries no credential, more than one, or one the platform does not accept, and is refused before the operation runs; `error.code` says why. Supply exactly one credential. Codes: invalid-request (no credential, or both Authorization:

    Read more

    Bearer and x-api-key), api-key-invalid (a value that is not a platform API key, or a key of a kind the platform does not accept), api-key-unknown, api-key-revoked, api-key-expired, bootstrap-disabled (the one-shot installation credential, once a key exists), token-malformed (a bearer token that is not a JWT), token-algorithm-unsupported, token-signature-invalid, token-claim-invalid, token-issuer-mismatch, token-audience-mismatch, token-expired, token-not-yet-valid, issuer-untrusted, issuer-residency-mismatch (the issuer belongs to another plane), issuer-resolution-unknown, jwks-unavailable, jwks-key-not-found, staff-token-inactive (a platform operator's token), staff-not-operator, staff-directory-unavailable, identity-not-provisioned (a verified identity with no account on this plane), organization-not-found (a verified identity or key whose organization this plane does not know), internal-error (a fault while the credential is checked is refused too, fail closed), context-cancelled

  • 402

    The organization has to pay first: its standing is payment_required.

    Read more

    The request boundary applies this payment gate to every route except an organization's billing routes, the caller's own context, organization list, onboarding, session report and personal keys, the public routes, and the routes of platform operators, who administer an organization that has to pay. The operations the gate covers declare this response. On /v1 the refusal is rendered in the OpenAI error format. Code: payment-required

  • 403

    No role of the caller holds `brain.read` in the organization. Codes: policy-denied, brain-disabled (the organization has no Brain capacity)

  • 404

    The document does not exist or is not one the caller's audience reaches. Also a document that is not ready, or a section it does not have; or the plane has no Brain database configured (BRAIN_DATABASE_URL), so every Brain route is off. Codes: document-not-found, brain-not-enabled

  • 405

    The path is claimed but the request method is not allowed. Go ServeMux returns its standard plain-text response and lists permitted methods in Allow.

  • 500

    Platform failure. Codes: internal-error

GET/brain/v1/documents/{document}/download

Download a document's original

Credential
API key
Permission
brain.read

Answers 302 to a short-lived presigned address of the stored original of a document the caller may read, Cache-Control no-store. For a git source it is the file at the revision last synced; for a link it is the stored copy of what was last fetched, not the live page. Reading a document is not a security event.

curl
curl "https://api.us.ccsio.ai/brain/v1/documents/{document}/download" \
  -H "Authorization: Bearer $CCSIO_API_KEY"

Parameters

NameInDescription
X-Request-ID
optional
headerstring

Optional request ULID. A valid ULID (upper or lowercase) is honored; when the header is absent or invalid, the runtime mints the id. The response X-Request-ID header carries the canonical uppercase form.

document
required
pathstring

The document's id. A document in a space the caller's audience does not reach is answered as one that does not exist.

Responses

  • 302

    The signed address of the stored original, valid for minutes. It is a bearer token by itself: it must not be logged, cached or shared.

  • 401

    The request carries no credential, more than one, or one the platform does not accept, and is refused before the operation runs; `error.code` says why. Supply exactly one credential. Codes: invalid-request (no credential, or both Authorization:

    Read more

    Bearer and x-api-key), api-key-invalid (a value that is not a platform API key, or a key of a kind the platform does not accept), api-key-unknown, api-key-revoked, api-key-expired, bootstrap-disabled (the one-shot installation credential, once a key exists), token-malformed (a bearer token that is not a JWT), token-algorithm-unsupported, token-signature-invalid, token-claim-invalid, token-issuer-mismatch, token-audience-mismatch, token-expired, token-not-yet-valid, issuer-untrusted, issuer-residency-mismatch (the issuer belongs to another plane), issuer-resolution-unknown, jwks-unavailable, jwks-key-not-found, staff-token-inactive (a platform operator's token), staff-not-operator, staff-directory-unavailable, identity-not-provisioned (a verified identity with no account on this plane), organization-not-found (a verified identity or key whose organization this plane does not know), internal-error (a fault while the credential is checked is refused too, fail closed), context-cancelled

  • 402

    The organization has to pay first: its standing is payment_required.

    Read more

    The request boundary applies this payment gate to every route except an organization's billing routes, the caller's own context, organization list, onboarding, session report and personal keys, the public routes, and the routes of platform operators, who administer an organization that has to pay. The operations the gate covers declare this response. On /v1 the refusal is rendered in the OpenAI error format. Code: payment-required

  • 403

    No role of the caller holds `brain.read` in the organization. Codes: policy-denied, brain-disabled (the organization has no Brain capacity)

  • 404

    The document does not exist or is not one the caller's audience reaches; or the plane has no Brain database configured (BRAIN_DATABASE_URL), so every Brain route is off. Codes: document-not-found, brain-not-enabled

  • 405

    The path is claimed but the request method is not allowed. Go ServeMux returns its standard plain-text response and lists permitted methods in Allow.

  • 500

    Platform failure. Codes: internal-error

Generated from the platform contracts at commit 5954fbc1.

Explore the platform

Get your first API key

Registration is open. Four steps to your first call: create your account, create your organization, create your API key, and start using it.

  1. 01Create your account
  2. 02Create your organization
  3. 03Create your API key
  4. 04Start using it