---
title: "Index documents"
method: POST
path: "/api/index/v1/indexdocuments"
tags: ["Documents"]
---

# Index documents

`POST /api/index/v1/indexdocuments`

Adds or updates multiple documents in the index. Please refer to the [bulk indexing](https://developers.glean.com/indexing/documents/bulk-indexing/choosing-indexdocuments-vs-bulkindexdocuments) documentation for an explanation of when to use this endpoint.

## Request body

- IndexDocumentsRequest — Describes the request body of the /indexdocuments API call
  - `uploadId` string — Optional id parameter to identify and track a batch of documents.
  - `datasource` string, required — Datasource of the documents
  - `documents` DocumentDefinition[], required — Batch of documents being added/updated
    - `title` string — Document title, in plain text, if present. If not present, the title would be attempted to be extracted from the content.
    - `filename` string — Source filename, in plain text, for the document. May be used as a fallback title for the document, if the title is not provided and cannot be extracted from the content. Populate this if there is no explicit title for the document and the content is sourced from a file.
    - `container` string — The container name for the content (Folder for example for file content).
    - `containerDatasourceId` string — This represents the datasource sepcific id of the container.
    - `containerObjectType` string — This represents the object type of the container. It cannot have spaces or _
    - `datasource` string, required
    - `objectType` string — The type of the document (Case, KnowledgeArticle for Salesforce for example). It cannot have spaces or _
    - `viewURL` string — The permalink for viewing the document. **Note: viewURL is a required field for non-entity datasources, but not required if the datasource is used to push custom entities (ie. datasources where isEntityDatasource is false).**'
    - `id` string — The datasource specific id for the document. This field is case insensitive and should not be more than 200 characters in length. Note: id is a required field for datasources created after 1st March 2025
    - `summary` ContentDefinition — Describes text content or base64 encoded binary content
      - `mimeType` string, required
      - `textContent` string — text content. Only one of textContent or binary content can be specified
      - `binaryContent` string — base64 encoded binary content. Only one of textContent or binary content can be specified
    - `body` ContentDefinition — Describes text content or base64 encoded binary content
      - `mimeType` string, required
      - `textContent` string — text content. Only one of textContent or binary content can be specified
      - `binaryContent` string — base64 encoded binary content. Only one of textContent or binary content can be specified
    - `author` UserReferenceDefinition — Describes how a user is referenced in a document. The user can be referenced by email or by a datasource specific id.
      - `email` string
      - `datasourceUserId` string — some datasources refer to the user by the datasource user id in the document
      - `name` string
    - `owner` UserReferenceDefinition — Describes how a user is referenced in a document. The user can be referenced by email or by a datasource specific id.
      - `email` string
      - `datasourceUserId` string — some datasources refer to the user by the datasource user id in the document
      - `name` string
    - `permissions` DocumentPermissionsDefinition — describes the access control details of the document
      - `allowedUsers` UserReferenceDefinition[] — List of users who can view the document
        - `email` string
        - `datasourceUserId` string — some datasources refer to the user by the datasource user id in the document
        - `name` string
      - `allowedGroups` string[] — List of groups that can view the document
      - `allowedGroupIntersections` PermissionsGroupIntersectionDefinition[] — List of allowed group intersections. This describes a permissions constraint of the form ((GroupA AND GroupB AND GroupC) OR (GroupX AND GroupY) OR ...
        - `requiredGroups` string[]
      - `allowAnonymousAccess` boolean — If true, then any Glean user can view the document
      - `allowAllDatasourceUsersAccess` boolean — If true, then any user who has an account in the datasource can view the document.
    - `createdAt` integer — The creation time, in epoch seconds.
    - `updatedAt` integer — The last update time, in epoch seconds.
    - `updatedBy` UserReferenceDefinition — Describes how a user is referenced in a document. The user can be referenced by email or by a datasource specific id.
      - `email` string
      - `datasourceUserId` string — some datasources refer to the user by the datasource user id in the document
      - `name` string
    - `tags` string[] — Labels associated with the document.
    - `interactions` DocumentInteractionsDefinition — describes the interactions on the document
      - `numViews` integer
      - `numLikes` integer
      - `numComments` integer
    - `status` string
    - `additionalUrls` string[] — Additional variations of the URL that this document points to.
    - `nativeAppUrl` string — A deep link, if available, into the datasource's native application for the user's platform (e.g. slack://channel/message).
    - `comments` CommentDefinition[] — Comments associated with the document.
      - `id` string, required — The document specific id for the comment. This field is case insensitive and should not be more than 200 characters in length.
      - `author` UserReferenceDefinition — Describes how a user is referenced in a document. The user can be referenced by email or by a datasource specific id.
        - `email` string
        - `datasourceUserId` string — some datasources refer to the user by the datasource user id in the document
        - `name` string
      - `content` ContentDefinition — Describes text content or base64 encoded binary content
        - `mimeType` string, required
        - `textContent` string — text content. Only one of textContent or binary content can be specified
        - `binaryContent` string — base64 encoded binary content. Only one of textContent or binary content can be specified
      - `createdAt` integer — The creation time, in epoch seconds.
      - `updatedAt` integer — The last updated time, in epoch seconds.
      - `updatedBy` UserReferenceDefinition — Describes how a user is referenced in a document. The user can be referenced by email or by a datasource specific id.
        - `email` string
        - `datasourceUserId` string — some datasources refer to the user by the datasource user id in the document
        - `name` string
    - `customProperties` CustomProperty[] — Additional metadata properties of the document. These can surface as [facets and operators](https://developers.glean.com/indexing/datasource/custom-properties/operators_and_facets).
      - `name` string
      - `value` unknown

## Response `200`

OK

## Other responses

- `400` — Bad Request
- `401` — Not Authorized
- `409` — Conflict
- `429` — Too Many Requests

---

[API](https://skmtc.net/gleanwork/apis/glean-indexing-api.md) · [All operations](https://skmtc.net/gleanwork/apis/glean-indexing-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/gleanwork/glean-indexing-api/versions/1c92beda1a4f/schema)
