# Save a workflow simulation

```http
POST https://trydimmi.com/api/v1/workflows/{workflow}/simulations
```

## Authorization

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

## Path parameters

- `workflow` (string, required): Id of the workflow, starting with wf_, such as wf_01jx2m8k4t. Find it with GET /workflows.

## Body

- `action_mocks` (object): What each action answers instead of really being called, as an object keyed by action id; each value has status (HTTP status, 100 to 599) and body (any JSON), such as {"aac_abc123": {"status": 200, "body": {"order": {"status": "shipped"}}}}. An action with no mock answers with the result of its last live test.
- `assertions` (object[] | null): Checks after the test, at most 30 objects with a type: procedure_matched, handed_off, action_called or action_not_called (action), action_order (action, before), branch_taken (step_id, branch then or else), reply_contains or reply_not_contains (text), llm_rubric (rubric). Such as [{"type": "action_called", "action": "aac_abc123"}].
- `messages` (object[] | null): The customer's scripted messages, oldest first, 1 to 12, each an object with text (1 to 4,000 characters) and optional confirm (true first confirms the writes waiting from the turn before; text may then be empty). Such as [{"text": "I want a refund for order 1042"}, {"text": "", "confirm": true}].
  - `confirm` (boolean): true to first confirm the writes left waiting by the turn before, as the customer pressing Confirm on the card would; with true the text may be empty. false or left out to only send the text.
  - `text` (string, required): What the made-up customer writes in this turn, 1 to 4000 characters, such as I want a refund for order 1042. It may be empty only when confirm is true.
- `name` (string): What the team calls the simulation, up to 120 characters, such as Refund past the window.
- `persona` (object)
  - `attributes` (object): The made-up customer's custom attributes, as an object of attribute key to value. They count as trusted. Such as {"plan": "pro"}.
  - `channel` (string): The channel the made-up customer writes from: widget, email, slack, whatsapp, instagram, facebook or api. Left out or empty, it is widget. Such as "email". One of: `widget`, `email`, `slack`, `whatsapp`, `instagram`, `facebook`, `api`, ``.
  - `company` (object): The custom attributes of the made-up customer's company, as an object of attribute key to value, such as {"plan": "enterprise"}.
  - `email` (string): The made-up customer's email address, at most 320 characters, such as ada@example.com.
  - `external_id` (string): Your own system's id of the made-up customer, at most 200 characters, such as user_8421. Giving one makes them a known user, not a lead.
  - `inbox_id` (string): Id of the inbox the made-up conversation is placed in, starting with inbox_, such as inbox_01jx2m8k4t. Find it with GET /inboxes.
  - `name` (string): The made-up customer's name, at most 200 characters, such as Ada Lovelace.
  - `verified` (boolean): true when the made-up customer is signed in, so their identity and email count as verified; false or left out for an unverified visitor.
- `scenario` (string): Who the customer is and what they came for, up to 1000 characters; the simulated customer answers from it.
- `simulated_at` (string): The date and time the simulation pretends it is when it runs, as an ISO 8601 time, such as "2026-12-24T18:00:00Z". Left out, it runs at the real current time.
- `source_conversation_id` (string): The real conversation (conv_...) the simulation was made from, when it was. Leave out otherwise.

## Response 201 (Created)

