For the complete documentation index, see llms.txt. This page is also available as Markdown.

API Reference

Base URL

https://facilitator.ivorypay.io

All x402 endpoints are under:

https://facilitator.ivorypay.io/api/x402

Authentication

All requests require your merchant API key in the Authorization header:

Authorization: <your-merchant-api-key>

No Bearer prefix — send the raw key value.

Headers

Header
Required
Description

Authorization

Yes — all endpoints

Your merchant API key.

Content-Type

Yes — endpoints with a JSON body

Set to application/json.

payment-signature

Yes — /submit only

Base64-encoded X402SignaturePayload JSON.


POST /api/x402/initiate

Initiates an x402 payment challenge for a protected resource. Returns a PAYMENT-REQUIRED payload describing the payment terms the payer must agree to.

Request Body

Field Reference

Field
Type
Rules
Description

amount

number

Positive

Amount in decimal token units. 0.01 = 1 cent for 2-decimal tokens.

token

string

Token to pay with.

network

string

Network to pay on.

resourceUrl

string

Non-empty

URL of the resource being paid for.

resourcesDescription

string

Non-empty

Human-readable description of the resource.

Response — 201

Decode PAYMENT-REQUIRED with:


POST /api/x402/build

Builds the EIP-712 typed data hash on the server and returns it ready to sign. The server selects the correct strategy (EIP-3009 or Permit2) based on the deposit's chain and token. You must call this endpoint for Permit2 payments to obtain the spender address.

Request Body

Field Reference

Field
Type
Rules
Description

to

string

Ethereum address

The payTo address from the accepted payment option.

from

string

Ethereum address

The payer's wallet address.

nonce

string

Non-empty hex string

A unique random hex value. Generate with ethers.hexlify(ethers.randomBytes(32)).

validBefore

number

≥ 0

Unix timestamp after which the authorization expires. Set to now + maxTimeoutSeconds.

Response — 201

Response Field Reference

Field
Description

typedDataHash

The EIP-712 hash to sign with the payer's private key.

chain

The chain the deposit is on. Cross-reference with Supported Assets to determine the signing strategy.

token

The token the deposit expects.

validAfter

Earliest unix timestamp the authorization is valid. Use this when building the payment-signature header.

spender

The gas-payer vault EOA. Required for Permit2 signing — must be included as the spender field in the Permit2 PermitTransferFrom message. Ignored for EIP-3009.


POST /api/x402/submit

Submits a signed x402 authorization to initiate the on-chain transfer. Requires a payment-signature header containing the base64-encoded signed payload.

Headers

Signature Payload Structure (before base64 encoding)

Signature encoding: The signature field must be a 0x-prefixed 65-byte hex string in the format r[32] + s[32] + v[1]. This encoding is the same for both EIP-3009 and Permit2.

Response — 201


POST /api/x402/verify/:reference

Verifies a payment reference and returns on-chain proof.

Path Parameters

Parameter
Description

reference

The sessionId returned by /submit.

Response — 201

Decoded shape:


Error Responses

Condition
Status
Message

Missing Authorization header

400

Please provide your api key

Missing payment-signature on /submit

400

PAYMENT-SIGNATURE header is required

Multiple payment-signature values

400

PAYMENT-SIGNATURE header must be a single value

Insufficient Permit2 allowance

400

x402: insufficient Permit2 allowance — sender must approve Permit2 contract

Invalid request body field

400

Validation error per field

Last updated