API

Authentication

How to authenticate with the Trunx API using API keys.

API Key Authentication

All Trunx API requests require authentication using an API key. Include your key in the Authorization header as a Bearer token:

curl -H "Authorization: Bearer tk_live_abc123..." \
  https://api.trunx.io/dids

Key Format

Trunx API keys use the prefix tk_live_ for production keys and tk_test_ for test keys. Keys are hashed using SHA-256 before storage — Trunx never stores your raw API key.

Key Scopes

API keys can be scoped to limit access to specific resources:

ScopeDescription
sms:sendSend SMS messages
sms:readRead SMS messages
voice:callInitiate voice calls
voice:readRead call records
campaigns:writeCreate and manage campaigns
campaigns:readRead campaign data
dids:manageProvision and manage DIDs
webhooks:manageCreate and delete webhooks
*Full access (default)

Caching

Authentication results are cached in Redis with a 60-second TTL for performance. Key revocation takes effect within 60 seconds.

MCP Authentication

The MCP endpoint at /mcp uses the same API key authentication. Pass your key in the Authorization header when establishing the MCP connection.

Rate Limiting

Rate limits are enforced per API key using an atomic Lua-based rate limiter. When you exceed the rate limit, you will receive a 429 Too Many Requests response with a Retry-After header.

On this page