Authorization: Bearer <token>. There are two ways to get that token:
- OAuth2 (recommended) — send your API owner email, password, and a Leaf-provisioned
client_idto get anaccess_tokenand arefresh_token. Put theaccess_tokenin the Bearer header and callhttps://api-v2.withleaf.io. When it expires, exchange therefresh_tokenfor a new access token without re-sending your password. /authenticate— send your API owner email and password to get anid_token. There is no refresh token; when it expires, authenticate again. Callhttps://api.withleaf.io.
OAuth2
All token requests go to:Username/Password Grant
Uses your API owner email and password together with aclient_id, sent with grant_type=password. Leaf provisions a client_id for you on request — contact your Customer Success representative to have it generated. Your existing logins continue to work unchanged.
cURL
Using and refreshing the token
The response contains anaccess_token and a refresh_token. Use the access_token in the Authorization: Bearer <token> header of every API request. When the access token expires, exchange the refresh_token for a new one without sending your credentials again.
For endpoint parameters, example requests per grant, and the full response and error shapes, see the Authentication API Reference.
Legacy /authenticate method
Email and password for an id_token. No refresh token. API calls go to https://api.withleaf.io.
Send a POST request to the authenticate endpoint:
Token lifecycle
TherememberMe field controls how long your token lasts:
When a token expires, request a new one from the same endpoint. There is no refresh token flow; you re-authenticate with credentials.
Using the token
Include the token in theAuthorization header of every API request:
401 Unauthorized response.
Multiple environments
Leaf does not provide separate test and production environments. Instead, create distinct API owner accounts for each:leaf-test@yourcompany.comfor development and testingleaf-prod@yourcompany.comfor production
What to do next
- Authentication API Reference: Endpoint details, request/response shapes, and error codes.
- Quickstart: Use your token to create a Leaf user and start pulling data.
- Core Concepts: Understand the data pipeline before building.

