Skip to main content
Every Leaf API request uses Authorization: Bearer <token>. There are two ways to get that token:
  • OAuth2 (recommended) — send your API owner email, password, and a Leaf-provisioned client_id to get an access_token and a refresh_token. Put the access_token in the Bearer header and call https://api-v2.withleaf.io. When it expires, exchange the refresh_token for a new access token without re-sending your password.
  • /authenticate — send your API owner email and password to get an id_token. There is no refresh token; when it expires, authenticate again. Call https://api.withleaf.io.
For conceptual background, see Authentication.

OAuth2 token endpoint

POST https://auth.withleaf.io/realms/leaf/protocol/openid-connect/token Requests use Content-Type: application/x-www-form-urlencoded. Two grant types are supported: Username/Password and refresh token.
Never expose credentials in browser or mobile clients, and store access and refresh tokens securely.

Username/Password Grant

Uses your API owner credentials together with a client_id.

Refresh token grant

Exchange a refresh token for a new access token without re-sending credentials.

Response

Use the access_token in the Authorization: Bearer <token> header of every API request. When it expires, use the refresh token grant to obtain a new one.
When using OAuth2, send API requests to the new base URL https://api-v2.withleaf.io instead of https://api.withleaf.io.For example, Get All Leaf Users: https://api-v2.withleaf.io/services/usermanagement/api/users
Token lifetimes (expires_in, refresh_expires_in) are configured per client; the values above are examples and may differ for yours.

Error responses


Legacy /authenticate method

Email and password for an id_token. No refresh token. API calls go to https://api.withleaf.io. POST /authenticate

Base URL

Request body

Token duration

When a token expires, request a new one from the same endpoint. There is no refresh token flow.

Request

Response

Using the token

Include the token in the Authorization header of every API request:

Error responses

Last modified on August 24, 2026