# Run brief action

Start a known task or chat recommendation from an existing brief. Tasks return a private job to poll; chat actions continue in the acting member’s Brigg conversation. The public API does not list recommendation IDs.

POST https://api.brigg.app/v1/operations/customers.RunBriefAction

## Access & visibility

Allow `customers.RunBriefAction` on your API key.

**Acting member required.** Send `Brigg-Act-As` with an [approved member account ID](https://developer.brigg.app/authentication#member-delegation). The key supplies permissions; the member selects whose data is used.

The selected member must be active and approved by the credential. This selects whose private data is used; the credential supplies permissions. Private ownership and project boundaries still apply.

[Set up authentication](https://developer.brigg.app/authentication) · [Choose permissions](https://developer.brigg.app/permissions)

## Request fields

Send a JSON object with the following fields. Required fields must be included; omit optional fields you do not need.
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `target` | [object](#request-target) | Yes | Record whose existing brief contains the selected action. Pair its exact type and record ID. |
| `action_id` | string | Yes | ID of an existing task or chat recommendation in this record’s brief. It is not the target record ID, a job ID, or a caller-created instruction. At least 1 character. At most 80 characters. |

### request.target

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string | Yes | The record's type: core:Meeting, core:Company or core:Person. At least 1 character. At most 60 characters. |
| `id` | string | Yes | The record's entry id. At least 1 character. At most 80 characters. |

## Use an existing recommendation, then follow its outcome

This operation executes an action already present on a Company, Person or Meeting brief. It does not create an arbitrary agent task. The public API does not enumerate brief action IDs or return the brief body. If you do not already have the action_id from an existing Brigg workflow, use the brief in Brigg instead of inventing an ID. Regenerating the brief can replace its recommendations.

A task action returns job_id: poll [Get job](https://developer.brigg.app/reference/workspace/GetJob), keeping the same approved member. A chat action returns chat: true and posts to that member’s own agent conversation; follow the conversation in Brigg. Neither response means the agent has finished. Email recommendations must be reviewed in Brigg’s composer and are refused here.

Reuse the original idempotency key after a lost response. A new call cannot rerun an already completed task action or repost an already sent chat recommendation. Work waiting for human input must be continued in Brigg; polling does not answer that question.

## Response

Returns **200 OK** with a JSON body.
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `ok` | boolean | Yes | The task was accepted or the chat message was posted. This does not mean the requested background work has completed. |
| `job_id` | string | No | Present for a task action. Poll workspace.GetJob with the same acting member; results and progress belong to that member. |
| `chat` | boolean | No | True for a chat action posted to the acting member’s own conversation. No job_id is returned for this branch; continue in Brigg. |

## Errors & retries

Set `BRIGG_REQUEST_ID` once for each logical action. The samples send it as `Idempotency-Key`. Reuse the same value and body on retries, including after a timeout; a missing response does not prove the action failed.

For rate limits, follow the server’s retry guidance and back off. See [HTTP errors](https://developer.brigg.app/http#errors) and [safe retries and limits](https://developer.brigg.app/reliability).

| HTTP status | Code | What to do |
| --- | --- | --- |
| 400 | `invalid_json` | Send a JSON object with Content-Type: application/json. |
| 400 | `invalid_input` | Check the request fields and types. Supply a stable Idempotency-Key containing 1–200 characters. |
| 401 | `invalid_key` | The workspace API key is missing, invalid or revoked. |
| 403 | `forbidden` | Check the key’s operation and resource grants. Supply Brigg-Act-As with a member authorized by the key’s delegation grant. The selected member must be active and approved by the credential. This selects whose private data is used; the credential supplies permissions. Private ownership and project boundaries still apply. |
| 404 | `not_found` | The target, brief or action is unavailable. Use an action that still belongs to this record’s current brief. |
| 429 | `rate_limited` | Wait for Retry-After before retrying. Reuse the original Idempotency-Key. |
| 400 | `not_runnable` | Email recommendations require review in Brigg’s composer; this endpoint runs task and chat actions only. |
| 409 | `already_done` | This task recommendation already completed. Review its existing result rather than starting it again. |
| 409 | `already_sent` | This chat recommendation was already posted. Continue that conversation in Brigg. |

## Next steps

- [Get job](https://developer.brigg.app/reference/workspace/GetJob)
- [Generate brief](https://developer.brigg.app/reference/customers/GenerateBrief)

[Download OpenAPI](https://developer.brigg.app/openapi.json) · [Versioning & retirement](https://developer.brigg.app/versioning)

## Examples

### Start a known task recommendation

The action ID already belongs to this company’s brief. Keep the returned job ID for polling.
#### cURL


```sh
curl 'https://api.brigg.app/v1/operations/customers.RunBriefAction' \
  -H "Authorization: Bearer $BRIGG_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Brigg-Act-As: $BRIGG_ACT_AS" \
  -H "Idempotency-Key: $BRIGG_REQUEST_ID" \
  --data-raw '{
  "target": {
    "type": "core:Company",
    "id": "e_company_northstar"
  },
  "action_id": "action_prepare_proposal"
}'
```

#### TypeScript


```typescript
const actAs = process.env.BRIGG_ACT_AS;
if (!actAs) throw new Error("Set BRIGG_ACT_AS to an approved member account ID.");

const requestId = process.env.BRIGG_REQUEST_ID;
if (!requestId) throw new Error("Set BRIGG_REQUEST_ID once per action and reuse it on retries.");

const response = await fetch("https://api.brigg.app/v1/operations/customers.RunBriefAction", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BRIGG_API_KEY}`,
    "Content-Type": "application/json",
    "Brigg-Act-As": actAs,
    "Idempotency-Key": requestId, // Create once per action; reuse on retries.
  },
  body: JSON.stringify({
    "target": {
      "type": "core:Company",
      "id": "e_company_northstar"
    },
    "action_id": "action_prepare_proposal"
  }),
});
const result = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${result.error} — ${result.message}`);
console.log(result);
```

#### Python


```python
import json
import os
from urllib.request import Request, urlopen
from urllib.error import HTTPError

request_id = os.environ["BRIGG_REQUEST_ID"]  # Reuse for retries of this action.
payload = {
  "target": {
    "type": "core:Company",
    "id": "e_company_northstar"
  },
  "action_id": "action_prepare_proposal"
}
request = Request(
    "https://api.brigg.app/v1/operations/customers.RunBriefAction",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {os.environ['BRIGG_API_KEY']}",
        "Content-Type": "application/json",
        "Brigg-Act-As": os.environ["BRIGG_ACT_AS"],
        "Idempotency-Key": request_id,  # Create once per action; reuse on retries.
    },
    method="POST",
)
try:
    with urlopen(request) as response:
        print(json.load(response))
except HTTPError as error:
    print(error.code, json.load(error))
    raise
```

#### Response example


```json
{
  "ok": true,
  "job_id": "job_prepare_proposal"
}
```

### Continue a known recommendation in chat

The message is posted to the acting member’s own conversation; there is no job ID to poll.
#### cURL


```sh
curl 'https://api.brigg.app/v1/operations/customers.RunBriefAction' \
  -H "Authorization: Bearer $BRIGG_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Brigg-Act-As: $BRIGG_ACT_AS" \
  -H "Idempotency-Key: $BRIGG_REQUEST_ID" \
  --data-raw '{
  "target": {
    "type": "core:Company",
    "id": "e_company_northstar"
  },
  "action_id": "action_discuss_proposal"
}'
```

#### TypeScript


```typescript
const actAs = process.env.BRIGG_ACT_AS;
if (!actAs) throw new Error("Set BRIGG_ACT_AS to an approved member account ID.");

const requestId = process.env.BRIGG_REQUEST_ID;
if (!requestId) throw new Error("Set BRIGG_REQUEST_ID once per action and reuse it on retries.");

const response = await fetch("https://api.brigg.app/v1/operations/customers.RunBriefAction", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BRIGG_API_KEY}`,
    "Content-Type": "application/json",
    "Brigg-Act-As": actAs,
    "Idempotency-Key": requestId, // Create once per action; reuse on retries.
  },
  body: JSON.stringify({
    "target": {
      "type": "core:Company",
      "id": "e_company_northstar"
    },
    "action_id": "action_discuss_proposal"
  }),
});
const result = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${result.error} — ${result.message}`);
console.log(result);
```

#### Python


```python
import json
import os
from urllib.request import Request, urlopen
from urllib.error import HTTPError

request_id = os.environ["BRIGG_REQUEST_ID"]  # Reuse for retries of this action.
payload = {
  "target": {
    "type": "core:Company",
    "id": "e_company_northstar"
  },
  "action_id": "action_discuss_proposal"
}
request = Request(
    "https://api.brigg.app/v1/operations/customers.RunBriefAction",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {os.environ['BRIGG_API_KEY']}",
        "Content-Type": "application/json",
        "Brigg-Act-As": os.environ["BRIGG_ACT_AS"],
        "Idempotency-Key": request_id,  # Create once per action; reuse on retries.
    },
    method="POST",
)
try:
    with urlopen(request) as response:
        print(json.load(response))
except HTTPError as error:
    print(error.code, json.load(error))
    raise
```

#### Response example


```json
{
  "ok": true,
  "chat": true
}
```

## JSON schemas


```json-schema-request
{
  "type": "object",
  "properties": {
    "target": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60,
          "description": "The record's type: core:Meeting, core:Company or core:Person."
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80,
          "description": "The record's entry id."
        }
      },
      "required": [
        "type",
        "id"
      ],
      "additionalProperties": false,
      "description": "Record whose existing brief contains the selected action. Pair its exact type and record ID."
    },
    "action_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "description": "ID of an existing task or chat recommendation in this record’s brief. It is not the target record ID, a job ID, or a caller-created instruction."
    }
  },
  "required": [
    "target",
    "action_id"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "target": {
        "type": "core:Company",
        "id": "e_company_northstar"
      },
      "action_id": "action_prepare_proposal"
    }
  ]
}
```


```json-schema-response
{
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean",
      "description": "The task was accepted or the chat message was posted. This does not mean the requested background work has completed."
    },
    "job_id": {
      "type": "string",
      "description": "Present for a task action. Poll workspace.GetJob with the same acting member; results and progress belong to that member."
    },
    "chat": {
      "type": "boolean",
      "description": "True for a chat action posted to the acting member’s own conversation. No job_id is returned for this branch; continue in Brigg."
    }
  },
  "required": [
    "ok"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "ok": true,
      "job_id": "job_prepare_proposal"
    }
  ]
}
```

