# Action routes: answer, ask, attest

URL: /code/api/action/verbs · Id: `page:code/api/action/verbs`

> The Action Verbs answer, ask, attest as api.sb routes, with inputs, result, refusals and an example.

Reference for [Action](/business/nouns/action), one group of [Action routes](/code/api/action).

### Action.answer
Answer gives the reply to an Action’s open Question, through any Interface, and the Action resumes. [Verb page](/business/nouns/action/answer?interface=api).

```text
POST /{namespace}/actions/{action}/answer
```

Path: `action`. Body, as JSON: the other inputs. Emits [`Action.answered`](/business/events/Action.answered).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | [Action](/business/nouns/action) | Yes | The Action waiting on the Question. |
| `question` | [Question](/business/nouns/question) | Yes | The Question answered. |
| `payload` | `json` | Yes | The answer, matching the Question’s choices or schema. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | [Action](/business/nouns/action) | Yes | The resumed Action. |

**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**

```bash
curl -X POST https://api.sb/leaseline.app/actions/act_br07HsG8MG/answer \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"question":"question_zuqUHd8LwY","payload":{}}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "$type": "Action",
    "status": "done",
    "mode": "try",
    "operation": "Action.answer"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### Action.ask
Ask puts a Question to a Party, a Role, or a Worker and holds the Action `pending` with reason `awaitingInput`. [Verb page](/business/nouns/action/ask?interface=api).

```text
POST /{namespace}/actions/{action}/ask
```

Path: `action`. Body, as JSON: the other inputs. Emits [`Action.asked`](/business/events/Action.asked).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | [Action](/business/nouns/action) | Yes | The Action that needs an answer to go on. |
| `to` | [Thing](/business/nouns/thing) | Yes | Who is asked: a Party, a Role, or a Worker. |
| `text` | `text` | Yes | The question, in one message. |
| `choices` | `string[]` | No | The answers offered. |
| `schema` | `json` | No | The typed answer’s shape. |
| `answerBy` | `datetime` | No | When the Action’s timeout rule applies. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `question` | [Question](/business/nouns/question) | Yes | The Question, posted in the record’s Thread. |
| `action` | [Action](/business/nouns/action) | Yes | The Action, now pending with reason `awaitingInput`. |

**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**

```bash
curl -X POST https://api.sb/leaseline.app/actions/act_br07HsG8MG/ask \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to":"thing_8ds0r9vvRl","text":"Example text"}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "question": {
    "$id": "https://api.sb/leaseline.app/questions/question_zuqUHd8LwY",
    "$type": "Question",
    "to": "thing_8ds0r9vvRl",
    "text": "Example text"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "$type": "Action",
    "status": "done",
    "mode": "try",
    "operation": "Action.ask"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### Action.attest
Attest records a credentialed Human’s signed performance of a Reserved Act that an Action needs to finish. [Verb page](/business/nouns/action/attest?interface=api).

```text
POST /{namespace}/actions/{action}/attest
```

Path: `action`. Body, as JSON: the other inputs. Emits [`Action.attested`](/business/events/Action.attested).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | [Action](/business/nouns/action) | Yes | The Action that waits on the Reserved Act. |
| `credential` | [Credential](/business/nouns/credential) | Yes | The Credential that authorizes it. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | [Action](/business/nouns/action) | Yes | The Action, free to finish. |

**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. |

**Example**

```bash
curl -X POST https://api.sb/leaseline.app/actions/act_br07HsG8MG/attest \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"credential":"credential_Abb9zatRR1"}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "$type": "Action",
    "status": "done",
    "mode": "try",
    "operation": "Action.attest"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```