AgentPMT

Pay for one eligible AgentPMT tool action with x402.

X402 Payments For Tool Usage

Use direct x402 payment when an autonomous agent needs one eligible tool action. The agent sends action parameters, receives a 402 Payment Required challenge, signs one token transfer authorization, and retries the exact same action body with X-PAYMENT.

The product action must be direct-x402-enabled.

Endpoint

POST https://www.agentpmt.com/api/external/tools/{productSlug}/actions/{actionSlug}/invoke

Direct x402 requests use the action parameters as the JSON request body.

Flow

Send the action parameters

POST the action's JSON parameters to the invoke endpoint without a payment header. If the action is direct-x402-enabled and payment is required, the server responds with 402.

Decode the payment challenge

Read the JSON response body and the base64 PAYMENT-REQUIRED header. Both describe the same payment challenge with x402Version, resource, and accepts.

Select the exact acceptance

Choose an accepts[] entry by network, token asset, payee, amount, and resource URL. Do not blindly sign the first acceptance if the agent has a network or asset policy.

Sign the EIP-712 authorization

Build the TransferWithAuthorization typed-data domain from acceptance.extra.name, acceptance.extra.version, the numeric chain id parsed from acceptance.network, and acceptance.asset.

Retry the same body with X-PAYMENT

Base64-encode the signed x402 envelope and retry the exact same action-parameter JSON body with X-PAYMENT: <base64-envelope>.

Initial Request

This example uses the live AI Writing Quality Check action tested on May 15, 2026.

curl -i -s -X POST "https://www.agentpmt.com/api/external/tools/ai-writing-quality-check/actions/check_for_banned_phrases/invoke" \
  -H "Content-Type: application/json" \
  -d '{ "content":"Our customers love us. Ask our AI." }'

Expected response:

  • HTTP status 402 Payment Required.
  • PAYMENT-REQUIRED header containing a base64 JSON challenge.
  • JSON body containing x402Version, resource, and accepts.

The decoded challenge includes one or more payment requirements similar to this shape:

{
  "x402Version": 2,
  "error": "Payment required",
  "resource": {
    "url": "https://www.agentpmt.com/api/external/tools/ai-writing-quality-check/actions/check_for_banned_phrases/invoke",
    "description": "AgentPMT tool action",
    "mimeType": "application/json"
  },
  "accepts": [
    {
      "scheme": "exact",
      "network": "eip155:8453",
      "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "payTo": "0x7ed9057a8edec4496c902c9aecf1d30947d7cc09",
      "amount": "50000",
      "extra": {
        "name": "USD Coin",
        "version": "2"
      }
    }
  ]
}

The example acceptance above is Base USDC. amount is in token minor units, so 50000 means 0.05 USDC for a six-decimal token.

Sign the Payment

Sign the selected acceptance with EIP-712 TransferWithAuthorization typed data.

EIP-712 domain:

FieldValue
nameacceptance.extra.name
versionacceptance.extra.version
chainIdNumeric chain id parsed from acceptance.network, such as 8453 from eip155:8453
verifyingContractacceptance.asset

EIP-712 primary type:

{
  "TransferWithAuthorization": [
    { "name": "from", "type": "address" },
    { "name": "to", "type": "address" },
    { "name": "value", "type": "uint256" },
    { "name": "validAfter", "type": "uint256" },
    { "name": "validBefore", "type": "uint256" },
    { "name": "nonce", "type": "bytes32" }
  ]
}

Authorization message:

{
  "from": "0xPAYER_WALLET",
  "to": "acceptance.payTo",
  "value": "acceptance.amount",
  "validAfter": "0",
  "validBefore": "<unix-timestamp-before-timeout>",
  "nonce": "0x<fresh-32-byte-nonce>"
}

The signed x402 envelope is base64-encoded JSON. Use the selected acceptance's network and asset, and include the signature plus authorization values.

{
  "x402Version": 2,
  "scheme": "exact",
  "network": "eip155:8453",
  "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
  "payload": {
    "signature": "0x<eip712-signature>",
    "authorization": {
      "from": "0xPAYER_WALLET",
      "to": "0x7ed9057a8edec4496c902c9aecf1d30947d7cc09",
      "value": "50000",
      "validAfter": "0",
      "validBefore": "<unix-timestamp-before-timeout>",
      "nonce": "0x<fresh-32-byte-nonce>"
    }
  }
}

Retry the exact same action body:

curl -s -X POST "https://www.agentpmt.com/api/external/tools/ai-writing-quality-check/actions/check_for_banned_phrases/invoke" \
  -H "Content-Type: application/json" \
  -H "X-PAYMENT: <base64-envelope>" \
  -d '{ "content":"Our customers love us. Ask our AI." }'

On success, the response is the paid tool result with x402 payment metadata.

Successful Response

A successful direct x402 tool call returns the paid tool result and sets PAYMENT-RESPONSE with a base64-encoded JSON settlement payload. Decode that header to read the settlement transaction, network, payer, and the payment requirement that the broadcast satisfied.

Build it yourself, or hire AgentPMT to build it with you.

Let’s turn these ideas into reality. Dive in and build it yourself, or bring in the AgentPMT consulting team for a seamless, end-to-end implementation.

Free to start. Consulting available when you want expert implementation.