Skip to content

How MicroAuth works ​

MicroAuth turns an API into a paid product: a branded developer portal for your customers, plus API key authentication, rate limiting and metered billing enforced inside your own service. MicroAuth never proxies or inspects your traffic. Your API talks to MicroAuth on the side, through an SDK or the SDK API.

 your customer            your API + SDK                    MicroAuth
┌─────────────┐  request  ┌───────────────────────┐ snapshot ┌───────────┐
│ X-API-Key:  │──────────►│ check key, limits and │◄─────────│ customers │
│ map_...     │◄──────────│ balance locally       │  usage   │ keys      │
└─────────────┘ response  │ serve, then count     │─────────►│ billing   │
                          └───────────────────────┘          └───────────┘

The three surfaces ​

SurfaceURLWho uses it
Dashboardapp.microauth.comYou and your team. Launch APIs, set pricing, manage customers
Developer portalhttps://<slug>.microauth.dev or your own domainYour customers. Sign up, get keys, add credit, subscribe
MicroAuth APIhttps://api.microauth.comYour backend and SDKs. The management API and the SDK API

Workspaces ​

A workspace is the top-level account in the dashboard. You can belong to several workspaces, each with its own team and roles (owner, admin and member). Everything you create, including APIs, automation keys and your MicroAuth subscription, belongs to a workspace.

APIs ​

An API is one product you sell. It has a name, branding, a *.microauth.dev address, optionally your own domain, and its own white-labeled developer portal. If you run a weather service, "Weather API" is an API and https://weather-api.microauth.dev is its portal.

The REST API and the SDK call an API a tenant, so you will see tenant_id and /v1/tenants/{tenantId} in payloads and paths. It is the same thing.

Each API has an SDK secret key (mas_...). Your backend uses it to talk to the SDK API. It is shown once when the API is created and can be rotated at any time from the API's Settings.

Customers ​

People who sign up on your developer portal are your customers. Each customer account is a small team. A solo signup is a team with one member, and larger accounts add teammates with portal roles (admin, developer, billing manager). Customers create API keys (map_...) and send them to your API, usually in an X-API-Key header. The first key is created for them automatically when they sign up.

