1. Get an API key
- Sign in to the dashboard: app.alguna.io for production, app.sandbox.alguna.io for sandbox.
- Go to Settings → Connections → Developers → API keys and create a key.
- Store it as an environment variable. It is a server-side secret — never ship it to a browser or a mobile app.
2. Base URL, authentication and versioning
Every request carries two headers:
Bodies are JSON in snake_case; amounts are decimal strings; timestamps are RFC 3339. Every response carries an
X-Request-Id header — log it. Full details: API overview.
3. First request: create a customer
A customer is the account you bill. Give it your own identifier as an alias so you never need to store Alguna IDs: anywhere the API takes a customer, an alias works in place of the ID.name and currency are required. The response is the customer object, including its id. Reference: Create a customer, Look up a customer ID by alias.
4. Start a subscription
Pricing lives on products and is packaged into plans. The simplest way to subscribe a customer is to reference a plan; the subscription’s items are materialized from it. Subscriptions are created indraft — pass auto_activate: true to go live in one call, or call Activate a subscription later.
Idempotency-Key makes the call safe to retry: a repeat with the same key returns the original subscription instead of creating a second one. See Idempotency.
Once active, Alguna generates invoices on the schedule the plan defines and collects payment with the customer’s stored payment method. For inline pricing, per-customer overrides and bundles, see Creating a subscription; for upgrades and downgrades, Updating a subscription.
5. Meter usage
Usage-based prices read a billable metric: a named aggregation (count, count_unique, sum, average, min, max) over events with a given event_name, optionally filtered by event properties. Create the metric once, attach it to a metered product, then send events as usage happens.
Create a metric
Send events
Up to 100 events per request. The response lists which
unique_ids were ingested and which failed. Batch and buffer on your side; send asynchronously. Full guide: Send usage events. Reference: Ingest billable events.
6. Gate features and credits
Two read paths tell your application what a customer is allowed to do:- Entitlements — feature flags and limits attached to the customer’s active subscription.
GET /customers/{id}/entitlementsreturns them keyed bykeywith atypeandvalue. See Entitlements and List active entitlements for a customer. - Credits — for prepaid or usage-gated products,
POST /credits/checkprices an intended action against the customer’s balance and can reserve the amount while the work runs;POST /credits/tracksettles it. See Credit consumption.
7. Sell self-serve
For product-led signups you do not need to build a payment form. Mint a session server-side, hand the returnedurl to the browser:
Both sessions are short-lived and are created with your secret key; only the
url (and, for embedded checkout, the session_token) is safe to expose. The end-to-end flow with trials and credits is in Launch self-serve.
8. Receive webhooks
Webhooks push events to your endpoint so you do not poll. Configure them under Settings → Connections → Developers → Webhooks: add your endpoint URL, choose events, and copy the signing secret. Events you will most likely subscribe to first:
Payloads are camelCase, wrapped as
{ "type", "timestamp", "data" }. Delivery is through Svix with signed requests; verify with the Svix library for your language rather than a hand-rolled check:
9. Errors, retries and idempotency
Every error is{ "status": <code>, "detail": "<message>" }. Branch on the status, never on the text.
The SDK raises
ValidationError (400), AuthenticationError (401), NotFoundError (404), RateLimitError (429, with retryAfter) and ApiError for everything else, each carrying requestId. Details and retry guidance: Errors, Idempotency.
10. Test in sandbox
- Sign in at app.sandbox.alguna.io and create a sandbox API key.
- Point your integration at
https://api.sandbox.alguna.io(with the SDK, passbaseUrl). - Connect your payment processor’s test mode and use its test cards at checkout.
- Point webhooks at a tunnel (for example ngrok) or a request-capture service while you develop.
11. Use the API from an AI assistant
The same operations are exposed as tools on Alguna’s MCP server athttps://api.alguna.io/mcp, with OAuth sign-in for clients that support it and an API key via mcp-remote for those that do not. Connect Claude, Cursor or ChatGPT to look up customers, create subscriptions or ingest events in natural language. See Model Context Protocol.
Limits
Common patterns
Provision on signup- User signs up →
POST /customerswith your user ID as an alias POST /subscriptionswithplan_idandauto_activate: true(or send them through checkout)- Webhook
subscription.activated→ enable features; read entitlements as needed
POST /eventsas usage happens, batched, with a stableunique_id- End of period: Alguna aggregates the metric and issues the invoice → webhook
invoice.issued - Payment collected → webhook
invoice.paid
- Grant credits (
POST /subscriptions/{id}/credits/grant) → webhookaccount.credits.granted - Before expensive work,
POST /credits/check; after it,POST /credits/track - Balance hits zero → webhook
account.credits.balance_depleted→ prompt an upgrade or top-up
Reference
API overview
Base URLs, headers, filtering, pagination.
TypeScript SDK
Typed client, errors and idempotency options.
Webhooks
Every event and payload.
Send usage
Event shape, batching and CSV import.
Metrics reference
Aggregations and filter operators.
Credits & wallets
Grants, consumption and wallets.
Subscriptions
Lifecycle, versions and amendments.
Model Context Protocol
Drive Alguna from an AI assistant.
Related quick starts
AI & Infrastructure
Token-based and usage billing.
Self-Serve (PLG)
Checkout and upgrade flows.
Fintech & Payments
Transaction-based metering.
← Back to Quick Starts
See all quick start guides