# Task methods: assign, claim, complete, delegate

URL: /code/sdk/task/verbs · Id: `page:code/sdk/task/verbs`

> The Task Verbs assign, claim, complete, delegate as typed SDK methods, with inputs, result, refusals and an example.

Reference for [Task](/business/nouns/task), one group of [Task methods](/code/sdk/task).

### Task.assign
Assign gives a Task to a Worker, human or agent, and places it in that Worker’s worklist. [Verb page](/business/nouns/task/assign?interface=sdk).

```ts
interface TaskVerbs {
  assign(input: TaskAssignInput, options?: SB.CallOptions): SB.Call<Task>
}
```

Emits [`Task.assigned`](/business/events/Task.assigned).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `task` | [Task](/business/nouns/task) | Yes | The Task to assign. |
| `worker` | [Worker](/business/nouns/worker) | Yes | The Worker who takes it. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `task` | [Task](/business/nouns/task) | Yes | The assigned Task. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |

**Example**

```ts
import { $ } from 'startup-builder'

const task = await $.Task.assign({ task: 'task_tVPKjporKn', worker: 'worker_whZFpOKWIV' })
```

### Task.claim
Claim takes an offered Task from a shared queue or a handoff and makes the calling Worker its assignee. [Verb page](/business/nouns/task/claim?interface=sdk).

```ts
interface TaskVerbs {
  claim(input: TaskClaimInput, options?: SB.CallOptions): SB.Call<Task>
}
```

Emits [`Task.claimed`](/business/events/Task.claimed).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `task` | [Task](/business/nouns/task) | Yes | The offered Task. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `task` | [Task](/business/nouns/task) | Yes | The Task, assigned to the caller. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```ts
import { $ } from 'startup-builder'

const task = await $.Task.claim({ task: 'task_tVPKjporKn' })
```

### Task.complete
Complete marks a Task done and resumes the Action that waited on it. [Verb page](/business/nouns/task/complete?interface=sdk).

```ts
interface TaskVerbs {
  complete(input: TaskCompleteInput, options?: SB.CallOptions): SB.Call<Task>
}
```

Emits [`Task.completed`](/business/events/Task.completed).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `task` | [Task](/business/nouns/task) | Yes | The assigned Task. |
| `result` | `json` | No | What the Worker produced. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `task` | [Task](/business/nouns/task) | Yes | The completed Task. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The input does not match the schema of the operation. | [`invalid-input`](/code/api/errors/invalid-input) | Read the schema of the operation, then send every required field with the right type. | None. |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |

**Example**

```ts
import { $ } from 'startup-builder'

const task = await $.Task.complete({ task: 'task_tVPKjporKn' })
```

### Task.delegate
Delegate passes a Task to another Role along a declared handoff and keeps its history. [Verb page](/business/nouns/task/delegate?interface=sdk).

```ts
interface TaskVerbs {
  delegate(input: TaskDelegateInput, options?: SB.CallOptions): SB.Call<Task>
}
```

Emits [`Task.delegated`](/business/events/Task.delegated).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `task` | [Task](/business/nouns/task) | Yes | The Task to pass on. |
| `role` | [Role](/business/nouns/role) | Yes | The Role that receives it. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `task` | [Task](/business/nouns/task) | Yes | The Task, held by the new Role. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |

**Example**

```ts
import { $ } from 'startup-builder'

const task = await $.Task.delegate({ task: 'task_tVPKjporKn', role: 'role_oloMFMUeCH' })
```