> ## 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.

# Charge in a cheap-rate window

> Charge a battery between a start and end time, such as an overnight off-peak tariff.

Charge a battery during an off-peak tariff window by sending `charge` with a `start` and an `end`. Amps runs the charge at `start` and takes it back at `end`, with no further calls from you.

## 1. Check the battery supports it

The battery must list `windowed` in `commands.charge.execution`.

```bash theme={null}
curl https://api.amps.ai/battery/device_abc123 \
  -H "x-api-key: $AMPS_API_KEY"
```

```json theme={null}
{
  "success": true,
  "data": {
    "id": "device_abc123",
    "commands": {
      "charge": {
        "parameters": {
          "target": { "unit": "percent", "min": 10, "max": 100 },
          "power": { "unit": "kw", "min": 0, "max": 5 }
        },
        "execution": ["immediate", "scheduled", "windowed"]
      }
    }
  }
}
```

If `windowed` is missing, the push returns `422 DEVICE_NOT_CAPABLE` with the supported shapes in `details.supportedExecution`.

## 2. Send the command

Charge to 90% between 00:30 and 04:30, capped at 3 kW. Times are the battery's local time, with no offset. See [Scheduling](/guides/scheduling).

```bash theme={null}
curl -X POST https://api.amps.ai/battery/device_abc123 \
  -H "x-api-key: $AMPS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action": {
      "command": "charge",
      "start": "2026-11-12T00:30:00",
      "end": "2026-11-12T04:30:00",
      "parameters": {
        "target": { "value": 90, "unit": "percent" },
        "power": { "value": 3, "unit": "kw" }
      }
    }
  }'
```

```json theme={null}
{
  "success": true,
  "data": {
    "id": "action_xyVCcLiYU9",
    "command": "charge",
    "state": "scheduled",
    "start": "2026-11-12T00:30:00.000Z",
    "end": "2026-11-12T04:30:00.000Z",
    "links": { "self": "/actions/action_xyVCcLiYU9" }
  }
}
```

The API returns `202 Accepted`. The action stays `scheduled` until `start`. To open the window now, leave out `start`: the charge is sent straight away and the action comes back `acknowledged` with its `end`. If the battery already has a pending action, you get a `409`; see [Conflicts](/guides/push/conflicts).

## 3. Confirm

Listen for `push.completed` or `push.failed` on your [webhook](/guides/webhooks), or read the action at `links.self`. See [Push](/guides/push) for the action lifecycle.

## Next steps

<CardGroup cols={2}>
  <Card title="Discharge during a peak" icon="bolt" href="/cookbooks/battery/discharge-in-window">
    The same window shape, for discharging.
  </Card>

  <Card title="Cancel an action" icon="xmark" href="/guides/push/cancelling">
    Cancel the window before it starts.
  </Card>
</CardGroup>


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