Billing
Billing runs on Stripe. These endpoints create Stripe Checkout sessions for plan upgrades and Stripe Billing Portal sessions for managing existing subscriptions.
All billing endpoints require a valid API key.
Credit meter
- Billable work debits your credit balance. Endpoints charge on a hit only: an empty result costs 0. An async batch holds one credit per URL while it runs and returns the credits of failed URLs when it ends. A crawl is charged per page as it runs.
- Read your balance with
GET /v1/credits:pools.scrapeis what scrape, crawl, map, batch, search and the other page endpoints spend, andpools.enrichis what/v1/enrich/*spends.GET /v1/credits/ledgerlists every grant, hold, refund and charge.GET /v1/usagecounts pages against your monthly page quota; pages are not credits. - Responses include
X-Credits-Consumedand, when available,X-Credits-Remaining. - On Free, a request the balance cannot cover is refused with HTTP 402 before any work runs.
- On a paid plan, auto-reload charges your card $5 for the next block of credits when you run out, so requests keep working. Plan credits are used first; top-up credits roll over. See Auto-reload.
See GET /v1/pricing for the live catalog and units per endpoint.
Endpoints
| Endpoint | Method | Description |
|---|---|---|
/v1/billing/checkout | POST | Start a Stripe Checkout session to subscribe to a plan |
/v1/billing/portal | GET | Open the Stripe Billing Portal for an existing subscription |
/v1/billing/usage | GET | Usage and quota (alias for GET /v1/usage) |
/v1/billing/auto-reload | GET | Auto-reload setting, monthly limit, this month's spend, top-up credits and recent charges |
/v1/billing/auto-reload | PUT | Turn auto-reload on or off, or set a monthly limit (monthly_cap_usd: a multiple of 5, 0 = off, null = no limit) |
POST /v1/billing/checkout
Creates a Stripe Checkout session for a plan subscription. Returns a url that redirects the user to Stripe's hosted checkout page.
If the tenant does not yet have a Stripe customer, one is created automatically using the email stored against the tenant in the database.
Request
POST /v1/billing/checkout
Content-Type: application/json
x-api-key: YOUR_KEYBody
| Field | Type | Required | Description |
|---|---|---|---|
plan | string | Yes | Which plan to subscribe to. See the note below. |
interval | string | No | "month" (default) or "year". |
uiMode | string | No | "hosted" (default) or "embedded". |
successUrl | string | Hosted only | URL Stripe redirects the user to after a successful payment. Must be http(s)://. |
cancelUrl | string | Hosted only | URL Stripe redirects the user to if they cancel. Must be http(s)://. |
returnUrl | string | Embedded only | URL Stripe returns the user to after an embedded checkout. Must be http(s)://. |
plan accepts either public names (hobby, pro, scale) or legacy ids (starter, pro, business). Prefer the public names.
Example request
curl -X POST https://api.superscraper.dev/v1/billing/checkout \
-H "x-api-key: ss_live_xxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"plan": "pro",
"successUrl": "https://app.superscraper.dev/billing/success",
"cancelUrl": "https://app.superscraper.dev/billing"
}'Response
HTTP 200 on success.
| Field | Type | Description |
|---|---|---|
url | string | Hosted: Stripe Checkout session URL. Redirect the user to this URL to complete payment. |
clientSecret | string | Embedded: pass to Stripe's embedded checkout on your page |
sessionId | string | Embedded: the Checkout session id |
uiMode | string | "hosted" or "embedded" |
Example response
{
"url": "https://checkout.stripe.com/c/pay/cs_test_a1b2c3...",
"uiMode": "hosted"
}Errors
| Status | Error | Cause |
|---|---|---|
| 400 | `plan` is required | plan field missing |
| 400 | `successUrl` is required | successUrl field missing |
| 400 | `cancelUrl` is required | cancelUrl field missing |
| 400 | `returnUrl` is required for embedded checkout | uiMode: "embedded" without returnUrl |
| 400 | successUrl/cancelUrl must be an allowed http(s) URL | Non-https:// scheme (e.g. javascript:) or origin not in ALLOWED_REDIRECT_ORIGINS allowlist |
| 400 | Unknown plan: <plan> | plan is not a known plan name or id. The body lists the accepted values. |
| 400 | Plan `<plan>` is not available for self-serve checkout. | Free and Enterprise cannot be bought through checkout |
| 400 | Invalid JSON body | Malformed request body |
| 400 | invalid_interval | interval is not "month" or "year" |
| 401 | API key required | Missing x-api-key header |
| 404 | Tenant not found | Authenticated tenant does not exist in the database |
| 409 | subscription_exists (code: "use_portal") | The account already has a subscription. Change plan or interval in the billing portal. |
| 500 | Internal server error | Stripe API error or database error |
GET /v1/billing/portal
Opens a Stripe Billing Portal session for the authenticated tenant. Returns a url that redirects the user to Stripe's self-service portal where they can update payment methods, view invoices, change plan, switch between monthly and yearly billing, and cancel subscriptions.
Upgrades take effect right away: you pay the prorated difference and get the matching share of the new plan's extra credits for the rest of the billing period. Downgrades take effect at the end of your billing period. The extra credits are added once the upgrade's invoice is paid: the difference between the two plans' monthly credits, times the share of the billing period that is left. From the next month you get the new plan's full monthly credits. A downgrade keeps your current plan and credits until the period ends, with no refund for the unused time.
Requires that the tenant already has a Stripe customer ID (i.e. they have previously subscribed via /v1/billing/checkout).
Request
GET /v1/billing/portal
x-api-key: YOUR_KEYNo request body.
Example request
curl https://api.superscraper.dev/v1/billing/portal \
-H "x-api-key: ss_live_xxxxxxxxxxxxxxxxxxxx"Response
HTTP 200 on success.
| Field | Type | Description |
|---|---|---|
url | string | Stripe Billing Portal session URL. Redirect the user to this URL. |
Example response
{
"url": "https://billing.stripe.com/p/session/live_abcd1234..."
}Errors
| Status | Error | Cause |
|---|---|---|
| 400 | No billing account found for this tenant | Tenant has no Stripe customer ID (it has never subscribed) |
| 401 | API key required | Missing x-api-key header |
| 404 | Tenant not found | Authenticated tenant does not exist in the database |
| 500 | Internal server error | Stripe API error or database error |
| 503 | billing_unavailable | The billing portal is misconfigured on the server. Try again later. |
Credit grants per plan
Each plan includes a monthly grant of credits per type, granted once per calendar month. These match the credits quoted on Pricing:
| Plan | Scrape credits | Enrich credits |
|---|---|---|
| Free | 1,000 | 1,000 |
| Hobby | 5,000 | 5,000 |
| Pro | 100,000 | 100,000 |
| Scale | 500,000 | 500,000 |
Credits are prepaid: each plan grants a monthly balance, and usage draws it down. Whether this period's grant landed is reported in credits.state on GET /v1/usage. On a paid plan, auto-reload adds $5 blocks when you run out; on Free, upgrade for more.
Notes
- The Stripe Checkout session is created in
subscriptionmode with a flat plan line item that grants the plan's monthly credit balance. - Open-redirect protection:
successUrlandcancelUrlmust usehttp://orhttps://schemes. IfALLOWED_REDIRECT_ORIGINS(comma-separated) is configured in the environment, both URLs must originate from an allowlisted origin. - Plan upgrades are processed asynchronously via the Stripe webhook (
POST /webhooks/stripe). Your plan changes when Stripe reports the checkout as completed. - Plan changes made in the billing portal arrive the same way. Credits for an upgrade are added when Stripe reports its prorated invoice as paid, never before.