Skip to main content
TRXN uses token-based authentication for all API requests. Every API call (except authentication itself) requires a valid API token.

Overview

Obtaining an API token

  1. Navigate to API Tokens in the account settings.
  2. Click New API Token.
  3. Enter a name for the token.
  4. The token value is displayed once after creation — copy it immediately.
The token value is only displayed once at creation time. If you lose it, you will need to create a new token.

Option 2: Via the auth endpoint

Exchange email and password credentials for an API token programmatically.
string
required
The user’s email address.
string
required
The user’s password.
string
The six-digit one-time password from the user’s authenticator app. Required when the user has two-factor authentication enabled.

Request

Success response (200 OK)

Error responses

Invalid credentials (401 Unauthorized):
Two-factor authentication required (422 Unprocessable Entity):
When the user has two-factor authentication enabled, include the otp_attempt parameter:
Invalid OTP code (401 Unauthorized):

Authenticating API requests

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

Authentication header format

The API also accepts the token keyword:

Missing or invalid token (401 Unauthorized)

Requests without a valid token receive an empty 401 Unauthorized response:
No JSON body is returned for missing or invalid tokens.

Account scoping

Each API token is tied to a specific account. All API requests are automatically scoped to that account’s data:
  • Customers returned are only those belonging to the token’s account.
  • Invoices, products, prices, and other resources are similarly scoped.
  • Tokens cannot access data from other accounts.

Token usage tracking

Each time a token is used for authentication, its last_used_at timestamp is updated. This is visible in the dashboard for auditing purposes.

Sandbox mode

API tokens can be created within a sandbox environment for testing purposes.
Production tokens access only production data. Sandbox tokens access only sandbox data. The sandbox association is set when the token is created.

How it works

  • Production tokens (no sandbox) access only production data.
  • Sandbox tokens access only sandbox data.
  • The sandbox association is set when the token is created.

Creating a sandbox token

Create an API token while in sandbox mode through the dashboard. The token will automatically be scoped to that sandbox and will only return sandbox data.

Token management

Listing tokens

View all API tokens for an account in the dashboard at API Tokens.

Revoking a token

Delete an API token from the dashboard to immediately revoke access. Any requests using that token will receive a 401 Unauthorized response.

Code examples

Available API endpoints

All endpoints require authentication unless noted otherwise.

Best practices

Follow these guidelines to keep your API tokens secure and your integration reliable.
  1. Store tokens securely — never commit tokens to source control or expose them in client-side code.
  2. Use environment variables to store tokens in your application.
  3. Create separate tokens for different integrations or environments.
  4. Revoke unused tokens promptly when they are no longer needed.
  5. Use sandbox tokens for development and testing to avoid affecting production data.
  6. Monitor usage by checking last_used_at in the dashboard for unusual activity.