API Reference
On-chain vs API
amser gives you two ways to read protocol state. Direct on-chain calls via viem or ethers are authoritative and trustless — but they require an RPC endpoint and extra infrastructure. The amser Indexer API reads state from the chain, requires only an API key, and returns pre-computed fields like next_charge_date and status that would otherwise require multiple contract calls to derive. Both approaches are correct. Choose based on your trust requirements and operational constraints.
| Task | On-chain | API |
|---|---|---|
| Check if a subscriber is active | isActive(address, planId) | GET /v0/auth/check |
| List all subscriptions for a merchant | Multiple contract reads | GET /v0/subscriptions/:merchant |
| Get plan details | getPlan(planId) | GET /v0/modules/:moduleAddress/plans |
| Monitor payment history | Parse events | GET /v0/activity/:merchant |
| Check failed payments | Parse events | GET /v0/failures/:merchant |
Conventions
- All response body fields use snake_case.
- All query parameters use snake_case.
- All webhook payload fields use snake_case.
- Numeric values that exceed JavaScript's safe integer range (> 2^53) are returned as strings. This applies to on-chain IDs, amounts, and block numbers.
- Amounts are always returned in token base units as strings (e.g. USDC with 6 decimals:
"10000000"= 10 USDC). Usetoken_decimalsto format for display.
Base URL
https://api.amser.io
Authentication
All endpoints except GET /v0/tokens and GET /v0/auth/check require authentication. Two auth methods are accepted:
API key (recommended for server-side read operations):
Authorization: Bearer amsr_live_xxxxxxxxxxxxx
SIWE session (required for write operations and the dashboard):
Cookie: sid=<jwt>
API keys are read-only — they work for GET requests only. Creating webhooks, API keys, or modifying settings requires a SIWE session. This is enforced server-side; a 403 is returned if a write is attempted with an API key.
See the API Keys page for key generation, rotation, and security guidelines.
Endpoint reference
| Page | Endpoints |
|---|---|
| Subscriptions | Subscription state and authorization checks |
| Plans | Plan details by merchant or module |
| Activity | Payment history, failures, and revenue reporting |
| Tokens | Supported payment tokens and per-token constraints |
Related
- API Keys — Generate and manage server-side credentials
- Authentication — SIWE, API keys, and on-chain gating patterns
- Webhooks — Receive real-time event notifications