Authorization header of each HTTP request. Requests that omit the header or supply an invalid key are rejected immediately with a 401 Unauthorized response.
Header Format
Include the following header in every API request, replacingYOUR_API_KEY with your actual key:
Example Request Headers
Obtaining an API Key
Generate and manage your API keys from the Swytcho Dashboard. Each key is shown only once at creation time — copy it immediately and store it securely. If you lose a key, revoke it and generate a new one.Security Best Practices
Follow these practices to keep your API key safe:- Use environment variables. Store your key in an environment variable such as
SWYTCHO_API_KEYand read it at runtime. Never hard-code it in source files. - Add key files to
.gitignore. If you use a.envfile locally, make sure it is listed in.gitignoreso it is never committed to version control. - Rotate keys periodically. Generate a new key on a regular schedule and revoke the old one to limit the blast radius of any undetected exposure.
- Use separate keys per environment. Maintain distinct keys for development, staging, and production so you can revoke a compromised key without affecting all environments.
- Restrict key scope where possible. The dashboard lets you assign keys to specific projects — use the narrowest scope that satisfies your use case.
Authentication Errors
When a request fails authentication, the API returns a401 Unauthorized status code with a JSON error body:
401 errors include: