# Maintenance Windows

## GET /api/maintenance-windows

Retrieve a paginated list of maintenance windows across your chargers. For parent organization API keys, this returns maintenance windows for all child organizations.

### Parameters

Parameters should be passed as query parameters on the URL.

* `afterTimestamp` - ISO 8601 date string. Returns maintenance windows that overlap with the time after this point (i.e. windows whose end time is after this timestamp)
* `beforeTimestamp` - ISO 8601 date string. Returns maintenance windows that overlap with the time before this point (i.e. windows whose start time is before this timestamp). When used together with `afterTimestamp`, returns windows overlapping the `[afterTimestamp, beforeTimestamp]` range.
* `chargerIds` - Filter to maintenance windows for specific charger IDs. To filter by multiple chargers, repeat the parameter: `&chargerIds=1&chargerIds=2`. When combined with `siteIds`, only chargers matching both filters are returned.
* `siteIds` - Filter to maintenance windows for chargers at specific site IDs. To filter by multiple sites, repeat the parameter: `&siteIds=1&siteIds=2`. When combined with `chargerIds`, only chargers matching both filters are returned.
* `organizationIds` - Filter to maintenance windows for specific organization IDs (only applicable for parent organization API keys). To filter by multiple organizations, repeat the parameter: `&organizationIds=1&organizationIds=2`. Requested IDs are intersected with the organizations accessible by the API key.
* `nextPageCursor` - When the filters match more than one page of data, pass this parameter to fetch the next page

### Response

The JSON response will contain a `data` field with a list of maintenance windows matching the filters (up to 50 per page), and a `pagination` field containing pagination details.

```ts
{
  data: {
    id: number;
    startTimestamp: string; // ISO 8601 format
    endTimestamp: string; // ISO 8601 format
    comment: string | null;
    userEmail: string; // Email of the user who created the window
    createdAt: string; // ISO 8601 format
    updatedAt: string; // ISO 8601 format
    charger: {
      id: number;
      name: string;
      manufacturer: string | null;
      model: string | null;
      networkServiceProvider: string;
      chargerType: string;
      serialNumber: string | null;
      numberOfPorts: number;
      latitude: number | null;
      longitude: number | null;
      externalId: string | null;
      ocppId: string | null;
    };
    site: {
      id: number;
      name: string;
      locationId: string | null;
    };
    organization: {
      id: number;
      name: string;
    };
  }[];
  pagination: {
    hasNextPage: boolean;
    nextPageCursor: string | null;
  };
}
```

### Example request and response

Request all maintenance windows:

```sh
curl "https://api.getflipturn.com/api/maintenance-windows" -H "Authorization: Bearer {api_key}"
```

Request maintenance windows overlapping a date range:

```sh
curl "https://api.getflipturn.com/api/maintenance-windows?afterTimestamp=2025-01-01T00:00:00Z&beforeTimestamp=2025-02-01T00:00:00Z" -H "Authorization: Bearer {api_key}"
```

Request maintenance windows for specific chargers:

```sh
curl "https://api.getflipturn.com/api/maintenance-windows?chargerIds=123&chargerIds=456" -H "Authorization: Bearer {api_key}"
```

Request maintenance windows for a specific child organization (parent org API key):

```sh
curl "https://api.getflipturn.com/api/maintenance-windows?organizationIds=5" -H "Authorization: Bearer {api_key}"
```

Response:

```json
{
  "data": [
    {
      "id": 1,
      "startTimestamp": "2025-01-15T08:00:00.000Z",
      "endTimestamp": "2025-01-15T12:00:00.000Z",
      "comment": "Dispenser Rotation",
      "userEmail": "tech@example.com",
      "createdAt": "2025-01-14T20:00:00.000Z",
      "updatedAt": "2025-01-14T20:00:00.000Z",
      "charger": {
        "id": 123,
        "name": "DCFC-001",
        "manufacturer": "ABB",
        "model": "Terra 184",
        "networkServiceProvider": "Flipturn",
        "chargerType": "DCFC",
        "serialNumber": "1234-5678",
        "numberOfPorts": 2,
        "latitude": 30.2672,
        "longitude": -97.7431,
        "externalId": "STATION-001",
        "ocppId": "CHARGER-001"
      },
      "site": {
        "id": 1,
        "name": "Main Depot",
        "locationId": null
      },
      "organization": {
        "id": 1,
        "name": "Example Transit Authority"
      }
    }
  ],
  "pagination": {
    "hasNextPage": false,
    "nextPageCursor": null
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api-docs.getflipturn.com/maintenance-windows.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
