Skip to content

ingest_data

ingest_data(
    memory_id: MemoryId,
    source: ContentSource,
    content_timestamp: datetime,
    actor_id: ActorId,
    *,
    config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
    session_id: Optional[SessionId] = None,
    extraction_config: Optional[ExtractionConfig] = None,
    metadata: Optional[MetadataMap] = None,
    client_token: Optional[str] = None,
) -> IngestDataOutput

Submits content directly for ingestion to generate long-term memory records in a AgentCore Memory resource.

To use this operation, you must have the bedrock-agentcore:IngestData permission.

Parameters:

  • memory_id (MemoryId) –

    The identifier of the AgentCore Memory resource to ingest content into.

  • source (ContentSource) –

    The content to ingest. Only inline content is supported.

  • content_timestamp (datetime) –

    The timestamp of when the content occurred.

  • actor_id (ActorId) –

    The identifier of the actor associated with this content. An actor represents an entity that participates in sessions and generates content.

  • session_id (Optional[SessionId], default: None ) –

    The identifier of the session that the content belongs to. If not provided, a session identifier is generated and returned in the response.

  • extraction_config (Optional[ExtractionConfig], default: None ) –

    The extraction configuration for long-term memory records. Use this parameter to specify namespace variable keys and their values for namespace substitution during extraction.

  • metadata (Optional[MetadataMap], default: None ) –

    The key-value metadata to attach to the content.

  • client_token (Optional[str], default: None ) –

    A unique, case-sensitive identifier to ensure that the operation completes no more than one time. If this token matches a previous request, AgentCore ignores the request, but does not return an error.

Raises:

  • AccessDeniedException –

    The exception that occurs when you do not have sufficient permissions to perform an action. Verify that your IAM policy includes the necessary permissions for the operation you are trying to perform.

  • ResourceNotFoundException –

    The exception that occurs when the specified resource does not exist. This can happen when using an invalid identifier or when trying to access a resource that has been deleted.

  • ServiceException –

    The service encountered an internal error. Try your request again later.

  • ServiceQuotaExceededException –

    The exception that occurs when the request would cause a service quota to be exceeded. Review your service quotas and either reduce your request rate or request a quota increase.

  • ThrottledException –

    The request was denied due to request throttling. Reduce the frequency of requests and try again.

  • ValidationException –

    The exception that occurs when the input fails to satisfy the constraints specified by the service. Check the error message for details about which input parameter is invalid and correct your request.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_bedrock_agentcore/_services/bedrock_agent_core.py
def ingest_data(
    self,
    memory_id: "capo_bedrock_agentcore.types.memory_id.MemoryId",
    source: "capo_bedrock_agentcore.types.content_source.ContentSource",
    content_timestamp: datetime.datetime,
    actor_id: "capo_bedrock_agentcore.types.actor_id.ActorId",
    *,
    config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
    session_id: Optional[
        "capo_bedrock_agentcore.types.session_id.SessionId"
    ] = None,
    extraction_config: Optional[
        "capo_bedrock_agentcore.types.extraction_config.ExtractionConfig"
    ] = None,
    metadata: Optional[
        "capo_bedrock_agentcore.types.metadata_map.MetadataMap"
    ] = None,
    client_token: Optional[str] = None,
) -> "capo_bedrock_agentcore.types.ingest_data_output.IngestDataOutput":
    """<p>Submits content directly for ingestion to generate long-term memory records in a AgentCore Memory resource.</p> <p>To use this operation, you must have the <code>bedrock-agentcore:IngestData</code> permission.</p>

    Args:
        memory_id: <p>The identifier of the AgentCore Memory resource to ingest content into.</p>
        source: <p>The content to ingest. Only inline content is supported.</p>
        content_timestamp: <p>The timestamp of when the content occurred.</p>
        actor_id: <p>The identifier of the actor associated with this content. An actor represents an entity that participates in sessions and generates content.</p>
        session_id: <p>The identifier of the session that the content belongs to. If not provided, a session identifier is generated and returned in the response.</p>
        extraction_config: <p>The extraction configuration for long-term memory records. Use this parameter to specify namespace variable keys and their values for namespace substitution during extraction.</p>
        metadata: <p>The key-value metadata to attach to the content.</p>
        client_token: <p>A unique, case-sensitive identifier to ensure that the operation completes no more than one time. If this token matches a previous request, AgentCore ignores the request, but does not return an error.</p>

    Raises:
        capo_bedrock_agentcore.errors.access_denied_exception.AccessDeniedException: <p>The exception that occurs when you do not have sufficient permissions to perform an action. Verify that your IAM policy includes the necessary permissions for the operation you are trying to perform.</p>
        capo_bedrock_agentcore.errors.resource_not_found_exception.ResourceNotFoundException: <p>The exception that occurs when the specified resource does not exist. This can happen when using an invalid identifier or when trying to access a resource that has been deleted.</p>
        capo_bedrock_agentcore.errors.service_exception.ServiceException: <p>The service encountered an internal error. Try your request again later.</p>
        capo_bedrock_agentcore.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The exception that occurs when the request would cause a service quota to be exceeded. Review your service quotas and either reduce your request rate or request a quota increase.</p>
        capo_bedrock_agentcore.errors.throttled_exception.ThrottledException: <p>The request was denied due to request throttling. Reduce the frequency of requests and try again.</p>
        capo_bedrock_agentcore.errors.validation_exception.ValidationException: <p>The exception that occurs when the input fails to satisfy the constraints specified by the service. Check the error message for details about which input parameter is invalid and correct your request.</p>
        capo_bedrock_agentcore.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_bedrock_agentcore.types.ingest_data_input.IngestDataInput]",
    ) -> OperationResponse[
        "capo_bedrock_agentcore.types.ingest_data_output.IngestDataOutput"
    ]:
        import capo_bedrock_agentcore._operations.amazon_bedrock_agent_core.ingest_data

        output, http_response = (
            capo_bedrock_agentcore._operations.amazon_bedrock_agent_core.ingest_data.ingest_data(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_bedrock_agentcore.types.ingest_data_input.IngestDataInput",
    ) -> dict[str, Any]:
        import capo_bedrock_agentcore.types.ingest_data_input

        return capo_bedrock_agentcore.types.ingest_data_input.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("IngestData", redact_input=_redact_input)
    )
    input_: capo_bedrock_agentcore.types.ingest_data_input.IngestDataInput = {
        "memory_id": memory_id,
        "source": source,
        "content_timestamp": content_timestamp,
        "actor_id": actor_id,
    }
    if session_id is not None:
        input_["session_id"] = session_id
    if extraction_config is not None:
        input_["extraction_config"] = extraction_config
    if metadata is not None:
        input_["metadata"] = metadata
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output