# Export a report — API reference

> Downloads the selected report as CSV, JSON, PDF or XLSX for a chosen reporting window.

Source: https://upfour.io/docs/api/reports/export-a-report

[Developers](https://upfour.io/docs/api.md)/[Reports](https://upfour.io/docs/api/reports.md)

Downloads the selected report as CSV, JSON, PDF or XLSX for a chosen reporting window.

GET https://app.upfour.io/v1/reports/export

scope report.read stable returns 200

## Parameters

| Field | Type | Description |
| --- | --- | --- |
| `type` optional | string one of`monitors` `summary` `trends` `incidents` `sla` `response-time` `downtime-ledger` default `"monitors"` | query parameter · Which report to render. |
| `format` optional | string one of`csv` `json` `pdf` `xlsx` default `"csv"` | query parameter · File format of the download (default `csv`). |
| `preset` optional | string one of`24h` `7d` `30d` `90d` `mtd` `last_month` `qtd` `ytd` | query parameter · Reporting window; `period` is accepted as an alias. Without `preset`, `from` and `to` the window is the last 30 days. The window is cut to the plan's history. |
| `from` optional | string | query parameter · Start of the window: an RFC 3339 timestamp or a date (`YYYY-MM-DD`, in `tz`). Replaces `preset`. |
| `to` optional | string | query parameter · End of the window, same formats as `from`; a date means the end of that day. Defaults to now. |
| `tz` optional | string | query parameter · IANA time zone for calendar presets and dates. Defaults to the Company's report time zone. |
| `lang` optional | string one of`en` `de` default `"en"` | query parameter · Language of the report text. |
| `monitor_id` optional | uuid | query parameter · Only this monitor; repeat the parameter or send a comma-separated list for several. |
| `severity` optional | string | query parameter · Incident reports only: keep incidents of this severity; repeat the parameter or send a comma-separated list for several. |
| `q` optional | string | query parameter · Case-insensitive text: keeps monitors whose name, or incidents whose title, contains it. |
| `business_hours` optional | string | query parameter · Count only these hours in SLA and response-time reports, for example `mon-fri,09:00-17:00` (several groups separated by `;`). The hours are read in `tz`, or in UTC when `tz` is not sent. |
| `client_id` optional | uuid | query parameter · Report on one client. |
| `all_clients` optional | boolean | query parameter · `true` includes all clients; without `client_id` the report covers the Company level. |
| `target` optional | number 0–100 | query parameter · Only for `type=sla`: replaces every monitor's SLA target (percent, 0 to 100). |

## Returns

A successful request returns `200` with application/json, application/pdf, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, text/csv.

Response fields 1 top-level fields

| Field | Type | Description |
| --- | --- | --- |
| `(body)` | object free-form keys | |

## Errors

Only the errors this operation can return. Every error uses the [same envelope](https://upfour.io/docs/api/responses.md).

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | [bad_request](https://upfour.io/docs/api/errors#code-bad_request) | The request is malformed or fails validation. |
| 403 | [permission_denied](https://upfour.io/docs/api/errors#code-permission_denied) | The credentials do not permit this action. |

Every call can also return `unauthorized` (401), `rate_limit_exceeded` (429) or `internal_error` (500 / 502). See [Responses and errors](https://upfour.io/docs/api/responses.md).

[PreviousGet the agency ribbon](https://upfour.io/docs/api/reports/get-the-agency-ribbon.md) [NextList report schedules](https://upfour.io/docs/api/reports/list-report-schedules.md)

## Request

### cURL

```bash
curl -s "https://app.upfour.io/v1/reports/export?format=json" \
  -H "Authorization: Bearer $UP4_API_KEY"
```

### JavaScript

```javascript
const res = await fetch("https://app.upfour.io/v1/reports/export?format=json", {
  headers: {
    Authorization: `Bearer ${process.env.UP4_API_KEY}`,
  },
});
console.log(res.status, await res.json());
```

### Python

```python
import os
import requests

res = requests.get(
    "https://app.upfour.io/v1/reports/export?format=json",
    headers={"Authorization": f"Bearer {os.environ['UP4_API_KEY']}"},
)
print(res.status_code, res.json())
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
)

func main() {
	req, _ := http.NewRequest("GET", "https://app.upfour.io/v1/reports/export?format=json", nil)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("UP4_API_KEY"))
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	out, _ := io.ReadAll(res.Body)
	fmt.Println(res.StatusCode, string(out))
}
```

### PHP

```php
<?php
$ch = curl_init("https://app.upfour.io/v1/reports/export?format=json");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("UP4_API_KEY"),
    ],
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), " ", $response, "\n";
curl_close($ch);
```

## Response

### 200

```json
{}
```

### 400

```json
{
  "error": {
    "code": "bad_request",
    "message": "The request is malformed or fails validation.",
    "request_id": "req_…"
  }
}
```

### 403

```json
{
  "error": {
    "code": "permission_denied",
    "message": "The credentials do not permit this action.",
    "request_id": "req_…"
  }
}
```
