# Walk one person through a series

```http
POST https://trydimmi.com/api/v1/series/{series}/simulations/run
```

## Authorization

Send an API token as `Authorization: Bearer <token>`.
The token needs: `series:write`.

## Path parameters

- `series` (string, required): Id of the series, starting with srs_, such as srs_01jx2m8k4t. Find it with GET /series.

## Body

- `action_mocks` (object): What extract and run action steps answer instead of the AI or the action, keyed by step id or action id (aac_...): a status and a body. An extract step's body holds the values by key; a run action step's body is the action's result, and a status outside 2xx takes the failed path.
- `contact_id` (string): The contact to walk through (cnt_...); or leave out and describe a person.
- `engaged` (string[] | null): Whether they open, click or reply to the messages: opened, clicked or replied.
- `events` (string[] | null): Events the person does on the way, by name.
- `person` (object)
  - `attributes` (object): The made-up person's attributes, by key.
  - `email` (string): The made-up person's email address.
  - `name` (string): The made-up person's name.
- `scenario` (string): How the person behaves, in words, such as opens every email but never clicks. The AI reads it to say whether they open, click, reply or do an event each time the series asks, in place of events and engaged.
- `version` (string): draft or live. Left out, it is draft. One of: `draft`, `live`, ``.

## Response 200 (OK)

- `data` (object, required)
  - `actions` (object[] | null, required): The changes the journey would make, such as tags and attributes, in order.
    - `detail` (object): What the change is, as an object.
    - `kind` (string, required): What the step does, such as tag or set_attribute.
    - `node_id` (string, required): Id of the step.
  - `decisions` (object[] | null, required): With a scenario, what the person did each time the series asked whether they open, click, reply or do an event. Empty without a scenario.
    - `before` (integer, required): The index in steps of the step this was asked before.
    - `did` (boolean, required): true when the person did it.
    - `what` (string, required): What the series asked, in words, such as open the message "Welcome".
  - `end` (string, required): How the journey ended: finished, goal, exited or still waiting.
  - `entered` (boolean, required): true when the person would enter the series.
  - `goal_reached` (boolean, required): true when the person would reach the series' goal.
  - `messages` (object[] | null, required): The messages that would go out, in order.
    - `body` (string, required): The message as written, variables unfilled.
    - `kind` (string, required): How it would go out: email, chat, post or slack.
    - `node_id` (string, required): Id of the step that sends it.
    - `subject` (string): The email subject. Empty for other kinds.
    - `to` (string): Who would receive it.
  - `object` (string, required): The kind of record this is, the same for every record of its kind, such as article.
  - `reason` (string): Why the person would not enter, or why the journey ended. Empty when nothing to say.
  - `steps` (object[] | null, required): Each step the person would reach, in order, with the path it took.
    - `detail` (object): A few facts the step kept, as an object.
    - `kind` (string, required): What the step does, such as wait, condition or ai_path.
    - `node_id` (string, required): Id of the step.
    - `path` (string): The path the step took. Empty when it has one way on.
    - `result` (string, required): What the step did, as a short word.
    - `skipped` (boolean): true when the step was a wait the simulation skipped.

## Response default (Error)

- `code` (string, required): Stable code for programs to tell errors apart, such as validation_failed or internal_error.
- `errors` (object): Each rejected field mapped to its messages. Only present when the input was invalid.
- `message` (string, required): What went wrong, in words safe to show a person.

## Example request

```bash
curl --request POST \
  --url 'https://trydimmi.com/api/v1/series/{series}/simulations/run' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "action_mocks": {
    "<key>": {
      "body": null,
      "status": 123
    }
  },
  "contact_id": "<string>",
  "engaged": [
    "<string>"
  ],
  "events": [
    "<string>"
  ],
  "person": {
    "attributes": {
      "<key>": null
    },
    "email": "<string>",
    "name": "<string>"
  },
  "scenario": "<string>",
  "version": "draft"
}'
```

## Example response

```json
{
  "data": {
    "actions": [
      {
        "detail": {
          "<key>": null
        },
        "kind": "<string>",
        "node_id": "<string>"
      }
    ],
    "decisions": [
      {
        "before": 123,
        "did": true,
        "what": "<string>"
      }
    ],
    "end": "<string>",
    "entered": true,
    "goal_reached": true,
    "messages": [
      {
        "body": "<string>",
        "kind": "<string>",
        "node_id": "<string>",
        "subject": "<string>",
        "to": "<string>"
      }
    ],
    "object": "<string>",
    "reason": "<string>",
    "steps": [
      {
        "detail": {
          "<key>": null
        },
        "kind": "<string>",
        "node_id": "<string>",
        "path": "<string>",
        "result": "<string>",
        "skipped": true
      }
    ]
  }
}
```

---

Index of all dimmi docs: https://trydimmi.com/llms.txt (full text: https://trydimmi.com/llms-full.txt)
