---
title: "PUT /knowledgebases/{knowledgeBaseId}/datasources/{dataSourceId}/documents"
method: PUT
path: "/knowledgebases/{knowledgeBaseId}/datasources/{dataSourceId}/documents"
---

# PUT /knowledgebases/{knowledgeBaseId}/datasources/{dataSourceId}/documents

`PUT /knowledgebases/{knowledgeBaseId}/datasources/{dataSourceId}/documents`

Ingests documents directly into the knowledge base that is connected to the data source. The <code>dataSourceType</code> specified in the content for each document must match the type of the data source that you specify in the header. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/kb-direct-ingestion.html">Ingest changes directly into a knowledge base</a> in the Amazon Bedrock User Guide.

## Path parameters

- `knowledgeBaseId` string, required
- `dataSourceId` string, required

## Request body

- object
  - `clientToken` string — A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a>.
  - `documents` KnowledgeBaseDocument[], required — A list of objects, each of which contains information about the documents to add.
    - `metadata` object — Contains the metadata to associate with the document.
      - `type` 'IN_LINE_ATTRIBUTE' | 'S3_LOCATION', required — The type of the source source from which to add metadata.
      - `inlineAttributes` MetadataAttribute[] — An array of objects, each of which defines a metadata attribute to associate with the content to ingest. You define the attributes inline.
        - `key` string, password, required — The key of the metadata attribute.
        - `value` object, required — Contains the value of the metadata attribute.
          - `type` 'BOOLEAN' | 'NUMBER' | 'STRING' | 'STRING_LIST', required — The type of the metadata attribute.
          - `numberValue` number, double — The value of the numeric metadata attribute.
          - `booleanValue` boolean — The value of the Boolean metadata attribute.
          - `stringValue` string, password — The value of the string metadata attribute.
          - `stringListValue` StringValue[] — An array of strings that define the value of the metadata attribute.
      - `s3Location` object — The Amazon S3 location of the file containing metadata to associate with the content to ingest.
        - `uri` string, required — The S3 URI of the file containing the content to ingest.
        - `bucketOwnerAccountId` string — The identifier of the Amazon Web Services account that owns the S3 bucket containing the content to ingest.
      - `accessControlList` DocumentAccessControlEntry[] — Access control list for the document. Used when metadata type is IN_LINE_ATTRIBUTE.
        - `name` string, required — The user identifier.
        - `type` 'USER', required — The type of principal.
        - `access` 'ALLOW' | 'DENY', required — Whether to allow or deny access.
    - `content` object, required — Contains the content of the document.
      - `dataSourceType` 'CUSTOM' | 'S3', required — The type of data source that is connected to the knowledge base to which to ingest this document.
      - `custom` object — Contains information about the content to ingest into a knowledge base connected to a custom data source.
        - `customDocumentIdentifier` object, required — A unique identifier for the document.
          - `id` string, required — The identifier of the document to ingest into a custom data source.
        - `sourceType` 'IN_LINE' | 'S3_LOCATION', required — The source of the data to ingest.
        - `s3Location` object — Contains information about the Amazon S3 location of the file from which to ingest data.
          - `uri` string, required — The S3 URI of the file containing the content to ingest.
          - `bucketOwnerAccountId` string — The identifier of the Amazon Web Services account that owns the S3 bucket containing the content to ingest.
        - `inlineContent` object — Contains information about content defined inline to ingest into a knowledge base.
          - `type` 'BYTE' | 'TEXT', required — The type of inline content to define.
          - `byteContent` object — Contains information about content defined inline in bytes.
            - `mimeType` string, required — <p>The MIME type of the content. For a list of MIME types, see <a href="https://www.iana.org/assignments/media-types/media-types.xhtml">Media Types</a>. The following MIME types are supported:</p> <ul> <li> <p>text/plain</p> </li> <li> <p>text/html</p> </li> <li> <p>text/csv</p> </li> <li> <p>text/vtt</p> </li> <li> <p>message/rfc822</p> </li> <li> <p>application/xhtml+xml</p> </li> <li> <p>application/pdf</p> </li> <li> <p>application/msword</p> </li> <li> <p>application/vnd.ms-word.document.macroenabled.12</p> </li> <li> <p>application/vnd.ms-word.template.macroenabled.12</p> </li> <li> <p>application/vnd.ms-excel</p> </li> <li> <p>application/vnd.ms-excel.addin.macroenabled.12</p> </li> <li> <p>application/vnd.ms-excel.sheet.macroenabled.12</p> </li> <li> <p>application/vnd.ms-excel.template.macroenabled.12</p> </li> <li> <p>application/vnd.ms-excel.sheet.binary.macroenabled.12</p> </li> <li> <p>application/vnd.ms-spreadsheetml</p> </li> <li> <p>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</p> </li> <li> <p>application/vnd.openxmlformats-officedocument.spreadsheetml.template</p> </li> <li> <p>application/vnd.openxmlformats-officedocument.wordprocessingml.document</p> </li> <li> <p>application/vnd.openxmlformats-officedocument.wordprocessingml.template</p> </li> </ul>
            - `data` string, password, required — The base64-encoded string of the content.
          - `textContent` object — Contains information about content defined inline in text.
            - `data` string, password, required — The text of the content.
      - `s3` object — Contains information about the content to ingest into a knowledge base connected to an Amazon S3 data source
        - `s3Location` object, required — The S3 location of the file containing the content to ingest.
          - `uri` string, required — The location's URI. For example, <code>s3://my-bucket/chunk-processor/</code>.