Billing always attaches to the team, not to individual people. The credit balance, ledger, usage, quotas and plan all belong to the team, and every customer ID you see in the API (customerId, the snapshot's customers[].id) is a team ID. One person can belong to several teams, each with its own balance and limits.

API keys at a glance ​

MicroAuth uses three key types, told apart by prefix. All are shown once, when they are created, and MicroAuth stores only a SHA-256 hash.

PrefixNameUsed forSent to
mas_SDK secret keySDK API: snapshots, key checks, usage reportsapi.microauth.com, from your backend
mak_Automation keyManagement API: automation, external creditsapi.microauth.com, from your billing or back office
map_Customer API keyCalling your APIYour API, from your customers

Credits and micro-USD ​

All money in MicroAuth is an integer in micro-USD: 1,000,000 micro = $1.00. A price of 500 micro per request is $0.0005. Integer math avoids rounding errors in billing.

Customers hold a prepaid credit balance. Billable requests are charged against it at the customer's effective price. Credits arrive through:

  • A welcome credit, granted once when a customer signs up, if you set one. See welcome credit.
  • Stripe top-ups and monthly plans, when you connect Stripe.
  • Your own billing, which calls the credits endpoint with an automation key.
  • A manual grant from the customer's page in the dashboard.

Every movement is recorded in a per-customer credit ledger.

Plans and effective limits ​

For each API you can offer pay as you go pricing, monthly plans (a monthly credit grant plus a price per request, RPS and quota), or both. You can also set custom limits for one customer. Plans can be public, shown to everyone on the portal, or private, shown only to the customers you assign.

When plan metadata appears in an API response, plan_id is a UUID encoded as a JSON string, or null when no plan is assigned. plan_name is a JSON string, or null in the same case. Neither field is a numeric plan code.

At enforcement time these resolve into one set of effective limits, in priority order:

  1. Custom limits for that customer (highest priority)
  2. The customer's monthly plan
  3. The API's pay as you go defaults

The resolved object looks like this:

json
{
  "rps": 10,
  "price_per_request_micro": 500,
  "monthly_quota": 1000000,
  "source": "plan",
  "billing_model": "subscription"
}

monthly_quota may be absent, which means no cap. source tells you which layer won: custom, plan or payg. billing_model is payg, subscription or none. With none, or a price of zero, requests are free.

MicroAuth platform request allowance ​

Your own MicroAuth plan also has a monthly allowance of tracked requests. This is separate from the quota you give one customer. The SDK snapshot publishes the authoritative values:

json
{
  "platform_monthly_limit": 10000000,
  "platform_monthly_used": 48210,
  "platform_monthly_remaining": 9951790,
  "platform_period_end": "2026-09-01T00:00:00Z",
  "platform_hard_cap": true
}

The API rejects a usage item that would exceed this allowance, but a report is sent after the customer request has run. For proactive enforcement, a conforming SDK reserves one request locally before it runs your handler and settles that reservation when usage is reported.

This is an honest-client safety control, not an untrusted gateway guarantee. You control the code and can bypass or modify the SDK, and concurrent processes can admit requests before reports converge. Redis can coordinate conforming processes, but it does not turn code on your infrastructure into a hard security boundary. See your MicroAuth plan for the allowance on each plan.

Billable status codes ​

Not every response should cost money. In the API's settings you choose which HTTP status codes are billable. The default is 200 only. The SDK reports every authenticated response for allowance and quota accounting, but only matching statuses charge the customer balance. A 404 or 500 never charges your customer unless you say so. See billable status codes.

Enforcement model: snapshot and report ​

The SDK, or your own integration, follows one pattern:

  1. Snapshot. Every 30 seconds, fetch all customers, keys and effective limits for the API (GET /sdk/v1/snapshot) and cache them in memory or Redis. Unchanged snapshots come back as a tiny 304.
  2. Enforce locally. On each request, hash the presented key, look it up in the cache, reserve monthly usage, and enforce suspension, balance, quota and RPS with no network call.
  3. Report. Record every authenticated response and send it to MicroAuth in batches (POST /sdk/v1/usage), by default every 5 seconds or every 500 requests. Every item carries a stable idempotency key, the API key UUID, the usage policy UUID from the snapshot, the final HTTP status, a count and an hourly UTC period_start. MicroAuth charges under that captured policy, so a later price change cannot reprice queued traffic.

This keeps authentication off the network path. A key created after the latest snapshot, shared RPS limits and recovery from stale data can still need a network or Redis call. Stable item IDs make retries safe across workers and restarts, and a duplicate idempotency key with different content is rejected rather than counted again.

Subscription payment grace ​

A failed Stripe subscription payment starts a 7-day grace period. Paid entitlements stay available during grace so the customer can update their payment method. A successful payment clears the grace state. If the grace period runs out, MicroAuth marks the affected customer billing_suspended without deleting any data. The same rule applies to your own MicroAuth subscription. See Stripe.

Customer email notifications ​

MicroAuth emails your customers about the billing events that affect their service, using your branding: your logo, colors, support email and docs link. Emails go to the team members whose role includes billing access, which means admins and billing managers but not developers.

Three groups of notifications can be switched on or off by each member on their portal Profile page. All are on by default:

  • Balance alerts. A warning when the prepaid balance drops below the team's alert threshold, and a notice when credits run out and requests start returning 402. The threshold defaults to $5.00 and each team can change it on the Billing page. Every alert fires once per depletion cycle, and adding credit re-arms it.
  • Billing activity. Top-up confirmations, manual credit adjustments, monthly plan credits, and credits removed after a refund or dispute.
  • Subscription updates. New subscriptions, plan changes, cancellations and payment recovery confirmations.

Two kinds of email ignore these toggles because skipping them risks real harm: security messages (verification codes, sign-in lockout alerts and invitations) and payment problem notices (a failed subscription payment that opens the grace period, and the suspension that follows if it lapses).

Delivery uses a durable outbox, so a mail provider outage delays notifications rather than dropping them, and webhook retries never send the same notice twice.

Next steps ​

MicroAuth is a product of Zyref, LLC.