Every API here is available over the APIs.io API and to AI agents over MCP.
openapi: 3.2.0
info:
title: Layerhop Com X402 API
version: 0.1.0
contact:
name: LayerHop
url: https://docs.layerhop.com
description: 'Operations tagged x402 across 2 of this provider''s published API definitions: layerhop-com-openapi.yaml, openapi.yaml. Each path carries the servers of the definition it was published in.'
servers:
- url: https://api.layerhop.com
description: Hosted API (production)
- url: http://localhost:8787
description: Local API (`pnpm --filter @layerhop/api dev`)
security:
- {}
- ApiKey: []
tags:
- name: X402
description: 'HTTP 402 pay-per-request in USDC (Coinbase''s open x402 protocol, v1 and v2): payment requirements
for your resources and a facilitator (`verify`, `settle`) for payments to your own fee-splitting
deposit addresses. Needs an API key; settlement is rolling out.'
paths:
/v1/x402/supported:
get:
tags:
- X402
operationId: x402Supported
summary: Supported x402 networks
description: 'x402 `GET /supported`: the schemes and networks this facilitator verifies and settles (scheme
`exact`, USDC with EIP-3009, as x402 v2 CAIP-2 ids and v1 names), and the settler address while
settlement is enabled (`settle`).'
security: []
responses:
'200':
description: Supported kinds.
content:
application/json:
schema:
type: object
required:
- kinds
- extensions
- signers
- settle
properties:
kinds:
type: array
items:
type: object
required:
- x402Version
- scheme
- network
properties:
x402Version:
type: integer
enum:
- 1
- 2
scheme:
type: string
const: exact
network:
type: string
extensions:
type: array
items:
type: string
signers:
type: object
additionalProperties:
type: array
items:
type: string
settle:
type: boolean
description: Whether `POST /v1/x402/settle` is enabled.
example:
kinds:
- x402Version: 2
scheme: exact
network: eip155:8453
- x402Version: 1
scheme: exact
network: base
extensions: []
signers: {}
settle: false
servers:
- url: https://api.layerhop.com
description: Hosted API (production)
- url: http://localhost:8787
description: Local API (`pnpm --filter @layerhop/api dev`)
/v1/x402/requirements:
post:
tags:
- X402
operationId: x402Requirements
summary: Payment requirements for a resource
description: 'Merchant side (API key). Returns the x402 payment requirements to answer `402 Payment Required`
with, for a price you net per request (`amount`, USDC base units) paid out to `payTo`.
The requirements'' `payTo` is not your address: it is your own fee-splitting deposit address
(`payee.depositAddress`, the D-065 `CheckoutSplitterFactory` contract), one per resource and
payout address. The payer signs `amount` = your price plus LayerHop''s checkout fee on top
(`fee.bps` of the gross, 0.25% by default); the deposit address can only pay you and the fee.
LayerHop sweeps it to `payTo` once it holds at least $1. `accepts` is the x402 v2 form,
`acceptsV1` the v1 form, `paymentRequired` the whole v2 `PaymentRequired` object (base64 it into
the `PAYMENT-REQUIRED` header). The `@layerhop/sdk` `x402()` middleware does all of this.'
security:
- ApiKey: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/X402RequirementsRequest'
example:
network: base
amount: '10000'
payTo: '0x2222222222222222222222222222222222222222'
resource: https://api.example.com/v1/weather
description: Current weather
responses:
'200':
description: Requirements.
content:
application/json:
schema:
$ref: '#/components/schemas/X402RequirementsResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
servers:
- url: https://api.layerhop.com
description: Hosted API (production)
- url: http://localhost:8787
description: Local API (`pnpm --filter @layerhop/api dev`)
/v1/x402/verify:
post:
tags:
- X402
operationId: x402Verify
summary: Verify an x402 payment
description: 'x402 facilitator `POST /verify` (read-only), for payments to your own requirements (API key).
Checks the EIP-3009 signature (EOA wallets), scheme, network, asset, `payTo` (one of your
deposit addresses), the exact amount, the validity window (at least 6 s left), that the nonce is
unused (on chain and here), the payer''s USDC balance, and simulates the transfer with `eth_call`.
Always HTTP 200 for a well-formed call; `isValid: false` carries an x402 `invalidReason`.'
security:
- ApiKey: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/X402FacilitatorRequest'
responses:
'200':
description: Verification result.
content:
application/json:
schema:
$ref: '#/components/schemas/X402VerifyResponse'
example:
isValid: true
payer: '0x857b06519e91e3a54538791bdbb0e22373e36b66'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
servers:
- url: https://api.layerhop.com
description: Hosted API (production)
- url: http://localhost:8787
description: Local API (`pnpm --filter @layerhop/api dev`)
/v1/x402/settle:
post:
tags:
- X402
operationId: x402Settle
summary: Settle an x402 payment
description: 'x402 facilitator `POST /settle` (live API key). Verifies again, records the payment (an
authorization settles once; repeating the call returns the same result), submits
`transferWithAuthorization` from LayerHop''s gas-only settler and waits for the receipt (about
20 s). `success: true` → the USDC is in your deposit address and `x402.payment.settled` fires;
`errorReason: settlement_pending` → sent, receipt not in yet (LayerHop finishes it and the
webhook fires then). `FORBIDDEN` while x402 settlement is not enabled on this API, and for test
keys.'
security:
- ApiKey: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/X402FacilitatorRequest'
responses:
'200':
description: Settlement result.
content:
application/json:
schema:
$ref: '#/components/schemas/X402SettleResponse'
example:
success: true
payer: '0x857b06519e91e3a54538791bdbb0e22373e36b66'
transaction: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
network: eip155:8453
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
servers:
- url: https://api.layerhop.com
description: Hosted API (production)
- url: http://localhost:8787
description: Local API (`pnpm --filter @layerhop/api dev`)
/v1/x402/payments:
get:
tags:
- X402
operationId: listX402Payments
summary: List x402 payments
description: Payments settled through LayerHop for your account, newest first.
security:
- ApiKey: []
parameters:
- name: status
in: query
required: false
description: Only payments with this status.
schema:
type: string
enum:
- submitted
- settled
- failed
- name: network
in: query
required: false
description: 'Only payments on this network: `base`, `optimism`, `arbitrum`, `polygon`, a CAIP-2 id (`eip155:8453`) or a chain id.'
schema:
type: string
example: base
- name: from
in: query
required: false
description: Only payments created at or after this time (ISO 8601 or unix seconds).
schema:
type: string
example: '2026-11-01T00:00:00Z'
- name: to
in: query
required: false
description: Only payments created before this time (ISO 8601 or unix seconds).
schema:
type: string
example: '2026-11-08T00:00:00Z'
- name: cursor
in: query
required: false
description: '`nextCursor` from the previous page.'
schema:
type: string
- name: limit
in: query
required: false
description: 1–200, default 50.
schema:
type: integer
minimum: 1
maximum: 200
responses:
'200':
description: A page of payments.
content:
application/json:
schema:
$ref: '#/components/schemas/X402PaymentList'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
servers:
- url: https://api.layerhop.com
description: Hosted API (production)
- url: http://localhost:8787
description: Local API (`pnpm --filter @layerhop/api dev`)
/v1/x402/payments/{id}:
get:
tags:
- X402
operationId: getX402Payment
summary: Get an x402 payment
security:
- ApiKey: []
parameters:
- name: id
in: path
required: true
description: Payment id.
schema:
type: string
example: x402_01k7t9m2c4x8q6r0v3b5n7p9d
responses:
'200':
description: The payment.
content:
application/json:
schema:
$ref: '#/components/schemas/X402Payment'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
servers:
- url: https://api.layerhop.com
description: Hosted API (production)
- url: http://localhost:8787
description: Local API (`pnpm --filter @layerhop/api dev`)
components:
responses:
NotFound:
description: The resource does not exist or belongs to another account (`NOT_FOUND`).
headers:
x-request-id:
$ref: '#/components/headers/RequestId'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: NOT_FOUND
message: API key not found
requestId: 0d5e1f6a-3b2c-4d1e-8f9a-7b6c5d4e3f21
docsUrl: https://docs.layerhop.com/errors/NOT_FOUND
Unauthorized:
description: Missing or wrong credentials (`UNAUTHORIZED`).
headers:
x-request-id:
$ref: '#/components/headers/RequestId'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: UNAUTHORIZED
message: Invalid admin token
requestId: 0d5e1f6a-3b2c-4d1e-8f9a-7b6c5d4e3f21
docsUrl: https://docs.layerhop.com/errors/UNAUTHORIZED
Forbidden:
description: Not allowed (`FORBIDDEN`).
headers:
x-request-id:
$ref: '#/components/headers/RequestId'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: FORBIDDEN
message: Send-to-address payments are not available for this checkout yet; connect a wallet instead
requestId: 0d5e1f6a-3b2c-4d1e-8f9a-7b6c5d4e3f21
docsUrl: https://docs.layerhop.com/errors/FORBIDDEN
BadRequest:
description: 'Invalid request (`INVALID_PARAMS`, `UNSUPPORTED_CHAIN`, `UNSUPPORTED_TOKEN`,
`AMOUNT_TOO_SMALL`, `AMOUNT_TOO_LARGE`).
'
headers:
x-request-id:
$ref: '#/components/headers/RequestId'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: INVALID_PARAMS
message: 'amount: amount must be an integer string in base units'
requestId: 0d5e1f6a-3b2c-4d1e-8f9a-7b6c5d4e3f21
docsUrl: https://docs.layerhop.com/errors/INVALID_PARAMS
schemas:
X402RequirementsRequest:
type: object
required:
- amount
- payTo
- resource
properties:
network:
type: string
description: '`base` (default), `optimism`, `arbitrum`, `polygon`, or a CAIP-2 id.'
default: base
amount:
type: string
pattern: ^\d+$
description: The price you net per request, USDC base units (`10000` = 0.01 USDC; at least 0.01 USDC by default).
payTo:
type: string
description: Your payout address on that network.
resource:
type: string
maxLength: 2048
description: The resource URL (query and fragment ignored for the deposit address) or any stable id.
description:
type: string
maxLength: 280
mimeType:
type: string
maxLength: 100
maxTimeoutSeconds:
type: integer
minimum: 10
maximum: 3600
default: 60
Error:
type: object
description: Every non-2xx response has this body.
required:
- error
properties:
error:
type: object
required:
- code
- message
- requestId
- docsUrl
properties:
code:
$ref: '#/components/schemas/ErrorCode'
message:
type: string
description: Human-readable detail. Do not parse it.
requestId:
type: string
format: uuid
description: Same value as the `x-request-id` header.
docsUrl:
type: string
format: uri
description: Error catalog page, `https://docs.layerhop.com/errors/{code}`.
details:
type: object
description: 'Extra structured data, only on some errors. `NO_ROUTE` (and `AMOUNT_TOO_SMALL` /
`AMOUNT_TOO_LARGE` decided from the providers'' answers) on a quote carry `errors`: why
each provider returned no quote, the same entries a successful response lists in `errors`.
`AMOUNT_TOO_SMALL` on a quote may also carry the route''s minimum (D-036): `minAmount`,
`minAmountUsd`, `minAmountApprox`. `NO_ROUTE` on a live quote (and `UNSUPPORTED_CHAIN`
into a route-restricted chain such as Blast) may carry `suggestions` (D-053).
'
properties:
errors:
type: array
items:
$ref: '#/components/schemas/ProviderError'
suggestions:
type: array
maxItems: 4
description: '`NO_ROUTE` / `UNSUPPORTED_CHAIN` on a live quote: alternatives that quoted, best first (D-053).'
items:
$ref: '#/components/schemas/RouteSuggestion'
minAmount:
type: string
pattern: ^\d+$
description: '`AMOUNT_TOO_SMALL`: smallest input known to quote on this route, base units of `srcToken`.'
minAmountUsd:
type: number
description: '`AMOUNT_TOO_SMALL`: `minAmount` in USD, when the token has a price.'
minAmountApprox:
type: boolean
description: '`AMOUNT_TOO_SMALL`: `true` when `minAmount` was found by probing larger amounts ($10 / $25 / $50), so the true minimum is at most this; `false` when a provider reported it.'
ErrorCode:
type: string
description: Stable error code. Each has a page at `https://docs.layerhop.com/errors/{code}`.
enum:
- INVALID_PARAMS
- UNSUPPORTED_CHAIN
- UNSUPPORTED_TOKEN
- AMOUNT_TOO_SMALL
- AMOUNT_TOO_LARGE
- CALLS_REVERTED
- LAUNCH_IMAGE_INVALID
- NO_ROUTE
- ROUTE_EXCLUDED
- QUOTE_NOT_FOUND
- QUOTE_EXPIRED
- ORDER_NOT_FOUND
- PROVIDER_ERROR
- PROVIDER_TIMEOUT
- RATE_LIMITED
- QUOTA_EXCEEDED
- UNAUTHORIZED
- FORBIDDEN
- ADDRESS_SANCTIONED
- NOT_FOUND
- CONFLICT
- GASLESS_PENDING
- GASLESS_FAILED
- MARKET_UNAVAILABLE
- LIMIT_ORDER_REJECTED
- INTERNAL
X402SettleResponse:
type: object
required:
- success
- transaction
- network
properties:
success:
type: boolean
errorReason:
type: string
description: x402 reason; `settlement_pending` = sent, receipt not in yet.
payer:
type: string
transaction:
type: string
description: Transaction hash (empty when nothing was sent).
network:
type: string
message:
type: string
X402VerifyResponse:
type: object
required:
- isValid
properties:
isValid:
type: boolean
invalidReason:
type: string
description: x402 reason, e.g. `insufficient_funds`, `invalid_exact_evm_payload_signature`, `invalid_exact_evm_payload_authorization_nonce_used`.
payer:
type: string
message:
type: string
description: Human-readable detail.
X402FacilitatorRequest:
type: object
required:
- paymentPayload
- paymentRequirements
properties:
x402Version:
type: integer
enum:
- 1
- 2
paymentPayload:
type: object
description: 'The decoded `X-PAYMENT` (v1) or `PAYMENT-SIGNATURE` (v2) header: `payload.signature` + `payload.authorization` (EIP-3009).'
paymentRequirements:
type: object
description: The requirements you answered the 402 with (v1 or v2 form).
ProviderError:
type: object
description: A provider that failed while the request as a whole succeeded.
required:
- provider
- code
- message
properties:
provider:
$ref: '#/components/schemas/ProviderId'
code:
$ref: '#/components/schemas/ErrorCode'
message:
type: string
RouteSuggestion:
description: 'An alternative to a route that returned no quote (D-053). `dst_token`: same payment, another
destination token. `src_token`: same destination token, paid with another source token worth the
same. `via_hub`: two signed steps through `hub` (`steps[0]` then `steps[1]`, each its own quote,
order and signature); the top-level fields describe the whole trip.
'
allOf:
- $ref: '#/components/schemas/RouteLeg'
- type: object
required:
- kind
- message
properties:
kind:
type: string
enum:
- dst_token
- src_token
- via_hub
message:
type: string
description: Short text for a button, e.g. "Receive USDC on Ethereum instead".
symbol:
type: string
description: 'The token that changed: the new source or destination token, or the hub token.'
hub:
type: object
description: '`via_hub` only: the token between the two steps.'
required:
- chainId
- token
- symbol
- decimals
properties:
chainId:
type: integer
token:
type: string
symbol:
type: string
decimals:
type: integer
steps:
type: array
description: '`via_hub` only: the two legs in order.'
minItems: 2
maxItems: 2
items:
$ref: '#/components/schemas/RouteLeg'
X402RequirementsV2:
type: object
description: x402 v2 `PaymentRequirements` (scheme `exact`).
required:
- scheme
- network
- amount
- asset
- payTo
- maxTimeoutSeconds
properties:
scheme:
type: string
const: exact
network:
type: string
description: CAIP-2 network id, e.g. `eip155:8453`.
amount:
type: string
pattern: ^\d+$
description: USDC base units the payer signs (price + LayerHop fee).
asset:
type: string
description: USDC contract.
payTo:
type: string
description: Your fee-splitting deposit address.
maxTimeoutSeconds:
type: integer
extra:
type: object
description: EIP-712 domain of the asset (`name`, `version`).
RouteLeg:
type: object
description: One quotable leg, in the same terms as a quote request. Amounts are base units.
required:
- srcChain
- srcToken
- amount
- dstChain
- dstToken
properties:
srcChain:
type: integer
description: Source chain id.
srcToken:
type: string
description: 'Source token address or mint (native coin: the zero address; SOL: the system program id).'
amount:
type: string
pattern: ^\d+$
description: Input in base units of `srcToken`.
dstChain:
type: integer
description: Destination chain id.
dstToken:
type: string
dstAmount:
type: string
pattern: ^\d+$
description: Estimated output in base units of `dstToken` (from the check quote; scaled when served from cache).
X402RequirementsResponse:
type: object
required:
- payee
- price
- amount
- fee
- accepts
- acceptsV1
- paymentRequired
properties:
payee:
type: object
required:
- id
- network
- chainId
- asset
- depositAddress
- merchant
- resource
- feeBps
- factory
properties:
id:
type: string
pattern: ^x4p_
network:
type: string
chainId:
type: integer
asset:
type: string
depositAddress:
type: string
merchant:
type: string
resource:
type: string
feeBps:
type: integer
factory:
type: string
lastSweepTx:
type:
- string
- 'null'
lastSweptAt:
type:
- string
- 'null'
format: date-time
price:
type: string
pattern: ^\d+$
amount:
type: string
pattern: ^\d+$
description: What the payer signs (price + fee).
fee:
type: object
required:
- bps
- amount
properties:
bps:
type: integer
amount:
type: string
pattern: ^\d+$
accepts:
type: array
items:
$ref: '#/components/schemas/X402RequirementsV2'
acceptsV1:
type: array
items:
type: object
description: The same requirements in x402 v1 form (`network` name, `maxAmountRequired`).
paymentRequired:
type: object
description: x402 v2 `PaymentRequired` (for the `PAYMENT-REQUIRED` header).
X402PaymentList:
type: object
required:
- payments
- nextCursor
properties:
payments:
type: array
items:
$ref: '#/components/schemas/X402Payment'
nextCursor:
type:
- string
- 'null'
X402Payment:
type: object
required:
- id
- object
- status
- network
- chainId
- asset
- payer
- payTo
- amount
- merchantAmount
- feeBps
- createdAt
properties:
id:
type: string
pattern: ^x402_
object:
type: string
const: x402.payment
status:
type: string
enum:
- submitted
- settled
- failed
statusDetail:
type:
- string
- 'null'
network:
type: string
chainId:
type: integer
asset:
type: string
payer:
type: string
payTo:
type: string
description: The deposit address paid.
amount:
type: string
pattern: ^\d+$
description: What the payer paid (USDC base units).
merchantAmount:
type: string
pattern: ^\d+$
description: What you net after the deposit contract's fee.
feeBps:
type: integer
resource:
type:
- string
- 'null'
transaction:
type:
- string
- 'null'
sweepTx:
type:
- string
- 'null'
description: The sweep that paid it out to you.
settledAt:
type:
- string
- 'null'
format: date-time
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time
ProviderId:
type: string
description: 'Liquidity provider. Loaded by default: `jupiter`, `relay`, `debridge`, `zerox`, `kyberswap`, `lifi`, `mayan`,
`blast-native` (Blast''s canonical bridge: ETH on Ethereum → ETH on Blast only, no LayerHop fee).
`across` (Across Protocol, cross-chain EVM ↔ EVM), `baltex` (Baltex exchanges and DEX swaps), `routefun`
(Route, same-chain), `bebop` (Bebop RFQ and Aggregation, same-chain), `near-intents` (NEAR Intents 1Click),
`thorchain` and `chainflip` (native BTC and other non-EVM routes) `layerhop-solver` (LayerHop''s own solver: USDC between Base,
Arbitrum and OP Mainnet, filled from our inventory) and `layerhop-router` (LayerHop''s own same-chain
router on Robinhood Chain and Berachain) are built but not loaded by default.
`odos` is shut down; `mock` exists only in local
development (`LAYERHOP_ENABLE_MOCK=1`). `sandbox` serves every request made with an `lh_test_` key.
`direct` is a plain token transfer, used by checkout when the payer already holds the settlement token.
'
enum:
- jupiter
- relay
- debridge
- mayan
- zerox
- kyberswap
- odos
- lifi
- blast-native
- across
- baltex
- routefun
- bebop
- near-intents
- thorchain
- chainflip
- layerhop-router
- layerhop-solver
- mock
- sandbox
- direct
headers:
RequestId:
description: Unique id for this request. Quote it when you report a problem.
schema:
type: string
format: uuid
securitySchemes:
ApiKey:
type: apiKey
in: header
name: x-api-key
description: 'Optional. An `lh_live_…` key from the dashboard attributes requests and orders to your account
and raises your rate limit (per key, default 120 requests/minute; without a key the limit is
per IP). An invalid or revoked key is rejected with `UNAUTHORIZED`. If your account has an
active partner profile, the key selects your partner fee and allows `integratorFeeBps`.
An `lh_test_…` key switches every request to **test mode**: quotes come from the `sandbox`
provider (priced from live USD prices), built transactions are placeholders that move no funds
(`tx.sandbox: true`), and reported orders run a simulated lifecycle (pending, then filled in about
10 seconds) with webhooks sent to your test endpoints only. Amounts ending in `4001` refund,
`4002` fail and `4004` return `NO_ROUTE`. Test and live data never mix: a quote, order or
webhook of one mode is invisible to the other.
'
Session:
type: apiKey
in: cookie
name: lh_session
description: 'Dashboard session cookie set by `POST /v1/auth/verify` (HttpOnly, Secure, SameSite=Lax,
7 days). Auth and Dashboard routes only.
'
AdminBearer:
type: http
scheme: bearer
description: Operator `ADMIN_TOKEN`. Admin routes only.
AdminSession:
type: apiKey
in: cookie
name: lh_admin
description: Owner sign-in cookie set by `POST /v1/admin/login` (12 hours). Admin routes only.
x-refined-from:
- layerhop-com-openapi.yaml
- openapi.yaml