---
title: "Create and run a metric collection job"
method: POST
path: "/v1/metric/collection-jobs"
tags: ["Metric Collection Job"]
---

# Create and run a metric collection job

`POST /v1/metric/collection-jobs`

Creates a metric collection job for the specified calls or chats and metrics, then triggers processing. Provide exactly one of callIds or chatIds.

## Request body

- CreateMetricCollectionJobInput — Input for creating and running a metric collection job
  - `callIds` string[] — Call IDs to collect metrics for. Mutually exclusive with chatIds.
  - `chatIds` string[] — Chat IDs to collect metrics for. Mutually exclusive with callIds.
  - `metrics` object[], required — Metric definitions to collect
    - `id` string, uuid, required

## Response `201`

The created metric collection job

- object
  - `data` MetricCollectionJobResponse, required — A metric collection job that processes metrics for calls or chats
    - `id` string, uuid, required — Unique identifier of the metric collection job
    - `status` 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'CANCELED', required — Current status of the job
    - `triggeredBy` 'USER_MANUAL' | 'USER_API' | 'METRIC_POLICY' | 'SIMULATION', required — What triggered this job
    - `totalItems` integer, required — Total number of call-metric pairs to process
    - `completedItems` integer, required — Number of successfully completed items
    - `failedItems` integer, required — Number of failed items
    - `startedAt` string, nullable, required — When the job started processing
    - `completedAt` string, nullable, required — When the job completed
    - `errorMessage` string, nullable, required — Error message if the job failed
    - `policyIds` string[], required — IDs of the metric policies that triggered this job
    - `createdAt` string, required — When the job was created
    - `updatedAt` string, required — When the job was last updated

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `403` — Forbidden
- `429` — Too Many Requests
- `500` — Internal Server Error

---

[API](https://skmtc.net/roarkhq/apis/roark-analytics-api.md) · [All operations](https://skmtc.net/roarkhq/apis/roark-analytics-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/roarkhq/roark-analytics-api/revisions/83528d3618ef/schema)
