Skip to main content
This article is for API providers. Billing is configured per billable object — this page covers the ways your server can report the actual amount at request time.
The normal way to meter usage is a formula on the endpoint’s billing element (or the object’s default formula): the gateway evaluates it against the finished response and bills the result. Two common patterns report the amount from your side:

Reporting with a response header

Return any header from your upstream and read it in the formula. The conventional header is X-Jojapi-Credits-Used, and migrated APIs use exactly this formula:
That bills the header’s value when present (an explicit 0 bills nothing) and falls back to 1 when your server doesn’t send it. Any header name works — the gateway strips x-jojapi-* headers from the client response but your formulas can read them. A non-numeric header value makes the formula non-numeric, and a formula that can’t produce a number bills 0. If you prefer a fallback for invalid values too, use:

Reporting inside SSE streams

For Server-Sent Events responses (content-type: text/event-stream), send a message during the stream:
The in-band value applies to the first object in the endpoint’s billing list and takes precedence over that object’s formula. An explicit 0 means “charge nothing” — it never falls through to a default.

Rules

  • On fixed costs (a plain number in the billing element), reported and computed values are capped at the declared amount — you can lower a request’s bill, never raise it above what consumers see.
  • Responses with a 5xx status bill 0 on every object, regardless of any header, SSE message or formula. Failed responses are always free.
  • Values must be non-negative integers; anything else is treated as unusable and bills 0 for that object.