Skip to content

start_browser_session async

start_browser_session(
    browser_identifier: str,
    *,
    config_overrides: Optional[AsyncBedrockAgentCoreClientConfig] = None,
    trace_id: Optional[str] = None,
    trace_parent: Optional[str] = None,
    name: Optional[Name] = None,
    session_timeout_seconds: Optional[BrowserSessionTimeout] = None,
    view_port: Optional[ViewPort] = None,
    extensions: Optional[BrowserExtensions] = None,
    profile_configuration: Optional[BrowserProfileConfiguration] = None,
    proxy_configuration: Optional[ProxyConfiguration] = None,
    enterprise_policies: Optional[BrowserEnterprisePolicies] = None,
    certificates: Optional[Certificates] = None,
    filesystem_configurations: Optional[ToolsFileSystemConfigurations] = None,
    client_token: Optional[ClientToken] = None,
) -> StartBrowserSessionResponse

Creates and initializes a browser session in Amazon Bedrock AgentCore. The session enables agents to navigate and interact with web content, extract information from websites, and perform web-based tasks as part of their response generation.

To create a session, you must specify a browser identifier and a name. You can also configure the viewport dimensions to control the visible area of web content. The session remains active until it times out or you explicitly stop it using the StopBrowserSession operation.

The following operations are related to StartBrowserSession:

Parameters:

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

    The trace identifier for request tracking.

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

    The parent trace information for distributed tracing.

  • browser_identifier (str) –

    The unique identifier of the browser to use for this session. This identifier specifies which browser environment to initialize for the session.

  • name (Optional[Name], default: None ) –

    The name of the browser session. This name helps you identify and manage the session. The name does not need to be unique.

  • session_timeout_seconds (Optional[BrowserSessionTimeout], default: None ) –

    The duration in seconds (time-to-live) after which the session automatically terminates, regardless of ongoing activity. Defaults to 3600 seconds (1 hour). Recommended minimum: 60 seconds. Maximum allowed: 28,800 seconds (8 hours).

  • view_port (Optional[ViewPort], default: None ) –

    The dimensions of the browser viewport for this session. This determines the visible area of the web content and affects how web pages are rendered. If not specified, Amazon Bedrock AgentCore uses a default viewport size.

  • extensions (Optional[BrowserExtensions], default: None ) –

    A list of browser extensions to load into the browser session.

  • profile_configuration (Optional[BrowserProfileConfiguration], default: None ) –

    The browser profile configuration to use for this session. A browser profile contains persistent data such as cookies and local storage that can be reused across multiple browser sessions. If specified, the session initializes with the profile's stored data, enabling continuity for tasks that require authentication or personalized settings.

  • proxy_configuration (Optional[ProxyConfiguration], default: None ) –

    Optional proxy configuration for routing browser traffic through customer-specified proxy servers. When provided, enables HTTP Basic authentication via Amazon Web Services Secrets Manager and domain-based routing rules. Requires secretsmanager:GetSecretValue IAM permission for the specified secret ARNs.

  • enterprise_policies (Optional[BrowserEnterprisePolicies], default: None ) –

    A list of files containing enterprise policies for the browser.

  • certificates (Optional[Certificates], default: None ) –

    A list of certificates to install in the browser session.

  • filesystem_configurations (Optional[ToolsFileSystemConfigurations], default: None ) –

    The file system configurations to mount into the browser session. Use these configurations to mount your own Amazon Simple Storage Service (Amazon S3) Files or Amazon Elastic File System (Amazon EFS) access points. Your session can then read and write your data. If you don't specify this field, no additional file systems are mounted.

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

    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 AgentCore ignores the request, but does not return an error. This parameter helps prevent the creation of duplicate sessions if there are temporary network issues.

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.

  • ConflictException –

    The exception that occurs when the request conflicts with the current state of the resource. This can happen when trying to modify a resource that is currently being modified by another request, or when trying to create a resource that already exists.

  • InternalServerException –

    The exception that occurs when the service encounters an unexpected internal error. This is a temporary condition that will resolve itself with retries. We recommend implementing exponential backoff retry logic in your application.

  • 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.

  • 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.

  • ThrottlingException –

    The exception that occurs when the request was denied due to request throttling. This happens when you exceed the allowed request rate for an operation. Reduce the frequency of requests or implement exponential backoff retry logic in your application.

  • 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/async_bedrock_agent_core.py
