Admin API Authentication
Admin API keys provide programmatic access to user resources. Admin keys are prefixed withadmin_
and must be included in the Authorization header as a Bearer token.
Need to create an admin API key? Follow our step-by-step guide: Getting a Tinfoil Admin Key
Available Endpoints
Admin API keys can access the following endpoints:API Key Management
GET /api/keys
- List all API keysPOST /api/keys
- Create a new API keyDELETE /api/keys/:key
- Delete an API keyPOST /api/keys/rename
- Rename an API key
Billing & Usage
GET /api/billing/usage
- Get usage statisticsGET /api/billing/time-series
- Get time series dataGET /api/billing/transactions
- Get transaction history
API Key Management
List API Keys
Returns all regular (non-admin) API keys for the authenticated user.
Response
Create API Key
Creates a new regular API key for token-based API access.
Request Body
Name for the API key. Must contain only alphanumeric characters, hyphens, underscores, spaces, and periods.
ISO 8601 timestamp when the key should expire. If not provided, the key doesn’t expire.
Maximum number of tokens this key can use. If not provided, no limit is enforced.
Custom metadata to attach to the key. Maximum size: 5KB.
Example Request
Response
Delete API Key
Deletes a specific API key owned by the user.
Path Parameters
The API key to delete (e.g.,
tk_abc123...
)Example Request
Response
Rename API Key
Renames an existing API key.
Request Body
The API key to rename.
New name for the API key. Must contain only alphanumeric characters, hyphens, underscores, spaces, and periods.
Example Request
Response
Billing & Usage
Get Usage Statistics
Retrieves token usage statistics for the specified time period.
Query Parameters
Time period for usage statistics. Valid values:
5m
- Last 5 minutes15m
- Last 15 minutes30m
- Last 30 minutes1h
- Last hour24h
- Last 24 hours7d
- Last 7 days30d
- Last 30 days60d
- Last 60 days90d
- Last 90 days
Example Request
Response
Get Time Series Data
Retrieves time-series data for token usage over the specified period.
Query Parameters
Time period for the time series. Valid values:
5m
- Last 5 minutes15m
- Last 15 minutes30m
- Last 30 minutes1h
- Last hour24h
- Last 24 hours7d
- Last 7 days30d
- Last 30 days60d
- Last 60 days90d
- Last 90 days
Example Request
Response
Get Transaction History
Retrieves the transaction history including invoices and charges.