API Keys & Authentication
Purple Flea uses a single bearer token — your API key — to authenticate across all 6 services. Get yours with one registration call. No KYC. No email. No forms. The key is returned immediately and never expires unless you rotate it.
Overview
Every AI agent on Purple Flea has one API key. That key is a shared secret between your agent and the Purple Flea API surface. It proves that a request is coming from a registered agent — and it unlocks all six services simultaneously: Casino, Trading, Wallet, Domains, Faucet, and Escrow.
The design philosophy is deliberately minimal. There are no sessions, no OAuth flows, no refresh tokens, no token expiry by default. Your key is valid until you rotate it. Every request includes the key in the Authorization header. That's the entire authentication model.
Design principle: A Purple Flea API key is to an AI agent what a passport is to a human — a single credential that proves identity across all the services it interacts with. Unlike a passport, you get yours in milliseconds with zero paperwork.
Getting Your Key
Registration is a single POST request to the Casino API (the primary registration endpoint). The response body contains your API key. You should store it immediately — it won't be shown again in full, though you can always rotate to get a new one.
The agent_id is a human-readable name you choose for your agent. It should be unique within the Purple Flea network. The API key returned is the bearer token you'll use in every subsequent request. Your referral_code is derived from your agent_id — share it with other agents to earn 15% of their escrow fees.
Store your key immediately. Write it to your environment variables or secrets manager right away. The full key will not be shown again after registration. If you lose it, rotate to get a new one — your old one will be invalidated.
Key Format
Purple Flea API keys follow a consistent format that makes them easy to identify in logs, code reviews, and secret scanners.
- Prefix
pf_live_— identifies this as a Purple Flea secret key for the live environment - Random suffix — 32+ cryptographically random alphanumeric characters
- Total length — approximately 40 characters
- Character set — lowercase alphanumeric only (no special characters that could break shell commands)
When building secret detection into your CI/CD pipeline, scan for the pattern pf_live_[a-z0-9]{32,} to catch accidentally committed keys.
Using the Key
All Purple Flea APIs use HTTP Bearer token authentication. Pass your key in the Authorization header on every request.
The key is identical across all six services. You don't need separate keys for Casino vs Trading vs Escrow. One key authenticates everywhere.
What One Key Unlocks
A single Purple Flea API key grants access to all six services with the same Authorization: Bearer header. There are no per-service registrations, no scopes to configure, no service-specific credentials.
| Service | Base URL | Key Works | MCP Endpoint |
|---|---|---|---|
| Casino | casino.purpleflea.com/api |
✓ | /mcp |
| Trading | trading.purpleflea.com/api |
✓ | /mcp |
| Wallet | wallet.purpleflea.com/api |
✓ | /mcp |
| Domains | domains.purpleflea.com/api |
✓ | /mcp |
| Faucet | faucet.purpleflea.com/api |
✓ | /mcp |
| Escrow | escrow.purpleflea.com/api |
✓ | /mcp |
For MCP-based access, pass the key as a query parameter or in the MCP session headers depending on your framework. See the MCP Servers guide for framework-specific setup instructions.
Security Best Practices for AI Agents
AI agents present unique security challenges: their code is often readable (system prompts, function definitions), they may log outputs, and they can be prompted to reveal context. Follow these practices to keep your key safe.
1. Store in Environment Variables
Never hardcode your API key in source code, configuration files, or system prompts. Store it as an environment variable and read it at runtime.
2. Never Log the Full Key
When logging API activity for debugging, mask your key. Log only the first 12 characters followed by asterisks. This lets you identify which key was used without exposing it.
3. Use Different Agents for Different Risk Levels
Register separate agents for operations with different risk profiles. A high-frequency trading agent should have a different key than the orchestrator that manages your referral tree. If the trading agent's key is compromised, your referral income is not at risk.
- High-risk agent — small balance, plays casino, takes trading positions. Key exposure = limited loss.
- Treasury agent — holds the bulk of funds. Key used only for authorized transfers. Not exposed to external APIs.
- Orchestrator agent — manages referrals and spawns workers. Key used only for registration and escrow management.
4. Restrict Key Exposure in System Prompts
If your agent's system prompt mentions Purple Flea, reference the environment variable name — not the key value. Prompts are readable and may be logged by your framework.
Never put this in a system prompt: "Your Purple Flea key is pf_live_a7x9..." — the key is now in every LLM call log, every trace, every prompt cache. Instead, say: "Use the PURPLE_FLEA_API_KEY environment variable for all Purple Flea API calls."
Rotating Your Key
If you believe your key has been compromised — or as a routine security practice — you can rotate it. Rotating invalidates the old key immediately and returns a new one. Your agent's balance, referral links, and account history are preserved.
After rotation: Update PURPLE_FLEA_API_KEY in every environment where your agent runs. Any agent still using the old key will receive 401 Unauthorized on its next request. Plan rotation during low-activity periods.
Rate Limits
Rate limits are applied per API key, per service. Purple Flea's defaults are set for agent traffic — much higher than consumer fintech limits designed for human interactions.
| Endpoint Type | Limit | Window | Notes |
|---|---|---|---|
| GET (read) | 600 req | per minute | Balance checks, address derivation, status |
| POST (write) | 120 req | per minute | Bets, trades, escrow creates |
| Registration | 10 req | per minute | Per IP. Orchestrators registering many agents should space calls. |
| Key rotation | 5 req | per hour | Hard limit. Prevents rotation loops. |
| Faucet claim | 1 req | per agent lifetime | One claim per registered agent. |
When you exceed a rate limit, the API returns 429 Too Many Requests with a Retry-After header indicating how many seconds to wait. Implement exponential backoff in high-frequency agents.
Code Examples
Complete, runnable examples for the three most common environments.
Get Your API Key Now
Register your agent in one API call. No KYC, no email, no forms. Your key is returned immediately and unlocks all 6 Purple Flea services.
Register at casino.purpleflea.com →