Skip to content
RELKIT
Esc
↑↓navigate↵open⌘Jpreview
On this page

Trigger.dev API

Generated public TypeScript reference for @relkit/trigger.

For configuration and examples, read docker, providers.

Public imports

  • @relkit/trigger — 7 exports
  • @relkit/trigger/runtime — 22 exports
  • @relkit/trigger/local-recipe — 1 exports
  • @relkit/trigger/deployment — 4 exports

All exported APIs

Names link to their complete contracts. Re-exports share their original contract; legacy exports keep their separate identity. Examples link to the API’s inline sample, a maintained repository usage, or the shared module walkthrough.

API Kind Import from Example
createTriggerHttpClient Value @relkit/trigger/runtime Module example
createTriggerRuntime Value @relkit/trigger/runtime Module example
createTriggerTask Value @relkit/trigger/runtime Module example
createTriggerTaskConfig Value @relkit/trigger/runtime Module example
createTriggerWorker Value @relkit/trigger/runtime Module example
deploymentProfile Value @relkit/trigger/deployment Module example
loadTriggerSdk Value @relkit/trigger/runtime Module example
localRecipe Value @relkit/trigger/local-recipe Module example
nativeWorkerPublication Value @relkit/trigger/deployment Module example
observeTriggerRun Value @relkit/trigger/runtime Module example
runtimeIntegration Value @relkit/trigger/runtime Module example
statusOf Value @relkit/trigger/runtime Module example
trigger Value @relkit/trigger Source example
TriggerAdapter Type @relkit/trigger Module example
TriggerBehavior Type @relkit/trigger Module example
triggerConnectionContract Value @relkit/trigger Module example
TriggerDeploymentProfile Type @relkit/trigger/deployment Module example
TriggerHttpClientOptions Type @relkit/trigger/runtime Module example
triggerIntegration Value @relkit/trigger Module example
triggerLocalRecipe Value @relkit/trigger Module example
TriggerNativeClient Type @relkit/trigger/runtime Module example
TriggerObservationOptions Type @relkit/trigger/runtime Module example
TriggerOptions Type @relkit/trigger Module example
TriggerRuntime Type @relkit/trigger/runtime Module example
TriggerRuntimeOptions Type @relkit/trigger/runtime Module example
TriggerSdk Type @relkit/trigger/runtime Module example
TriggerSdkApi Type @relkit/trigger/runtime Module example
triggerSnapshot Value @relkit/trigger/runtime Module example
TriggerSubscription Type @relkit/trigger/runtime Module example
TriggerTaskDefinition Type @relkit/trigger/runtime Module example
triggerTaskIdentifier Value @relkit/trigger/runtime Module example
TriggerWorkerHandle Type @relkit/trigger/runtime Module example
TriggerWorkerPublication Type @relkit/trigger/deployment Module example
TriggerWorkerRegistrationOptions Type @relkit/trigger/runtime Module example

index.ts

TriggerDeploymentProfile (interface)

Signature

export interface TriggerDeploymentProfile {
  readonly provider: "trigger";
  readonly compatibility: "unverified";
  readonly adapterId: "trigger";
  readonly sdk: "4.5.16";
  readonly dockerImageDigest: "sha256:3563088912cf4b880602d99815ddd787274c4ce5fc77738adf1e5bad287fbd1e";
  readonly dockerDurableSleep: false;
  readonly managedStatus: "not-tested";
  readonly scheduleVariants: readonly string[];
  readonly workerRuntime: "bun";
  readonly executionLimits: Readonly<{
    readonly inputBytes: number;
    readonly progressBytes: number;
    readonly maxRunList: number;
  }>;
  readonly policyIdentity: readonly string[];
}

Source

TriggerWorkerPublication (interface)

Signature

export interface TriggerWorkerPublication {
  readonly provider: "trigger";
  readonly mechanism: "trigger-sdk";
  readonly taskId: string;
  readonly taskVersion: string;
  readonly buildId: string;
  readonly serviceGeneration: string;
  readonly entrypoint: string;
}

