Resources
A Resource is anything that executes work — a human, an AI agent, an external service, or a physical asset. Resources have an optional capacity limit, and Clockwork enforces that limit automatically during allocation.
When to use client.resources
- Registering your AI agents so they can be assigned to tasks and tracked
- Modeling human specialists with limited availability (capacity = 1 means one task at a time)
- Tracking shared assets (conference rooms, lab equipment) with capacity constraints
- Filling role slots in a workflow template (see Roles)
Methods
| Method | Description |
|---|---|
create(input) | Register a new resource |
get(resourceId) | Fetch a resource |
list(opts?) | List resources in a project |
allocate(resourceId, input) | Allocate to an execution, task, or actor |
release(resourceId, allocationId?) | Release an allocation |
resources.create(input)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | yes | Display name |
type | ResourceType | yes | 'human', 'agent', 'service', or 'asset' |
capacity | number | no | Max concurrent allocations (unbounded if omitted) |
projectId | string | no | Defaults to personal project |
metadata | Record<string, unknown> | no | Arbitrary data |
Example
typescript
// Register an AI agent with capacity for 3 concurrent tasks
const { data: agent } = await client.resources.create({
name: 'Claude Analysis Agent',
type: 'agent',
capacity: 3,
metadata: { model: 'claude-opus-4-8', endpoint: 'https://api.example.com/agent' },
})
// Register a human specialist (one task at a time)
const { data: specialist } = await client.resources.create({
name: 'Alice Chen — Legal',
type: 'human',
capacity: 1,
})resources.allocate(resourceId, input)
Allocates a resource to a task or execution. Throws CAPACITY_EXCEEDED if the resource is at capacity.
typescript
const { data: allocation } = await client.resources.allocate('res_abc123', {
taskId: 'tsk_xyz',
})
console.log(allocation.id, allocation.status) // alloc_... 'allocated'resources.release(resourceId, allocationId?)
Releases an allocation. If allocationId is omitted, releases the most recent open allocation.
typescript
await client.resources.release('res_abc123', 'alloc_xyz')Type reference
typescript
type ResourceType = 'human' | 'agent' | 'service' | 'asset'
interface Resource {
id: string
projectId: string | null
name: string
type: ResourceType
capacity: number | null
metadata: Record<string, unknown> | null
createdAt: string
}
interface ResourceAllocation {
id: string
resourceId: string
executionId: string | null
taskId: string | null
actorId: string | null
status: 'allocated' | 'released'
allocatedAt: string
releasedAt: string | null
}