Introducing a new way to review your PRs.

Read the announcement

hatchet-dev / hatchet

🪓 An orchestration engine for background tasks, AI agents, and durable workflows

View on GitHub

31 documents · Updated Nov 23, 2026

docs / public-api-contracts

Public API contracts

Hatchet exposes workflow operations through versioned HTTP and gRPC contracts. OpenAPI defines the HTTP paths and JSON views. Protocol buffers define service calls for workflow control, event intake, worker dispatch, and durable task progress. The API server joins these contracts to tenant-scoped platform operations.

Contract landscape

The contract layer separates public resource access from service-to-service execution. HTTP clients manage tenants, workflows, runs, tasks, events, integrations, webhooks, streams, and operational views. gRPC clients use typed calls and streams for workflow control, event delivery, worker work, and durable task state.

SurfaceMain purposeContract form
HTTP APIManage resources and inspect or control executionVersioned OpenAPI paths and JSON schemas
Workflow administrationPublish workflows and control runsVersioned AdminService protocol
Event serviceIngest events, logs, and stream dataEventsService protocol
Worker dispatcherRegister workers, deliver actions, and report stateDispatcher protocol
Durable task dispatcherTrack durable task branches and acknowledgementsVersioned V1Dispatcher protocol

The API and access layer gives the wider service-boundary view. This page focuses on contract surfaces. See authorization and tenancy for identity and tenant checks and operational command interfaces for command paths outside these public contracts.

Versioned HTTP surface

The HTTP API uses explicit path families so older resource routes and newer stable operations can evolve together. The OpenAPI document describes /api/v1 resources and /api/v1/stable views for runs, tasks, events, filters, webhooks, streams, concurrency, serverless endpoints, and operational data.

The API is organized around platform objects rather than internal services. A caller can create workflows and runs, schedule or cancel work, define event filters, inspect task and event data, manage webhooks and workers, read queue state, and operate tenant features through one HTTP boundary. Responses use typed resource views with declared status codes and pagination.

Tenant views also expose platform context. They include routing data such as the server URL, policy data such as retention, and capability data such as durable streams and serverless operator access. Resource policy views show enforceable limits while hiding internal retention accounting. Partial entitlement updates return the complete current entitlement view.

References: api/…/openapi.gen.go• L1163-1172 api/…/openapi.gen.go• L1361-1371 api/…/tenant.go• L13-24 api/…/tenant.go• L52-89

OpenAPI models and enum boundary

OpenAPI models form the public vocabulary for resource fields, request values, status values, and error responses. Generated Go models use shared enum types for values that must stay consistent with platform and database state.

The generated contract is checked against the shared enum set. This prevents a schema from accepting or returning a value that the API model cannot represent. The same boundary carries public status meanings such as task state, concurrency scope, webhook authentication type, scheduled-run creation method, and serverless endpoint kind.

References: api/…/openapi.gen.go• L197-221 api/…/openapi.gen.go• L2035-2143 api/…/openapi.gen.go• L2474-2554 api/…/enums_spec_test.go• L20-91

Expression debugging

The stable CEL debug operation lets a caller check a Common Expression Language (CEL) expression with the same kinds of input used by event and workflow matching. The request supplies workflow input and can add event metadata or a prior filter payload. The response reports success or error and returns the Boolean result only when evaluation succeeds.

This surface helps callers validate event keys, scopes, and filters before they depend on them in a workflow or webhook. It exposes evaluation meaning without exposing the internal expression engine.

References: api/…/openapi.gen.go• L1445-1473 api/…/openapi.gen.go• L9092 api/…/debug.go• L11-44 api/…/cel.go• L5-17

API-server handler boundary

The API server turns an OpenAPI operation into a tenant-aware platform action. Generated bindings decode the request and select a typed response. Route-aware middleware applies authentication, resource loading, authorization, rate limits, telemetry, and request logging before the handler runs.

Handlers translate public request data into repository or internal service calls. Response transformers then turn stored state into public views. This lets the API hide internal fields, normalize statuses, preserve pagination meaning, and return a clear payload-restricted result when the caller cannot view data.

The request path is therefore:

flowchart LR
    C[HTTP client] --> O[OpenAPI operation]
    O --> B[Typed request binding]
    B --> M[Route-aware middleware]
    M --> H[API handler]
    H --> P[Platform operation]
    P --> T[Typed HTTP response]

References: api/…/openapi.gen.go• L3-4 api/…/openapi.gen.go• L9148-9172 api/…/openapi.gen.go• L9898-10051 api/…/workflow.go• L12-37 api/…/workflow_runs.go• L133-176

