# Arm a standing message rule

Arms a rule of the shape "whenever X happens to a record, write Y from this template" — the one to reach for when somebody wants a message to happen on its own in future rather than one message now. Body: `name` (required), `channel` ("email" or "sms"), `entityKind` (lead, facility, counterparty, submission, offer, contract, funding, lender, task, record, relationship, object, team, user, workspace), `triggerEvent` (created, updated, status_changed, stage_changed, assigned or completed), `triggerCondition` (extra narrowing, an object), `templateId`, `requiresApproval` (true by default, so what a rule produces waits in the approval queue), `recipientField` (which field on the record carries the address) and `enabled`. This stores the rule and nothing else: no scheduler in this service fires one yet, so arming it puts nothing on a rail. A rule is about the future — one letter to one person right now is the comms surface's, and words a person should read over first are `post_message-drafts`.

Access class: `workspace`.

## Endpoint

`POST /v1/message-automation-rules`

## Request body

Content type: `application/json`.

```json
{
  "body": {
    "channel": "string",
    "description": "string",
    "enabled": true,
    "entityKind": "string",
    "name": "string",
    "recipientField": "string",
    "requiresApproval": true,
    "templateId": 1,
    "triggerCondition": {},
    "triggerEvent": "string"
  },
  "params": {},
  "query": {}
}
```

## Responses

### 201

the action's answer

Content type: `application/json`.

```json
{
  "data": {
    "channel": "string",
    "createdAt": "string",
    "createdByUserId": 1,
    "description": "string",
    "detail": {},
    "enabled": true,
    "entityKind": "string",
    "id": 1,
    "name": "string",
    "recipientField": "string",
    "requiresApproval": true,
    "templateId": 1,
    "triggerCondition": {},
    "triggerEvent": "string",
    "updatedAt": "string"
  }
}
```

### default

a refusal: `{"error": "<what a person needs to read>"}`. 401 no credential, 402 the plan does not include this, 403 the seat does not, 404 the thing does not exist or is not yours to see.

Content type: `application/json`.

```json
{
  "error": "string"
}
```
