Skip to main content

Overview

Atlantic’s POST /atlantic-query endpoint speaks the canonical x402 v2 HTTP-payments protocol. Header names match the public spec exactly (PAYMENT-REQUIRED, PAYMENT-SIGNATURE, PAYMENT-RESPONSE), so any standard x402 client library — x402-fetch, @coinbase/x402-axios, or your own — works against Atlantic without modification. Use x402 when you want pay-per-call access to Atlantic from an EVM wallet, either:
  • as a fallback when an API-key project runs out of prepaid credits, or
  • as a fully anonymous wallet-only client with no account on Herodotus Cloud.
If you want long-lived session-based access with prepaid credits, use the Atlantic API authentication flow instead. For AI agents, see the atlantic-api AI skill.

Two flows at a glance

Wire-level walkthrough

Step 1 — Submit the query normally

If the API key has sufficient credits, the response is the usual 200 with the query body. Do not preemptively send a PAYMENT-SIGNATURE header — the server only invokes x402 after detecting INSUFFICIENT_CREDITS, and a payment header sent with credits available is wasted.

Step 2 — Receive the 402

If credits are insufficient (or no API key was provided and anonymous payments are enabled), the server responds:
The PAYMENT-REQUIRED HTTP header carries the same payload, base64- encoded, for compatibility with standard x402 clients. Either source is canonical; the body form is shown here because it’s easier to inspect. extra field reference:

Step 3 — Sign EIP-3009 transferWithAuthorization

Pick one entry from accepts[] (typically the first; production deployments may offer multiple networks). Then sign EIP-712 typed-data for transferWithAuthorization on the chosen asset contract:
The wallet must hold at least value units of the asset on the specified network. For base-sepolia USDC, that’s Circle’s faucet.

Step 4 — Retry with PAYMENT-SIGNATURE

Build a v2 PaymentPayload and base64-encode it as the PAYMENT-SIGNATURE header. Resubmit the same body:

Step 5 — Read PAYMENT-RESPONSE

On success, the response is 200 with the usual query body and a settlement receipt in the PAYMENT-RESPONSE header:
Decoded PAYMENT-RESPONSE:
alreadyProcessed: true means the facilitator has already settled this exact (challengeId, signature) pair before — the query is allowed through but no new credit is added. Do not retry the payment. This typically happens when the client times out after the server has settled but before the response is read.

Replay, dedup, and idempotency

  • Challenges are single-use. The server stores each issued challenge with its challengeId and consumes it on a successful settle. Reusing the same PAYMENT-SIGNATURE after success returns X402_SETTLEMENT_FAILED. For each new query, fetch a fresh 402.
  • Settlements are idempotent on providerPaymentId. Submitting the same signed payment twice in a tight loop will not double-charge — the second attempt returns the same 200 with alreadyProcessed: true.
  • Resume an in-flight query. If you submit a query, get the 402, sign, but lose the connection before retrying, you can recover the pre-issued extra.atlantic_query_id from your decoded challenge, embed it in the signed accepted.extra, and retry. The server routes the payment to the original query rather than minting a new one.

Error taxonomy

curl-only recipe

For sanity-checking your environment before integrating a signer:

AI agent integration

If you’re integrating Atlantic from an AI assistant or autonomous agent, load the atlantic-api AI skill. It includes this entire flow as a copy-pasteable playbook with anti- hallucination guardrails and a viem reference snippet that handles both flows in one parameterized function. In Claude Code: