The Billing API uses OAuth2 client credentials flow. Create an API client in the FRAGMENT dashboard and use the client ID and secret to obtain an access token.
Token endpoint: https://auth.us-west-2.fragment.dev/oauth2/token
API base URL: https://api.us-west-2.fragment.dev
Include the token in requests with the Authorization: Bearer <access_token> header. Tokens expire in 1 hour.
curl -X POST "https://auth.us-west-2.fragment.dev/oauth2/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Authorization: Basic $(echo -n 'client_id:client_secret' | base64)" \
-d "grant_type=client_credentials&client_id=client_id"FRAGMENT provides official SDKs for the Billing API:
TypeScript / Node.js
npm install @fragment-dev/ts-nodePackage: @fragment-dev/ts-node · Source: fragment-dev/fragment-typescript
Python
pip install fragment-pyPackage: fragment-py · Source: fragment-dev/fragment-py
Both SDKs handle authentication and provide typed interfaces for all endpoints.