---
title: "Send practice messages and configure scripted patient replies"
method: POST
path: "/api/sites/gp/messages"
tags: ["Messaging"]
---

# Send practice messages and configure scripted patient replies

`POST /api/sites/gp/messages`

## Request

- Base URL: `https://sim.animahealth.com`
- URL: `https://sim.animahealth.com/api/sites/gp/messages`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer
  - API key in cookie `sim_session`

Requires GP scope. Existing conversations/templates require resourceId and their latest expectedVersion. New conversations require patientId. Commands are validated by role. Mutations are attributed to the authenticated team; incoming/outgoing direction identifies the simulated role. Patient responses omit private practice information. Practice messages are queued until a delivery command marks them delivered. configure_auto_reply sets an ordered script for future successful deliveries: each delivered outgoing message consumes one step and schedules a reply after delayMinutes of simulation time. Configure before delivery, then POST /api/clock with paused:true and advanceMinutes. Reconfiguration resets the script and cancels pending replies; empty steps disable it. Manual patient replies and completing a conversation cancel pending replies without reusing consumed steps. Read the latest conversation version after clock changes. Existing generic messaging_action commands remain supported.

## Query parameters

- `world` string

## Headers

- `Idempotency-Key` string

## Request body

- PracticeMessageRequest
  - `resourceId` string
  - `expectedVersion` integer
  - `patientId` string
  - `command` union, required
    - object
      - `kind` 'create', required
      - `subject` string, required
      - `body` string, required
      - `channel` 'sms' | 'email', required
      - `allowReply` boolean, required
    - object
      - `kind` 'send', required
      - `body` string, required
      - `channel` 'sms' | 'email', required
    - object
      - `kind` 'configure_auto_reply', required
      - `steps` object[], required
        - `body` string, required
        - `delayMinutes` number, required
    - object
      - `kind` 'note', required
      - `body` string, required
    - object
      - `kind` 'assign', required
      - `assignee` string, required
    - object
      - `kind` 'complete', required
    - object
      - `kind` 'reopen', required
    - object
      - `kind` 'delivery', required
      - `entryId` string, required
      - `status` 'delivered' | 'failed', required
    - object
      - `kind` 'retry', required
      - `entryId` string, required
    - object
      - `kind` 'save_template', required
      - `title` string, required
      - `body` string, required
      - `channel` 'sms' | 'email', required
    - object
      - `kind` 'archive_template', required

## Response `200`

Success

- Resource
  - `id` string, required
  - `patientId` string
  - `kind` string, required
  - `title` string, required
  - `status` string, required
  - `owner` string, required
  - `visibleTo` string[], required
  - `priority` 'routine' | 'urgent', required
  - `createdAt` number, required: Simulation Unix timestamp in milliseconds.
  - `dueAt` number: Simulation Unix timestamp in milliseconds.
  - `data` object, required: Kind-specific payload. Hospital notes, medication orders and blood-test orders use the named schemas; the full workspace payload is returned without projection.
  - `version` integer, required
  - `provenance` object
    - `created` RecordChange, required
      - `actor` object, required
        - `kind` 'team' | 'operator' | 'simulation', required
        - `name` string, required
      - `source` string, required
      - `action` string, required
      - `time` number, required: Simulation Unix timestamp in milliseconds.
      - `version` integer, required
    - `changes` RecordChange[], required
      - `actor` object, required
        - `kind` 'team' | 'operator' | 'simulation', required
        - `name` string, required
      - `source` string, required
      - `action` string, required
      - `time` number, required: Simulation Unix timestamp in milliseconds.
      - `version` integer, required
    - `recovery` object

## Other responses

- `400`: Invalid input or unsupported workflow
- `401`: Missing or invalid credentials
- `403`: Scope, origin or operator restriction
- `404`: Unknown resource
- `409`: Stale version, invalid transition or unavailable capacity
- `413`: Request exceeds this operation's body-size limit
- `429`: Deployment has reached its 5,000-team capacity
- `500`: Internal simulation error

---

[API](https://skmtc.dev/animahealth/apis/nhs-sim-api.md) - [All operations](https://skmtc.dev/animahealth/apis/nhs-sim-api/llms.txt) - [OpenAPI document](https://skmtc.dev/animahealth/apis/nhs-sim-api/revisions/c7803d7a3e58?raw)
