Skip to main content
Swytcho authenticates every API request using an API key passed as a Bearer token in the 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 the Authorization 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

Treat your API key like a password. Anyone who holds your key can make requests billed to your account and access any resource the key’s scope permits. If you suspect a key has been exposed, revoke it immediately from the dashboard and issue a new one.
Never hardcode API keys in your source code. Instead, load them at runtime from environment variables or a secrets manager:
  • Set SWYTCHO_API_KEY in your shell, .env file, 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 .env to your .gitignore so 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 a 401 Unauthorized response. This happens when the key is missing, malformed, revoked, or passed in the wrong header.
When you receive a 401, verify the following:
  1. The Authorization header is present and formatted as Bearer YOUR_API_KEY (note the space after Bearer).
  2. The key hasn’t been revoked — check the API Keys page in the dashboard.
  3. 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.