How It Works
1
Generate a Token
Obtain a signed JWT token from the Zygo API while logged in via the browser or using an existing valid token.
2
Pass the Token
Include the token in the
token HTTP header on every API request.3
Specify the Tenant
The tenant is determined by the
{tenant_id} in each endpoint’s URL path. No session or tenant switching is needed.Generating a Token
You must be logged in via the browser to generate your first token. After that, you can use the token itself to generate new tokens.
Parameters
Using the Token
Pass the token in thetoken header on every request. No session cookie is needed.
- curl
- Python
- JavaScript
Token vs. Session
Understanding the difference between the two authentication methods:Multi-Tenant Access
Unlike browser sessions where you switch tenants, API tokens let you access any tenant you’re a member of by changing thetenant_id in the URL:
Error Responses
For security, Zygo returns
404 rather than 403 when you try to access a specific resource in a tenant you’re not a member of. This prevents leaking information about whether a resource exists.Security Best Practices
Use short expiration times
Use short expiration times
Set token expiration to the minimum duration you need. For scripts that run once, 600 seconds (10 minutes) is reasonable. For long-running integrations, consider refreshing the token periodically rather than using a very long expiration.
Never commit tokens to source control
Never commit tokens to source control
Store tokens in environment variables or a secrets manager. Treat them like passwords.
Use one token per integration
Use one token per integration
If you have multiple scripts or services calling the API, generate a separate token for each. This makes it easier to revoke access if one is compromised.
Rotate tokens regularly
Rotate tokens regularly
Tokens are short-lived by design. Build your integrations to handle token refresh gracefully.