# UsageRail API ## API Docs - HTTP check [Check a request](https://usagerail.apidog.io/check-a-request-47340139e0.md): Call this at the start of each request your API receives. Send exactly one of `key` or `consumer`. An allowed check counts its units right away. The check never sees your API's response, so those units still count if the request later fails. Refused checks (`allowed: false`) are excluded from billable usage. - Customers [Create a customer](https://usagerail.apidog.io/create-a-customer-47340140e0.md): A new customer gets a 201 and starts on the app's default plan, if one is set. With an `external_id` that already belongs to a customer, that customer comes back with a 200 and nothing changes; use claim to add an email to an existing customer. - Customers [Get a customer](https://usagerail.apidog.io/get-a-customer-47340141e0.md): - Customers [Claim an email or external ID](https://usagerail.apidog.io/claim-an-email-or-external-id-47340142e0.md): Attaches exactly one of `email` or `external_id` to an existing customer, for example to connect a customer who signed up in the portal to your own user ID. - Customers [Get a customer's usage](https://usagerail.apidog.io/get-a-customers-usage-47340143e0.md): Ask for 1 to 30 calendar days in the app's time zone. The response's `days` is the number returned after your plan's retention limit. `daily` includes days with zero usage; `endpoints` lists up to 20 method and route pairs, ranked by request count. - Keys [Create a key](https://usagerail.apidog.io/create-a-key-47340144e0.md): Only the first response includes the full key. A replay with the same idempotency key returns the IDs without it. - Keys [Revoke a key](https://usagerail.apidog.io/revoke-a-key-47340145e0.md): UsageRail revokes the key immediately. Running SDKs normally pick up the change within about 20 seconds; an SDK that can't reach UsageRail may still accept the key from its local cache. - Billing [Change a customer's plan](https://usagerail.apidog.io/change-a-customers-plan-47340146e0.md): Without a subscription, only free plans work and the change is immediate; a plan with a price returns 409 `paid_plan_needs_checkout`, because customers move onto paid plans by paying through checkout. For a subscription created by UsageRail, the change follows the portal rules listed under Changing plans in the UsageRail docs; read `change.status` for the result, and send `{"keep": true}` to drop the change that's waiting. A subscription you manage directly in Stripe returns 409 `subscription_managed_in_stripe`: change it in Stripe. - Billing [Open Stripe Checkout](https://usagerail.apidog.io/open-stripe-checkout-47340147e0.md): Opens a Stripe Checkout page in your own Stripe account, for a paid plan (`plan_id`) or a credit pack (`credit_pack_id`). A customer who isn't on a prepaid plan yet also needs `plan_id` with a credit pack. `success_url` and `cancel_url` must use https; for local development, `http://localhost` works too. - Billing [Adjust a prepaid balance](https://usagerail.apidog.io/adjust-a-prepaid-balance-47340148e0.md): Positive `units` add credits that never expire and pay off any debt first. Negative `units` come out of the credits that expire soonest; whatever is left over becomes debt. The reason goes in your audit log. - Portal [Create a portal sign-in link](https://usagerail.apidog.io/create-a-portal-sign-in-link-47340149e0.md): The link works once and for 15 minutes. It opens a page with a Sign in button, so a link previewed by an email scanner isn't used up. The customer needs an email; claim one first if they don't have it. ## Schemas - [Error](https://usagerail.apidog.io/error-18962417d0.md): - [CheckRequest](https://usagerail.apidog.io/checkrequest-18962418d0.md): - [CheckResult](https://usagerail.apidog.io/checkresult-18962419d0.md): - [Consumer](https://usagerail.apidog.io/consumer-18962420d0.md): - [Usage](https://usagerail.apidog.io/usage-18962421d0.md):