Payments API
The payments API allows agents to request authorization and execute stablecoin payments.Overview
The payment flow has two steps:- Request - Request authorization and policy evaluation
- Execute - Execute the approved payment onchain
autoExecute: true to request and execute in a single API call. You can also use the SDK convenience method pay() to do both in one call.
payments.request()
Request authorization for a payment. This evaluates policies without executing.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | number | Yes | Payment amount |
recipientAddress | string | Yes | Wallet address — 0x + 40 hex chars for EVM, or base58 (32-44 chars) for Solana. Validated via Zod schema. |
recipientName | string | No | Human-readable name |
purpose | string | No | Why this payment is needed |
category | string | No | Spending category |
context | object | No | Additional metadata |
walletId | string | No | Specific wallet to use |
urgency | string | No | LOW, NORMAL, HIGH, CRITICAL |
autoExecute | boolean | No | If true, automatically execute the payment when approved. Returns the transaction result directly instead of requiring a separate execute() call. |
targetContractAddress | string | No | Smart contract address for contract interaction policy evaluation |
functionSelector | string | No | 4-byte function selector (e.g., 0xa9059cbb) for contract allowlist rules |
idempotencyKey | string | No | Client-supplied key that makes retries safe. Reusing the same key with the same request returns the original request; reusing it with different request parameters returns a conflict. |
External wallet users (OpenClaw): If your agent controls its own wallet keys and uses the
/api/sdk/payments/approve endpoint instead, chainId is a required parameter. See the OpenClaw guide for the external wallet flow.Response
All payment responses now include
currency (e.g., “USDC”, “USDT”, or “pathUSD”) and chain (with chainId, chainName, chainType, and explorerUrl) so agents know exactly which network and token the payment uses.Currency depends on chain: The
currency field reflects the stablecoin used on the wallet’s blockchain. On Base, Ethereum, Arbitrum, and Polygon, both USDC and USDT are supported. On Tempo, it is pathUSD. The amount is always denominated in the stablecoin configured for the payment.Idempotent Retries
UseidempotencyKey when your caller may retry the same payment request because of network timeouts or uncertain client state.
- Same
idempotencyKey+ same request payload: returns the originalrequestIdwithidempotent: true - Same
idempotencyKey+ different request payload: returns HTTP409withcode: "IDEMPOTENCY_CONFLICT" - Different
idempotencyKey: creates a new payment request
Example
payments.execute()
Execute an approved payment request.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
requestId | string | Yes | The requestId from payment request |
Response
Example
payments.pay()
Convenience method that requests and executes in one call.Behavior
- If approved: Executes immediately and returns result
- If denied: Throws
ContoErrorwith codePAYMENT_DENIED - If requires approval: Throws
ContoErrorwith codeREQUIRES_APPROVAL
Example
autoExecute Flag
TheautoExecute flag lets you request authorization and execute the payment in a single API call, without needing a separate execute() call.
How It Works
- If APPROVED +
autoExecute: true: Executes immediately, returnsstatus: "EXECUTED"withexecutionobject containingtxHash - If DENIED or REQUIRES_APPROVAL:
autoExecuteis ignored, normal response returned - If execution fails: Returns
status: "APPROVED"withautoExecuteErrormessage andexecuteUrlfor manual retry
Example
payments.status()
Check the status of a payment request.Response
Example: Polling for Confirmation
Status Reference
Payment requests and transactions use different status values:| Payment Request Status | Description |
|---|---|
APPROVED | Policies passed, ready to execute |
DENIED | Blocked by a policy or wallet limit |
REQUIRES_APPROVAL | Needs manual human approval |
EXECUTED | Auto-executed successfully (when autoExecute: true) |
PENDING | Awaiting human approval (maps to REQUIRES_APPROVAL in SDK response) |
COMPLETED | Payment fully confirmed onchain |
EXPIRED | Approval window elapsed without execution |
| Transaction Status | Description |
|---|---|
PENDING | Transaction submitted, awaiting confirmation |
EXECUTING | Transaction is being processed |
CONFIRMING | Transaction broadcast, awaiting block confirmation |
CONFIRMED | Transaction confirmed onchain |
FAILED | Transaction failed |
REJECTED | Transaction rejected |
CANCELLED | Transaction cancelled before execution |
| Policy Result | Description |
|---|---|
ALLOWED | All policies passed |
DENIED | At least one policy denied the payment |
REQUIRES_APPROVAL | Policies passed but approval threshold triggered |
FLAGGED | Payment flagged for review |
PENDING | Policy evaluation not yet complete |
Categories
Use standard categories for better analytics:| Category | Description |
|---|---|
INFRASTRUCTURE | Cloud, hosting, compute |
AI_SERVICES | AI APIs, model training |
MARKETING | Advertising, promotions |
OPERATIONS | General operations |
VENDOR | Vendor payments |
EMPLOYEE | Employee reimbursements |
TESTING | Test transactions |
Urgency Levels
| Level | Description |
|---|---|
LOW | Can wait, batch if possible |
NORMAL | Standard priority (default) |
HIGH | Process quickly |
CRITICAL | Immediate processing |
Best Practices
Always Include Purpose
Always Include Purpose
Including purpose improves audit trails and analytics:
Handle Expiration
Handle Expiration
Approvals from
/request expire after 5 minutes. Approvals from /approve (external wallets) expire after 10 minutes. Check expiration before executing:Use Two-Step for Complex Flows
Use Two-Step for Complex Flows
Use separate request/execute when you need to:
- Validate before executing
- Show user confirmation
- Handle requires_approval status
Add Context for Debugging
Add Context for Debugging
Use the context field for debugging info:
Next Steps
Error Handling
Handle payment errors gracefully
Examples
See complete integration examples