API Tokens
API tokens are long-lived credentials scoped to your organization. Every token starts with the prefixentri_ so they are easy to identify in logs and environment variables.
Creating a Token
Tokens can be created in two ways:- Web app — Navigate to your organization settings, open the API Tokens section, and click “Create token”. Give the token a descriptive name so you remember what it is used for. The full token value is shown only once at creation time.
- API — Use the API Tokens endpoint to create tokens programmatically.
Using a Token
Pass the token in theX-API-Key request header on every API call:
- curl
- JavaScript (fetch)
- JavaScript (axios)
- Python
Using Environment Variables
Never hard-code tokens in source code. Use an environment variable instead:Session Cookies (Web App Only)
The Entri web application authenticates via session cookies managed by BetterAuth. When you sign in through the browser, a secure HTTP-only cookie is set automatically and included on every subsequent request.Session authentication is intended for browser-based usage only. If you are building an integration or automation, use an API token instead.
What Happens if Authentication Fails
If no credentials are provided, or if the provided token is invalid or revoked, the API returns a401 Unauthorized response:
403 Forbidden response:
Token Best Practices
- Create a separate token for each integration or service that calls the API. This makes it easy to revoke access for one consumer without affecting others.
- Rotate tokens periodically as part of your security hygiene.
- Never commit tokens to version control. Use a secrets manager or environment variable.
- For CI/CD pipelines, use your provider’s secrets mechanism (GitHub Actions secrets, GitLab CI variables, etc.).