API Tokens
Generate and use API tokens for direct AgnicPay access
API Tokens
API tokens provide direct access to AgnicPay APIs without the OAuth2 flow. They're ideal for scripts, CI/CD pipelines, and AI agents.
Creating a Token
- Go to your AgnicPay Dashboard
- Click Connect App
- Configure spending limits:
- Max per transaction: Maximum USD for a single payment
- Daily limit: Total USD allowed per 24 hours
- Monthly limit: Total USD allowed per 30 days
- Select allowed networks (Base, Solana)
- Add an optional label
- Click Generate Token
Your token is only shown once! Save it securely.
Using Your Token
Include the token in the X-Agnic-Token header:
Token Format
AgnicPay tokens follow this format:
| Part | Description |
|---|---|
agnic_tok | Token type identifier |
sk | Secret key indicator |
live | Environment (live/test) |
abc123... | Unique token hash |
Environment Variables
Store your token in environment variables:
Managing Tokens
List Tokens
View all your tokens in the dashboard. You can see:
- Token label
- Spending limits
- Created date
- Networks
Revoke a Token
- Go to your Dashboard
- Find the token in the list
- Click Revoke
Revoking a token is immediate and cannot be undone. Any applications using the token will stop working.
Spending Limits
Each token has three spending limits:
| Limit | Description | Resets |
|---|---|---|
| Per-transaction | Max for single payment | Per request |
| Daily | Total per 24 hours | Rolling 24h |
| Monthly | Total per 30 days | Rolling 30d |
If a payment would exceed any limit, the request returns a 402 error:
Best Practices
- Use descriptive labels - "Production API", "Dev Testing", etc.
- Set conservative limits - Start low, increase as needed
- Use separate tokens for different environments
- Rotate tokens periodically for long-running applications
- Never commit tokens to version control
Example: Python Script
CLI Login
You can also generate a token directly from the command line using email OTP:
The CLI stores the token locally at ~/.agnic/config.json. See the CLI reference for details.