---
title: "Create Case Duration"
method: POST
path: "/workspaces/{workspace_id}/cases/{case_id}/durations"
tags: ["case-durations"]
---

# Create Case Duration

`POST /workspaces/{workspace_id}/cases/{case_id}/durations`

## Request

- Base URL: `https://platform.tracecat.com/api`
- URL: `https://platform.tracecat.com/api/workspaces/{workspace_id}/cases/{case_id}/durations`
- Auth: one of:
  - API key in cookie `fastapiusersauth`
  - HTTP bearer

Create a persisted case duration.

## Path parameters

- `case_id` string, uuid, required
- `workspace_id` string, uuid, required

## Request body

- CaseDurationCreate: Create payload for case duration records.
  - `definition_id` string, uuid, required: Identifier of the case duration definition generating this duration.
  - `start_event_id` string, uuid, nullable: Case event that started the duration, if available.
  - `end_event_id` string, uuid, nullable: Case event that ended the duration, if available.
  - `started_at` string, date-time, nullable: Timestamp when the duration began.
  - `ended_at` string, date-time, nullable: Timestamp when the duration ended.
  - `duration` string, duration, nullable: Total elapsed time between start and end timestamps.

## Response `201`

Successful Response

- CaseDurationRead: Read model for case duration records.
  - `definition_id` string, uuid, required: Identifier of the case duration definition generating this duration.
  - `start_event_id` string, uuid, nullable: Case event that started the duration, if available.
  - `end_event_id` string, uuid, nullable: Case event that ended the duration, if available.
  - `started_at` string, date-time, nullable: Timestamp when the duration began.
  - `ended_at` string, date-time, nullable: Timestamp when the duration ended.
  - `duration` string, duration, nullable: Total elapsed time between start and end timestamps.
  - `id` string, uuid, required
  - `case_id` string, uuid, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/tracecat/apis/tracecat-api.md) - [All operations](https://skmtc.dev/tracecat/apis/tracecat-api/llms.txt) - [OpenAPI document](https://skmtc.dev/tracecat/apis/tracecat-api/revisions/2efdda25045f?raw)
