Skip to content
Pyck docs

HTTP headers

Audience Programmer

Since pyck v0.27.0

This document details the HTTP headers used when interacting with the pyck API. These headers control authentication, tenant context, and query behavior.

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 or all), 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
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
  • 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
  • You can use the special tenant ID all to select all tenants the user has access to.
    • Example: X-Pyck-Tenant-Id: all
  • 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. all or an omitted header works for a mutation only when it leaves exactly one live tenant; with more, the mutation is refused.

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-123 is disabled, X-Pyck-Tenant-Id: abc-123 returns 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

When working with multi-tenant contexts:

  • Query operations can use X-Pyck-Tenant-Id to 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

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-Id header is omitted
  • This provides a convenient default for single-tenant scenarios

For users with access to multiple tenants:

  • The X-Pyck-Tenant-Id header 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 the system role. The pyck services read it from PYCK_SERVICE_TOKEN and send it in the Authorization header 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-Id header 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.

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 registerTenant mutation refuses a request that carries any X-Pyck-Feature header, before it validates or writes anything

The following features can be toggled on:

  • Controls whether deleted resources should be included in query results
  • Example: X-Pyck-Feature: showdeleted
  • 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
  • Makes the server skip the events it would otherwise emit for the mutations in the request
  • Example: X-Pyck-Feature: suppressevents
  • 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.

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: application/json; charset=UTF-8
  • Required for all POST requests to the API
  • All request bodies should be valid JSON

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.

  • Always include the Authorization header for authenticated endpoints
  • Always explicitly specify the tenant(s) to use. Use all to query all tenants.
  • Only enable the showdeleted feature when specifically needing to access deleted resources
  • Set appropriate Content-Type headers for all requests