Skip to content

batch_create_memory_records

batch_create_memory_records(
    memory_id: MemoryId,
    records: MemoryRecordsCreateInputList,
    *,
    config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
    client_token: Optional[str] = None,
    record_expiry_specification: Optional[RecordExpirySpecification] = None,
) -> BatchCreateMemoryRecordsOutput

Creates multiple memory records in a single batch operation for the specified memory with custom content.

Parameters:

  • memory_id (MemoryId) –

    The unique ID of the memory resource where records will be created.

  • records (MemoryRecordsCreateInputList) –

    A list of memory record creation inputs to be processed in the batch operation.

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

    A unique, case-sensitive identifier to ensure idempotent processing of the batch request.

  • record_expiry_specification (Optional[RecordExpirySpecification], default: None ) –

    The record expiry (long-term memory time-to-live) applied to every record created by this request. Set recordExpiryDurationDays to the number of days after which the records expire. Only the expiry provided here is applied; the records' strategy association has no effect on their expiry. If you do not provide this value, the records do not expire. The REMOVE action does not apply when creating records.

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 batch_create_memory_records(
    self,
    memory_id: "capo_bedrock_agentcore.types.memory_id.MemoryId",
    records: "capo_bedrock_agentcore.types.memory_records_create_input_list.MemoryRecordsCreateInputList",
    *,
    config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
    client_token: Optional[str] = None,
    record_expiry_specification: Optional[
        "capo_bedrock_agentcore.types.record_expiry_specification.RecordExpirySpecification"
    ] = None,
) -> "capo_bedrock_agentcore.types.batch_create_memory_records_output.BatchCreateMemoryRecordsOutput":
    """<p>Creates multiple memory records in a single batch operation for the specified memory with custom content.</p>

    Args:
        memory_id: <p>The unique ID of the memory resource where records will be created.</p>
        records: <p>A list of memory record creation inputs to be processed in the batch operation.</p>
        client_token: <p>A unique, case-sensitive identifier to ensure idempotent processing of the batch request.</p>
        record_expiry_specification: <p>The record expiry (long-term memory time-to-live) applied to every record created by this request. Set <code>recordExpiryDurationDays</code> to the number of days after which the records expire. Only the expiry provided here is applied; the records' strategy association has no effect on their expiry. If you do not provide this value, the records do not expire. The <code>REMOVE</code> action does not apply when creating records.</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.batch_create_memory_records_input.BatchCreateMemoryRecordsInput]",
    ) -> OperationResponse[
        "capo_bedrock_agentcore.types.batch_create_memory_records_output.BatchCreateMemoryRecordsOutput"
    ]:
        import capo_bedrock_agentcore._operations.amazon_bedrock_agent_core.batch_create_memory_records

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

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

        return capo_bedrock_agentcore.types.batch_create_memory_records_input.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("BatchCreateMemoryRecords", redact_input=_redact_input),
    )
    input_: capo_bedrock_agentcore.types.batch_create_memory_records_input.BatchCreateMemoryRecordsInput = {
        "memory_id": memory_id,
        "records": records,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if record_expiry_specification is not None:
        input_["record_expiry_specification"] = record_expiry_specification

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