Skip to main content
All CollectionsSellReporting API Usage
Reporting API Usage to Stripe
Reporting API Usage to Stripe

How to report your customers API usage for billing purposes

Updated over 11 months ago

With Apiable's Usage Events Add-on, it's possible to connect your API Gateway logs and have Apiable calculate and report the monthly developer usage.

However, some circumstances may mean you wish to report your own usage:

  • Your API Gateway still needs to be connected to usage events. Apiable supports usage events from AWS and Kong.

  • You have complex logic that you want to implement in the backend and use Apiable for the billing part.

In this case, using the usage_records API to report API usage is possible. Usage records allow you to report developer usage and metrics to Apiable for usage-based monetization.

curl -X POST --location "https://{YourPortal}.apiable.io/api/v1/subscriptions/{{ApiableSubscriptionId}}/usage_records" \
-H "Authorization: Bearer {{accessToken}}" \
-H "Content-Type: application/json" \
-d "{\"quantity\": 1, \"timestamp\": 1700733060, \"lookupkey\": \"gandalf\", \"action\": \"increment\"}"

Parameters

The following parameters are available in this API:

  • quantity integer

    The usage quantity for the specified timestamp.

  • timestamp string | timestamp

    The timestamp for the usage event. This timestamp must be within the current billing period of the subscription of the provided subscription_item, and must not be in the future.

  • lookupkey string

    Use lookup keys to make future pricing changes easier and to report the exact price the customer paid.

  • action enum

    Valid values are increment (default) or set. When using increment the specified quantity will be added to the usage at the specified timestamp. The set action will overwrite the usage quantity at that timestamp.

How to get the Apiable Subscription ID

There are two ways to find the Subscription ID

Via the Dashboard

Navigate to API Subscriptions and drill into a subscription.

The ID is contained within the URL, e.g. https://dashboard.apiable.io/subscriptions/659d9c51fae2e65b4aac1983

Programmatically via the Apiable API

Upon request, Apiable provides programmatic access to your API Portal via our API.

It's possible to GET all Teams and find the associated subscription_id accordingly.

To see the full API Reference please register on the Apiable Developer Portal and then navigate to the full API Reference

How to get an Access Token

Please make a request to support@apiable.io in order to get your client_id and secret.

Did this answer your question?