Skip to main content
Credal | Documentation

Search documentation

Type to search this documentation.

On this pageOverview

Upload Document Contents

POST https://api.credal.ai/api/v0/catalog/uploadDocumentContents Content-Type: application/json

Reference: https://docs.credal.ai/api-reference/api-reference/document-catalog/upload-document-contents

  • Authorization header (bearer token, required) — Bearer authentication of the form Bearer <token>, where token is your auth token.

This endpoint expects an object.

  • documentName (string, required) — The name of the document you want to upload.
  • documentContents (string, required) — The full LLM-formatted text contents of the document you want to upload.
  • allowedUsersEmailAddresses (list of string, required) — Users allowed to access the document. Unlike Credal's out of the box connectors which reconcile various permissions models from 3rd party software, for custom uploads the caller is responsible for specifying who can access the document and currently flattening groups if applicable. Documents can also be marked as internal public.
  • uploadAsUserEmail (string, required) — [Legacy] The user on behalf of whom the document should be uploaded. In most cases, this can simply be the email of the developer making the API call. This field will be removed in the future in favor of purely specifying permissions via allowedUsersEmailAddresses.
  • documentExternalId (string, required) — The external ID of the document. This is typically the ID as it exists in its original external system. Uploads to the same external ID will update the document in Credal.
  • documentExternalUrl (string, optional) — The external URL of the document you want to upload. If provided Credal will link to this URL.
  • customMetadata (map from string to CustomMetadataValue, optional) — Optional JSON representing any custom metadata for this document
  • collectionId (string, optional) — If specified, the document will also be added to the provided document collection. This operation is eventually consistent, meaning the document does not immediately start appearing in searches of that collection due to an asynchronous embedding process. To achieve strong consistency use the awaitVectorStoreSync parameter.
  • forceUpdate (boolean, optional) — If specified, document contents will be re-uploaded and re-embedded even if the document already exists in Credal
  • internalPublic (boolean, optional) — If specified, document will be accessible to everyone within the organization of the uploader
  • awaitVectorStoreSync (boolean, optional) — Document uploads are eventually consistent by default. If specified true the API will wait for the vector store to be updated before returning. This is useful if you want to ensure that the document is immediately searchable after this call returns.
  • documentId (UUID, required)

Request

JSON
{
  "documentName": "My Document",
  "documentContents": "Lorem ipsum...",
  "allowedUsersEmailAddresses": [
    "jack@credal.ai",
    "ravin@credal.ai"
  ],
  "uploadAsUserEmail": "jack@credal.ai",
  "documentExternalId": "73eead26-d124-4940-b329-5f068a0a8db9"
}

Response

JSON
{
  "documentId": "82e4b12a-6990-45d4-8ebd-85c00e030c24"
}

SDK Code

Example1
import { CredalClient } from "@credal/sdk";

async function main() {
    const client = new CredalClient({
        apiKey: "YOUR_TOKEN_HERE",
    });
    await client.documentCatalog.uploadDocumentContents({
        documentName: "My Document",
        documentContents: "Lorem ipsum...",
        allowedUsersEmailAddresses: [
            "jack@credal.ai",
            "ravin@credal.ai",
        ],
        uploadAsUserEmail: "jack@credal.ai",
        documentExternalId: "73eead26-d124-4940-b329-5f068a0a8db9",
    });
}
main();
Example1
from credal import CredalV0

client = CredalV0(
    api_key="YOUR_TOKEN_HERE",
)

client.document_catalog.upload_document_contents(
    document_name="My Document",
    document_contents="Lorem ipsum...",
    allowed_users_email_addresses=[
        "jack@credal.ai",
        "ravin@credal.ai"
    ],
    upload_as_user_email="jack@credal.ai",
    document_external_id="73eead26-d124-4940-b329-5f068a0a8db9",
)
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu