# Start a Workflow Execution

Starts a workflow for one patient. `workflow_type` must match the workflow's `type`.
For a `booking_link` workflow, Hero creates a single-use booking link and sends it to the patient in the invite. Follow-ups are sent at their offsets only while the link is unused. Once the patient books, follow-ups cancel and the execution stays `in_progress` until the appointment starts, then ends `completed` with outcome `booked`. If the appointment is cancelled before it starts, the outcome is `appointment_cancelled`; if the link expires unused, the outcome is `not_booked`. Hero sends its usual appointment reminders, as the practice has set them up.
Messages are sent as the practice's default admin and are not written to the patient's record.
For a `campaign` workflow, a patient is in the campaign once. Adding them again while their execution is unfinished returns it; once it has ended, including when it was cancelled before or after sending started, the add is refused with `422` (`already_ran`).
**Idempotency:** only one execution can be in progress per `external_reference`. Repeating the same request returns that execution; a different request body with the same reference returns `409`.

Endpoint: POST /v1/workflows/{workflow_id}/executions
Version: 1.0.0
Security: apiKeyAuth, practiceGroupId

## Security:

  - `apiKeyAuth` (unknown)
    apiKey in header x-api-key

  - `practiceGroupId` (unknown)
    apiKey in header x-practice-group-id

## Path parameters:

  - `workflow_id` (string, required)
    The workflow's ID, from List Workflows.

## Request fields (application/json):

  - `workflow_type` (string, required)
    Enum: "booking_link"

  - `external_reference` (string, required)
    Your own ID for the request, up to 128 characters. Only one execution can be in progress per reference; the reference can be reused once that execution has ended.

  - `patient_id` (string, required)
    The ID of the Hero patient to send the invite and follow-ups to.

  - `link` (object, required)

  - `link.appointment_type_id` (any, required)
    One appointment type ID, or a list of them, from GET /v1/appointment_types. The link offers these appointment types.

  - `link.location_id` (any, required)
    One location ID, or a list of them, from GET /v1/locations. The link offers slots at these locations. Required, as Hero cannot create the link without a location.

  - `link.practitioner_id` (any)
    One practitioner ID, or a list of them. If left out, the link offers slots with any practitioner.

  - `link.from_date` (string)
    The first day the link offers slots. Must be within 3 months.
    Example: 2026-12-22

  - `link.to_date` (string)
    The last day the link offers slots. Must be within 3 months and after from_date.
    Example: 2026-12-22

  - `link.expiry_date` (string)
    When the link stops working. Must be within 3 months and at least a day after the last follow-up is due. If left out, the link expires after 14 days, or a day after the last follow-up if that is later.
    Example: 2026-12-22

  - `link.link_name` (string)

  - `invite` (object, required)

  - `invite.message_type` (string, required)
    How the message is sent: by SMS or email.
    Enum: "sms", "email"

  - `invite.template_id` (string, required)
    The ID of a template from GET /v1/templates. It must be visible to your practice group and not archived.

  - `invite.recipient_contact_detail` (string)
    Where the message will be sent (e.g. patient@email.com or +44 79000000000). If no value is provided a default will be picked from the patients record (for that contact method, SMS/Email).
    Example: 07911123456

  - `follow_ups` (object)

  - `follow_ups.message_type` (string, required)
    How the message is sent: by SMS or email.
    Enum: "sms", "email"

  - `follow_ups.template_id` (string, required)
    The ID of a template from GET /v1/templates. It must be visible to your practice group and not archived.

  - `follow_ups.recipient_contact_detail` (string)
    Where the message will be sent (e.g. patient@email.com or +44 79000000000). If no value is provided a default will be picked from the patients record (for that contact method, SMS/Email).
    Example: 07911123456

  - `follow_ups.after` (array, required)
    ISO 8601 durations after the invite, in ascending order: 1 to 5 of them, each between PT1H and P30D and at least an hour apart. Weeks, days, hours and minutes are accepted; months and years are not.

## Response 200:

  - `200` (unknown)
    Ok

## Response 200 fields (application/json):

  - `id` (string, required)

  - `workflow_id` (string, required)

  - `workflow_type` (string, required)
    Enum: "booking_link", "campaign"

  - `external_reference` (string, required)

  - `patient_id` (string, required)

  - `status` (string, required)
    The state of the execution. An execution that books an appointment stays in_progress until the appointment starts. scheduled is for campaigns only, and a booking_link execution never has it: a campaign patient whose run is waiting for the campaign's sending to start. Cancel a Workflow Execution stops a campaign patient at any time while their execution is unfinished, before or after sending starts.
    Enum: "scheduled", "in_progress", "completed", "cancelled", "failed"

  - `outcome` (string, required)
    How the execution ended, such as booked or not_booked. A cancelled booking_link execution has cancelled_by_partner; cancelled (by staff) and workflow_cancelled are for campaigns only. Null while scheduled or in_progress.

  - `booking_link` (object, required)

  - `booking_link.id` (string, required)

  - `booking_link.url` (string, required)

  - `booking_link.status` (string, required)
    Enum: "unexpired", "expired"

  - `booking_link.expires_at` (string, required)

  - `steps` (array, required)

  - `steps.position` (integer, required)

  - `steps.kind` (string, required)
    Enum: "invite", "follow_up"

  - `steps.message_type` (string, required)
    How the message is sent: by SMS or email.
    Enum: "sms", "email"

  - `steps.status` (string, required)
    The state of the step.
    Enum: "scheduled", "in_progress", "completed", "skipped", "failed"

  - `steps.due_at` (string, required)

  - `steps.completed_at` (string, required)

  - `steps.failure_reason` (string, required)
    Why the step failed. Null unless status is failed.

  - `steps.message` (object, required)
    The message Hero sent for this step. Null until the step is completed.

  - `steps.message.id` (string, required)

  - `steps.message.status` (string, required)
    The delivery status of the message.
    Enum: "delivered", "declined", "sent", "pending", "retry", "fatal"

  - `steps.message.failure_reason` (string, required)

  - `appointment` (object, required)
    The appointment booked through the link. Null until one is booked.

  - `appointment.id` (string, required)

  - `appointment.start_time` (string, required)

  - `appointment.booking_status` (string, required)
    The appointment's booking status in Hero.
    Enum: "reserved", "pending", "confirmed", "cancelling", "rescheduling", "abandoned", "cancelled", "failed", "unknown"

  - `started_at` (string, required)

  - `finished_at` (string, required)

  - `created_at` (string, required)

  - `updated_at` (string, required)

## Response 400:

  - `400` (unknown)
    Validation error. The response names the field and the rule it failed.

## Response 401:

  - `401` (unknown)
    Unauthorised

## Response 404:

  - `404` (unknown)
    Workflow not found

## Response 409:

  - `409` (unknown)
    An execution with this `external_reference` is already in progress, started with a different request body

## Response 422:

  - `422` (unknown)
    Template not found, `workflow_type` does not match the workflow's `type`, or a campaign patient has already been in the campaign (`already_ran`)

## Response 429:

  - `429` (unknown)
    Too Many Requests

## Response 500:

  - `500` (unknown)
    Unknown error

