# AutomatedAction

An automation: "when this happens, start that". Its triggers are schedules and message triggers (another run changing), and every trigger starts all of its actions. Runs it starts are recorded in its history.

**Kind:** an object, used in responses.

## Fields

Every field is present in a response; empty ones are `null`.

| Field | Type | Description |
|---|---|---|
| `name` | `string` | The automation's name. |
| `description` | `string \| null` | What the automation is for, in your own words. Optional. |
| `actions` | [`AutomatedActionItem`](https://docs.maitento.com/reference/types/automated-action-item.md)`[]` | What to start when it is triggered. Every trigger starts each action in turn. |
| `schedules` | [`CronSchedule`](https://docs.maitento.com/reference/types/cron-schedule.md)`[]` | Schedules that trigger it, as cron fields (UTC). |
| `messageTriggers` | [`MessageTrigger`](https://docs.maitento.com/reference/types/message-trigger.md)`[]` | Triggers that fire when another run changes and matches a filter. |
| `nextScheduledRunAt` | `datetime \| null` | When its schedules next trigger it, in UTC: the earliest next time of its enabled schedules. Null when no schedule is enabled. |
| `history` | [`ExecutionHistoryEntry`](https://docs.maitento.com/reference/types/execution-history-entry.md)`[]` | The runs it started, oldest first: the most recent `maxHistoryEntries` of them. |
| `maxHistoryEntries` | `integer` | How many entries `history` keeps; older ones are dropped. 50. |
| `totalExecutions` | `integer` | How many runs it has started, in all. |
| `consecutiveFailures` | `integer` | How many of its runs in a row have failed. A run that succeeds sets it back to zero. |
| `lastExecutedAt` | `datetime \| null` | When it last started a run, in UTC. Null if it never has. |
| `lastProcessId` | `uuid \| null` | The id of the last run it started. Null if it never has. |
| `userCreatedById` | `uuid` | The id of the user who created it. A call made with an API key is recorded as the key's user. |
| `namespaceId` | `uuid` | The id of the namespace it belongs to. |
| `tenantId` | `uuid` | The id of the tenant it belongs to. |
| `id` | `uuid` | The unique id. Use it in `by-id` routes and wherever another object refers to this one. |
| `dateCreated` | `datetime` | When it was created, in UTC. |
| `dateUpdated` | `datetime` | When it was last changed, in UTC. |

## Example

```json
{
  "name": "...",
  "description": "...",
  "actions": [
    {
      "id": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
      "name": "...",
      "config": {
        "$type": "app"
      }
    }
  ],
  "schedules": [
    {
      "id": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
      "name": "...",
      "isEnabled": false,
      "second": "...",
      "minute": "...",
      "hour": "...",
      "dayOfMonth": "...",
      "month": "...",
      "dayOfWeek": "...",
      "nextOccurrence": "2026-10-26T12:00:00.0000000Z"
    }
  ],
  "messageTriggers": [
    {
      "id": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
      "name": "...",
      "isEnabled": false,
      "triggerType": "AppProcessUpdated",
      "eventFilter": "..."
    }
  ],
  "nextScheduledRunAt": "2026-10-26T12:00:00.0000000Z",
  "history": [
    {
      "id": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
      "triggerType": "Schedule",
      "triggerId": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
      "actionId": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
      "processId": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
      "processType": "App",
      "dateStarted": "2026-10-26T12:00:00.0000000Z",
      "dateCompleted": "2026-10-26T12:00:00.0000000Z",
      "outcome": "Pending",
      "errorMessage": "..."
    }
  ],
  "maxHistoryEntries": 0,
  "totalExecutions": 0,
  "consecutiveFailures": 0,
  "lastExecutedAt": "2026-10-26T12:00:00.0000000Z",
  "lastProcessId": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
  "userCreatedById": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
  "namespaceId": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
  "tenantId": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
  "id": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
  "dateCreated": "2026-10-26T12:00:00.0000000Z",
  "dateUpdated": "2026-10-26T12:00:00.0000000Z"
}
```

## Where it's used

- [`automations.addMessageTrigger`](https://docs.maitento.com/reference/api/automations.md) (`POST /automated-actions/by-id/{id}/message-triggers`)
- [`automations.addSchedule`](https://docs.maitento.com/reference/api/automations.md) (`POST /automated-actions/by-id/{id}/schedules`)
- [`automations.create`](https://docs.maitento.com/reference/api/automations.md) (`POST /namespaces/{namespaceName}/automated-actions`)
- [`automations.disableMessageTrigger`](https://docs.maitento.com/reference/api/automations.md) (`POST /automated-actions/by-id/{id}/message-triggers/{triggerId}/disable`)
- [`automations.disableSchedule`](https://docs.maitento.com/reference/api/automations.md) (`POST /automated-actions/by-id/{id}/schedules/{scheduleId}/disable`)
- [`automations.enableMessageTrigger`](https://docs.maitento.com/reference/api/automations.md) (`POST /automated-actions/by-id/{id}/message-triggers/{triggerId}/enable`)
- [`automations.enableSchedule`](https://docs.maitento.com/reference/api/automations.md) (`POST /automated-actions/by-id/{id}/schedules/{scheduleId}/enable`)
- [`automations.getByName`](https://docs.maitento.com/reference/api/automations.md) (`GET /namespaces/{namespaceName}/automated-actions/by-name/{name}`)
- [`automations.get`](https://docs.maitento.com/reference/api/automations.md) (`GET /automated-actions/by-id/{id}`)
- [`automations.list`](https://docs.maitento.com/reference/api/automations.md) (`GET /automated-actions`)
- [`automations.list`](https://docs.maitento.com/reference/api/automations.md) (`GET /namespaces/{namespaceName}/automated-actions`)
- [`automations.removeMessageTrigger`](https://docs.maitento.com/reference/api/automations.md) (`DELETE /automated-actions/by-id/{id}/message-triggers/{triggerId}`)
- [`automations.removeSchedule`](https://docs.maitento.com/reference/api/automations.md) (`DELETE /automated-actions/by-id/{id}/schedules/{scheduleId}`)
- [`automations.updateMessageTrigger`](https://docs.maitento.com/reference/api/automations.md) (`PUT /automated-actions/by-id/{id}/message-triggers/{triggerId}`)
- [`automations.updateSchedule`](https://docs.maitento.com/reference/api/automations.md) (`PUT /automated-actions/by-id/{id}/schedules/{scheduleId}`)
- [`automations.update`](https://docs.maitento.com/reference/api/automations.md) (`PUT /automated-actions/by-id/{id}`)