Source

deploymentProfile

Signature

declare const deploymentProfile: TriggerDeploymentProfile;

Source

nativeWorkerPublication

Signature

declare const nativeWorkerPublication: (
  value: Omit<TriggerWorkerPublication, "provider" | "mechanism">,
) => TriggerWorkerPublication;

Source

index.ts

TriggerAdapter (type alias)

Signature

type TriggerAdapter<Options extends TriggerOptions = TriggerOptions> = ProviderAdapter<
  typeof job,
  "trigger",
  ProviderConnectionValues,
  ProviderBehavior<TriggerBehavior>
>;

Source

TriggerBehavior (type alias)

Signature

type TriggerBehavior = JobsServiceBehavior;

Source

TriggerOptions (interface)

Signature

export interface TriggerOptions extends JobsServiceOptions {
  readonly projectRef?: string | TextReference;
  readonly secretKey?: SecretReference;
  readonly baseUrl?: string | URL | TextReference;
  readonly native?: Readonly<Record<string, import("@relkit/contracts").JsonValue>>;
}

Source

trigger

Signature

declare const trigger: <const Options extends TriggerOptions = TriggerOptions>(
  options?: Options,
) => TriggerAdapter<Options>;

Source

triggerConnectionContract

Signature

declare const triggerConnectionContract: ProviderConnectionContract;

Source

triggerIntegration

Signature

declare const triggerIntegration: IntegrationReference<"trigger">;

Source

triggerLocalRecipe

Signature

declare const triggerLocalRecipe: ProviderLocalRecipeReference;

Source

index.ts

localRecipe

Signature

declare const localRecipe: Readonly<{
  kind: "local-service-recipe";
  protocolVersion: 2;
  integrationId: "trigger";
  recipeId: "trigger-docker";
  recipeVersion: 2;
  materializerId: "docker";
  containers: ReadonlyArray<
    | Readonly<{
        id: "postgres";
        image: "postgres:16-alpine@sha256:cf78e76683b9ca8c5733cbbdce6c9262b45b6767934dd0a95e671f9a0fc20685";
        ports: Readonly<{}>;
        volumes: ReadonlyArray<{ name: string; mountPath: string }>;
        environment: Readonly<{
          POSTGRES_DB: Readonly<{ value: "trigger" }>;
          POSTGRES_USER: Readonly<{ value: "trigger" }>;
          POSTGRES_PASSWORD: Readonly<{ secret: "postgresPassword" }>;
        }>;
        health: Readonly<{ command: Array<string>; intervalMs: 250; timeoutMs: 2000; retries: 60 }>;
        networkAliases: ReadonlyArray<string>;
      }>
    | Readonly<{
        id: "trigger";
        image: "triggerdotdev/trigger.dev@sha256:3563088912cf4b880602d99815ddd787274c4ce5fc77738adf1e5bad287fbd1e";
        dependsOn: ReadonlyArray<string>;
        ports: Readonly<{ api: 8030 }>;
        health: Readonly<{
          command: Array<string>;
          intervalMs: 500;
          timeoutMs: 2000;
          retries: 120;
        }>;
        networkAliases: ReadonlyArray<string>;
        environment: Readonly<{
          DATABASE_URL: Readonly<{
            value: "postgres://trigger:$POSTGRES_PASSWORD@postgres:5432/trigger";
          }>;
          TRIGGER_ACCOUNT_FREE: Readonly<{ value: "1" }>;
          TRIGGER_PROJECT_REF: Readonly<{ secret: "projectRef" }>;
          TRIGGER_SECRET_KEY: Readonly<{ secret: "secretKey" }>;
        }>;
      }>
  >;
  init: ReadonlyArray<
    Readonly<{
      id: "postgres-ready";
      image: "postgres:16-alpine@sha256:cf78e76683b9ca8c5733cbbdce6c9262b45b6767934dd0a95e671f9a0fc20685";
      dependsOn: ReadonlyArray<string>;
      command: ReadonlyArray<string>;
      environment: Readonly<{ POSTGRES_PASSWORD: Readonly<{ secret: "postgresPassword" }> }>;
    }>
  >;
  workers: ReadonlyArray<
    Readonly<{
      id: "worker";
      image: "oven/bun:1.3.10@sha256:b86c67b531d87b4db11470d9b2bd0c519b1976eee6fcd71634e73abfa6230d2e";
      command: ReadonlyArray<string>;
      dependsOn: ReadonlyArray<string>;
      ports: Readonly<{ api: 3000 }>;
      health: Readonly<{ command: Array<string>; intervalMs: 500; timeoutMs: 2000; retries: 120 }>;
      networkAliases: ReadonlyArray<string>;
    }>
  >;
  volumes: Readonly<{
    postgres: Readonly<{ mountPath: "/var/lib/postgresql/data"; persistent: true }>;
  }>;
  generatedSecrets: Readonly<{
    postgresPassword: Readonly<{ bytes: 24; encoding: "hex" }>;
    projectRef: Readonly<{ bytes: 12; encoding: "hex" }>;
    secretKey: Readonly<{ bytes: 32; encoding: "hex" }>;
  }>;
  network: Readonly<{ internal: false }>;
  ownership: Readonly<{ scope: "project"; retainVolumes: true }>;
  outputs: ({ ports, secrets }: LocalServiceRecipeOutputContext) => Readonly<{
    baseUrl: string;
    projectRef: string;
    secretKey: string;
  }>;
}>;

