# Add Workflow Trigger

Add a trigger to the workflow's draft. A schedule starts every hour, every day, until you change it; a webhook gets its URL at once, answered in webhookUrl. Send the revision you last read in If-Match; the response's meta.revision is the new one.

`POST https://connect.mindcloud.co/v2/workflows/:workflowId/triggers`

Permissions: `workflow:edit`.

## Parameters

### Path

- `workflowId` (string, required): The workflow's id.

### Headers

- `If-Match` (string, required): Required. The revision you last read: the `revision` from its read (Get Workflow Definition for a workflow, Get Analytics Page Definition for an Analytics page, Get Analytics Data Source Table for a fixed source's table), or `meta.revision` from your last change to it. The `ETag` header of either answer is the same value, ready to send back. The change applies only if nobody changed it since: otherwise it answers 412 with the current revision in `error.details.revision`. Send it as a strong entity tag (`"r_..."`): a weak one (`W/"..."`) never matches and answers 412. Without it the request answers 428.
- `X-Company-Id` (string): Optional. The id of the organization to act in. Leave it out to act in the API key's own organization. A key can also act in its child organizations, and, with "Use this key across all of your organizations" on, in every organization its creator can open in the app. List them with GET /v2/companies. Every response's X-Company-Id header names the organization it acted in. See [Organizations](https://mindcloud.co/docs/api/rest/introduction/organizations).

### Body

- `app` (string, required): schedule, webhook, runWorkflow, or an app id or slug.
  schedule, webhook, runWorkflow (When called: another workflow calls this one), or an app with trigger actions (List Universal Apps, usableAsTrigger=true).
- `appVersion` (string): latest, or a version number.
  latest (the default) pins the current published version. A version number pins that version.
- `action` (string): An app event's trigger id or slug.
  For an app event: the trigger's id or slug (List Universal Actions, kind=trigger). Built-ins take none.
- `name` (string): The trigger's display name.
  The step's display name. Left out, it is named the way the editor names it.

## Example request

```bash
curl --request POST \
  --url 'https://connect.mindcloud.co/v2/workflows/Wq3kZ8pLx2Nb/triggers' \
  --header 'Authorization: Bearer $MINDCLOUD_API_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "app": "schedule",
  "appVersion": "latest",
  "action": "new-order",
  "name": "Every hour"
}'
```

## Response fields

- `id` (string): The trigger's id.
- `name` (string): The trigger's display name.
- `appSlug` (string): What starts the workflow: schedule, webhook, runWorkflow (when another workflow calls it), or the app whose event does.
- `appVersion` (string): The app version the trigger is pinned to. For a built-in trigger (Schedule, Webhook, When called), the version of the built-in app it was added with, "0" or "0.0.1" (some older ones hold "draft" or null); it does not change what the trigger does.
- `actionId` (string): The app event the trigger listens for. Null for a built-in trigger.
- `isDisabled` (boolean): True when the trigger is turned off.
- `isConfigured` (boolean): Whether the trigger passed the editor's validation. Null when it was never validated.
- `webhookUrl` (string): For a webhook trigger, the URL that starts the workflow. Null for other triggers.
