---
search:
  tags:
    - Automations
    - POST
seo:
  description: >-
    Create an automation for the API key's organization. Modem assigns the
    organization's earliest… Reference for the POST /automations endpoint in the
    Modem API.
sidebar:
  label: Create automation
  badge: POST
title: Create automation
type: openapi-operation
---
Create an automation for the API key's organization. Modem assigns the organization's earliest owner.

Provide a complete automation definition. Event schedules accept canonical registered event names only.
GitHub PR event schedules can include targetBranches with exact names or * wildcards; omit it to match
every target branch. A target-branch filter is only valid when every configured event is a GitHub PR event.
To send output to Slack or Discord, provide sourceName and sourceChannelId together. Otherwise Modem uses
the organization's saved default output destination. Requests fail when no valid destination is available.

This operation supports Idempotency-Key and accepts organization API keys only; service JWTs are rejected.

`POST /automations`

**Request body** (`application/json`, required)

Request body example:

```json
{
  "allowedCapabilities": [
    "string"
  ],
  "capabilityMode": "all",
  "enabled": true,
  "modelLevel": "high",
  "name": "string",
  "prompt": "string",
  "schedule": {
    "expr": "string",
    "type": "cron"
  },
  "templateSlug": "string",
  "timezone": "string"
}
```

**Responses**

- `200` — OK
- `400` — Invalid request (validation failed).
- `401` — Missing or invalid API key.
- `403` — The API key does not have access to this resource.
- `404` — The requested resource was not found.
- `409` — The request conflicts with an existing resource or idempotency operation.
- `429` — Rate limit exceeded.
- `500` — Internal server error.

Response example, 200:

```json
{
  "allowedCapabilities": [
    "string"
  ],
  "capabilityMode": "all",
  "createdAt": "2019-08-24T14:15:22Z",
  "enabled": true,
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "lastAttemptAt": "2019-08-24T14:15:22Z",
  "lastErrorMessage": "string",
  "lastRunAt": "2019-08-24T14:15:22Z",
  "modelLevel": "high",
  "name": "string",
  "nextRunAt": "2019-08-24T14:15:22Z",
  "outputChannels": [
    {
      "channel": "discord",
      "destinations": [
        "string"
      ],
      "mode": "any-internal"
    }
  ],
  "prompt": "string",
  "schedule": {
    "expr": "string",
    "type": "cron"
  },
  "status": "completed",
  "templateSlug": "string",
  "timezone": "string",
  "updatedAt": "2019-08-24T14:15:22Z"
}
```
