Skip to content

get_payment_instrument_balance

get_payment_instrument_balance(
    payment_manager_arn: PaymentManagerArn,
    payment_connector_id: PaymentConnectorId,
    payment_instrument_id: PaymentInstrumentId,
    chain: BlockchainChainId,
    token: InstrumentBalanceToken,
    *,
    config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
    user_id: Optional[UserId] = None,
    agent_name: Optional[PaymentAgentName] = None,
) -> GetPaymentInstrumentBalanceResponse

Get the balance of a payment instrument.

Parameters:

  • user_id (Optional[UserId], default: None ) –

    The user ID associated with this payment instrument.

  • agent_name (Optional[PaymentAgentName], default: None ) –

    The agent name associated with this request, used for observability.

  • payment_manager_arn (PaymentManagerArn) –

    The ARN of the payment manager that owns this payment instrument.

  • payment_connector_id (PaymentConnectorId) –

    The ID of the payment connector associated with this instrument.

  • payment_instrument_id (PaymentInstrumentId) –

    The ID of the payment instrument to query balance for.

  • chain (BlockchainChainId) –

    The specific blockchain chain to query balance on. Required because balances are chain-specific.

  • token (InstrumentBalanceToken) –

    The token to query balance for. Only tokens supported for X402 payments are returned.

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.

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

  • 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/bedrock_agent_core.py
def get_payment_instrument_balance(
    self,
    payment_manager_arn: "capo_bedrock_agentcore.types.payment_manager_arn.PaymentManagerArn",
    payment_connector_id: "capo_bedrock_agentcore.types.payment_connector_id.PaymentConnectorId",
    payment_instrument_id: "capo_bedrock_agentcore.types.payment_instrument_id.PaymentInstrumentId",
    chain: "capo_bedrock_agentcore.types.blockchain_chain_id.BlockchainChainId",
    token: "capo_bedrock_agentcore.types.instrument_balance_token.InstrumentBalanceToken",
    *,
    config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
    user_id: Optional["capo_bedrock_agentcore.types.user_id.UserId"] = None,
    agent_name: Optional[
        "capo_bedrock_agentcore.types.payment_agent_name.PaymentAgentName"
    ] = None,
) -> "capo_bedrock_agentcore.types.get_payment_instrument_balance_response.GetPaymentInstrumentBalanceResponse":
    """<p>Get the balance of a payment instrument.</p>

    Args:
        user_id: <p>The user ID associated with this payment instrument.</p>
        agent_name: <p>The agent name associated with this request, used for observability.</p>
        payment_manager_arn: <p>The ARN of the payment manager that owns this payment instrument.</p>
        payment_connector_id: <p>The ID of the payment connector associated with this instrument.</p>
        payment_instrument_id: <p>The ID of the payment instrument to query balance for.</p>
        chain: <p>The specific blockchain chain to query balance on. Required because balances are chain-specific.</p>
        token: <p>The token to query balance for. Only tokens supported for X402 payments are returned.</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.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.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.
    """

    def _handler(
        req: "OperationRequest[capo_bedrock_agentcore.types.get_payment_instrument_balance_request.GetPaymentInstrumentBalanceRequest]",
    ) -> OperationResponse[
        "capo_bedrock_agentcore.types.get_payment_instrument_balance_response.GetPaymentInstrumentBalanceResponse"
    ]:
        import capo_bedrock_agentcore._operations.amazon_bedrock_agent_core.get_payment_instrument_balance

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetPaymentInstrumentBalance")
    )
    input_: capo_bedrock_agentcore.types.get_payment_instrument_balance_request.GetPaymentInstrumentBalanceRequest = {
        "payment_manager_arn": payment_manager_arn,
        "payment_connector_id": payment_connector_id,
        "payment_instrument_id": payment_instrument_id,
        "chain": chain,
        "token": token,
    }
    if user_id is not None:
        input_["user_id"] = user_id
    if agent_name is not None:
        input_["agent_name"] = agent_name

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