Authentication overview

The ways to authenticate with Kustomer (API keys, OAuth 2.0 and chat keys) and how to choose between them.

Every API request carries a bearer token in the Authorization header:

HTTP
GET /v1/users/current HTTP/1.1
Host: acme.api.kustomerapp.com
Authorization: Bearer eyJhbGciOi...

What changes is where the token comes from and whose identity it carries.

Choose a method

MethodActs asBest forLifetime
API keyA machine user with fixed rolesServer-to-server integrations, scheduled syncs, internal toolsUntil it expires or is deleted
OAuth 2.0The signed-in Kustomer userTools that act on behalf of individual agents or admins, such as CLIs and AI assistantsAccess token about 24 hours, renewed with a refresh token
Chat keyAn anonymous or identified chat customerKustomer Chat in your website or mobile appUntil it expires or is deleted

Yes

No

Yes

No

Does the code run on a
customer's device or browser?

Chat key
(role org.tracking only)

Should actions be attributed
to individual Kustomer users?

OAuth 2.0
authorization code + PKCE

API key
with least-privilege roles

Diagram source
flowchart TD
  Q1{"Does the code run on a<br/>customer's device or browser?"} -- Yes --> CHAT["Chat key<br/>(role org.tracking only)"]
  Q1 -- No --> Q2{"Should actions be attributed<br/>to individual Kustomer users?"}
  Q2 -- Yes --> OAUTH["OAuth 2.0<br/>authorization code + PKCE"]
  Q2 -- No --> KEY["API key<br/>with least-privilege roles"]

API keys in brief

An admin creates keys in Settings › Security › API Keys. Each key:

  • is backed by its own machine user, which appears as the author of anything the key creates;
  • has a set of roles chosen at creation that can't be changed afterwards;
  • can expire after a number of days, or never;
  • can be limited to a CIDR IP range;
  • is shown once, when it's created.

Read API keys and roles for the role naming scheme and least-privilege recipes.

OAuth in brief

Kustomer supports the OAuth 2.0 authorization code flow with PKCE. Users sign in at their org's web host (https://acme.kustomerapp.com/oauth/authorize), and your app exchanges the code at the API host (https://acme.api.kustomerapp.com/oauth/token). The OAuth client is a private app installed in the org, with redirectUris in its app definition.

The OAuth 2.0 page has the full parameter reference and a working example.

Checking a token

Two endpoints work with any valid token and are handy for health checks:

get/v1/auth/tokens/current get/v1/users/current

The first describes the token (name, roles, last access). The second returns the user it acts as: the machine user for API keys, or the signed-in person for OAuth.

Authentication errors

StatusCodeMeaningFix
401unauthorizedMissing, malformed, expired or deleted token, or a request from outside the key's IP restrictionCheck the Bearer prefix, the key's status and its CIDR range
403forbiddenThe token is valid but lacks a role the operation requiresCreate a key with the needed role. Each reference page lists the accepted roles.
4xxnoneAuth token associated with pod prod2 but request is being handled by prod1Use your org host. See Regions and base URLs.