---
title: "Buy (or check) an x402 session"
method: GET
path: "/v1/session"
---

# Buy (or check) an x402 session

`GET /v1/session`

## Request

- Base URL: `https://qmax.exchange/api`
- URL: `https://qmax.exchange/api/v1/session`
- Auth: none declared

Without a session or payment this answers 402 with the x402 body: accepts[0] gives the exact amount, payTo (QPayhub) and extra.{sellerId, resourceId, settlement:'contract'}, and paymentTicket carries a nonce. Pay on-chain with QPAYHUB.Pay (inputType 1; seller = sellerId, resource = sha256(resourceId), the ticket's nonce, exactly that amount), then repeat the request with `X-PAYMENT: base64(JSON { x402Version: 2, resource, accepted, payload: { txHash, ticket }, extensions })`. The server finds the payment in QPayhub's receipt, checks payer, seller, resource, nonce and amount, counts each payment once, and returns 200 with `X-ACCESS-GRANT` and `X-ACCESS-GRANT-EXPIRES`. Send the grant as `X-ACCESS-GRANT` on later requests. If the transaction is not confirmed yet the 402 says `invalid_transaction_state`: wait a few seconds and send the same header again. Inside a session there is no per-call charge for split quotes or arbitrage results, and the rate limit is the keyed one (ten times the free limit), counted for the session rather than the IP address.

## Headers

- `X-PAYMENT` string
- `X-ACCESS-GRANT` string

## Response `200`

{ ok, expiresAt, seconds, note }; headers X-PAYMENT-RESPONSE, X-ACCESS-GRANT, X-ACCESS-GRANT-EXPIRES

## Other responses

- `402`: x402 challenge, or a rejection with a reason such as invalid_transaction_state (retry), payment_already_used, invalid_payment_nonce_mismatch or recipient_mismatch

---

[API](https://skmtc.dev/qmax/apis/qmax-api.md) · [All operations](https://skmtc.dev/qmax/apis/qmax-api/llms.txt) · [OpenAPI document](https://skmtc.dev/qmax/apis/qmax-api/revisions/af70e2813a7a?raw)
