Skip to content

Task routes: assign, claim, complete, delegate

The Task Verbs assign, claim, complete, delegate as api.sb routes, with inputs, result, refusals and an example.

Reference for Task, one group of Task routes.

Task.assign

Assign gives a Task to a Worker, human or agent, and places it in that Worker’s worklist. Verb page.

Text
POST /{namespace}/tasks/{task}/assign

Path: task. Body, as JSON: the other inputs. Emits Task.assigned.

Inputs

InputTypeRequiredDescription
taskTaskrequiredThe Task to assign.
workerWorkerrequiredThe Worker who takes it.

Returns

OutputTypeRequiredDescription
taskTaskrequiredThe assigned Task.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse 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.refusedRead the record, run the Verb that moves it to an allowed state, then retry.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/tasks/task_tVPKjporKn/assign \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"worker":"worker_whZFpOKWIV"}'
JSON
{
  "api": "https://api.sb/leaseline.app",
  "task": {
    "$id": "https://api.sb/leaseline.app/tasks/task_tVPKjporKn",
    "$type": "Task",
    "status": "pending",
    "mode": "try"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Task.assign",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}

Task.claim

Claim takes an offered Task from a shared queue or a handoff and makes the calling Worker its assignee. Verb page.

Text
POST /{namespace}/tasks/{task}/claim

Path: task. Emits Task.claimed.

Inputs

InputTypeRequiredDescription
taskTaskrequiredThe offered Task.

Returns

OutputTypeRequiredDescription
taskTaskrequiredThe Task, assigned to the caller.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/tasks/task_tVPKjporKn/claim \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
JSON
{
  "api": "https://api.sb/leaseline.app",
  "task": {
    "$id": "https://api.sb/leaseline.app/tasks/task_tVPKjporKn",
    "$type": "Task",
    "status": "pending",
    "mode": "try"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Task.claim",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}

Task.complete

Complete marks a Task done and resumes the Action that waited on it. Verb page.

Text
POST /{namespace}/tasks/{task}/complete

Path: task. Body, as JSON: the other inputs. Emits Task.completed.

Inputs

InputTypeRequiredDescription
taskTaskrequiredThe assigned Task.
resultjsonWhat the Worker produced.

Returns

OutputTypeRequiredDescription
taskTaskrequiredThe completed Task.

Refuses when

CheckErrorFixThen call
The input does not match the schema of the operation.invalid-inputRead 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.forbiddenUse 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.refusedRead the record, run the Verb that moves it to an allowed state, then retry.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/tasks/task_tVPKjporKn/complete \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
JSON
{
  "api": "https://api.sb/leaseline.app",
  "task": {
    "$id": "https://api.sb/leaseline.app/tasks/task_tVPKjporKn",
    "$type": "Task",
    "status": "pending",
    "mode": "try"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Task.complete",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}

Task.delegate

Delegate passes a Task to another Role along a declared handoff and keeps its history. Verb page.

Text
POST /{namespace}/tasks/{task}/delegate

Path: task. Body, as JSON: the other inputs. Emits Task.delegated.

Inputs

InputTypeRequiredDescription
taskTaskrequiredThe Task to pass on.
roleRolerequiredThe Role that receives it.

Returns

OutputTypeRequiredDescription
taskTaskrequiredThe Task, held by the new Role.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse 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.refusedRead the record, run the Verb that moves it to an allowed state, then retry.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/tasks/task_tVPKjporKn/delegate \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"role":"role_oloMFMUeCH"}'
JSON
{
  "api": "https://api.sb/leaseline.app",
  "task": {
    "$id": "https://api.sb/leaseline.app/tasks/task_tVPKjporKn",
    "$type": "Task",
    "status": "pending",
    "mode": "try"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Task.delegate",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}