Tenant and payload scope

Most operations are tenant-scoped. A route identifies the tenant or a child resource, and the handler uses that scope for reads and changes. This keeps workflow, run, task, event, filter, webhook, concurrency, and serverless data inside one tenant boundary.

Payload visibility is a separate public contract. The authorization result controls whether inputs, outputs, event data, log data, or response excerpts appear. Resource views keep their shape and mark restricted payloads, while direct payload reads return an access error.

Membership views expose the same rule. Owner and admin members always have payload access in the public member view. Other members carry the stored payload-view choice. Invitation views carry that choice so membership policy is known before acceptance.

References: api/…/user.go• L29-55 api/…/tenant_invite.go• L8-34 api/…/tasks.go• L23-31 api/…/tasks.go• L63-109 api/…/webhooks.go• L59-103

Workflow contracts

Workflow contracts describe executable work and the commands that create or inspect its runs. They are shared by HTTP handlers, gRPC services, workflow clients, and the execution engine.

Workflow definition and administration

The versioned workflow administration service publishes workflow versions and controls their runs. It supports run triggers, cancellation, task replay, run inspection, and durable task branching. Requests use tenant-relative identifiers and workflow data. Responses return created identifiers or run state.

Workflow definitions carry the rules that shape execution. Public views can include input schema, workflow configuration, event and cron triggers, priority, scheduling, stickiness, and workflow- or task-level concurrency. The transformer presents these as workflow metadata instead of exposing storage records directly.

References: api-contracts/…/workflows.proto• L11-69 api/…/openapi.gen.go• L2988-3012 api/…/workflow.go• L55-177

Scheduled workflow controls

Scheduled workflow resources let clients manage future runs that were created through the API. A client can update the trigger time before execution, delete an individual scheduled run, or bulk-delete runs by ID or by filters. The bulk result separates deleted IDs from per-item errors, so a mixed request can report partial success.

The contract keeps code-defined schedules distinct from API-created schedules. Code-defined schedules remain visible but cannot be changed or deleted through these API operations. A scheduled run that already started also cannot be moved to a new time.

References: api/…/openapi.gen.go• L881-906 api/…/openapi.gen.go• L9192-9197 api/…/update_scheduled.go• L17-60 api/…/delete_scheduled.go• L14-33 api/…/bulk_delete_scheduled.go• L19-172 api/…/workflow_run.go• L10-53

Workflow run and task views

The HTTP surface provides broad workflow and run management plus stable task-oriented execution views. These views expose run and task identity, status, timing, retry and attempt data, task events, workflow shape, and durable event-log information.

The public status model can differ from the storage status model. Evicted work is reported in the public running state and is marked as evicted. The transformer maps every readable storage status to a valid public task status. Payload restriction applies to both task and run details, so the same execution can be inspected without exposing its input or output.

List views preserve their filter and pagination meanings across rows and counts. They also preserve task identity in timing results, because a status change can remove a row and make input-position matching unsafe.

References: api/…/tasks.go• L23-31 api/…/tasks.go• L34-111 api/…/tasks.go• L394-518 api/…/tasks.go• L521-572 api/…/workflow_runs.go• L15-130 api/…/status_test.go• L9-19

Concurrency views

The stable concurrency API gives tenants an operational view of run limits. A strategy describes its scope, key expression, limit behavior, run capacity, queue counts, running counts, and whether an older strategy is draining. Shared strategies also show the workflows and tasks that use them.

Key views show running and queued work for each key. Search, queued-only filtering, and offset pagination let operators inspect queue pressure without changing policy.

References: api/…/openapi.gen.go• L1552-1604 api/…/concurrency.go• L10-60 api/…/concurrency.go• L63-103

Serverless endpoint views

The stable serverless endpoint API manages a tenant-owned HTTPS endpoint that the operator polls and uses for task delivery. Public configuration includes endpoint kind, URLs, timing, labels, enablement, and operator-observed status.

The public view excludes the signing secret and internal partition assignment. Status is absent until the operator has checked the endpoint. Endpoint event views preserve health, catalog, and delivery details while treating response excerpts as payloads that require permission. Empty labels and action lists remain JSON objects and arrays rather than null values.

flowchart LR
    T[Tenant] --> A[Stable HTTP API]
    A --> E[Endpoint configuration]
    E --> O[Serverless operator]
    O --> H[Health check]
    O --> D[Task delivery]
    O --> V[Status and event history]
    V --> A

