End User Accounts

Sign x402 payment via end user Solana account

Changed on

Signs an x402 payment payload using the end user's given Solana account. Accepts the full x402 payment required response body from a resource server plus an index into the accepts array selecting which payment option to sign. The paymentRequired envelope's x402Version, resource, and extensions are carried through into the signed payment payload; only the selected accept entry becomes paymentPayload.accepted. Returns a signed payment payload that can be base64-encoded and sent in the PAYMENT-SIGNATURE header of the resource request. If acceptsIndex is out of range for paymentRequired.accepts, or the selected accept is not a Solana network payment option, the request fails with 422.

post/v2/embedded-wallet-api/end-users/{userId}/solana/sign/x402-payment

Request

  • Base URL
    https://api.cdp.coinbase.com/platform
  • Auth
    • HTTP bearer
    • or HTTP bearer

Path parameters

userId, string required
Example:e051beeb-7163-4527-a5b6-35e301529ff2

The ID of the end user.

Query parameters

projectID, string
Example:8e03978e-40d5-43e8-bc93-6894a57f9324

The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).

Headers

X-Wallet-Auth, string

A JWT signed using your Wallet Secret, encoded in base64. Refer to the Generate Wallet Token section of our Authentication docs for more details on how to generate your Wallet Token.

X-Idempotency-Key, string

An optional string request header for making requests safely retryable. When included, duplicate requests with the same key will return identical responses. Refer to our Idempotency docs for more information on using idempotency keys.

X-Developer-Auth, string

A JWT signed using your Wallet Secret, encoded in base64. Refer to the Generate Wallet Token section of our Authentication docs for more details on how to generate your Wallet Token.

Request body

object required
paymentRequired, X402PaymentRequired required

The complete x402 payment required response body from the resource server. Top-level fields (x402Version, resource, error, extensions) are preserved in the signed payment payload; acceptsIndex selects which entry from accepts is signed as paymentPayload.accepted.

acceptsIndex, integer required

Zero-based index into paymentRequired.accepts selecting which payment option to sign. Must be less than the length of accepts. The entry at this index must be a Solana network payment option for this endpoint.

address, string required

The base58 encoded address of the end user's Solana account to sign with.

walletSecretId, string

Required when not using delegated signing. The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.

Example request

{
  "paymentRequired": {
    "x402Version": 2,
    "accepts": [
      {
        "scheme": "exact",
        "network": "eip155:8453",
        "amount": "1000000",
        "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
        "payTo": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
        "maxTimeoutSeconds": 60
      },
      {
        "scheme": "exact",
        "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
        "amount": "1000000",
        "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
        "payTo": "2wKupLR9q6wXYppw8Gr2NvWxKBUqm4PPJKkQfoxHDBg4",
        "maxTimeoutSeconds": 60
      }
    ],
    "resource": {
      "url": "https://api.example.com/premium/resource/123",
      "description": "Premium API access for data analysis.",
      "mimeType": "application/json"
    },
    "error": "PAYMENT-SIGNATURE header is required",
    "extensions": {}
  },
  "address": "HpabPRRCFbBKSuJr5PdkVvQc85FyxyTWkFM2obBRSvHT",
  "walletSecretId": "e051beeb-7163-4527-a5b6-35e301529ff2"
}

Response

Successfully signed x402 payment payload.

object required
paymentPayload, union required

The signed x402 payment payload. Base64-encode this and send it in the PAYMENT-SIGNATURE header of the resource request.

Example response

{
  "paymentPayload": {
    "x402Version": 2,
    "accepted": {
      "scheme": "exact",
      "network": "eip155:84532",
      "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
      "amount": "1000",
      "payTo": "0x122F8Fcaf2152420445Aa424E1D8C0306935B5c9",
      "maxTimeoutSeconds": 60,
      "extra": {
        "name": "USDC",
        "version": "2"
      }
    },
    "payload": {
      "signature": "0xf3746613c2d920b5fdabc0856f2aeb2d4f88ee6037b8cc5d04a71a4462f134801234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1b",
      "authorization": {
        "from": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
        "to": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
        "value": "1000000000000000000",
        "validAfter": "1716150000",
        "validBefore": "1716150000",
        "nonce": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
      }
    },
    "resource": {
      "url": "https://api.example.com/premium/resource/123",
      "description": "Premium API access for data analysis.",
      "mimeType": "application/json"
    }
  }
}

Changes

    • warning

      added the new policy_not_applicable enum value to the errorType response property for the response status

    • warning

      added the new policy_not_applicable enum value to the errorType response property for the response status

    • warning

      added the new policy_not_applicable enum value to the errorType response property for the response status

    7 more changes in this revision