# Get workflow analytics by owner, team or source

`GET /v4/workflows/{id}/analytics/breakdowns`

The headline numbers per owner, team, source or source group, one dimension per call. `truncated` is true when there were more rows than returned; `overlapping` is true when a record counts in several rows (teams). A row with a null `id` is the unassigned bucket. Requires `workflows:read`.

The numbers cover the whole workspace, so only managers' tokens and API keys get them; tokens of users with restricted record access get `403 ANALYTICS_RESTRICTED`. Leave out both dates for the last 90 days, ending today in the workspace's timezone; the span is at most 730 days. While the analytics replica is being prepared: `503 ANALYTICS_NOT_READY` with `Retry-After: 60`.

Authentication (security requirement alternatives):

```json
[
  {
    "bearer_auth": [
      "workflows:read"
    ]
  },
  {
    "oauth2_auth": [
      "workflows:read"
    ]
  },
  {
    "apikey_auth": [
      "workflows:read"
    ]
  }
]
```

- bearer_auth: http (bearer). API key or OAuth access token in Authorization header; scopes: workflows:read
- oauth2_auth: oauth2. OAuth authorization code flow with mandatory S256 PKCE.; scopes: workflows:read
- apikey_auth: apiKey, query api_key. API key in query string; scopes: workflows:read

Parameters:

- `id` (path, string, required) - Workflow ID from GET /v4/workflows
  Type: string

- `from_date` (query, string, optional) - YYYY-MM-DD, with to_date
  Type: string

- `to_date` (query, string, optional) - YYYY-MM-DD, with from_date
  Type: string

- `owner_ids` (query, string, optional) - Comma-separated user IDs, at most 100
  Type: string

- `team_ids` (query, string, optional) - Comma-separated team IDs, at most 100
  Type: string

- `source_ids` (query, string, optional) - Comma-separated source IDs, at most 100
  Type: string

- `source_group_ids` (query, string, optional) - Comma-separated source group IDs, at most 100
  Type: string

- `type_ids` (query, string, optional) - Comma-separated record type IDs, at most 100
  Type: string

- `by` (query, string, required) - owners, teams, sources or source_groups
  Type: string

Responses:

- 200: Workflow analytics breakdown

Content type: application/json

Type: object

Schema: [WorkflowAnalyticsBreakdownResponse](https://docs.searchsoftware.nl/api/models/workflowanalyticsbreakdownresponse.md)

- `status` (required)
  Type: string
  
  enum: ["ok"]
  
  Example:
  
  ```json
  "ok"
  ```

- `data` (required)
  Reference: [WorkflowAnalyticsBreakdownData](https://docs.searchsoftware.nl/api/models/workflowanalyticsbreakdowndata.md); Type: object

- 401: Invalid API key

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "INVALID_API_KEY",
    "status_code": 401,
    "message": "Invalid API key"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "INVALID_API_KEY",
    "status_code": 401,
    "message": "Invalid API key"
  }
}
```

- 403: Insufficient scope, or restricted record access

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "FORBIDDEN",
    "status_code": 403,
    "message": "Insufficient scope"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "FORBIDDEN",
    "status_code": 403,
    "message": "Insufficient scope"
  }
}
```

- 404: Workflow not found

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "NOT_FOUND",
    "status_code": 404,
    "message": "Record not found"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "NOT_FOUND",
    "status_code": 404,
    "message": "Record not found"
  }
}
```

- 422: Invalid filters

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "VALIDATION_FAILED",
    "status_code": 422,
    "message": "Validation failed"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "VALIDATION_FAILED",
    "status_code": 422,
    "message": "Validation failed"
  }
}
```

- 500: Internal server error

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "INTERNAL_ERROR",
    "status_code": 500,
    "message": "Internal server error"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "INTERNAL_ERROR",
    "status_code": 500,
    "message": "Internal server error"
  }
}
```

- 503: Analytics not ready or unavailable

Content type: application/json

Type: object

Schema: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md)

- `status` (required)
  Type: string
  
  enum: ["error"]
  
  Example:
  
  ```json
  "error"
  ```

- `error` (required)
  Reference: [ErrorBody](https://docs.searchsoftware.nl/api/models/errorbody.md); Type: object

## Examples

### cURL

```bash
curl -X GET 'https://api.searchsoftware.nl/v4/workflows/string/analytics/breakdowns?by=string' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### TypeScript

```typescript
const response = await fetch('https://api.searchsoftware.nl/v4/workflows/string/analytics/breakdowns?by=string', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://api.searchsoftware.nl/v4/workflows/string/analytics/breakdowns?by=string',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```

### Ruby

```ruby
require 'net/http'
require 'json'

uri = URI('https://api.searchsoftware.nl/v4/workflows/string/analytics/breakdowns?by=string')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer YOUR_TOKEN'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(request) }
data = JSON.parse(response.body)
```

### Go

```go
package main

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

func main() {
  req, _ := http.NewRequest("GET", "https://api.searchsoftware.nl/v4/workflows/string/analytics/breakdowns?by=string", nil)
  req.Header.Set("Authorization", "Bearer YOUR_TOKEN")
  resp, _ := http.DefaultClient.Do(req)
  defer resp.Body.Close()
  data, _ := io.ReadAll(resp.Body)
  fmt.Println(string(data))
}
```

### PHP

```php
<?php
$ch = curl_init('https://api.searchsoftware.nl/v4/workflows/string/analytics/breakdowns?by=string');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer YOUR_TOKEN']);

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
```

### Rust

```rust
use reqwest;

#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
    let client = reqwest::Client::new();
    let response = client.get("https://api.searchsoftware.nl/v4/workflows/string/analytics/breakdowns?by=string")
        .header("Authorization", "Bearer YOUR_TOKEN")
        .send()
        .await?
        .text()
        .await?;
    println!("{}", response);
    Ok(())
}
```