Source

local.ts

localRecipe

Signature

declare const localRecipe: Readonly<{
  kind: "local-service-recipe";
  protocolVersion: 2;
  integrationId: "trigger";
  recipeId: "trigger-docker";
  recipeVersion: 2;
  materializerId: "docker";
  containers: ReadonlyArray<
    | Readonly<{
        id: "postgres";
        image: "postgres:16-alpine@sha256:cf78e76683b9ca8c5733cbbdce6c9262b45b6767934dd0a95e671f9a0fc20685";
        ports: Readonly<{}>;
        volumes: ReadonlyArray<{ name: string; mountPath: string }>;
        environment: Readonly<{
          POSTGRES_DB: Readonly<{ value: "trigger" }>;
          POSTGRES_USER: Readonly<{ value: "trigger" }>;
          POSTGRES_PASSWORD: Readonly<{ secret: "postgresPassword" }>;
        }>;
        health: Readonly<{ command: Array<string>; intervalMs: 250; timeoutMs: 2000; retries: 60 }>;
        networkAliases: ReadonlyArray<string>;
      }>
    | Readonly<{
        id: "trigger";
        image: "triggerdotdev/trigger.dev@sha256:3563088912cf4b880602d99815ddd787274c4ce5fc77738adf1e5bad287fbd1e";
        dependsOn: ReadonlyArray<string>;
        ports: Readonly<{ api: 8030 }>;
        health: Readonly<{
          command: Array<string>;
          intervalMs: 500;
          timeoutMs: 2000;
          retries: 120;
        }>;
        networkAliases: ReadonlyArray<string>;
        environment: Readonly<{
          DATABASE_URL: Readonly<{
            value: "postgres://trigger:$POSTGRES_PASSWORD@postgres:5432/trigger";
          }>;
          TRIGGER_ACCOUNT_FREE: Readonly<{ value: "1" }>;
          TRIGGER_PROJECT_REF: Readonly<{ secret: "projectRef" }>;
          TRIGGER_SECRET_KEY: Readonly<{ secret: "secretKey" }>;
        }>;
      }>
  >;
  init: ReadonlyArray<
    Readonly<{
      id: "postgres-ready";
      image: "postgres:16-alpine@sha256:cf78e76683b9ca8c5733cbbdce6c9262b45b6767934dd0a95e671f9a0fc20685";
      dependsOn: ReadonlyArray<string>;
      command: ReadonlyArray<string>;
      environment: Readonly<{ POSTGRES_PASSWORD: Readonly<{ secret: "postgresPassword" }> }>;
    }>
  >;
  workers: ReadonlyArray<
    Readonly<{
      id: "worker";
      image: "oven/bun:1.3.10@sha256:b86c67b531d87b4db11470d9b2bd0c519b1976eee6fcd71634e73abfa6230d2e";
      command: ReadonlyArray<string>;
      dependsOn: ReadonlyArray<string>;
      ports: Readonly<{ api: 3000 }>;
      health: Readonly<{ command: Array<string>; intervalMs: 500; timeoutMs: 2000; retries: 120 }>;
      networkAliases: ReadonlyArray<string>;
    }>
  >;
  volumes: Readonly<{
    postgres: Readonly<{ mountPath: "/var/lib/postgresql/data"; persistent: true }>;
  }>;
  generatedSecrets: Readonly<{
    postgresPassword: Readonly<{ bytes: 24; encoding: "hex" }>;
    projectRef: Readonly<{ bytes: 12; encoding: "hex" }>;
    secretKey: Readonly<{ bytes: 32; encoding: "hex" }>;
  }>;
  network: Readonly<{ internal: false }>;
  ownership: Readonly<{ scope: "project"; retainVolumes: true }>;
  outputs: ({ ports, secrets }: LocalServiceRecipeOutputContext) => Readonly<{
    baseUrl: string;
    projectRef: string;
    secretKey: string;
  }>;
}>;

