Skip to main content
Zygo supports two authentication methods: browser sessions for the web UI and API tokens for programmatic access. This guide covers API token authentication.

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.
Response:

Parameters

Using the Token

Pass the token in the token header on every request. No session cookie is needed.

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 the tenant_id in the URL:
The token identifies you. The URL identifies what you’re accessing. Your roles are resolved per-tenant — you might be an Admin in Tenant A and a Viewer in Tenant B.
Each individual API request is scoped to a single tenant. You cannot access resources from multiple tenants within a single request.

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

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.
Store tokens in environment variables or a secrets manager. Treat them like passwords.
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.
Tokens are short-lived by design. Build your integrations to handle token refresh gracefully.