Creating workers
To create a worker, specify a name, a prompt, and the Base it runs in.
Endpoint: POST /v2/workers
import { Exabase } from "@exabase/sdk";
const api = new Exabase({
apiKey: process.env.EXABASE_API_KEY,
});
const worker = await api.workers.create(
{
name: 'Summarizer Bot',
prompt: 'Summarize this week\'s meeting and save it in a new document.',
},
{
baseId: '<BASE_ID>',
},
);
curl https://api.exabase.io/v2/workers \
-X POST \
-H 'X-Api-Key: <EXABASE_API_KEY>' \
-H 'X-Exabase-Base-Id: <BASE_ID>' \
-H 'Content-Type: application/json' \
-d '{
"name": "Summarizer Bot",
"prompt": "Summarize this week's meeting and save it in a new document.",
}'
Setting a schedule
Pass frequency, hour, and optionally timezone when creating the worker.
Weekly and monthly workers also need a day value.
import { Exabase } from "@exabase/sdk";
const api = new Exabase({
apiKey: process.env.EXABASE_API_KEY,
});
const worker = await api.workers.create(
{
name: 'News Bot',
prompt: 'Fetch the latest news and save a summary in a new notepad.',
active: true,
frequency: 'daily',
hour: 9,
timezone: 'America/Toronto',
},
{
baseId: '<BASE_ID>',
},
);
curl https://api.exabase.io/v2/workers \
-X POST \
-H 'X-Api-Key: <EXABASE_API_KEY>' \
-H 'X-Exabase-Base-Id: <BASE_ID>' \
-H 'Content-Type: application/json' \
-d '{
"name": "News Bot",
"prompt": "Fetch the latest news and save a summary in a new notepad.",
"active": true,
"frequency": "daily",
"hour": 9,
"timezone": "America/Toronto"
}'
Scoping to specific resources
Pass focusResourceIds to provide specific resources as context or
accessResourceIds to strictly limit which resources the worker can access.
import { Exabase } from "@exabase/sdk";
const api = new Exabase({
apiKey: process.env.EXABASE_API_KEY,
});
const worker = await api.workers.create(
{
name: 'Summarizer Bot',
prompt: 'Summarize the meeting in five words.',
focusResourceIds: [resource.id],
},
{
baseId: '<BASE_ID>',
},
);
curl https://api.exabase.io/v2/workers \
-X POST \
-H 'X-Api-Key: <EXABASE_API_KEY>' \
-H 'X-Exabase-Base-Id: <BASE_ID>' \
-H 'Content-Type: application/json' \
-d '{
"name": "Summarizer Bot",
"prompt": "Summarize the meeting in five words.",
"focusResourceIds": ["<RESOURCE_ID>"],
}'
Restricting tools
By default, all built-in tools are available. To restrict a worker to specific
tools, set toolPermissions when creating or editing it. Only the tools you list
will be available, everything else is blocked.
import { Exabase } from "@exabase/sdk";
const api = new Exabase({
apiKey: process.env.EXABASE_API_KEY,
});
const worker = await api.workers.create(
{
name: 'Exabase News Bot',
prompt: 'Find latest news about exabase and summarize it.',
toolPermissions: {
native: {
'search-resources': 'always_allow',
'web-search': 'always_allow',
},
},
},
{
baseId: '<BASE_ID>',
},
);
curl https://api.exabase.io/v2/workers \
-X POST \
-H 'X-Api-Key: <EXABASE_API_KEY>' \
-H 'X-Exabase-Base-Id: <BASE_ID>' \
-H 'Content-Type: application/json' \
-d '{
"name": "Exabase News Bot",
"prompt": "Find latest news about exabase and summarize it.",
"toolPermissions": {
"native": {
"search-resources": "always_allow",
"web-search": "always_allow"
}
}
}'
See Worker tools for the full list of available tool names.
Updating a worker
Use the same parameters to update an existing worker's prompt, schedule, tool permissions, or resource access.
Endpoint: PATCH /v2/workers/{workerId}
import { Exabase } from "@exabase/sdk";
const api = new Exabase({
apiKey: process.env.EXABASE_API_KEY,
});
const worker = await api.workers.update(
'<WORKER_ID>',
{
active: true,
},
{
baseId: '<BASE_ID>',
},
);
curl https://api.exabase.io/v2/workers/<WORKER_ID> \
-X PATCH \
-H 'X-Api-Key: <EXABASE_API_KEY>' \
-H 'X-Exabase-Base-Id: <BASE_ID>' \
-H 'Content-Type: application/json' \
-d '{
"active": true,
}'