HTTP headers
Audience Programmer
Since pyck v0.27.0
Overview
Section titled “Overview”This document details the HTTP headers used when interacting with the pyck API. These headers control authentication, tenant context, and query behavior.
Required headers
Section titled “Required headers”Authorization
Section titled “Authorization”Authorization: Bearer <token>- The token can be either a JWT or a Personal Access Token (PAT)
- Example:
Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjEu... - An invalid token gets 401 Unauthorized
- A request without a token is treated as unauthenticated: if it names a tenant in
X-Pyck-Tenant-Id(a tenant ID orall), it gets 400 Bad Request; otherwise every query on tenant data fails with an unauthorized error
NOTE:
The Authorization header is required for all authenticated endpoints except
the following GraphQL mutations/queries:
registerTenant
Tenant context headers
Section titled “Tenant context headers”X-Pyck-Tenant-Id
Section titled “X-Pyck-Tenant-Id”X-Pyck-Tenant-Id: <ID1>,<ID2>,...- Specifies one or more tenants for the request
- Used for both query and mutation operations
- Example:
X-Pyck-Tenant-Id: d4b5319e-1daa-57ed-9676-c6bfc717cf76
- Example:
- To provide multiple tenant IDs, you can set the header multiple times and/or
add multiple tenant IDs to a single header by separating them with a comma
- Example:
X-Pyck-Tenant-Id: d4b5319e-1daa-57ed-9676-c6bfc717cf76,7cdbc30a-6f27-5aa1-bd4a-e7d5106075a5
- Example:
- You can use the special tenant ID
allto select all tenants the user has access to.- Example:
X-Pyck-Tenant-Id: all
- Example:
- For query operations, if not provided, it defaults to
all. - For mutations (create/update/delete), the request must act on exactly one
tenant, so provide exactly one tenant ID.
allor an omitted header works for a mutation only when it leaves exactly one live tenant; with more, the mutation is refused.
Disabled tenant behavior
Section titled “Disabled tenant behavior”When a tenant is disabled (soft-deleted), the system applies different access control rules based on how the tenant is specified:
Explicitly named disabled tenants:
- If you explicitly name a disabled tenant in the header, the request is rejected with 403 Forbidden
- Example: If tenant
abc-123is disabled,X-Pyck-Tenant-Id: abc-123returns 403 - This applies whether the tenant is named alone or as part of a comma-separated list
Disabled tenants reached through all:
- Disabled tenants are automatically filtered out when using
X-Pyck-Tenant-Id: all - The request proceeds with only active (non-disabled) tenants
- However, if filtering out disabled tenants would result in an empty tenant set when the expansion was originally non-empty, the request returns 403 Forbidden
- Without this check, the request would run with no tenant context although you expected to have access
User’s home tenant:
- If the authenticated user’s home tenant is disabled, all requests return 401 Unauthorized regardless of which tenants are named in the header
- Users from disabled tenants lose access immediately across the entire system
Multi-tenant operations
Section titled “Multi-tenant operations”When working with multi-tenant contexts:
- Query operations can use
X-Pyck-Tenant-Idto retrieve data from one or more tenant contexts - Mutation operations must use exactly one tenant in
X-Pyck-Tenant-Id - The system validates that tenants specified in headers are accessible to the authenticated user
Setting the tenant context for mutations
Section titled “Setting the tenant context for mutations”All mutation operations require an unambiguous tenant context. While query operations can span multiple tenants, mutations must target exactly one tenant for data integrity.
For users with access to a single tenant:
- The tenant context is automatically inferred from the JWT when the
X-Pyck-Tenant-Idheader is omitted - This provides a convenient default for single-tenant scenarios
For users with access to multiple tenants:
- The
X-Pyck-Tenant-Idheader is mandatory - The API will return an error if the header is missing
- You must explicitly specify which tenant the mutation should affect
For system users and service tokens:
- A service token is the personal access token of pyck’s own
service-user, a ZITADEL machine user with thesystemrole. The pyck services read it fromPYCK_SERVICE_TOKENand send it in theAuthorizationheader when they call the API themselves. - System users operate differently: they have no default tenant context by design, as they can operate across all tenant boundaries
- When performing mutations with a system user token, you must always include the
X-Pyck-Tenant-Idheader to explicitly specify which tenant the mutation should affect - Omitting this header will result in an error that contains the message:
"a single tenant must be selected"
Best practice:
To avoid errors, always include X-Pyck-Tenant-Id: <tenant-uuid> in your mutation requests when using system tokens or when you have access to multiple tenants.
Additional headers
Section titled “Additional headers”X-Pyck-Feature
Section titled “X-Pyck-Feature”X-Pyck-Feature: <FEATURE1>,<FEATURE2>,...- Used to selectively enable additional features in the API
- Can be provided multiple times with one or more feature IDs separated by comma
- The
registerTenantmutation refuses a request that carries anyX-Pyck-Featureheader, before it validates or writes anything
The following features can be toggled on:
showdeleted
Section titled “showdeleted”- Controls whether deleted resources should be included in query results
- Example:
X-Pyck-Feature: showdeleted
syncupdates
Section titled “syncupdates”- Makes the server send the field-level change events of an update and wait for them to finish, instead of sending them in the background
- Example:
X-Pyck-Feature: syncupdates
suppressevents
Section titled “suppressevents”- Makes the server skip the events it would otherwise emit for the mutations in the request
- Example:
X-Pyck-Feature: suppressevents
asyncsignals
Section titled “asyncsignals”- Deprecated: the server accepts it and ignores it, because mutation events are always fire-and-forget now
- Example:
X-Pyck-Feature: asyncsignals
An unknown feature ID is rejected with HTTP 400. Feature IDs are not case-sensitive.
Response headers
Section titled “Response headers”X-Request-ID
Section titled “X-Request-ID”X-Request-ID: <uuid>- Automatically included in all HTTP responses from the pyck API
- Contains a unique UUID v7 identifier generated by the server for each request
- Used for request tracing, debugging, and support purposes
- Example:
X-Request-ID: 01010101-0202-7303-8404-050505050505
Use cases:
- Debugging: Include this ID when reporting issues to help support teams locate specific requests in logs
- Request tracing: Track a request’s flow through the system across multiple services
- Correlation: The same request ID appears in server logs, making it easier to correlate API requests with backend operations
Note: The request ID is always server-generated. Any client-supplied X-Request-ID header in the request will be ignored.
Content-Type headers
Section titled “Content-Type headers”For API requests
Section titled “For API requests”Content-Type: application/json; charset=UTF-8- Required for all POST requests to the API
- All request bodies should be valid JSON
Authentication providers
Section titled “Authentication providers”While ZITADEL is the reference implementation for authentication in pyck, the system is designed to support other identity providers. The headers and authentication mechanisms described here are part of pyck’s API contract and will remain consistent regardless of the underlying authentication provider.
Best practices
Section titled “Best practices”- Always include the
Authorizationheader for authenticated endpoints - Always explicitly specify the tenant(s) to use. Use
allto query all tenants. - Only enable the
showdeletedfeature when specifically needing to access deleted resources - Set appropriate
Content-Typeheaders for all requests