> ## Documentation Index
> Fetch the complete documentation index at: https://glide-9da73dea.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# x402.pay

> Pay an x402 micropayment endpoint with mandatory server-side RPC verification; the facilitator receipt is never trusted for money-safety fields.

Pay an x402 micropayment endpoint. Server-side RPC verification of the on-chain tx is MANDATORY — the facilitator receipt is never trusted for money-safety fields (PLAN.md F1).

## Metadata

| Field                    | Value      |
| ------------------------ | ---------- |
| Name                     | `x402.pay` |
| Category                 | `write`    |
| Required scope           | `x402:pay` |
| Idempotency key required | yes        |

## Annotations

| Annotation              | Value             |
| ----------------------- | ----------------- |
| Title                   | Pay x402 Endpoint |
| Read-only               | no                |
| Destructive             | yes               |
| Idempotent              | yes               |
| Open-world              | yes               |
| Requires human approval | no                |

## Input schema

```json theme={null}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "resource_url": {
      "type": "string",
      "format": "uri"
    },
    "max_amount_cents": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "chain": {
      "type": "string",
      "enum": [
        "eth",
        "base",
        "arb",
        "op",
        "polygon",
        "sol"
      ]
    },
    "token": {
      "type": "string",
      "minLength": 1
    },
    "idempotency_key": {
      "type": "string",
      "minLength": 8,
      "maxLength": 128
    }
  },
  "required": [
    "resource_url",
    "max_amount_cents",
    "chain",
    "token",
    "idempotency_key"
  ],
  "additionalProperties": false
}
```

## Output schema

```json theme={null}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "payment_id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "amount_cents_paid": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "on_chain_tx": {
      "type": "string",
      "pattern": "(?:0x[0-9a-fA-F]{64})|(?:[1-9A-HJ-NP-Za-km-z]{86,88})"
    },
    "resource_payload_sha256": {
      "type": "string",
      "minLength": 64,
      "maxLength": 64
    },
    "paid_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
    }
  },
  "required": [
    "payment_id",
    "amount_cents_paid",
    "on_chain_tx",
    "resource_payload_sha256",
    "paid_at"
  ],
  "additionalProperties": false
}
```

## Auth

Caller's grant must include the `x402:pay` scope. Grants whose scope set is a superset of the required scope are accepted.

## Request examples

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://mcp.glide.co/mcp/write \
    -H "Authorization: Bearer $GLIDE_GRANT_TOKEN" \
    -H "Content-Type: application/json" \
    -H "Idempotency-Key: x402-weather-20260504-001" \
    -d '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "x402.pay",
      "params": {
        "resource_url": "https://api.weatherdata.io/premium/forecast?lat=37.77&lon=-122.41",
        "max_amount_cents": 10,
        "chain": "base",
        "token": "USDC",
        "idempotency_key": "x402-weather-20260504-001"
      }
    }'
  ```

  ```ts TypeScript theme={null}
  import { GlideClient } from './glide-client';

  const client = new GlideClient({ grantToken: process.env.GLIDE_GRANT_TOKEN! });

  const result = await client.call(
    'x402.pay',
    {
      resource_url: 'https://api.weatherdata.io/premium/forecast?lat=37.77&lon=-122.41',
      max_amount_cents: 10,
      chain: 'base',
      token: 'USDC',
      idempotency_key: 'x402-weather-20260504-001',
    },
    { idempotencyKey: 'x402-weather-20260504-001' },
  );

  console.log('Paid', result.amount_cents_paid, 'cents, tx:', result.on_chain_tx);
  ```

  ```python Python theme={null}
  from glide_client import GlideClient
  import os

  client = GlideClient(grant_token=os.environ["GLIDE_GRANT_TOKEN"])
  result = client.call(
      "x402.pay",
      {
          "resource_url": "https://api.weatherdata.io/premium/forecast?lat=37.77&lon=-122.41",
          "max_amount_cents": 10,
          "chain": "base",
          "token": "USDC",
          "idempotency_key": "x402-weather-20260504-001",
      },
      idempotency_key="x402-weather-20260504-001",
  )
  print(f"Paid {result['amount_cents_paid']} cents, tx: {result['on_chain_tx']}")
  ```
</CodeGroup>

## Response examples

**Success**

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "payment_id": "9a8b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d",
    "amount_cents_paid": 5,
    "on_chain_tx": "0x4a3b2c1d9e8f7a6b5c4d3e2f1a0b9c8d7e6f5a4b3c2d1e0f9a8b7c6d5e4f3a2b",
    "resource_payload_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    "paid_at": "2026-05-04T15:00:00Z"
  }
}
```

**Vendor unavailable — RPC could not verify tx**

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32006,
    "message": "RPC could not verify tx 0x4a3b... on base",
    "data": {
      "reason_id": "chain_tx_unverifiable"
    }
  }
}
```

## Errors

| Code     | `reason_id`                    | Meaning                                                                                                                               |
| -------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
| `-32000` | `unauthenticated`              | Bearer token missing or expired.                                                                                                      |
| `-32001` | `unauthorized`                 | Grant does not include `x402:pay`.                                                                                                    |
| `-32002` | `policy_denied`                | Envelope denied the payment (amount, counterparty, velocity).                                                                         |
| `-32004` | `rate_limited`                 | Request rate exceeded. `data.retry_after_seconds` present.                                                                            |
| `-32006` | `chain_tx_unverifiable`        | Server-side RPC returned no result for the facilitator-claimed tx. Do not retry without investigation — the funds may not have moved. |
| `-32602` | `invalid_tx_hash_format`       | RPC-verified tx hash format does not match the requested chain (EVM vs Solana mismatch).                                              |
| `-32602` | `facilitator_tx_hash_mismatch` | Facilitator's claimed tx hash differs from the RPC-verified value.                                                                    |
| `-32602` | `facilitator_amount_mismatch`  | Facilitator claimed an amount different from the on-chain verified amount.                                                            |
| `-32602` | `amount_over_max`              | Verified on-chain amount exceeds `max_amount_cents`.                                                                                  |
| `-32603` | `internal_error`               | Transient server fault. Retry with the same idempotency key.                                                                          |

**Money-safety note:** `on_chain_tx` in the response is always the server-fetched RPC value, never the facilitator-supplied value. The facilitator receipt is used only for the x402 handshake; all money-safety fields are independently verified (PLAN.md F1).
