Skip to content
Pyck docs

You are reading the Dev docs (main @ e991a08). They can differ from the released product.Dev docs, not the release

Switch to LatestLatest

HTTP headers

Audience Developer

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.

Idempotency-Key: <key>
  • The gateway passes the header on to the services
  • Makes a mutation safe to retry: the server runs it at most once per successful commit and answers a retry with the stored response
  • Send it on a GraphQL mutation request, for example after a timeout or a dropped connection. On a query it is ignored
  • The key is any string of at most 255 bytes that is valid UTF-8. Surrounding whitespace is trimmed, and a header that is empty or only whitespace counts as not sent
  • Example: Idempotency-Key: 6f1c3c1e-2a54-4b7a-9d57-7d1a0e5f2c11

A request with a key must meet these conditions, or it is refused with an error from Error codes:

  • The mutation is a named operation, for example mutation CreateItem { ... }
  • It selects no more than one top-level mutation field
  • The request is authenticated and resolves to exactly one tenant, see Setting the tenant context for mutations

How the key behaves:

  • Scope: a key is unique for a combination of tenant, user and key value. The same key sent by another user or for another tenant is a different key
  • Retry within the time to live: a retry with the same key, operation and variables does not run the mutation again. It returns the stored response of the first request, with HTTP status 200 and the same transactionID. The server removes stored responses that are older than 24 hours. The cleanup job runs every 5 minutes, so removal can lag a little. Once a key is removed it counts as new and the mutation runs again
  • A failed mutation does not use up the key: the key is stored in the same database transaction as the mutation. When the mutation fails and rolls back, nothing is stored, so a retry with the same key runs the mutation again
  • Same key, different request: the server compares the operation name, the operation text including its selection set and the variables. Whitespace, the order of object keys in the variables and an omitted variable that has a schema default do not count as a difference. Any other difference is refused with OPERATION_MISMATCH. Use a new key for every distinct request
  • Same key while the first request runs: a second request with the same key waits for the first one to finish. If the first committed, the second gets its stored response. If the first rolled back, the second runs the mutation. IDEMPOTENCY_IN_FLIGHT is a safeguard that does not occur in normal operation
  • Response size: the response is stored with the key. A response above 1 MiB (the default) is not stored, the mutation is rolled back and the request fails with RESPONSE_TOO_LARGE. Split the mutation into smaller calls
  • Not honored: registerTenant ignores the key, because it manages its own transactions. Do not rely on a retry of it being safe
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