Skip to content

create_space async

create_space(
    name: SpaceName,
    *,
    config_overrides: Optional[AsyncOpenSearchMemoryClientConfig] = None,
    memory_strategies: Optional[MemoryStrategyList] = None,
    event_expiry_days: Optional[EventExpiryDays] = None,
    memory_expiry_days: Optional[MemoryExpiryDays] = None,
    extraction_model_id: Optional[ExtractionModelId] = None,
    encryption_configuration: Optional[EncryptionConfiguration] = None,
    tags: Optional[TagList] = None,
    client_token: Optional[ClientToken] = None,
) -> CreateSpaceResponse

Creates a space. A space is an AWS resource that stores the events you send and the memories extracted from them, and defines the memory strategies that extract those memories.

The operation returns before provisioning finishes, with status CREATING. Call GetSpace until the status is ACTIVE, and then use the space. If provisioning fails, the status becomes FAILED and statusReason says why.

Parameters:

  • name (SpaceName) –

    A name for the space, unique within your account in the Region. If another space already has the name, the request fails with ConflictException.

  • memory_strategies (Optional[MemoryStrategyList], default: None ) –

    The memory strategies that extract memories from the space's events: up to 10 strategies, each with a name that is unique within the space.

    Optional. Omit it, or send an empty list, to create a space with no memory strategies. Such a space stores the conversation events you send it and returns them through SearchEvents and ListEvents, but extracts no memories and has none to search. You can add strategies later with UpdateSpace.

    The serialized list can be at most 384 KiB.

  • event_expiry_days (Optional[EventExpiryDays], default: None ) –

    How many days the space keeps each event, from 1 to 365. The default is 90.

  • memory_expiry_days (Optional[MemoryExpiryDays], default: None ) –

    How many days the space keeps each memory, from 0 to 3650, counted from when the service writes the memory. Updating a memory with UpdateMemory doesn't restart the count. 0 means memories never expire. If you omit it, memories never expire.

    Searches and lists leave out a memory past its expiry, and reading, updating, or deleting it returns ResourceNotFoundException.

  • extraction_model_id (Optional[ExtractionModelId], default: None ) –

    The model that extracts and consolidates memories for every strategy in the space, as an Amazon Bedrock model ID without an inference-profile prefix: anthropic.claude-opus-5-5 or anthropic.claude-haiku-5-5. Another value fails with ValidationException, and the message lists the supported IDs. Omit it to use the service default, which can change over time and isn't returned by GetSpace. Setting a value pins the model.

  • encryption_configuration (Optional[EncryptionConfiguration], default: None ) –

    The AWS KMS key that encrypts the space's data. Omit it, or omit its kmsKeyArn, to use an AWS owned key. You can't change the key after you create the space.

  • tags (Optional[TagList], default: None ) –

    The tags to add to the space.

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

    A unique, case-sensitive identifier that makes the request idempotent. A retry with the same token and the same parameters within 2 hours returns the space that the first request created, instead of creating another. Reusing the token with different parameters, or while the first request is still in progress, fails with ConflictException.

Raises:

  • AccessDeniedException –

    You don't have sufficient access to perform this operation. To use this operation, you must have AWS Identity and Access Management (IAM) permissions for the operation, and on the resource it acts on. If the space uses a customer managed AWS Key Management Service (AWS KMS) key, you must also have permission to use the key.

  • ConflictException –

    The request conflicts with the current state of the resource. For example, the space is being created, updated, or deleted, a space with the same name already exists, or you reused a client token with different parameters. Wait for the space to finish being created, updated, or deleted, or use a different name or client token, and then retry.

  • InternalServerException –

    The service couldn't process the request because of an internal error. Retry the request.

  • ServiceQuotaExceededException –

    The request would exceed a quota, such as the number of spaces in your account or the number of strategies in a space.

  • ThrottlingException –

    The service throttled the request. Retry the request with exponential backoff.

  • ValidationException –

    The request isn't valid. The reason, message, and fieldList members describe the problem. Fix the request, and then try again.

  • UnknownServiceError –

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

