X402 - Permissions

Verify Permission

Validates a delegated permission before processing a request.

post/x402/verify

Request

  • Base URL: https://api.sandbox.nevermined.app/api/v1
  • URL: https://api.sandbox.nevermined.app/api/v1/x402/verify
  • Auth: HTTP bearer

Request body

x402AccessTokenstring required

The x402 payment payload, base64-encoded — the token minted by POST /x402/permissions.

maxAmountstring

Maximum credits to verify against the payer's balance. Send it as a decimal STRING: the value is parsed with BigInt() and then required to be a bigint, so a JSON number is rejected with 400.

Example request

{
  "paymentRequired": {
    "x402Version": 2,
    "error": "Payment required to access resource",
    "resource": {
      "url": "https://myagent.ai/api/v1/tasks",
      "description": "AI agent task execution",
      "mimeType": "application/json"
    },
    "accepts": [
      {
        "scheme": "nvm:erc4337",
        "network": "eip155:84532",
        "planId": "44742763076047497640080230236781474129970992727896593861997347135613135571071",
        "extra": {
          "version": "1",
          "agentId": "80918427023170428029540261117198154464497879145267720259488529685089104529015",
          "httpVerb": "POST"
        }
      }
    ],
    "extensions": {}
  },
  "x402AccessToken": "eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiaHR0cHM6Ly9teWFnZW50LmFpL2FwaS92MS90YXNrcyJ9LCJhY2NlcHRlZCI6eyJzY2hlbWUiOiJudm06ZXJjNDMzNyIsIm5ldHdvcmsiOiJlaXAxNTU6ODQ1MzIiLCJwbGFuSWQiOiI0NDc0Mjc2MzA3NjA0NzQ5NzY0MDA4MDIzMDIzNjc4MTQ3NDEyOTk3MDk5MjcyNzg5NjU5Mzg2MTk5NzM0NzEzNTYxMzEzNTU3MTA3MSIsImV4dHJhIjp7InZlcnNpb24iOiIxIiwiYWdlbnRJZCI6IjgwOTE4NDI3MDIzMTcwNDI4MDI5NTQwMjYxMTE3MTk4MTU0NDY0NDk3ODc5MTQ1MjY3NzIwMjU5NDg4NTI5Njg1MDg5MTA0NTI5MDE1IiwiaHR0cFZlcmIiOiJQT1NUIn19LCJwYXlsb2FkIjp7InNpZ25hdHVyZSI6IjB4MTIzNCIsImF1dGhvcml6YXRpb24iOnsiZnJvbSI6IjB4ZjM5RmQ2ZTUxYWFkODhGNkY0Y2U2YUI4ODI3Mjc5Y2ZmRmI5MjI2NiIsInNlc3Npb25LZXlzUHJvdmlkZXIiOiJ6ZXJvZGV2Iiwic2Vzc2lvbktleXMiOltdfX0sImV4dGVuc2lvbnMiOnt9fQ==",
  "maxAmount": "2"
}

Response

Verification result

isValidboolean required

Whether the payment authorization is valid

invalidReasonstring

Reason for invalidity. Only present when isValid is false.

payerstring

Address of the payer's wallet

networkstring

Network identifier (CAIP-2 chain id, or the payment provider for fiat rails)

agentRequestIdstring

Agent request id for observability tracking (Nevermined extension). Pass it back on POST /x402/settle.

urlMatchingstring

URL pattern that matched the endpoint. Only present when endpoint validation is performed.

agentRequestobject

Agent request context for observability (Nevermined extension)

Example response

{
  "isValid": true,
  "invalidReason": "Insufficient balance",
  "payer": "0xD4f58B60330bC59cB0A07eE6A1A66ad64244eC8c",
  "network": "eip155:84532",
  "agentRequestId": "arId-123e4567-e89b-12d3-a456-426614174000",
  "urlMatching": "/api/v1/agents/:agentId/tasks",
  "agentRequest": {
    "agentRequestId": "arId-123e4567-e89b-12d3-a456-426614174000",
    "agentName": "AI Assistant Agent",
    "agentId": "80918427023170428029540261117198154464497879145267720259488529685089104529015",
    "balance": {
      "planId": "44742763076047497640080230236781474129970992727896593861997347135613135571071",
      "planName": "Premium AI Access",
      "planType": "credits",
      "holderAddress": "0xD4f58B60330bC59cB0A07eE6A1A66ad64244eC8c",
      "balance": "98",
      "creditsContract": "0x1234567890abcdef1234567890abcdef12345678",
      "isSubscriber": true,
      "pricePerCredit": 0.001
    },
    "urlMatching": "/api/v1/agents/:agentId/tasks",
    "verbMatching": "POST",
    "batch": false
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.