Source

index-support.ts

observationOptions

Signature

declare const observationOptions: (options: TriggerRuntimeOptions) => TriggerObservationOptions;

Source

optionalText

Signature

declare const optionalText: (value: unknown) => string | undefined;

Source

text

Signature

declare const text: (value: unknown, label: string) => string;

Source

unknown

Signature

declare const unknown: (value: NativeControlReceipt) => boolean;

Source

url

Signature

declare const url: (value: string) => void;

Source

index.ts

“./native.js” (namespace export)

Re-exports all named exports from the “./native.js” module.

Signature

export * from "./native.js";

Source

“./subscription.js” (namespace export)

Re-exports all named exports from the “./subscription.js” module.

Signature

export * from "./subscription.js";

Source

“./task-binding.js” (namespace export)

Re-exports all named exports from the “./task-binding.js” module.

Signature

export * from "./task-binding.js";

Source

TriggerRuntime (interface)

Signature

export interface TriggerRuntime extends JobsAdapterRuntime {
  readonly registerWorker: (options: TriggerWorkerRegistrationOptions) => TriggerWorkerHandle;
}

Source

TriggerRuntimeOptions (interface)

Signature

export interface TriggerRuntimeOptions {
  readonly projectRef: string;
  readonly secretKey?: string;
  readonly baseUrl: string;
  readonly fetch?: typeof globalThis.fetch;
  readonly native?: TriggerNativeClient;
  readonly sdk?: TriggerSdk;
  readonly supportsDurableSleep?: boolean;
  readonly pollIntervalMs?: number;
  readonly maxPolls?: number;
  readonly serviceOptions?: JobsServiceOptions;
}

Source

TriggerWorkerRegistrationOptions (interface)

Signature

export interface TriggerWorkerRegistrationOptions {
  readonly definitions: readonly TriggerTaskDefinition[];
  readonly executor: import("@relkit/jobs/adapter").TaskExecutor;
  readonly startWorker?: boolean;
  readonly register?: (tasks: readonly unknown[]) => Promise<void> | void;
}

Source

createTriggerRuntime

Signature

declare const createTriggerRuntime: (options: TriggerRuntimeOptions) => TriggerRuntime;

Source

runtimeIntegration

Signature

declare const runtimeIntegration: RuntimeProviderIntegration<"trigger">;

Source

native.ts

TriggerHttpClientOptions (interface)

Signature

