X402 Git Auth API
Challenges and key rotation.
Challenges and key rotation.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/x402git-com:x402git-com-auth-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: X402 Git Auth API
version: 0.0.1
summary: Paid access to private git repos over x402/USDC, for humans and agents.
description: 'Every creator and buyer capability is an authenticated JSON endpoint before it is a web page (D9); the web app calls these same routes.
**Money.** Every amount is micro-USDC (6 decimals) encoded as a decimal integer string: `"9000000"` is $9.00. Never a JSON number, because a JSON number is a double.
**Errors.** Every error on every route is `{ code, message, docs_url, details? }` from the catalogue below.
**Payment.** x402 v2, `exact` scheme, USDC on Base. Access is granted only after the facilitator''s `settle` returns a transaction hash.'
license:
name: AGPL-3.0-only
identifier: AGPL-3.0-only
contact:
name: X402 Git
email: abuse@x402git.com
url: https://x402git.com/abuse
x-guidance: Every listing is a private git repository sold as a zip over x402 (USDC on Base). Read the free manifest at GET /api/label/{owner}/{slug} first; GET /api/r/{owner}/{slug} answers 402 with the price and the exact requirement to sign, and 200 with a signed download URL once the payment settles. Echo extra.quote_id as X-Quote-Id and extensions.bazaar in the payment payload. The full procedure is at https://x402git.com/.well-known/agent-skills/buy-a-repo/SKILL.md; the same tools are an MCP server at https://x402git.com/api/mcp. Every live resource is listed at https://x402git.com/.well-known/x402.
servers:
- url: https://x402git.com
tags:
- name: Auth
description: Challenges and key rotation.
paths:
/api/auth/challenge:
get:
operationId: getApiAuthChallenge
summary: Get a challenge to sign
tags:
- Auth
description: 'FR-20. Single use, 5-minute expiry. A challenge is bound to one `purpose` — `address_proof` on registration, `step_up` on a payout change, `rotate_key`, or `wallet_ownership` for the `X-Wallet-Signature` header — and a signature is refused on any other path (W2.2). `purpose` is required; there is no default. A payout rebind additionally requires `new_payout_address`: the signed message names the incoming address, and the signature authorises that one change only.'
security: []
parameters:
- name: address
in: query
required: true
description: The address that will sign.
schema:
type: string
- name: purpose
in: query
required: true
description: 'The action this signature authorises: `address_proof`, `step_up`, `rotate_key`, or `wallet_ownership`.'
schema:
type: string
- name: new_payout_address
in: query
required: false
description: 'For a `step_up` challenge that will authorise a payout rebind: the address payouts should move to. The signed message names it, and PATCH /api/creators/me refuses a rebind signed without it.'
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Challenge'
'400':
description: '`invalid_request` — The request body or parameters did not validate.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
examples:
invalid_request:
value:
code: invalid_request
message: The request body or parameters did not validate.
docs_url: https://x402git.com/docs/errors#invalid_request
'429':
description: '`rate_limited` — Too many requests. Retry after the interval given.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
examples:
rate_limited:
value:
code: rate_limited
message: Too many requests. Retry after the interval given.
docs_url: https://x402git.com/docs/errors#rate_limited
retry_after_seconds: 60
headers:
retry-after:
description: Seconds to wait.
schema:
type: string
/api/auth/rotate-key:
post:
operationId: postApiAuthRotateKey
summary: Rotate the API key with a wallet signature
tags:
- Auth
description: 'FR-4. No Authorization header: the signature from the bound payout address is the credential. The old key is revoked immediately.'
security: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RotateKeyRequest'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/RotateKeyResponse'
'400':
description: '`invalid_request` — The request body or parameters did not validate.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
examples:
invalid_request:
value:
code: invalid_request
message: The request body or parameters did not validate.
docs_url: https://x402git.com/docs/errors#invalid_request
'401':
description: '`invalid_signature` — The wallet signature is missing, malformed, expired or already used.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
examples:
invalid_signature:
value:
code: invalid_signature
message: The wallet signature is missing, malformed, expired or already used.
docs_url: https://x402git.com/docs/errors#invalid_signature
'404':
description: '`not_found` — No such listing, version or resource.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
examples:
not_found:
value:
code: not_found
message: No such listing, version or resource.
docs_url: https://x402git.com/docs/errors#not_found
'429':
description: '`rate_limited` — Too many requests. Retry after the interval given.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
examples:
rate_limited:
value:
code: rate_limited
message: Too many requests. Retry after the interval given.
docs_url: https://x402git.com/docs/errors#rate_limited
retry_after_seconds: 60
headers:
retry-after:
description: Seconds to wait.
schema:
type: string
components:
schemas:
Nonce:
type: string
pattern: ^[A-Za-z0-9_-]{16,128}$
description: The opaque nonce from GET /api/auth/challenge. Single use, 5-minute expiry.
Challenge:
type: object
properties:
nonce:
$ref: '#/components/schemas/Nonce'
message:
type: string
expires_at:
$ref: '#/components/schemas/IsoDateTime'
address:
$ref: '#/components/schemas/Address'
required:
- nonce
- message
- expires_at
- address
additionalProperties: false
description: 'A single-use challenge, valid 5 minutes. Sign `message` verbatim (EIP-191 personal_sign) and present it as `address_proof`, `step_up`, the rotate-key body, or the `X-Wallet-Signature: <address>.<nonce>.<signature>` header.'
IsoDateTime:
type: string
format: date-time
pattern: ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
description: RFC 3339 timestamp.
RotateKeyRequest:
type: object
properties:
handle:
$ref: '#/components/schemas/Handle'
address:
$ref: '#/components/schemas/Address'
nonce:
$ref: '#/components/schemas/Nonce'
signature:
$ref: '#/components/schemas/HexSignature'
required:
- handle
- address
- nonce
- signature
additionalProperties: false
description: 'No Authorization header is required: the wallet signature is the credential. `handle` disambiguates which creator, since a payout address may be shared (W2.5).'
Error:
type: object
properties:
code:
$ref: '#/components/schemas/ErrorCode'
message:
type: string
docs_url:
type: string
details: {}
retry_after_seconds:
type: integer
minimum: 0
maximum: 9007199254740991
required:
- code
- message
- docs_url
additionalProperties: false
description: Every error on every route. `docs_url` anchors into /docs/errors.
examples:
- code: invite_required
message: A valid invite code is required to register through the API.
docs_url: https://x402git.com/docs/errors#invite_required
HexSignature:
type: string
maxLength: 4096
pattern: ^0x[0-9a-fA-F]+$
description: An EIP-191 personal_sign signature, or an ERC-1271 payload for a contract wallet.
Handle:
type: string
pattern: ^[a-z0-9-]{2,40}$
description: A creator handle. The `owner` segment of every URL.
ApiScope:
type: string
enum:
- listings:write
- earnings:read
RotateKeyResponse:
type: object
properties:
creator_id:
type: string
format: uuid
pattern: ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
handle:
$ref: '#/components/schemas/Handle'
api_key:
type: string
api_key_scopes:
type: array
items:
$ref: '#/components/schemas/ApiScope'
rotated_at:
$ref: '#/components/schemas/IsoDateTime'
required:
- creator_id
- handle
- api_key
- api_key_scopes
- rotated_at
additionalProperties: false
description: The previous key is revoked the moment this returns.
Address:
type: string
pattern: ^0x[0-9a-fA-F]{40}$
description: An EVM address, 0x-prefixed and 40 hex characters.
examples:
- '0x0000000000000000000000000000000000000001'
ErrorCode:
type: string
enum:
- insufficient_balance
- expired_authorization
- replay
- settlement_pending
- settlement_timeout
- authorization_mismatch
- price_changed
- sanctioned_counterparty
- listing_not_ready
- licence_block
- scan_failed
- version_exists
- description_missing
- retired
- not_entitled
- derivative_of
- public_repo
- invalid_key
- insufficient_scope
- step_up_required
- terms_version_stale
- payout_address_unverified
- invite_required
- invalid_signature
- rate_limited
- repo_too_large
- too_many_unpublished
- blocked_jurisdiction
- paused
- invalid_request
- not_found
- internal
description: The PRD §9 error catalogue.
securitySchemes:
apiKey:
type: http
scheme: bearer
description: '`Authorization: Bearer <key>`. Scoped (`listings:write`, `earnings:read`); a bearer key cannot move money (FR-26) and cannot destroy data without a step-up signature (FR-5).
There are two kinds. Every route that takes this scheme accepts either:
- **Agent key**, `x4c_live_…` — long-lived, one per creator, shown once when it is issued and never again, rotatable without the old key (`POST /api/auth/rotate-key`). This is the one an agent holds; it is the only one you can be given.
- **Session key**, `x4s_live_…` — minted for a browser session when a creator signs in to the website, never shown to anyone, expires with the session and dies on sign-out. It exists because the site calls these same endpoints (D9).'
walletSignature:
type: apiKey
in: header
name: X-Wallet-Signature
description: '`<address>.<nonce>.<eip191_signature>` over the message from GET /api/auth/challenge (FR-20). Single use, 5-minute expiry. Without it, /api/r quotes the new-buyer price and /api/v returns version data only.'
externalDocs:
url: https://github.com/pcmarts/x402git
description: Source code and security policy