- `data` (object, required)
  - `action_mocks` (any, required): What each mocked step answers instead of a real call, by step id, each with a status and a body: an HTTP request or run action step (also keyed by action id, aac_...) its response, an extract step the values by key, a classify step the path as path_id.
  - `assertions` (any, required): What must hold after the run, as a JSON array of checks.
  - `created_at` (string, required): When it was created, as an RFC 3339 time, such as 2026-01-31T09:00:00Z.
  - `draft_history` (object, required)
    - `passed` (integer, required): How many of the counted runs passed.
    - `runs` (object[] | null, required): The counted runs, newest first.
      - `id` (string, required): The id of this record. Send it wherever an endpoint asks for this record; never use its name or title in its place.
      - `passed` (boolean, required): true when every check of the run held.
      - `ran_at` (string, required): When the run happened.
    - `state` (string, required): passing when every counted run passed, failing when none did, flaky in between. One of: `passing`, `flaky`, `failing`.
    - `total` (integer, required): How many runs are counted.
    - `window` (integer, required): The most runs a history counts: only the latest this many.
  - `draft_result` (any, required): How its last run on the draft went, as a JSON object with passed, ran_at, the trace of steps, the result of each check and, on a broken run, error. Null when it never ran there.
  - `id` (string, required): The id of this record. Send it wherever an endpoint asks for this record; never use its name or title in its place.
  - `live_history` (object, required)
    - `passed` (integer, required): How many of the counted runs passed.
    - `runs` (object[] | null, required): The counted runs, newest first.
      - `id` (string, required): The id of this record. Send it wherever an endpoint asks for this record; never use its name or title in its place.
      - `passed` (boolean, required): true when every check of the run held.
      - `ran_at` (string, required): When the run happened.
    - `state` (string, required): passing when every counted run passed, failing when none did, flaky in between. One of: `passing`, `flaky`, `failing`.
    - `total` (integer, required): How many runs are counted.
    - `window` (integer, required): The most runs a history counts: only the latest this many.
  - `live_result` (any, required): How its last run on the live version went, as a JSON object with passed, ran_at, the trace of steps, the result of each check and, on a broken run, error. Null when it never ran there.
  - `messages` (any, required): The customer's messages, in order, as a JSON array.
  - `name` (string, required): Name of the simulation, up to 120 characters.
  - `object` (string, required): The kind of record this is, the same for every record of its kind, such as article.
  - `persona` (any, required): The made-up customer, as a JSON object with fields such as name, email and attributes.
  - `scenario` (string, required): Who the customer is and what they came for. The simulated customer answers from it.
  - `simulated_at` (string | null, required): The moment the simulation pretends it is. Null to run at the real time.
  - `source_conversation_id` (string | null, required): Id of the real conversation the simulation was made from (conv_...). Null when written by hand.
  - `updated_at` (string, required): When it last changed, as an RFC 3339 time, such as 2026-01-31T09:00:00Z.
  - `workflow_id` (string, required): Id of the workflow the simulation belongs to (wf_...).

## 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/workflows/{workflow}/simulations' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "action_mocks": {
    "<key>": {
      "body": null,
      "status": 123
    }
  },
  "assertions": [
    {
      "<key>": null
    }
  ],
  "messages": [
    {
      "confirm": true,
      "text": "<string>"
    }
  ],
  "name": "<string>",
  "persona": {
    "attributes": {
      "<key>": null
    },
    "channel": "widget",
    "company": {
      "<key>": null
    },
    "email": "<string>",
    "external_id": "<string>",
    "inbox_id": "<string>",
    "name": "<string>",
    "verified": true
  },
  "scenario": "<string>",
  "simulated_at": "2026-11-01T09:30:00Z",
  "source_conversation_id": "<string>"
}'
```

## Example response

```json
{
  "data": {
    "action_mocks": null,
    "assertions": null,
    "created_at": "2026-11-01T09:30:00Z",
    "draft_history": {
      "passed": 123,
      "runs": [
        {
          "id": "<string>",
          "passed": true,
          "ran_at": "2026-11-01T09:30:00Z"
        }
      ],
      "state": "passing",
      "total": 123,
      "window": 123
    },
    "draft_result": null,
    "id": "<string>",
    "live_history": {
      "passed": 123,
      "runs": [
        {
          "id": "<string>",
          "passed": true,
          "ran_at": "2026-11-01T09:30:00Z"
        }
      ],
      "state": "passing",
      "total": 123,
      "window": 123
    },
    "live_result": null,
    "messages": null,
    "name": "<string>",
    "object": "<string>",
    "persona": null,
    "scenario": "<string>",
    "simulated_at": "2026-11-01T09:30:00Z",
    "source_conversation_id": "<string>",
    "updated_at": "2026-11-01T09:30:00Z",
    "workflow_id": "<string>"
  }
}
```

---

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