Overview
The Trust Accounting API uses token-based authentication. Every request must include:Authorization: Bearer {apiKey}email: user@example.com
bearerAuth security scheme in the API Reference, and it ensures that:
- The API key grants access to your Stax account.
- The
emailheader identifies the acting user for auditing, authorization, and logging.
email header will be rejected.
Getting your API key
- Go to the Stax dashboard
- Click on the “Setttings” tab
- On the “Account” page, scroll down to the “Developer Keys” section
- Use server-side environments (for example, environment variables or a secrets manager) to store keys.
- Avoid embedding keys directly in frontend code, mobile apps, or client-side logs.
- Use separate keys for test and production environments.
Making an authenticated request
Here is a minimal example of an authenticated request to the Trust Accounting API. The path is illustrative; consult the API Reference → Trust Accounting API tab for the exact endpoints you will call.curl:
HTTP status codes for auth errors
When authentication fails, you can expect standard HTTP error responses, such as:401 Unauthorizedwhen the API key is missing, invalid, or expired.403 Forbiddenwhen the key is valid but does not have permission to access the requested resource.
Error schema defined in the API Reference and typically includes:
- A human-readable
errormessage. - An
authErrorflag indicating that the failure is related to authentication.
Best practices
- Rotate keys regularly: Treat API keys like passwords. Rotate them periodically and immediately if you suspect compromise.
- Scope usage by environment: Use different keys for development, staging, and production.
- Log responsibly: Do not log full API keys. If you need to log something for debugging, log only a short, non-sensitive prefix (for example, the last 4 characters).
- Use HTTPS everywhere: Always call the API over HTTPS to prevent interception of tokens and headers.