export interface TriggerHttpClientOptions {
  readonly baseUrl: string;
  readonly projectRef: string;
  readonly secretKey?: string;
  readonly fetch?: typeof globalThis.fetch;
  readonly client?: TriggerSdkApi;
}

Source

TriggerNativeClient (interface)

Signature

export interface TriggerNativeClient {
  readonly submit: (request: NativeSubmission, context: OperationContext) => Promise<NativeReceipt>;
  readonly get: (runId: string, context: OperationContext) => Promise<NativeRun>;
  readonly list: (query: NativeRunQuery, context: OperationContext) => Promise<NativeRunPage>;
  readonly cancel: (
    runId: string,
    operationId: string,
    reason: string | undefined,
    context: OperationContext,
  ) => Promise<NativeControlReceipt>;
  readonly retry: (
    request: NativeRetryRequest,
    context: OperationContext,
  ) => Promise<NativeControlReceipt>;
  readonly subscribeToRun?: (
    runId: string,
    context: OperationContext,
    after?: string,
  ) => Promise<TriggerSubscription | undefined>;
  readonly schedules?: NativeScheduleOperations;
  readonly registerTasks?: (tasks: readonly unknown[]) => Promise<void> | void;
  readonly close?: () => Promise<void>;
}

Source

TriggerSdkApi (interface)

Signature

export interface TriggerSdkApi {
  readonly tasks: {
    readonly trigger: (...args: readonly unknown[]) => Promise<unknown>;
  };
  readonly runs: {
    readonly retrieve: (...args: readonly unknown[]) => Promise<unknown>;
    readonly list: (...args: readonly unknown[]) => Promise<unknown>;
    readonly cancel: (...args: readonly unknown[]) => Promise<unknown>;
    readonly replay: (...args: readonly unknown[]) => Promise<unknown>;
    readonly subscribeToRun: (...args: readonly unknown[]) => AsyncIterable<unknown>;
  };
}

Source

TriggerSubscription (interface)

Signature

export interface TriggerSubscription {
  readonly stream: AsyncIterable<unknown>;
  readonly unsubscribe?: () => Promise<void> | void;
}

Source

createTriggerHttpClient

Compatibility name retained for callers; the implementation uses the pinned SDK.

Signature

declare const createTriggerHttpClient: (options: TriggerHttpClientOptions) => TriggerNativeClient;

Source

statusOf

Signature

declare const statusOf: (value: unknown) => RunSnapshot["status"];

Source

triggerSnapshot

Signature

declare const triggerSnapshot: (
  value: unknown,
  context: OperationContext,
  fallbackRunId?: string,
) => NativeRun;

Source

triggerTaskIdentifier

Signature

declare const triggerTaskIdentifier: (
  request: Pick<NativeSubmission, "jobId" | "taskId" | "taskVersion" | "buildId">,
) => string;

Source

sdk-list.ts

listRuns

Signature

declare const listRuns: (
  client: TriggerSdkApi,
  projectRef: string,
  query: NativeRunQuery,
  context: OperationContext,
) => Promise<NativeRunPage>;

Source

sdk-mapping.ts

isJsonValue

Signature

declare const isJsonValue: (value: unknown) => boolean;

Source

record

Signature

declare const record: (value: unknown) => Record<string, any> | undefined;

Source

statusOf

Signature

declare const statusOf: (value: unknown) => RunSnapshot["status"];

Source

triggerSnapshot

Signature

declare const triggerSnapshot: (
  value: unknown,
  context: OperationContext,
  fallbackRunId?: string,
) => NativeRun;

Source

sdk-native-support.ts

definiteRejection

Signature

declare const definiteRejection: (error: unknown) => boolean;

Source

handle

Signature

declare const handle: (value: unknown, request: NativeSubmission) => RunHandle;

Source

loadClient

Signature

declare const loadClient: (options: TriggerHttpClientOptions) => TriggerSdkApi;

Source

metadata

Signature

declare const metadata: (
  request: NativeSubmission,
  context: OperationContext,
) => Record<string, string>;

Source

text