## Response `202`

Success

- IngestKnowledgeBaseDocumentsResponse
  - `documentDetails` KnowledgeBaseDocumentDetail[] — A list of objects, each of which contains information about the documents that were ingested.
    - `knowledgeBaseId` string, required — The identifier of the knowledge base that the document was ingested into or deleted from.
    - `dataSourceId` string, required — The identifier of the data source connected to the knowledge base that the document was ingested into or deleted from.
    - `status` 'INDEXED' | 'PARTIALLY_INDEXED' | 'PENDING' | 'FAILED' | 'METADATA_PARTIALLY_INDEXED' | 'METADATA_UPDATE_FAILED' | 'IGNORED' | 'NOT_FOUND' | 'STARTING' | 'IN_PROGRESS' | 'DELETING' | 'DELETE_IN_PROGRESS', required — <p>The ingestion status of the document. The following statuses are possible:</p> <ul> <li> <p>STARTING – You submitted the ingestion job containing the document.</p> </li> <li> <p>PENDING – The document is waiting to be ingested.</p> </li> <li> <p>IN_PROGRESS – The document is being ingested.</p> </li> <li> <p>INDEXED – The document was successfully indexed.</p> </li> <li> <p>PARTIALLY_INDEXED – The document was partially indexed.</p> </li> <li> <p>METADATA_PARTIALLY_INDEXED – You submitted metadata for an existing document and it was partially indexed.</p> </li> <li> <p>METADATA_UPDATE_FAILED – You submitted a metadata update for an existing document but it failed.</p> </li> <li> <p>FAILED – The document failed to be ingested.</p> </li> <li> <p>NOT_FOUND – The document wasn't found.</p> </li> <li> <p>IGNORED – The document was ignored during ingestion.</p> </li> <li> <p>DELETING – You submitted the delete job containing the document.</p> </li> <li> <p>DELETE_IN_PROGRESS – The document is being deleted.</p> </li> </ul>
    - `identifier` object, required — Contains information that identifies the document.
      - `dataSourceType` 'CUSTOM' | 'S3', required — The type of data source connected to the knowledge base that contains the document.
      - `s3` object — Contains information that identifies the document in an S3 data source.
        - `uri` string, required — The location's URI. For example, <code>s3://my-bucket/chunk-processor/</code>.
      - `custom` object — Contains information that identifies the document in a custom data source.
        - `id` string, required — The identifier of the document to ingest into a custom data source.
    - `statusReason` string — The reason for the status. Appears alongside the status <code>IGNORED</code>.
    - `updatedAt` string, date-time — The date and time at which the document was last updated.

## Other responses

- `480` — ThrottlingException
- `481` — AccessDeniedException
- `482` — ValidationException
- `483` — InternalServerException
- `484` — ResourceNotFoundException
- `485` — ServiceQuotaExceededException

---

[API](https://skmtc.net/aws/apis/bedrock-agent.md) · [All operations](https://skmtc.net/aws/apis/bedrock-agent/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/aws/bedrock-agent/versions/a3b2356f17da/schema)
