Space Context Agent API
The Agent API from Space Context — 1 operation(s) for agent.
The Agent API from Space Context — 1 operation(s) for agent.
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/spacecontext-app:spacecontext-app-agent-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: Space Context Agent API
version: v1
servers:
- url: https://api.spacecontext.app/v1
tags:
- name: Agent
paths:
/agent/credits:
post:
operationId: buyAgentCredits
summary: Pay with x402 and get an API key (agents)
description: 'For an agent with a wallet and no account: pay in USDC on **Base** or **Solana** with x402 v2 and receive an API key. No key, no sign-in: the payment is the credential, and the paying address is the account. Any x402 v2 client works (for example `@x402/fetch` with `@x402/evm` and `@x402/svm`): the network fee is paid by the facilitator, the payer needs only USDC.
1. Call without `PAYMENT-SIGNATURE`: 402 `PAYMENT_REQUIRED` with the `PAYMENT-REQUIRED` header (base64 JSON, also in the body as `payment_required`). `accepts` has one entry per network, Base first: scheme `exact`, the network (CAIP-2), the amount in atomic USDC units (6 decimals: US$1.00 = `1000000`), the USDC contract or mint, the address to pay, and `extra` (the EIP-712 domain of USDC on Base; on Solana `feePayer`, the facilitator account that pays the network fee). `extensions.bazaar` describes the call for x402 catalogs.
2. Pick one entry, sign it, and send **the same request, with the same body**, adding `PAYMENT-SIGNATURE` (base64 JSON PaymentPayload with that entry, unchanged, as `accepted`). On Base the payload is an EIP-3009 `transferWithAuthorization`; on Solana a transaction partially signed by the payer: SetComputeUnitLimit, SetComputeUnitPrice, a `TransferChecked` of exactly the amount into the USDC account of `payTo`, optional memo, fee payer `extra.feePayer`. The payment is verified and settled by the facilitator; the answer carries `PAYMENT-RESPONSE` with the transaction.
On mainnet (Base `eip155:8453`, Solana `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`) the payment is credited to the account''s wallet (`amount_cents`, then US$1.00 per live scan; reading, search and answers are included; agents have no free scan; the credit does not expire) and the key is **live**. On testnets (Base Sepolia `eip155:84532`, Solana devnet `solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1`) USDC is free, so the payment credits nothing: the key is a **test** key (demo space, no charges, no model). The same paying address always gets the same account; a Base wallet and a Solana wallet are two accounts.
**Store `api_key` from your first purchase: it is shown once.** A signed authorization can be submitted by whoever holds it, so a payment alone returns a key only when it opens the account. Later payments from the same wallet top up the same account and return only `api_key_prefix`. An existing key is replaced only with that key: `rotate_key: true` plus `Authorization: Bearer ` (the previous key is revoked). The first key of the other mode (e.g. a live key for an account that so far paid on testnet) needs `Authorization: Bearer `. Both are checked before any payment is taken (403 `AGENT_KEY_REQUIRED`, nothing charged). A payment replayed with the same transaction is recognised: nothing is credited or minted twice.
400 `PAYMENT_INVALID` when the signature header is malformed or does not match the requirements (amount, network, asset, address, fee payer, the payer''s signature), before anything is sent to the facilitator. 402 `PAYMENT_FAILED` when the facilitator rejects or cannot settle the payment (`reason`; nothing was charged). 503 `PAYMENTS_UNAVAILABLE` when the chosen network cannot be served right now (nothing was charged). 404 when agent payments are off on this deployment. Limited per IP.'
security:
- {}
- apiKey: []
parameters:
- name: PAYMENT-SIGNATURE
in: header
required: false
description: 'base64 of the JSON x402 v2 PaymentPayload: `x402Version: 2`, `accepted` (one entry of `accepts`, unchanged), and `payload`: on Base `{ signature, authorization: { from, to, value, validAfter, validBefore, nonce } }`, on Solana `{ transaction }` (base64 of the partially signed transaction).'
schema:
type: string
maxLength: 16384
requestBody:
required: false
content:
application/json:
schema:
$ref: '#/components/schemas/AgentCreditRequest'
responses:
'200':
description: 'Paid: the account, its credit (mainnet) and its key'
headers:
PAYMENT-RESPONSE:
description: 'base64 of the JSON settlement: `{ success, transaction, network, payer }`'
schema:
type: string
Cache-Control:
schema:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/AgentCredit'
'400':
description: Invalid body, or `PAYMENT_INVALID`
content:
application/json:
schema:
$ref: '#/components/schemas/AgentPaymentError'
'402':
description: '`PAYMENT_REQUIRED` (pay first) or `PAYMENT_FAILED` (rejected or not settled; nothing was charged)'
headers:
PAYMENT-REQUIRED:
description: base64 of the JSON PaymentRequired
schema:
type: string
PAYMENT-RESPONSE:
description: 'On `PAYMENT_FAILED`: base64 of `{ success: false, errorReason, payer, transaction, network }`'
schema:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/AgentPaymentError'
'403':
description: '`AGENT_KEY_REQUIRED`: changing the keys of an existing account needs one of its current keys (nothing was charged)'
content:
application/json:
schema:
$ref: '#/components/schemas/AgentPaymentError'
'404':
$ref: '#/components/responses/ErrorResponse'
'429':
$ref: '#/components/responses/RateLimited'
'500':
description: 'Settled but not recorded: reconciled by hand (`transaction`)'
content:
application/json:
schema:
$ref: '#/components/schemas/AgentPaymentError'
'502':
description: The settlement could not be confirmed (`nonce` on Base, `signature` on Solana)
content:
application/json:
schema:
$ref: '#/components/schemas/AgentPaymentError'
'503':
$ref: '#/components/responses/ErrorResponse'
tags:
- Agent
components:
schemas:
AgentCredit:
type: object
required:
- object
- network
- payer
- transaction
- livemode
- amount_cents
- balance_cents
- api_key_prefix
- notice
- docs
properties:
object:
type: string
enum:
- agent_credit
network:
type: string
enum:
- eip155:8453
- eip155:84532
- solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
- solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1
payer:
type: string
pattern: ^(0x[0-9a-f]{40}|[1-9A-HJ-NP-Za-km-z]{32,44})$
description: Lowercase on Base; base58 as written on Solana
transaction:
type: string
pattern: ^(0x[0-9a-f]{64}|[1-9A-HJ-NP-Za-km-z]{64,88})$
description: The transaction hash (Base) or signature (Solana)
livemode:
type: boolean
description: 'true on mainnet: live credit and a live key'
amount_cents:
type: integer
balance_cents:
type:
- integer
- 'null'
description: The wallet after this payment; null on testnet (nothing is credited)
api_key:
type: string
pattern: ^sc_(live|test)_
description: 'Only when the key was created by this call: store it, it is not shown again'
api_key_prefix:
type:
- string
- 'null'
description: The account's key of this mode; null when it has none
notice:
type: string
description: What to do with the key (store it now, or use the one stored)
docs:
type: string
format: uri
AgentPaymentError:
type: object
required:
- error
properties:
error:
type: object
required:
- code
- message
- request_id
properties:
code:
type: string
message:
type: string
request_id:
type: string
reason:
type: string
description: Why the payment was refused (x402 reason)
payment_required:
$ref: '#/components/schemas/X402PaymentRequired'
transaction:
type: string
description: 'On 500: the settled transaction, for reconciliation'
network:
type: string
nonce:
type: string
description: 'On 502 (Base): the authorization nonce, for reconciliation'
signature:
type: string
description: 'On 502 (Solana): the payer''s transaction signature, for reconciliation'
X402PaymentRequired:
type: object
required:
- x402Version
- resource
- accepts
properties:
x402Version:
type: integer
enum:
- 2
error:
type: string
resource:
type: object
required:
- url
- description
- mimeType
properties:
url:
type: string
format: uri
description:
type: string
mimeType:
type: string
accepts:
type: array
items:
$ref: '#/components/schemas/X402PaymentRequirements'
extensions:
type: object
description: '`bazaar`: how to call this resource and what it returns, for x402 catalogs'
AgentCreditRequest:
type: object
properties:
amount_cents:
type: integer
minimum: 100
maximum: 50000
default: 100
description: 'US cents to pay (and, on mainnet, to credit): US$1.00 is one live scan. x402 clients cap a payment at US$1 by default; raise their limit to pay more at once'
rotate_key:
type: boolean
default: false
description: 'Make a new key and revoke the current one. Needs `Authorization: Bearer <the current key>`'
X402PaymentRequirements:
type: object
required:
- scheme
- network
- amount
- asset
- payTo
- maxTimeoutSeconds
- extra
properties:
scheme:
type: string
enum:
- exact
network:
type: string
enum:
- eip155:8453
- eip155:84532
- solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
- solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1
description: 'CAIP-2: Base (`eip155:…`) or Solana (`solana:…`)'
amount:
type: string
pattern: ^\d+$
description: 'Atomic units of the asset (USDC: 6 decimals)'
asset:
type: string
pattern: ^(0x[0-9a-fA-F]{40}|[1-9A-HJ-NP-Za-km-z]{32,44})$
description: The USDC contract (Base) or mint (Solana)
payTo:
type: string
pattern: ^(0x[0-9a-fA-F]{40}|[1-9A-HJ-NP-Za-km-z]{32,44})$
description: 'Who is paid: on Solana, the owner of the USDC account the transfer goes to'
maxTimeoutSeconds:
type: integer
extra:
anyOf:
- type: object
required:
- name
- version
properties:
name:
type: string
version:
type: string
description: 'Base: the EIP-712 domain of USDC'
- type: object
required:
- feePayer
properties:
feePayer:
type: string
pattern: ^(0x[0-9a-fA-F]{40}|[1-9A-HJ-NP-Za-km-z]{32,44})$
description: 'Solana: the facilitator account that pays the network fee (the transaction''s fee payer)'
Error:
type: object
required:
- error
properties:
error:
type: object
required:
- code
- message
- request_id
properties:
code:
type: string
message:
type: string
request_id:
type: string
retry_after:
type: integer
description: 'On a 429: seconds to wait, as in `Retry-After`.'
daily_limit:
type: integer
description: 'On a 429 for a daily allowance: the allowance (it resets at midnight UTC).'
max_streams:
type: integer
description: 'On a 429 from `GET /scans/{id}/events`: the streams an account may hold open at once.'
max_open_scans:
type: integer
description: 'On a 429 from `POST /spaces/{id}/scans`: the scans an account may hold created and not started.'
additionalProperties: true
responses:
RateLimited:
description: Too many requests. Retry after the number of seconds in `Retry-After`.
headers:
Retry-After:
schema:
type: integer
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
ErrorResponse:
description: Error response
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
securitySchemes:
apiKey:
type: http
scheme: bearer
bearerFormat: sc_live or sc_test