REST API Authentication
All REST API requests require an API key passed in theX-API-Key header.
Getting Your API Key
1
Go to the API Keys page
2
Create a new key
Click “Create API Key”
3
Copy and store your key
Copy and store your key securely
Using Your API Key
Pass your API key when making requests. The Python SDK readsTINYFISH_API_KEY from your environment automatically:
Environment Variables
Store your API key in an environment variable:.env file:
MCP Authentication
The MCP endpoint uses OAuth 2.1 for secure authentication with AI assistants.How It Works
1
Add the TinyFish MCP server
Add the TinyFish MCP server to your AI client configuration. See the MCP Integration guide for setup instructions.
2
Authenticate in browser
When you first use the tool, a browser window opens for authentication
3
Log in
Log in with your TinyFish account
4
Start using TinyFish Web Agent
Authorization is cached for future sessions
You need a TinyFish account. Search and Fetch are free; Agent and Browser draw from your wallet (plan credits on legacy accounts). Sign up here.
Error Responses
Authentication errors return standard HTTP status codes with a JSON error body. See Error Codes for the full reference.403 Forbidden — Insufficient Credits (legacy accounts)
403 Forbidden — Insufficient Credits (legacy accounts)
Authentication succeeded, but you lack credits or an active subscription. This applies to legacy credit/subscription accounts — wallet accounts get a 402 instead, see below.How to fix:
- Check your account at agent.tinyfish.ai/api-keys
- Add credits to your account
402 Payment Required — Insufficient Credits (wallet accounts)
402 Payment Required — Insufficient Credits (wallet accounts)
Your TinyFish wallet balance is too low to start this run. Non-retryable until money is added.How to fix:
- Check your balance with
GET /v1/wallet(orclient.wallet.get(),tinyfish wallet status) - Add money at agent.tinyfish.ai/wallet — minimum top-up is $10
- If
auto_reload_needs_payment_fixistrue, auto-reload is also paused on a declined payment method — update it on the same page
GET /v1/wallet returns 404 with error.code: "FEATURE_NOT_AVAILABLE" for legacy accounts — see Error Codes for the full discriminator.Security Best Practices
Use Environment Variables
Never hardcode API keys in source code
Rotate Keys Regularly
Regenerate keys periodically and after team changes
Limit Exposure
Use separate keys for development and production
Monitor Usage
Review API usage in your dashboard for anomalies
Related
Quick Start
Run your first automation
Error Codes
Full error code reference