References: api/…/openapi.gen.go• L2035-2143 api/…/serverless.go• L13-65 api/…/serverless.go• L68-124 api/…/serverless_test.go• L41-181

Event contracts

Event contracts connect external signals and worker-produced data to workflow execution and observability. HTTP paths manage events, filters, and webhooks. gRPC calls carry typed event, log, and stream data into the platform.

Event ingestion and filtering

The event service accepts single and bulk events, event replay, task log lines, and stream messages. An event carries tenant context, a key, payload, time, and optional metadata or scope. The platform uses that context to find workflows and filters that should react.

HTTP event and filter resources let callers list, inspect, replay, cancel, and configure event matching. Payload reads remain permission-checked, and event or log views follow the tenant retention boundary.

References: api-contracts/…/events.proto• L7-17 api-contracts/…/events.proto• L19-114 api/…/tasks.go• L176-239

Webhook ingress

Webhook paths turn an external HTTP request into a tenant event. A webhook defines its source, authentication type, event-key expression, optional scope expression, static payload, and response mode.

The receive contract supports provider challenges, JSON and supported form payloads, basic authentication, API keys, and signed requests. It checks source-specific signatures and time windows before it accepts an event. It combines request data with configured static data, with static values taking precedence, then derives the event key and scope and submits the event. A valid request returns a challenge, a message, an event, or no content according to the webhook configuration. Resource limits can return a rate-limit response. Event payload data appears only when the caller has payload access.

References: api/…/openapi.gen.go• L1639-1666 api/…/openapi.gen.go• L2383-2487 api/…/create.go• L20-74 api/…/create.go• L104-234 api/…/receive.go• L36-356 api/…/webhooks.go• L14-103

Dispatcher contracts

Dispatcher contracts connect workers to the execution engine. They define how workers announce capabilities, receive actions, report task state, and follow workflow or durable-task events.

Worker dispatcher protocol

The worker dispatcher supports registration, heartbeats, action delivery, action results, worker labels, slot and timeout operations, evicted-task restore, workflow event subscriptions, and protocol discovery. An assigned action identifies the tenant, workflow, task run, action kind, retry state, and execution payload.

Unary calls handle discrete lifecycle actions. Server and bidirectional streams carry work and execution events as they occur.

References: api-contracts/…/dispatcher.proto• L7-47 api-contracts/…/dispatcher.proto• L71-108 api-contracts/…/dispatcher.proto• L127-218 api-contracts/…/dispatcher.proto• L359-444

Durable task dispatcher protocol

The versioned durable dispatcher tracks progress for durable task branches. Its main stream carries worker registration, memo checks, child-run triggers, wait conditions, worker state, eviction requests, acknowledgements, completed event-log entries, and server eviction notices.

Invocation counts and task-entry references identify the expected durable attempt and event-log position. This lets the engine reject stale completions and match asynchronous worker results to the correct branch.

References: api-contracts/…/dispatcher.proto• L10-16 api-contracts/…/dispatcher.proto• L26-52 api-contracts/…/dispatcher.proto• L93-176 internal/…/server_v1.go• L553-669

Contract lifecycle

Contract sources become generated bindings and then live service boundaries. HTTP uses OpenAPI while gRPC uses protocol buffers, but both rely on generated types so clients and servers agree on names, fields, enum values, and response shapes.

When a contract changes, the source, generated bindings, handler or service, response transformer, client, and worker path must move together. Generated OpenAPI bindings provide request decoding, route registration, models, and typed response variants. Transformers preserve the public meaning when stored data has extra fields or different status names.

flowchart TD
    S[OpenAPI or proto source] --> G[Generated bindings]
    G --> H[HTTP handler or gRPC service]
    H --> P[Shared platform operation]
    P --> C[Client, worker, or engine]

References: api/…/openapi.gen.go• L1-4 api/…/enums_spec_test.go• L20-91 api/…/workflow.go• L55-177 api/…/tasks.go• L23-31 api/…/serverless.go• L13-124

Change checklist

