*.cargo.app). defineWorker and defineApp deploy a source bundle directory that Cargo Hosting builds on deploy.
Define a worker
workers/webhook.ts
Define an app
apps/dashboard.ts
plan.
defineWorker/defineApp are the deployable resource (the hosted slot).
Author the worker’s runtime code in TypeScript with createWorker from
@cargo-ai/worker-sdk at src/index.ts — bundles are uploaded as source and
built server-side: the hosting build runs npm ci then esbuilds the worker
entrypoint (esbuild transpiles TypeScript natively) or vite build for apps.
A pre-built index.js at the bundle root is still accepted for backwards
compatibility. Bundle sub-directories have their own package.json, so the
loader treats them as content to upload, not resource files to import.Cron triggers
A worker can be called on a schedule: each trigger describes the full request Cargo fires — cron (or Temporal’s@every shorthand), path, method (default POST), a JSON body, and headers. Set an authorization header and guard the route with standard Hono middleware (bearerAuth/basicAuth); ticks only fire once the worker has a promoted deployment.
Triggers can be set from the worker’s page in the Cargo app, via defineWorker (above), or with the CLI/API:
Calling the Cargo API
Create a workspace API token and add it to the worker as aCARGO_API_TOKEN secret environment variable — the Cargo API host is allowed without an outboundAllowlist entry. createCargoApi(env) from @cargo-ai/worker-sdk returns the fully-typed @cargo-ai/api client:
Custom integrations
A worker that serves the Custom Integration HTTP contract (createCustomIntegration from @cargo-ai/worker-sdk) can be registered in the connector catalog declaratively:
Scaffolding and deploying standalone
You can also scaffold and ship bundles directly with the CLI:my-worker).
