API reference
Early accessAPI reference
Base URL for server-to-server calls: https://terrawallet.us/api/v1. Authenticate with Authorization: Bearer tw_..._sk_... (see Authentication).
Resources#
| Resource | Operations | Summary |
|---|---|---|
| Partner account and session | 27 | Sign-up, sign-in, two-factor authentication and the current user. The dashboard calls these routes on its own origin with a session cookie; server integrations never call them. |
| Organizations and members | 11 | An organization owns projects, keys and every Terra Pay object. Members have one of six roles. |
| Projects and allowed origins | 6 | A project groups keys and settings inside an organization. Allowed origins lock publishable keys to your own https sites. |
| API keys | 5 | Secret keys for your server and publishable keys for the browser, per project and environment. |
| Audit logs | 1 | Every write in your organization, with actor, action, target, IP as stored, request id and time. Never secrets. |
| Payout wallets | 2 | The merchant's own wallets that customers pay into. Changes are locked down: an authenticator code, email confirmation, then a 24-hour cooldown. |
| Payment intents | 1 | One payment for one amount. Terra quotes an exact crypto amount per accepted asset, the customer pays from their own wallet to yours, and the intent succeeds only on verified chain data. |
| Payment links | 1 | Reusable, no-code links with a fixed or customer-chosen amount. |
| Invoices | 2 | Line items, a due date and a hosted invoice page. |
| Plans | 1 | A price and an interval for subscriptions (pay each period). |
| Subscriptions | 1 | A customer on a plan. In v1 every subscription is pay each period: Terra sends a renewal invoice each period and the customer pays it from their own wallet. |
| Refunds | 1 | Refund drafts. Terra never moves funds: the merchant signs and sends the refund from their own wallet, and the server only verifies it on chain. |
| Public checkout | 3 | The routes the hosted pages on pay.terrawallet.us use. No authentication, strict per-IP limits, and only what the page needs. |
| Webhook endpoints | 1 | Where Terra sends signed events. https only, with SSRF protection on every delivery. |
Conventions#
- Amounts are decimal strings (
"10.50"), never floats.currencyis a fiat ISO code; crypto assets are{chain, symbol, contract, decimals}; on-chain amounts are integer base units in strings. - Ids are prefixed and opaque:
org_,proj_,key_,usr_,pi_,plink_,inv_,plan_,sub_,cus_,whe_,evt_,ses_. - Errors:
{"error":{"code","message","requestId"}}. See Errors. - Every create needs an
Idempotency-Key. See Idempotency. - Lists use cursors (
limit,starting_after). See Pagination. - Unknown fields are rejected. Every string has a size cap.
Common errors#
| Status | Code | When |
|---|---|---|
| 401 | INVALID_API_KEY | The key is malformed, unknown, expired or revoked. Every case gets the same response. |
| 403 | INSUFFICIENT_SCOPE | The key does not carry the scope the route needs. |
| 403 | PRODUCT_DISABLED | The product behind the route is switched off for the platform. |
| 403 | LIVE_DISABLED | A live-mode action while live mode is not enabled. |
| 404 | The object does not exist or belongs to another organization. The two cases look the same. | |
| 409 | IDEMPOTENCY_KEY_REUSED | An Idempotency-Key was reused with a different body. |
| 429 | RATE_LIMITED | Too many requests for this key or organization. |
| 503 | MAINTENANCE | Platform maintenance. /v1/auth/* and /v1/me stay available. |