When these files or sections are changed, remember to consider these:

  • An OpenAPI path or schema change must stay aligned with generated route bindings, handler response variants, and response transformers.
  • Shared enum changes must update both the OpenAPI enum list and the shared enum values. Keep the enum agreement check passing.
  • Public status changes must preserve the mapping between evicted work, running filters, retry counts, and attempt numbers.
  • Payload visibility changes must stay aligned across authorization checks, generated fields, and task, run, event, webhook, and serverless-event transformers.
  • Tenant, member, and invite changes must preserve server URL, retention, role, and payload-view meaning.
  • Concurrency changes must preserve scope-specific fields, shared-strategy usage, queue counts, and offset pagination.
  • Serverless changes must preserve operator-owned status, write-only signing secrets, internal-field redaction, empty-object and empty-array JSON shapes, and event excerpt redaction.
  • Workflow version changes must keep configuration, input schema, triggers, and concurrency aligned between OpenAPI models and public transformers.
  • Scheduled-run changes must preserve the distinction between API-created and code-defined schedules, the pre-trigger update rule, and partial-error reporting for bulk deletion.
  • CEL contract changes must preserve the input context and the success/error shape used by expression callers.
  • Webhook changes must preserve the auth discriminator, protected credential variants, challenge handling, static-payload precedence, event-key expressions, source-specific signature rules, resource-limit response, and response mode.
  • A proto field or RPC change must be reflected in generated clients and servers, including worker consumers of dispatcher streams.

Important failure modes

TriggerConsequenceGuard
A route changes without its generated binding or response variantValid requests can fail or reach the wrong handlerTreat the OpenAPI source, generated binding, and handler as one contract
A shared enum and OpenAPI enum list divergeClients can send values that the server cannot representKeep TestSharedEnumsMatchSpec passing
A stored status maps to an invalid or incorrect public statusRun lists can hide work or show the wrong stateMap every readable status and mark evicted work explicitly
A payload-aware transformer ignores the authorization resultA caller can see task, event, or endpoint response data without permissionApply payload options before building the public view
A serverless response includes its signing secret or partitionProtected configuration or internal placement data can leakKeep those fields outside the public model and test serialization
Operator status is treated as endpoint configurationClients can see false health or action-registration dataLet the operator own observed status and represent unseen status as absent
A webhook request bypasses source-specific signature or timestamp checksAn untrusted request can create a tenant eventValidate the configured auth method and source protocol before ingestion
A webhook merges request data over configured static dataAn external request can override tenant-defined event valuesKeep static configuration authoritative during the merge
An event or webhook exceeds a tenant resource limitThe request is accepted by the contract but no event or run is createdReturn and handle the documented rate-limit response
A client updates a code-defined or already-triggered scheduleA schedule can be changed outside its supported lifecycleReject non-API schedules and triggered schedules
A dispatcher completion carries stale invocation or entry identityA durable task can accept an old result or remain blockedPreserve invocation-count and task-entry matching rules

Key files

FileWhy to read it
api-contracts/…/openapi.yamlTop-level HTTP security, route families, and operation map
api-contracts/…/workflow_run.yamlStable run, task, filter, timing, and durable-task contract
api-contracts/…/webhook.yamlWebhook management and public ingress contract
api-contracts/…/workflows.protoWorkflow administration and definition messages
api-contracts/…/events.protoEvent, log, and stream ingestion contract
api-contracts/…/dispatcher.protoWorker registration, assignment, and reporting protocol
api-contracts/…/dispatcher.protoDurable task stream and acknowledgement protocol
api/…/openapi.gen.goGenerated HTTP models, routes, query binding, and typed responses
api/…/enums_spec_test.goContract check between OpenAPI enum values and shared platform enums
api/…/debug.goStable expression-check operation and its result contract
api/…/cel.goPublic success and error view for expression evaluation
api/…/create.goWebhook authentication variants and creation rules
api/…/receive.goWebhook validation, event derivation, and ingress responses
api/…/update_scheduled.goScheduled-run update lifecycle and API ownership rule
api/…/delete_scheduled.goScheduled-run deletion boundary
api/…/bulk_delete_scheduled.goFiltered bulk deletion and partial-error contract
api/…/workflow.goPublic workflow, version, trigger, and concurrency mapping
api/…/workflow_runs.goPublic workflow-run task views and pagination mapping
api/…/tasks.goPublic task status, retry, timing, and payload mapping
api/…/serverless.goPublic endpoint status, event, redaction, and pagination mapping
api/…/serverless_test.goGuarantees for endpoint secret redaction, status, labels, events, and pagination
api/…/webhooks.goPublic webhook and webhook-trigger response mapping
api/…/concurrency.goPublic concurrency strategy and key views
api/…/tenant.goPublic tenant routing, entitlement, and resource-policy metadata
api/…/tenant_invite.goPublic invitation role and payload-view mapping
api/…/user.goPublic user and tenant-member access views