---
title: "Create a metric."
method: POST
path: "/v2/metrics"
tags: ["Metrics"]
---

# Create a metric.

`POST /v2/metrics`

## Headers

- `Idempotency-Key` string — Non-empty idempotency key for deduplicating write requests on the same route.

## Request body

- MetricRequest — Create-metric request. Unknown JSON fields are rejected.
  - `name` string, required — Human-readable name. Maximum 256 Unicode scalar values.
  - `description` string, nullable — Optional description. Maximum 2048 Unicode scalar values.
  - `measurement_units` string, nullable — Optional unit of measure for the metric, such as m, ft, seconds, or tokens.

## Response `200`

Created.

- Metric
  - `id` string, required — LedgerUp metric identifier.
  - `name` string, required — Human-readable name. Maximum 256 Unicode scalar values.
  - `description` string, nullable, required — Optional description. Maximum 2048 Unicode scalar values.
  - `measurement_units` string, nullable, required — Optional unit of measure for the metric, such as m, ft, seconds, or tokens.
  - `created_at` integer, required — Unix timestamp in seconds.
  - `updated_at` integer, required — Unix timestamp in seconds.
  - `archived_at` integer, required — Unix timestamp in seconds.

## Other responses

- `400` — Bad request, invalid header, invalid amount/quantity/currency, or text validation failure.
- `401` — Missing or invalid API key.
- `403` — API key lacks the required permission, or reset was attempted outside the test namespace.
- `408` — Request exceeded the 30 second timeout.
- `409` — Duplicate idempotency key, uniqueness conflict, or foreign-key conflict.
- `413` — Request body exceeded the 256 KiB limit.
- `415` — Write request content type was not application/json.
- `422` — Semantically invalid request, such as a service period with start greater than end.
- `429` — Rate limit exceeded.
- `500` — Internal server error or queue failure.

---

[API](https://skmtc.dev/ledgerup/apis/ledgerup-api.md) · [All operations](https://skmtc.dev/ledgerup/apis/ledgerup-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/ledgerup/ledgerup-api/revisions/be257191807b/schema)
