API Reference

The Flexprice REST API uses standard HTTP verbs, JSON request bodies, and Bearer token authentication. All endpoints are served over HTTPS.

Authentication

All requests must include an Authorization header with your API key:

Authorization: Bearer fp_live_...

Retrieve API keys from Settings > API Keys in the Flexprice dashboard. Use separate keys for test and production environments.

Base URL

https://api.flexprice.org/v1

Errors

StatusCodeMeaning
400invalid_requestMissing or malformed request body
401unauthorizedInvalid or missing API key
404not_foundResource does not exist
409conflictIdempotent request with conflicting body
429rate_limitedToo many requests (retry after header present)
500internal_errorServer-side error; contact support

Events

Events represent individual units of usage. They are the raw material from which Flexprice calculates invoices.

POST /v1/events

Ingest a single event

ParameterTypeRequired
event_namestringrequired
customer_idstringrequired
idempotency_keystringrequired
timestampISO 8601optional — defaults to now
propertiesobjectoptional
POST /v1/events/batch

Ingest up to 1,000 events in a single request

Request body: { "events": [ ...event objects ] }. Each event carries its own idempotency key.

GET /v1/events

List events (paginated, max 200/page)

Query params: customer_id, event_name, from (ISO 8601), to (ISO 8601), cursor, limit.

Customers

A customer maps to a paying entity in your product. Customer IDs must match the customer_id field in your events.

POST /v1/customers

Create a customer

ParameterTypeRequired
external_idstringrequired
namestringoptional
emailstringoptional
currencyISO 4217optional — defaults to account currency
metadataobjectoptional

Pricing Plans

Pricing plans define the mapping from usage events to line items on an invoice. A plan has one or more charges, each tied to an event name.

POST /v1/pricing-plans

Create a pricing plan

Supported pricing_model values: flat, per_unit, graduated, volume, package, credit. See the quickstart for a graduated tier example.

GET /v1/pricing-plans/{id}

Retrieve a pricing plan

Returns full plan object including tier configuration.

Subscriptions

A subscription assigns a pricing plan to a customer and starts the billing cycle.

POST /v1/subscriptions

Create a subscription

ParameterTypeRequired
customer_idstringrequired
plan_idstringrequired
start_dateISO 8601optional — defaults to now
trial_end_dateISO 8601optional

Invoices

Invoices are generated automatically at the end of each billing period. Use the Invoices API to retrieve, void, or manually trigger generation.

GET /v1/invoices

List invoices

Query: customer_id, status (draft/open/paid/void), from, to.

GET /v1/invoices/{id}

Retrieve an invoice

Returns line items, amounts, tax, and payment status.

Credit Grants

Grant prepaid credit balances to customers. Credits are consumed before usage-based charges on each invoice.

POST /v1/credit-grants

Issue a credit grant

ParameterTypeRequired
customer_idstringrequired
amountnumber (events)required
expires_in_daysintegeroptional
rolloverbooleanoptional — default false