DocumentationStatisticsAuthentication

Authentication

The API uses the OAuth 2.0 Client Credentials Flow. Your integration sends its client ID and secret to the identity host and gets a bearer token back.

Pick your environment and the hosts on this page update to match.

Token Endpoint

POST https://identity-v2.metaforce.net/connect/token

This path is stable. We are moving Doc Gen onto Keycloak, which serves OAuth under different paths internally, but the identity host keeps accepting /connect/token and forwards it. You do not need to change your integration when that move happens, and you do not need to read the discovery document to find the endpoint.

Required Parameters

Send them as application/x-www-form-urlencoded.

NameTypeValue
grant_typestringclient_credentials
client_idstringYour client ID
client_secretstringYour client secret
scopestringapi.external

Example Response

{
  "access_token": "...",
  "expires_in": 3600,
  "token_type": "Bearer"
}

Use the token in the header of every call:

Authorization: Bearer <access_token>

Tokens last an hour. Cache the token and reuse it until it expires rather than asking for a new one on every call.

Your client must belong to a company

Statistics returns the data of one company. The company is taken from the token, so the client (or the user) that asks for the token must be linked to a company in Doc Gen. Use an API client registered for your company, see API Clients.

A token without a company is accepted as a valid sign-in, but Statistics returns no data for it: /analytics answers 403 and /analytics/prometheus answers 500.

Common failures

StatusMeaningWhat to do
401No token, an expired token, or a token that was issued for a different APIRequest a new token and send it in the Authorization header
403The token is valid but is not tied to a companyUse an API client registered for your company

The full list of responses for each call is on API Endpoints.