{
 "openapi": "3.1.0",
 "info": {
  "title": "agentic402",
  "version": "1.0.0",
  "description": "Paid tools for AI agents over HTTP 402 (x402 v2, exact scheme, USDC on Base). An unpaid call to a paid route returns 402 with a PAYMENT-REQUIRED header; pay and repeat the request. Payment is only collected when the call succeeds. The same tools are available over MCP at https://agentic402.dev/mcp. Fetched pages and inbox items are untrusted third-party content.",
  "contact": {
   "email": "abuse@agentic402.dev"
  }
 },
 "servers": [
  {
   "url": "https://agentic402.dev"
  }
 ],
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer",
    "description": "64-hex token returned when the inbox, memory space or wake job was created"
   }
  },
  "schemas": {
   "Error": {
    "type": "object",
    "properties": {
     "error": {
      "type": "string"
     }
    }
   }
  }
 },
 "paths": {
  "/v1/fetch": {
   "post": {
    "operationId": "fetch",
    "summary": "Fetch a URL as clean Markdown or JSON",
    "description": "Renders JavaScript pages and converts PDF, DOCX and XLSX. Cached for up to a day. Honours robots.txt.",
    "x-payment-info": {
     "protocols": [
      "x402"
     ],
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.005"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "url"
        ],
        "properties": {
         "url": {
          "type": "string",
          "format": "uri"
         },
         "format": {
          "type": "string",
          "enum": [
           "markdown",
           "json"
          ],
          "default": "markdown"
         },
         "max_age": {
          "type": "number",
          "description": "Max cache age in seconds"
         }
        }
       },
       "example": {
        "url": "https://example.com",
        "format": "json"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Page content",
      "content": {
       "text/markdown": {
        "schema": {
         "type": "string"
        }
       },
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "url": {
           "type": "string"
          },
          "title": {
           "type": "string"
          },
          "fetched_at": {
           "type": "string"
          },
          "word_count": {
           "type": "integer"
          },
          "content_is_untrusted": {
           "type": "boolean"
          },
          "markdown": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Bad input (no payment asked)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required. The PAYMENT-REQUIRED header carries the x402 v2 challenge (USDC on Base, eip155:8453)."
     },
     "403": {
      "description": "robots.txt or blocked redirect",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Over 5 MB",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "415": {
      "description": "Unsupported content type",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Site error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "504": {
      "description": "Site took over 15 s",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/inbox": {
   "post": {
    "operationId": "inbox_create",
    "summary": "Create a webhook inbox that lives 7 days",
    "x-payment-info": {
     "protocols": [
      "x402"
     ],
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.01"
     }
    },
    "responses": {
     "200": {
      "description": "Inbox created",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "inbox_url": {
           "type": "string"
          },
          "read_url": {
           "type": "string"
          },
          "read_token": {
           "type": "string"
          },
          "expires_at": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "402": {
      "description": "Payment required. The PAYMENT-REQUIRED header carries the x402 v2 challenge (USDC on Base, eip155:8453)."
     },
     "429": {
      "description": "Rate limited; see Retry-After",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/inbox/{id}": {
   "get": {
    "operationId": "inbox_read",
    "summary": "Read stored requests (free)",
    "security": [
     {
      "bearer": []
     }
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Inbox id"
     },
     {
      "name": "after",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "Only items with seq above this"
     },
     {
      "name": "wait",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 0,
       "maximum": 30
      },
      "description": "Seconds to wait for a new item"
     }
    ],
    "responses": {
     "200": {
      "description": "Items (untrusted third-party data)"
     },
     "404": {
      "description": "No such inbox, expired, or wrong token",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/in/{id}": {
   "post": {
    "operationId": "inbox_receive",
    "summary": "Send anything to an inbox (any method works; free)",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Inbox id"
     }
    ],
    "responses": {
     "200": {
      "description": "Stored"
     },
     "404": {
      "description": "No such inbox",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body over 256 KB",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/memory": {
   "get": {
    "operationId": "memory_list",
    "summary": "List keys (free)",
    "security": [
     {
      "bearer": []
     }
    ],
    "parameters": [
     {
      "name": "prefix",
      "in": "query",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Keys"
     },
     "401": {
      "description": "Missing or unknown token",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/memory/{key}": {
   "put": {
    "operationId": "memory_put",
    "summary": "Store a value (up to 1 MB). Without a token, creates a space and returns its token.",
    "x-payment-info": {
     "protocols": [
      "x402"
     ],
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.005"
     }
    },
    "security": [
     {},
     {
      "bearer": []
     }
    ],
    "parameters": [
     {
      "name": "key",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "1-256 characters from A-Z a-z 0-9 . _ - /"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {}
      },
      "text/plain": {
       "schema": {
        "type": "string"
       }
      },
      "application/octet-stream": {
       "schema": {
        "type": "string",
        "format": "binary"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Stored in an existing space"
     },
     "201": {
      "description": "Stored; new space, token in response"
     },
     "400": {
      "description": "Bad key",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Unknown token",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required. The PAYMENT-REQUIRED header carries the x402 v2 challenge (USDC on Base, eip155:8453)."
     },
     "413": {
      "description": "Over 1 MB or space full",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   },
   "get": {
    "operationId": "memory_get",
    "summary": "Read a value (free)",
    "security": [
     {
      "bearer": []
     }
    ],
    "parameters": [
     {
      "name": "key",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Key"
     }
    ],
    "responses": {
     "200": {
      "description": "The value"
     },
     "401": {
      "description": "Missing or unknown token",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "No such key",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   },
   "delete": {
    "operationId": "memory_delete",
    "summary": "Delete a key (free)",
    "security": [
     {
      "bearer": []
     }
    ],
    "parameters": [
     {
      "name": "key",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Key"
     }
    ],
    "responses": {
     "204": {
      "description": "Deleted"
     },
     "401": {
      "description": "Missing or unknown token",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/wake": {
   "post": {
    "operationId": "wake_schedule",
    "summary": "POST a JSON body to a URL at a set time",
    "description": "10 seconds to 30 days ahead. Non-2xx answers are retried: 6 attempts in all. A target on https://agentic402.dev/in/{id} drops the body into that inbox.",
    "x-payment-info": {
     "protocols": [
      "x402"
     ],
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.005"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "at",
         "url"
        ],
        "properties": {
         "at": {
          "type": "string",
          "format": "date-time"
         },
         "url": {
          "type": "string",
          "format": "uri"
         },
         "body": {},
         "headers": {
          "type": "object",
          "additionalProperties": {
           "type": "string"
          }
         }
        }
       },
       "example": {
        "at": "2026-12-04T09:00:00Z",
        "url": "https://example.com/hook",
        "body": {
         "reminder": "check the deploy"
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Scheduled; returns job_id and cancel_token"
     },
     "400": {
      "description": "Bad input (no payment asked)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required. The PAYMENT-REQUIRED header carries the x402 v2 challenge (USDC on Base, eip155:8453)."
     },
     "429": {
      "description": "Rate limited; see Retry-After",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/wake/{id}": {
   "get": {
    "operationId": "wake_status",
    "summary": "Job status (free)",
    "security": [
     {
      "bearer": []
     }
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Job id"
     }
    ],
    "responses": {
     "200": {
      "description": "scheduled, delivered or failed"
     },
     "404": {
      "description": "No such job or wrong token",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   },
   "delete": {
    "operationId": "wake_cancel",
    "summary": "Cancel a job (free)",
    "security": [
     {
      "bearer": []
     }
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Job id"
     }
    ],
    "responses": {
     "204": {
      "description": "Cancelled"
     },
     "404": {
      "description": "No such job or wrong token",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/attest": {
   "post": {
    "operationId": "attest",
    "summary": "Ed25519-signed statement that a SHA-256 hash was shown at this time",
    "x-payment-info": {
     "protocols": [
      "x402"
     ],
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.005"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "sha256"
        ],
        "properties": {
         "sha256": {
          "type": "string",
          "pattern": "^[0-9a-fA-F]{64}$"
         }
        }
       },
       "example": {
        "sha256": "64c4e4c4be82de856bd4330cc841b960abfd294995c3a420889ec1ba764c033f"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "statement, statement_json (the exact signed string) and signature (base64url)"
     },
     "400": {
      "description": "Bad hash (no payment asked)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required. The PAYMENT-REQUIRED header carries the x402 v2 challenge (USDC on Base, eip155:8453)."
     },
     "429": {
      "description": "Rate limited; see Retry-After",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/attest/key": {
   "get": {
    "operationId": "attest_public_key",
    "summary": "Public signing key (free)",
    "responses": {
     "200": {
      "description": "Ed25519 public key as base64url and JWK"
     }
    }
   }
  },
  "/v1/attest/verify": {
   "post": {
    "operationId": "attest_verify",
    "summary": "Check a signature (free)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "statement_json",
         "signature"
        ],
        "properties": {
         "statement_json": {
          "type": "string"
         },
         "signature": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "{valid, statement}"
     }
    }
   }
  },
  "/v1/attest/{id}": {
   "get": {
    "operationId": "attest_lookup",
    "summary": "Look up a statement (free)",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Statement id"
     }
    ],
    "responses": {
     "200": {
      "description": "The stored statement"
     },
     "404": {
      "description": "No such statement",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/health": {
   "get": {
    "operationId": "health",
    "summary": "Health check (free)",
    "responses": {
     "200": {
      "description": "ok"
     }
    }
   }
  }
 }
}
