---
title: "Delete a trace"
description: "Use `start_time` and `end_time` to narrow deletion to the relevant time range. Deletion is asynchronous: the trace leaves List traces right away, but its spans can stay visible in List spans and Get a trace for several minutes. An unknown ID also returns 200."
---

<a id="playground-button:docs/apis/traces/delete-trace"></a>

**DELETE** `https://api.respan.ai/api/traces/{trace_unique_id}/`

Use `start_time` and `end_time` to narrow deletion to the relevant time range. Deletion is asynchronous: the trace leaves List traces right away, but its spans can stay visible in List spans and Get a trace for several minutes. An unknown ID also returns 200.

## Servers

`https://api.respan.ai` — Respan API Server

<a id="request.auth"></a>

## Authentication

<a id="request.auth.Authorization"></a>

### RespanApiKey

Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer &lt;RESPAN_API_KEY&gt;. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -&gt; Providers or respan_params.credential_override in the request body, not in this authentication field.

HTTP scheme: `bearer`; format: `Respan API key`.


```http
Authorization: Bearer $RESPAN_API_KEY
```


**Or:**

### DashboardJwt

Use a dashboard JWT only for dashboard-authenticated endpoints. Respan API-key endpoints use the respanApiKey auth field instead.

HTTP scheme: `bearer`; format: `Dashboard JWT`.


```http
Authorization: Bearer $RESPAN_DASHBOARD_JWT
```


<a id="request.path"></a>

## Path parameters


| Parameter | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| <a id="request.path.trace_unique_id"></a>`trace_unique_id` | `string` | Required | Unique trace identifier. |


<a id="request.query"></a>

## Query parameters


| Parameter | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| <a id="request.query.start_time"></a>`start_time` | `string` | Optional | Start of time range (ISO 8601). Defaults to one hour before `end_time` when omitted.<br />Format: `date-time`<br />Example: `"2025-01-01T00:00:00Z"` |
| <a id="request.query.end_time"></a>`end_time` | `string` | Optional | End of time range (ISO 8601). Defaults to now when omitted.<br />Format: `date-time`<br />Example: `"2025-01-31T23:59:59Z"` |


<a id="response"></a>

## Responses

### 200

Trace delete issued successfully.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | — |
| <a id="response.body.message"></a>`message` | `string` | Required in parent | Delete confirmation message. |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "Delete confirmation message."
    }
  },
  "required": [
    "message"
  ]
}
```

</details>

##### Example


```json
{
  "message": "Successfully deleted trace trace_abc123"
}
```


<a id="response.error"></a>

### 403

The API key is missing, invalid or expired.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | — |
| `detail` | `string` | Required in parent | — |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
```


### 500

Internal Server Error

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | — |
| `detail` | `string` | Optional | Example: `"Internal server error"` |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "example": "Internal server error"
    }
  }
}
```

</details>

## OpenAPI source

The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.

<!-- openapi-operation:start -->
<details class="api-schema-source">
<summary>OpenAPI operation</summary>


```json
{
  "summary": "Delete a trace",
  "operationId": "deleteTrace",
  "tags": [
    "Traces"
  ],
  "description": "Use `start_time` and `end_time` to narrow deletion to the relevant time range. Deletion is asynchronous: the trace leaves List traces right away, but its spans can stay visible in List spans and Get a trace for several minutes. An unknown ID also returns 200.",
  "parameters": [
    {
      "name": "trace_unique_id",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string"
      },
      "description": "Unique trace identifier."
    },
    {
      "name": "start_time",
      "in": "query",
      "schema": {
        "type": "string",
        "format": "date-time"
      },
      "description": "Start of time range (ISO 8601). Defaults to one hour before `end_time` when omitted.",
      "example": "2025-01-01T00:00:00Z"
    },
    {
      "name": "end_time",
      "in": "query",
      "schema": {
        "type": "string",
        "format": "date-time"
      },
      "description": "End of time range (ISO 8601). Defaults to now when omitted.",
      "example": "2025-01-31T23:59:59Z"
    }
  ],
  "responses": {
    "200": {
      "description": "Trace delete issued successfully.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "description": "Delete confirmation message."
              }
            },
            "required": [
              "message"
            ]
          },
          "example": {
            "message": "Successfully deleted trace trace_abc123"
          }
        }
      }
    },
    "403": {
      "$ref": "#/components/responses/InvalidApiKey"
    },
    "500": {
      "description": "Internal Server Error",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "detail": {
                "type": "string",
                "example": "Internal server error"
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "RespanApiKey": []
    },
    {
      "DashboardJwt": []
    }
  ]
}
```

</details>
<!-- openapi-operation:end -->

<!-- openapi-path-item:start -->
<details class="api-schema-source">
<summary>OpenAPI path metadata</summary>


```json
{}
```

</details>
<!-- openapi-path-item:end -->

<!-- openapi-components:start -->
<details class="api-schema-source">
<summary>Referenced OpenAPI components</summary>


```json
{
  "responses": {
    "InvalidApiKey": {
      "description": "The API key is missing, invalid or expired.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "detail"
            ],
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
          }
        }
      }
    }
  },
  "securitySchemes": {
    "DashboardJwt": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "Dashboard JWT",
      "description": "Use a dashboard JWT only for dashboard-authenticated endpoints. Respan API-key endpoints use the respanApiKey auth field instead.",
      "x-fern-bearer": {
        "name": "dashboardJwt",
        "env": "RESPAN_DASHBOARD_JWT"
      }
    },
    "RespanApiKey": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "Respan API key",
      "description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
      "x-fern-bearer": {
        "name": "respanApiKey",
        "env": "RESPAN_API_KEY"
      }
    }
  }
}
```

</details>
<!-- openapi-components:end -->