async def start_browser_session(
    self,
    browser_identifier: str,
    *,
    config_overrides: Optional[AsyncBedrockAgentCoreClientConfig] = None,
    trace_id: Optional[str] = None,
    trace_parent: Optional[str] = None,
    name: Optional["capo_bedrock_agentcore.types.name.Name"] = None,
    session_timeout_seconds: Optional[
        "capo_bedrock_agentcore.types.browser_session_timeout.BrowserSessionTimeout"
    ] = None,
    view_port: Optional["capo_bedrock_agentcore.types.view_port.ViewPort"] = None,
    extensions: Optional[
        "capo_bedrock_agentcore.types.browser_extensions.BrowserExtensions"
    ] = None,
    profile_configuration: Optional[
        "capo_bedrock_agentcore.types.browser_profile_configuration.BrowserProfileConfiguration"
    ] = None,
    proxy_configuration: Optional[
        "capo_bedrock_agentcore.types.proxy_configuration.ProxyConfiguration"
    ] = None,
    enterprise_policies: Optional[
        "capo_bedrock_agentcore.types.browser_enterprise_policies.BrowserEnterprisePolicies"
    ] = None,
    certificates: Optional[
        "capo_bedrock_agentcore.types.certificates.Certificates"
    ] = None,
    filesystem_configurations: Optional[
        "capo_bedrock_agentcore.types.tools_file_system_configurations.ToolsFileSystemConfigurations"
    ] = None,
    client_token: Optional[
        "capo_bedrock_agentcore.types.client_token.ClientToken"
    ] = None,
) -> "capo_bedrock_agentcore.types.start_browser_session_response.StartBrowserSessionResponse":
    """<p>Creates and initializes a browser session in Amazon Bedrock AgentCore. The session enables agents to navigate and interact with web content, extract information from websites, and perform web-based tasks as part of their response generation.</p> <p>To create a session, you must specify a browser identifier and a name. You can also configure the viewport dimensions to control the visible area of web content. The session remains active until it times out or you explicitly stop it using the <code>StopBrowserSession</code> operation.</p> <p>The following operations are related to <code>StartBrowserSession</code>:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_GetBrowserSession.html">GetBrowserSession</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_UpdateBrowserStream.html">UpdateBrowserStream</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_SaveBrowserSessionProfile.html">SaveBrowserSessionProfile</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_StopBrowserSession.html">StopBrowserSession</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_InvokeBrowser.html">InvokeBrowser</a> </p> </li> </ul>

    Args:
        trace_id: <p>The trace identifier for request tracking.</p>
        trace_parent: <p>The parent trace information for distributed tracing.</p>
        browser_identifier: <p>The unique identifier of the browser to use for this session. This identifier specifies which browser environment to initialize for the session.</p>
        name: <p>The name of the browser session. This name helps you identify and manage the session. The name does not need to be unique.</p>
        session_timeout_seconds: <p>The duration in seconds (time-to-live) after which the session automatically terminates, regardless of ongoing activity. Defaults to 3600 seconds (1 hour). Recommended minimum: 60 seconds. Maximum allowed: 28,800 seconds (8 hours).</p>
        view_port: <p>The dimensions of the browser viewport for this session. This determines the visible area of the web content and affects how web pages are rendered. If not specified, Amazon Bedrock AgentCore uses a default viewport size.</p>
        extensions: <p>A list of browser extensions to load into the browser session.</p>
        profile_configuration: <p>The browser profile configuration to use for this session. A browser profile contains persistent data such as cookies and local storage that can be reused across multiple browser sessions. If specified, the session initializes with the profile's stored data, enabling continuity for tasks that require authentication or personalized settings.</p>
        proxy_configuration: <p>Optional proxy configuration for routing browser traffic through customer-specified proxy servers. When provided, enables HTTP Basic authentication via Amazon Web Services Secrets Manager and domain-based routing rules. Requires <code>secretsmanager:GetSecretValue</code> IAM permission for the specified secret ARNs.</p>
        enterprise_policies: <p>A list of files containing enterprise policies for the browser.</p>
        certificates: <p>A list of certificates to install in the browser session.</p>
        filesystem_configurations: <p>The file system configurations to mount into the browser session. Use these configurations to mount your own Amazon Simple Storage Service (Amazon S3) Files or Amazon Elastic File System (Amazon EFS) access points. Your session can then read and write your data. If you don't specify this field, no additional file systems are mounted.</p>
        client_token: <p>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 AgentCore ignores the request, but does not return an error. This parameter helps prevent the creation of duplicate sessions if there are temporary network issues.</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.conflict_exception.ConflictException: <p>The exception that occurs when the request conflicts with the current state of the resource. This can happen when trying to modify a resource that is currently being modified by another request, or when trying to create a resource that already exists.</p>
        capo_bedrock_agentcore.errors.internal_server_exception.InternalServerException: <p>The exception that occurs when the service encounters an unexpected internal error. This is a temporary condition that will resolve itself with retries. We recommend implementing exponential backoff retry logic in your application.</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_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.throttling_exception.ThrottlingException: <p>The exception that occurs when the request was denied due to request throttling. This happens when you exceed the allowed request rate for an operation. Reduce the frequency of requests or implement exponential backoff retry logic in your application.</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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_bedrock_agentcore.types.start_browser_session_request.StartBrowserSessionRequest]",
    ) -> AsyncOperationResponse[
        "capo_bedrock_agentcore.types.start_browser_session_response.StartBrowserSessionResponse"
    ]:
        import capo_bedrock_agentcore._operations.amazon_bedrock_agent_core.start_browser_session

        (
            output,
            http_response,
        ) = await capo_bedrock_agentcore._operations.amazon_bedrock_agent_core.start_browser_session.async_start_browser_session(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("StartBrowserSession")
    )
    input_: capo_bedrock_agentcore.types.start_browser_session_request.StartBrowserSessionRequest = {
        "browser_identifier": browser_identifier
    }
    if trace_id is not None:
        input_["trace_id"] = trace_id
    if trace_parent is not None:
        input_["trace_parent"] = trace_parent
    if name is not None:
        input_["name"] = name
    if session_timeout_seconds is not None:
        input_["session_timeout_seconds"] = session_timeout_seconds
    if view_port is not None:
        input_["view_port"] = view_port
    if extensions is not None:
        input_["extensions"] = extensions
    if profile_configuration is not None:
        input_["profile_configuration"] = profile_configuration
    if proxy_configuration is not None:
        input_["proxy_configuration"] = proxy_configuration
    if enterprise_policies is not None:
        input_["enterprise_policies"] = enterprise_policies
    if certificates is not None:
        input_["certificates"] = certificates
    if filesystem_configurations is not None:
        input_["filesystem_configurations"] = filesystem_configurations
    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