Source code in docs_src/capo_opensearchmemory/_services/async_open_search_memory.py
async def create_space(
    self,
    name: "capo_opensearchmemory.types.space_name.SpaceName",
    *,
    config_overrides: Optional[AsyncOpenSearchMemoryClientConfig] = None,
    memory_strategies: Optional[
        "capo_opensearchmemory.types.memory_strategy_list.MemoryStrategyList"
    ] = None,
    event_expiry_days: Optional[
        "capo_opensearchmemory.types.event_expiry_days.EventExpiryDays"
    ] = None,
    memory_expiry_days: Optional[
        "capo_opensearchmemory.types.memory_expiry_days.MemoryExpiryDays"
    ] = None,
    extraction_model_id: Optional[
        "capo_opensearchmemory.types.extraction_model_id.ExtractionModelId"
    ] = None,
    encryption_configuration: Optional[
        "capo_opensearchmemory.types.encryption_configuration.EncryptionConfiguration"
    ] = None,
    tags: Optional["capo_opensearchmemory.types.tag_list.TagList"] = None,
    client_token: Optional[
        "capo_opensearchmemory.types.client_token.ClientToken"
    ] = None,
) -> "capo_opensearchmemory.types.create_space_response.CreateSpaceResponse":
    """<p>Creates a space. A space is an AWS resource that stores the events you send and the memories extracted from them, and defines the memory strategies that extract those memories.</p> <p>The operation returns before provisioning finishes, with <code>status</code> <code>CREATING</code>. Call <code>GetSpace</code> until the status is <code>ACTIVE</code>, and then use the space. If provisioning fails, the status becomes <code>FAILED</code> and <code>statusReason</code> says why.</p>

    Args:
        name: <p>A name for the space, unique within your account in the Region. If another space already has the name, the request fails with <code>ConflictException</code>.</p>
        memory_strategies: <p>The memory strategies that extract memories from the space's events: up to 10 strategies, each with a name that is unique within the space.</p> <p>Optional. Omit it, or send an empty list, to create a space with no memory strategies. Such a space stores the conversation events you send it and returns them through <code>SearchEvents</code> and <code>ListEvents</code>, but extracts no memories and has none to search. You can add strategies later with <code>UpdateSpace</code>.</p> <p>The serialized list can be at most 384 KiB.</p>
        event_expiry_days: <p>How many days the space keeps each event, from 1 to 365. The default is 90.</p>
        memory_expiry_days: <p>How many days the space keeps each memory, from 0 to 3650, counted from when the service writes the memory. Updating a memory with <code>UpdateMemory</code> doesn't restart the count. 0 means memories never expire. If you omit it, memories never expire.</p> <p>Searches and lists leave out a memory past its expiry, and reading, updating, or deleting it returns <code>ResourceNotFoundException</code>.</p>
        extraction_model_id: <p>The model that extracts and consolidates memories for every strategy in the space, as an Amazon Bedrock model ID without an inference-profile prefix: <code>anthropic.claude-opus-5-5</code> or <code>anthropic.claude-haiku-5-5</code>. Another value fails with <code>ValidationException</code>, and the message lists the supported IDs. Omit it to use the service default, which can change over time and isn't returned by <code>GetSpace</code>. Setting a value pins the model.</p>
        encryption_configuration: <p>The AWS KMS key that encrypts the space's data. Omit it, or omit its <code>kmsKeyArn</code>, to use an AWS owned key. You can't change the key after you create the space.</p>
        tags: <p>The tags to add to the space.</p>
        client_token: <p>A unique, case-sensitive identifier that makes the request idempotent. A retry with the same token and the same parameters within 2 hours returns the space that the first request created, instead of creating another. Reusing the token with different parameters, or while the first request is still in progress, fails with <code>ConflictException</code>.</p>

    Raises:
        capo_opensearchmemory.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this operation. To use this operation, you must have AWS Identity and Access Management (IAM) permissions for the operation, and on the resource it acts on. If the space uses a customer managed AWS Key Management Service (AWS KMS) key, you must also have permission to use the key.</p>
        capo_opensearchmemory.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of the resource. For example, the space is being created, updated, or deleted, a space with the same name already exists, or you reused a client token with different parameters. Wait for the space to finish being created, updated, or deleted, or use a different name or client token, and then retry.</p>
        capo_opensearchmemory.errors.internal_server_exception.InternalServerException: <p>The service couldn't process the request because of an internal error. Retry the request.</p>
        capo_opensearchmemory.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would exceed a quota, such as the number of spaces in your account or the number of strategies in a space.</p>
        capo_opensearchmemory.errors.throttling_exception.ThrottlingException: <p>The service throttled the request. Retry the request with exponential backoff.</p>
        capo_opensearchmemory.errors.validation_exception.ValidationException: <p>The request isn't valid. The <code>reason</code>, <code>message</code>, and <code>fieldList</code> members describe the problem. Fix the request, and then try again.</p>
        capo_opensearchmemory.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_opensearchmemory.types.create_space_request.CreateSpaceRequest]",
    ) -> AsyncOperationResponse[
        "capo_opensearchmemory.types.create_space_response.CreateSpaceResponse"
    ]:
        import capo_opensearchmemory._operations.open_search_memory.create_space

        (
            output,
            http_response,
        ) = await capo_opensearchmemory._operations.open_search_memory.create_space.async_create_space(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_opensearchmemory.types.create_space_request.CreateSpaceRequest",
    ) -> dict[str, Any]:
        import capo_opensearchmemory.types.create_space_request

        return capo_opensearchmemory.types.create_space_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateSpace", redact_input=_redact_input),
    )
    input_: capo_opensearchmemory.types.create_space_request.CreateSpaceRequest = {
        "name": name
    }
    if memory_strategies is not None:
        input_["memory_strategies"] = memory_strategies
    if event_expiry_days is not None:
        input_["event_expiry_days"] = event_expiry_days
    if memory_expiry_days is not None:
        input_["memory_expiry_days"] = memory_expiry_days
    if extraction_model_id is not None:
        input_["extraction_model_id"] = extraction_model_id
    if encryption_configuration is not None:
        input_["encryption_configuration"] = encryption_configuration
    if tags is not None:
        input_["tags"] = tags
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output