# Get timeseries data for a task

> Source: https://docs.clonepartner.com/api-reference/metrics/get-metrics-timeseries/

`GET /api/metrics/data/timeseries/{taskId}`

Daily data points from the metrics database.

**Operation ID:** `getMetricsTimeseries`

## Authentication

### Option 1

- **BearerAuth** (`http bearer`)
  API key token. Create via POST /api/api-keys. Format: `envoy_<hex>`

### Option 2

- **CookieAuth** (`apiKey`)
  Session cookie set after login + TOTP verification

## Path parameters

- `taskId` — `integer`, `required`

## Query parameters

- `days` — `integer`
  Number of days to look back
  Example: `30`
  - Default: `30`
  - Maximum: 90

## Success responses

### 200

Timeseries data

**Content type:** `application/json`

- Type: `object`
- Properties:
  - `available` (`boolean`)
  - `task` (`string`)
  - `points` (`array<object>`)
    - Items:
      - Type: `object`
      - Properties:
        - `day` (`string`)
          - Format: `date`
        - `success` (`integer`)
        - `error` (`integer`)
        - `avg_duration_ms` (`number`)
        - `total_items` (`integer`)

## Error responses

### 404

Resource not found

**Content type:** `application/json`

- Reference: `Error`
  - Type: `object`
  - Properties:
    - `error` (`string`)
      - Example: `NOT_FOUND`
    - `message` (`string`)
      - Example: `Resource not found`

Example:

```json
{
  "error": "NOT_FOUND",
  "message": "Resource not found"
}
```

## Examples

### cURL

```bash
curl --request GET \
  --url 'https://your-envoy.example.com/api/metrics/data/timeseries/YOUR_TASK_ID' \
  --header 'Authorization: Bearer $API_KEY'
```

### JavaScript (fetch)

```javascript
const response = await fetch('https://your-envoy.example.com/api/metrics/data/timeseries/YOUR_TASK_ID', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
  },
});

if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = response.status === 204 ? null : await response.json();
console.log(data);
```
