> ## Documentation Index
> Fetch the complete documentation index at: https://docs.amps.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancelling

> Cancel a scheduled action before it runs.

Cancel an action that hasn't started yet. Only actions in `scheduled` state can be cancelled.

## Cancel by ID

```bash theme={null}
curl -X POST https://api.amps.ai/actions/action_qjSucnQFAk/cancel \
  -H "x-api-key: $AMPS_API_KEY"
```

```json theme={null}
{
  "success": true,
  "data": {
    "id": "action_qjSucnQFAk",
    "state": "cancelled",
    "completedAt": "2026-05-08T11:32:00.000Z"
  }
}
```

The API returns `202` with the cancelled action. It won't run, and no webhook is sent for it. If it was windowed, nothing is reverted at `end`.

## What can be cancelled

| State | Cancellable |
| - | - |
| `scheduled` | Yes |
| `acknowledged` | No. It's already been sent to the device. |
| `completed`, `failed`, `cancelled` | No. These are final. |

Anything other than `scheduled` returns `409 ACTION_NOT_CANCELLABLE`.

```json theme={null}
{
  "success": false,
  "error": {
    "code": "ACTION_NOT_CANCELLABLE",
    "message": "The action cannot be cancelled in its current state.",
    "details": {
      "description": "Action in state 'acknowledged' cannot be cancelled"
    }
  }
}
```

To undo a command that has already run, push a new one, such as `idle`.

## Cancel and replace in one request

If you're cancelling to send something else, push the new action with `onConflict: "cancel_and_replace"`. This cancels the scheduled action and accepts the new one in one request, so the old one can't start in between. See [Conflicts](/guides/push/conflicts).

## Find actions to cancel

```bash theme={null}
curl "https://api.amps.ai/actions?deviceId=device_abc123&state=scheduled" \
  -H "x-api-key: $AMPS_API_KEY"
```

## Next steps

<CardGroup cols={2}>
  <Card title="Conflicts" icon="code-merge" href="/guides/push/conflicts">
    Replace or queue behind an active action.
  </Card>

  <Card title="Push" icon="arrow-up" href="/guides/push">
    Action states and how to track them.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.