---
title: "Trim dataset by duration"
method: POST
path: "/datasets/{dataset_id}/trim"
tags: ["datasets"]
---

# Trim dataset by duration

`POST /datasets/{dataset_id}/trim`

## Request

- Base URL: `https://api.axiom.co/v2`
- URL: `https://api.axiom.co/v2/datasets/{dataset_id}/trim`
- Auth: OAuth 2
  - Authorization code: `https://accounts.google.com/o/oauth2/v2/auth`
  - Token URL: `https://www.googleapis.com/oauth2/v4/token` scopes: `trim|update`
- TypeScript: <https://skmtc.dev/axiom/apis/axiom-public-api/docs/datasets/:dataset_id/trim/post.ts> (a function with typed inputs; its response is checked against the schema)

Queues a job that deletes data older than `maxDuration` from an events, logs, or metrics dataset, and returns the job ID. Deletion runs asynchronously.

## Path parameters

- `dataset_id` string, required

## Request body

- TrimOptions
  - `maxDuration` string, required

## Response `200`

Job created

- JobCreateResponse
  - `jobID` string, required

## Other responses

- `403`: Forbidden
- `404`: Not found

## Changes

- **2026-10-14** (v2) `8920e1697284`: 1 breaking, 1 info
  - removed the success response with the status `204`
  - added the success response with the status `200`

[Operation history](https://skmtc.dev/axiom/apis/axiom-public-api/changes/datasets/:dataset_id/trim/post.md)

---

[API](https://skmtc.dev/axiom/apis/axiom-public-api.md) - [All operations](https://skmtc.dev/axiom/apis/axiom-public-api/llms.txt) - [OpenAPI document](https://skmtc.dev/axiom/apis/axiom-public-api/revisions/7e39a295e3ba?raw)