Signature

declare const text: (value: unknown, label: string) => string;

Source

triggerOptions

Signature

declare const triggerOptions: (
  request: NativeSubmission,
  context: OperationContext,
) => Record<string, unknown>;

Source

unknownControl

Signature

declare const unknownControl: (operationId: string) => JobUnknownOutcome;

Source

unknownSubmission

Signature

declare const unknownSubmission: (request: NativeSubmission) => JobUnknownOutcome;

Source

sdk-native.ts

createTriggerSdkNativeClient

Signature

declare const createTriggerSdkNativeClient: (
  options: TriggerHttpClientOptions,
) => TriggerNativeClient;

Source

sdk-support.ts

triggerTaskIdentifier

Signature

declare const triggerTaskIdentifier: (
  request: Pick<NativeSubmission, "jobId" | "taskId" | "taskVersion" | "buildId">,
) => string;

Source

subscription.ts

TriggerObservationOptions (interface)

Signature

export interface TriggerObservationOptions {
  readonly pollIntervalMs?: number;
  readonly readTimeoutMs?: number;
  readonly maxPolls?: number;
}

Source

observeTriggerRun

Signature

declare const observeTriggerRun: (
  request: NativeWatchRequest,
  context: OperationContext,
  client: TriggerNativeClient,
  options?: TriggerObservationOptions,
) => AsyncGenerator<NativeObservation>;

Source

task-binding-support.ts

bindingFrom

Signature

declare const bindingFrom: (
  envelope: TaskExecutionEnvelope,
  context: unknown,
) => TaskExecutionBinding;

Source

envelopeFrom

Signature

declare const envelopeFrom: (
  payload: unknown,
  context: unknown,
  definition: TriggerTaskDefinition,
) => TaskExecutionEnvelope;

Source

number

Signature

declare const number: (value: unknown) => number | undefined;

Source

record

Signature

declare const record: (value: unknown) => Record<string, any> | undefined;

Source

text

Signature

declare const text: (value: unknown, label: string) => string;

Source

task-binding.ts

TriggerSdk (interface)

Signature

export interface TriggerSdk {
  readonly createTask?: (options: Readonly<Record<string, unknown>>) => unknown;
  readonly task?: (options: Readonly<Record<string, unknown>>) => unknown;
  readonly tasks?:
    ((options: Readonly<Record<string, unknown>>) => unknown) | Readonly<Record<string, unknown>>;
}

Source

TriggerTaskDefinition (interface)

Signature

export interface TriggerTaskDefinition {
  readonly id: string;
  readonly jobId?: string;
  readonly taskId?: string;
  readonly version: string;
  readonly buildId: string;
  readonly retries?: number;
  readonly trigger?: Readonly<Record<string, unknown>>;
  readonly policy?: unknown;
  readonly resources?: {
    readonly cpu: number;
    readonly memory: string;
    readonly nativeClass?: string;
  };
}

Source

TriggerWorkerHandle (interface)

Signature

export interface TriggerWorkerHandle {
  readonly tasks: readonly unknown[];
  readonly ready: () => Promise<void>;
  readonly close: () => Promise<void>;
}

Source

createTriggerTask

Signature

declare const createTriggerTask: (
  sdk: TriggerSdk,
  definition: TriggerTaskDefinition,
  executor: TaskExecutor,
) => unknown;

Source

createTriggerTaskConfig

Signature

declare const createTriggerTaskConfig: (
  definition: TriggerTaskDefinition,
) => Readonly<Record<string, unknown>>;

Source

createTriggerWorker

Signature

declare const createTriggerWorker: (options: {
  readonly sdk?: TriggerSdk;
  readonly definitions: readonly TriggerTaskDefinition[];
  readonly executor: TaskExecutor;
  readonly register?: (tasks: readonly unknown[]) => Promise<void> | void;
}) => TriggerWorkerHandle;

Source

loadTriggerSdk

Signature

declare const loadTriggerSdk: () => TriggerSdk;

Source