# Trigger automation (https://docs.capy.ai/api-reference/automations/trigger-automation)

`POST https://api.capy.ai/api/v1/automations/{automationId}/trigger`

## Authorization

Send an API key as a bearer token: `Authorization: Bearer $CAPY_API_KEY`. See https://docs.capy.ai/api-reference/authentication.md.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `automationId` | path | string | yes |  |

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `requestId` | string | yes |  |

## Responses

- `200` AutomationRun: `AutomationRunEncoded`
- `400` capy/InvalidRequest: `capy_InvalidRequestEncoded`
- `401` capy/Unauthorized: `capy_UnauthorizedEncoded`
- `403` capy/Forbidden: `capy_ForbiddenEncoded \| capy_ForbiddenEncoded`
- `404` capy/AutomationNotFound: `capy_AutomationNotFoundEncoded`
- `429` capy/RateLimited: `capy_RateLimitedEncoded`

## Example

```bash
curl -X POST "https://api.capy.ai/api/v1/automations/{automationId}/trigger" \
  -H "Authorization: Bearer $CAPY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"requestId":"<requestId>"}'
```

## Referenced schemas

```json
{
  "AutomationRunEncoded": {
    "type": "object",
    "properties": {
      "id": {
        "type": "string"
      },
      "automationId": {
        "type": "string"
      },
      "status": {
        "type": "string",
        "enum": [
          "queued",
          "running",
          "completed",
          "failed",
          "skipped",
          "cancelled"
        ]
      },
      "jamId": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "failure": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "startedAt": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "completedAt": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "createdAt": {
        "type": "string"
      }
    },
    "required": [
      "id",
      "automationId",
      "status",
      "jamId",
      "failure",
      "startedAt",
      "completedAt",
      "createdAt"
    ],
    "additionalProperties": false
  },
  "capy_InvalidRequestEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/InvalidRequest"
        ]
      },
      "message": {
        "type": "string"
      }
    },
    "required": [
      "_tag",
      "message"
    ],
    "additionalProperties": false
  },
  "capy_UnauthorizedEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/Unauthorized"
        ]
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  },
  "capy_ForbiddenEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/Forbidden"
        ]
      },
      "mfaRequiredOrgId": {
        "type": "string"
      },
      "ssoRequired": {
        "type": "boolean"
      },
      "passkeyRequired": {
        "type": "boolean"
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  },
  "capy_AutomationNotFoundEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/AutomationNotFound"
        ]
      },
      "automationId": {
        "type": "string"
      }
    },
    "required": [
      "_tag",
      "automationId"
    ],
    "additionalProperties": false
  },
  "capy_RateLimitedEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/RateLimited"
        ]
      },
      "retryAfterSeconds": {
        "type": "integer"
      }
    },
    "required": [
      "_tag",
      "retryAfterSeconds"
    ],
    "additionalProperties": false
  },
  "TriggerAutomationRequest": {
    "type": "object",
    "properties": {
      "requestId": {
        "type": "string",
        "allOf": [
          {
            "minLength": 1
          },
          {
            "maxLength": 160
          }
        ]
      }
    },
    "required": [
      "requestId"
    ],
    "additionalProperties": false
  }
}
```

Full document: https://docs.capy.ai/openapi.json