# Cancel batch (https://docs.capy.ai/api-reference/automations/cancel-batch)

`POST https://api.capy.ai/api/v1/automations/{automationId}/batches/{batchId}/cancel`

## 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 |  |
| `batchId` | path | string | yes |  |

## Responses

- `200` AutomationWebhookBatch: `AutomationWebhookBatchEncoded`
- `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}/batches/{batchId}/cancel" \
  -H "Authorization: Bearer $CAPY_API_KEY"
```

## Referenced schemas

```json
{
  "AutomationWebhookBatchEncoded": {
    "type": "object",
    "properties": {
      "id": {
        "type": "string"
      },
      "automationId": {
        "type": "string"
      },
      "triggerId": {
        "type": "string"
      },
      "status": {
        "$ref": "#/components/schemas/WebhookBatchStatus"
      },
      "group": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/WebhookBatchGroupValue"
        }
      },
      "eventCount": {
        "type": "integer"
      },
      "byteCount": {
        "type": "integer"
      },
      "firstEventAt": {
        "type": "string"
      },
      "lastEventAt": {
        "type": "string"
      },
      "dispatchAfter": {
        "type": "string"
      },
      "maxEvents": {
        "type": "integer"
      },
      "maxWaitSeconds": {
        "type": "integer"
      },
      "quietPeriodSeconds": {
        "anyOf": [
          {
            "type": "integer"
          },
          {
            "type": "null"
          }
        ]
      },
      "closedAt": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "reason": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/WebhookBatchReason"
          },
          {
            "type": "null"
          }
        ]
      },
      "runId": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "runStatus": {
        "anyOf": [
          {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "completed",
              "failed",
              "skipped",
              "cancelled"
            ]
          },
          {
            "type": "null"
          }
        ]
      },
      "jamId": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "failure": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      }
    },
    "required": [
      "id",
      "automationId",
      "triggerId",
      "status",
      "group",
      "eventCount",
      "byteCount",
      "firstEventAt",
      "lastEventAt",
      "dispatchAfter",
      "maxEvents",
      "maxWaitSeconds",
      "quietPeriodSeconds",
      "closedAt",
      "reason",
      "runId",
      "runStatus",
      "jamId",
      "failure"
    ],
    "additionalProperties": false
  },
  "WebhookBatchStatus": {
    "type": "string",
    "enum": [
      "collecting",
      "queued",
      "cancelled"
    ],
    "description": "Collecting accepts events; queued has one automation run; cancelled retains scrubbed history without a run."
  },
  "WebhookBatchGroupValue": {
    "anyOf": [
      {
        "type": "string"
      },
      {
        "type": "number"
      },
      {
        "type": "boolean"
      }
    ],
    "description": "A non-null finite JSON scalar; string, number, and boolean grouping values remain distinct."
  },
  "WebhookBatchReason": {
    "type": "string",
    "enum": [
      "count",
      "quiet",
      "max_wait",
      "bytes",
      "manual",
      "cancelled",
      "configuration_changed",
      "disabled",
      "project_deleted"
    ],
    "description": "The boundary that closed or cancelled a webhook batch."
  },
  "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
  }
}
```

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