x402 Subscription and top-up
This guide covers how to subscribe an agent to a paid plan and add credits via top-up using the x402 rail — paying in USDC on Base or Solana.How It Works
Agent access is built on two things: a plan and credits.- A plan (Startup, Growth, or Enterprise) sets your agent’s credit limit and billing cycle. You pay the plan price once per period.
- Credits are consumed by API usage. When credits run low, top up to add more without changing your plan.
- Your wallet is your identity. The same wallet used to subscribe is used for status checks and top-ups.
- After subscribing, you receive an
api_key(forAuthorizationheaders) and auser_id(used asagent_idfor top-ups). Store both.
Pricing
Enterprise pricing includes a base fee plus a variable component based on usage. Contact the Mobula team for a quote.
Top-ups are a minimum of $20 USDC and go directly to Mobula.
The $0.001 USDC charged on subscription status checks is a facilitator fee for x402 protocol settlement — it does not go to Mobula.
Endpoints
All endpoints are underhttps://api.mobula.io.
Per-endpoint reference: x402 Get subscription status · x402 Subscribe to a plan · x402 Top up credits · x402 Create API key · x402 Revoke API key
Check Plan Status
Every flow starts with a call toGET /agent/x402/subscription. This costs $0.001 USDC and returns the current state of the wallet before taking any action.
The scripts below handle this check automatically.
Subscribe to a Plan
Subscribing creates (or renews) your agent and returns anapi_key and user_id.
Flow:
- Call
GET /agent/x402/subscription→ pay $0.001 USDC → check plan status. - If
plan_active === trueand plan is not Free → stop, already subscribed. - Otherwise → call
GET /agent/x402/subscribe?plan=...&payment_frequency=...→ receive 402 with the plan price. - Sign the payment and retry with the
x-paymentheader → 200 OK returnsapi_keyanduser_id.
Top Up Credits
Top up to add credits to your agent’s limit without changing the plan. Minimum $20 USDC. Flow:- Call
GET /agent/x402/subscription→ pay $0.001 USDC → confirm plan is active. - If
plan_active !== true→ subscribe first before topping up. - Otherwise → call
GET /agent/x402/top-up?agent_id=<user_id>&amount_usd=<amount>→ receive 402 with the payment amount. - Sign the payment and retry with the
x-paymentheader → 200 OK returnscredits_addedandnew_credits_limit.
Learn more
External x402 references:- x402 (CDP) — Protocol overview, facilitators, and SDKs
- x402.org — Open standard for HTTP-native payments
Using Your API Key
Once subscribed, authenticate all data requests with yourapi_key: