Authorization header. There are no session cookies or OAuth flows to set up — every call is stateless, and your key is the only credential you need. This makes Swytcho straightforward to integrate from any language, framework, or HTTP client.
Get an API key
API keys are managed from the Swytcho dashboard. Follow these steps to create one:1
Open the API Keys page
Log in to your account at swytcho.com, then click API Keys in the left navigation sidebar.
2
Create a new key
Click Create new key. Enter a descriptive name that helps you identify where the key is used — for example,
production-backend or local-dev. Select the appropriate scope (see API key scopes below), then click Create.3
Copy and store the key
Your key is displayed exactly once. Copy it immediately and save it to a secure location such as a secrets manager or an environment variable in your deployment environment. If you lose the key, you’ll need to generate a new one.
Use your API key in requests
Include your API key in theAuthorization header of every request using the Bearer scheme. The examples below show how to do this in curl, Python, and Node.js.
Security best practices
Never hardcode API keys in your source code. Instead, load them at runtime from environment variables or a secrets manager:
- Set
SWYTCHO_API_KEYin your shell,.envfile, or your hosting platform’s environment variable settings. - Use a tool like dotenv (Node.js) or python-dotenv (Python) to load the variable locally.
- Add
.envto your.gitignoreso the file is never committed to version control. - Rotate keys regularly and revoke any key that is no longer in active use.
API key scopes
When you create a key, you assign it one of two scopes that control what it can do:
Grant the minimum scope a key needs for its purpose. If a read-only key is compromised, no inference costs can be incurred.
Handling authentication failures
If a request cannot be authenticated, the API returns a401 Unauthorized response. This happens when the key is missing, malformed, revoked, or passed in the wrong header.
401, verify the following:
- The
Authorizationheader is present and formatted asBearer YOUR_API_KEY(note the space afterBearer). - The key hasn’t been revoked — check the API Keys page in the dashboard.
- You’re targeting the correct base URL:
https://api.swytcho.com/v1.
A
403 Forbidden response means your key is valid but lacks the scope required for the requested operation. Regenerate the key with the correct scope, or contact support if you believe the scope assignment is incorrect.