# App automations

> Triggers your app fires into a shop’s automations, and the menu they are built from.

Source: https://storeware.ai/docs/api-reference/rest/app-automations

## Fire one of your automation triggers

`POST /api/v1/app/events`

Tells the shop that something your app declares under `[[automations.triggers]]` happened, so every automation the merchant built on it runs. `trigger` is the trigger's `key` in your installed release. `data` carries its declared fields: a field you did not declare is dropped, a declared field of the wrong type is refused with 400, and the whole may be at most 16 KB. Answered 202, before the automations run. At most 60 a minute and 1000 an hour for each installation; past that, 429 with `Retry-After`. The event is not sent to any app's webhooks, yours included.

Answers only your app’s own token for the shop, and needs no permission.

**Body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `trigger` | string | Yes | The trigger’s `key`. Matches `^[a-z][a-z_]{1,31}$`. |
| `data` | map of string or number or boolean or null | No | The trigger’s fields, by `key`. A null or missing field is read as unknown. |

**Answers** `202`

| Field | Type | Description |
| --- | --- | --- |
| `data` | object |  |
| `data.trigger` | string | The trigger as a merchant’s rule names it: `app:&lt;slug&gt;:&lt;key&gt;`. |
| `data.data` | map of string or number or boolean | What was kept, after undeclared fields were dropped. |

```bash
curl -X POST "https://api.storeware.ai/api/v1/app/events" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d @body.json
```

## Get what this shop’s automations may be made of

`GET /api/v1/stores/{storeId}/automations/vocabulary`

The platform’s triggers with the fields each carries, its steps and its exits, and the triggers and actions the shop’s installed apps add, each under the app’s name. An app’s trigger is named `app:&lt;slug&gt;:&lt;key&gt;`; a rule names it as `\{ "kind": "app", "app": "&lt;slug&gt;", "trigger": "&lt;key&gt;" \}` and an action as a step of type `app_action`.

Needs `automations:read`.

**Parameters**

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `storeId` | path | string | The shop. |

**Answers** `200`

| Field | Type | Description |
| --- | --- | --- |
| `data` | object |  |
| `data.triggers` | array of object |  |
| `data.steps` | array of object |  |
| `data.steps[].step` | string |  |
| `data.steps[].does` | string |  |
| `data.actions` | array of object |  |
| `data.actions[].app` | string |  |
| `data.actions[].appName` | string | The app’s name, as the merchant sees it. |
| `data.actions[].key` | string |  |
| `data.actions[].label` | string |  |
| `data.actions[].description` | string or null |  |
| `data.actions[].fields` | array of object |  |
| `data.actions[].fields[].key` | string |  |
| `data.actions[].fields[].label` | string |  |
| `data.actions[].fields[].type` | string | One of `text`, `multi_line_text`, `number`, `boolean`, `url`, `select`. |
| `data.actions[].fields[].required` | boolean |  |
| `data.actions[].fields[].options` | array of object |  |
| `data.actions[].fields[].options[].value` | string |  |
| `data.actions[].fields[].options[].label` | string |  |
| `data.exits` | array of object |  |
| `data.exits[].exit` | string |  |
| `data.exits[].means` | string |  |

```bash
curl "https://api.storeware.ai/api/v1/stores/$STORE_ID/automations/vocabulary" \
  -H "Authorization: Bearer $TOKEN"
```
