Skip to content
Get started
Guides

Workers

Create, update, and delete reusable Handinger worker templates.

A worker is a reusable agent template. Its title, system instructions, output schema, attached files, MCP connections, and members live on the worker — every task inherits them. Most production integrations create a small number of workers up front and run thousands of tasks against them.

This guide covers the worker lifecycle: POST create, PATCH update, and DELETE delete. See tasks for how to actually run them.

There are two ways to specify what the worker should do:

  1. prompt — a natural-language description. Handinger expands it into structured instructions and, when the request implies extraction, an output schema. Use this to bootstrap a worker quickly.
  2. instructions — a fully-specified system prompt. Use this once you know exactly what behaviour you want. When you pass instructions, Handinger does not modify them.
import Handinger from '@ramensoft/handinger';
const client = new Handinger({
apiKey: process.env['HANDINGER_API_KEY'], // This is the default and can be omitted
});
const workerTemplate = await client.workers.create({
prompt: 'A worker that fact-checks short claims and returns a verdict with citations.',
});
console.log(workerTemplate.id);

With explicit instructions and an output schema

Section titled “With explicit instructions and an output schema”

Pass instructions instead of prompt to skip the AI expansion step. When you want deterministic structured output, also pass JSON Schema Draft-07 in outputSchema — every task response will then expose a typed structuredOutput object that has been validated against the schema.

A minimal outputSchema looks like this:

{
"type": "object",
"required": ["verdict", "summary"],
"properties": {
"verdict": {
"type": "string",
"enum": ["supported", "debunked", "mixed", "unknown"]
},
"summary": { "type": "string" },
"citations": { "type": "array", "items": { "type": "string" } }
}
}
  • public (default) — every member of the organization can list and run the worker.
  • private — only invited members and the creator can see or run it.

You can flip visibility at any time with update. To invite a specific user to a private worker, use the worker members endpoint (POST /api/workers/{workerId}/members).

What gets filled in automatically?
  • title — when omitted, Handinger assigns a random dog-themed name.
  • summary — auto-generated from your prompt when you don’t provide one.
  • avatar — a unique dog avatar is picked per organization.
  • instructions — generated from prompt when you don’t pass them. The generated prompt is detailed and durable; you can read it back via retrieve.
  • outputSchema — generated when your prompt implies extraction. Pass null to keep responses free-form.

Use workers.retrieve(workerId) to fetch the current configuration plus the messages of the most recent task. This is the same endpoint the dashboard uses to render a worker’s chat view, so the response shape is task-centric (output, output_text, messages).

import Handinger from '@ramensoft/handinger';
const client = new Handinger({
apiKey: process.env['HANDINGER_API_KEY'], // This is the default and can be omitted
});
const worker = await client.workers.retrieve('t_org_123_w_01HZY2ZJQ8G7K42W2D7WF6V4GM');
console.log(worker.id);

PATCH /api/workers/{workerId} performs a partial update — only the fields you send are changed. Subsequent tasks immediately pick up the new instructions; tasks already running keep their original prompt.

Updating a worker requires the creator role on that worker.

import Handinger from '@ramensoft/handinger';
const client = new Handinger({
apiKey: process.env['HANDINGER_API_KEY'], // This is the default and can be omitted
});
const workerTemplate = await client.workers.update('t_org_123_w_01HZY2ZJQ8G7K42W2D7WF6V4GM', {
title: 'Claim verdict v2',
});
console.log(workerTemplate.id);

To return a worker to free-form text responses, pass outputSchema: null explicitly — this is the one field where null and “omitted” mean different things.

await handinger.workers.update('wrk_vk81XUHKHG-qr4', { outputSchema: null });

DELETE /api/workers/{workerId} permanently removes the worker template and all of its tasks, turns, files, schedules, and MCP connections. The operation is not reversible.

Only the creator of the worker may delete it. The endpoint always returns { "deleted": true } once the cascade completes.

import Handinger from '@ramensoft/handinger';
const client = new Handinger({
apiKey: process.env['HANDINGER_API_KEY'], // This is the default and can be omitted
});
const deleteWorkerResponse = await client.workers.delete('t_org_123_w_01HZY2ZJQ8G7K42W2D7WF6V4GM');
console.log(deleteWorkerResponse.deleted);

403 Forbidden when updating or deleting Update and delete require the creator role. If you’re using an API key that was issued by a different user, transfer ownership in the dashboard first, or have the original creator run the call.

The worker keeps generating with the old instructions In-flight tasks finish with the prompt they started with. Wait for them to complete (or cancel them via the dashboard) before sending a new task.

Output schema validation fails The schema must be valid JSON Schema Draft-07. Top-level type: "object" is required, and unknown keywords are rejected at create/update time, not at task time. Use json-schema.org’s validators to debug.