---
title: "purge_logs"
description: "Generated reference for the management action purge_logs: its description, access metadata, payload contract, and registration status."
slug: /reference/actions/purge-logs
order: 20
visibility: public
redirects_from: []
---

# purge\_logs

Generated automatically from the [published contract sources](/cloud/reference/about/#contract-sources).

A script calls this action over HTTPS at `POST https://tzcloud.turnzero.ai/v1/purge_logs`, with a bearer credential and the action's payload as the JSON body. An MCP connection lists this action as the tool `tzcloud_purge_logs`.

OAuth access tokens and minted tokens, including the turnzero command's computer token, are bearer credentials. The action determines which kinds, scopes and grants it accepts ([Sign-in, sessions, and tokens](/cloud/concepts/sign-in-sessions-and-tokens/)).

**Build metadata:** Registered in this build. Registration describes the default dispatcher in this build. It does not guarantee that a caller has the required credential or grant, that a tool is listed for that connection, or that the required service is configured.

## Contract description

Erase every log entry and counter total for one application environment, or all environments if you pass none, before retention ends\. It can clear `log_capacity_reached`\. This cannot be undone\. The control plane's own record stays\. Container console output stays in the hosting provider's logs for up to thirty days, beyond any purge\.

Destructive: needs a signed\-in session or a token minted with `destructive`\. Give `approval_url` to the account's owner for browser approval\. Nothing is erased before it\. Read `read_approval_status` to its end for the counts erased\.

## More about this action

Pass `request_id` to make a repeat safe\. While the earlier pending action is still live \(requested, approved, or executing\), a call with the same `request_id` from the same account returns that action and creates no second one\. Once the action has completed, failed, been declined, or expired, the same `request_id` starts a new one\.

Approval covers the selected streams, including entries added before the purge; it does not bind the counts at request time\.

## Access and action metadata

```json
{
  "name": "purge_logs",
  "resource": "application",
  "tier": "destructive",
  "surface": "tzcloud",
  "addresses": [
    "tzcloud"
  ],
  "product": "cloud",
  "summary": "Erase the application's log entries and counter totals ahead of retention: one environment's, or every environment's where none is given. It is your own purge under the approval flow, never undone, the control plane's record untouched.",
  "annotations": {
    "readOnlyHint": false,
    "destructiveHint": true,
    "openWorldHint": false
  }
}
```

## MCP catalog entry

```json
{
  "name": "purge_logs",
  "title": "Purge logs",
  "tier": "destructive",
  "scenario": "CHI-L0-10",
  "summary": "Erase every log entry and counter total for one application environment, or all environments if you pass none, before retention ends. It can clear `log_capacity_reached`. This cannot be undone. The control plane's own record stays. Container console output stays in the hosting provider's logs for up to thirty days, beyond any purge.\n\nDestructive: needs a signed-in session or a token minted with `destructive`. Give `approval_url` to the account's owner for browser approval. Nothing is erased before it. Read `read_approval_status` to its end for the counts erased.",
  "owners": [
    "LGS-L0-19",
    "MAPI-05"
  ]
}
```

## request

| JSON pointer | Description and constraints |
|---|---|
| "" \(root\) | Type: object<br>Required fields: \["application"\] |
| /<wbr>properties/<wbr>application | Your account's application `id` from `list_applications`, not its name or label\.<br><br>Type: string |
| /<wbr>properties/<wbr>environment | Erase `development`, `production` or `local`; omitted or empty erases all\. Other strings draw `invalid_request` before any approval request\.<br><br>Type: string |
| /<wbr>properties/<wbr>request\_id | Any string you choose\. A repeat from the same account while that pending action is live returns it again, creating no second one\. Omitted, every call creates a new one\.<br><br>Type: string |

## response

| JSON pointer | Description and constraints |
|---|---|
| "" \(root\) | The 202 creation envelope: the pending action and its approval link\. Read the terminal outcome on the pending record with read\_approval\_status\.<br><br>Type: object<br>Required fields: \["contract\_version","pending\_action","approval\_url"\] |
| /<wbr>properties/<wbr>contract\_version | Required value: 1 |
| /<wbr>properties/<wbr>reference | The short reference the platform recorded your call under: ten lowercase hexadecimal characters, the value in the call’s record row\. Quote it when you report the call\.<br><br>Type: string<br>Pattern: ^\[0\-9a\-f\]\{10\}$ |
| /<wbr>properties/<wbr>pending\_action | $ref: \#/shapes/pending\_action |
| /<wbr>properties/<wbr>approval\_url | Type: string |
| /<wbr>properties/<wbr>detail | Type: string |

## Complete payload contract

```json
{
  "request": {
    "type": "object",
    "required": [
      "application"
    ],
    "properties": {
      "application": {
        "type": "string",
        "description": "Your account's application `id` from `list_applications`, not its name or label."
      },
      "environment": {
        "type": "string",
        "description": "Erase `development`, `production` or `local`; omitted or empty erases all. Other strings draw `invalid_request` before any approval request."
      },
      "request_id": {
        "type": "string",
        "description": "Any string you choose. A repeat from the same account while that pending action is live returns it again, creating no second one. Omitted, every call creates a new one."
      }
    }
  },
  "response": {
    "type": "object",
    "description": "The 202 creation envelope: the pending action and its approval link. Read the terminal outcome on the pending record with read_approval_status (API-L0-07).",
    "required": [
      "contract_version",
      "pending_action",
      "approval_url"
    ],
    "properties": {
      "contract_version": {
        "const": 1
      },
      "reference": {
        "type": "string",
        "pattern": "^[0-9a-f]{10}$",
        "description": "The short reference the platform recorded your call under: ten lowercase hexadecimal characters, the value in the call’s record row. Quote it when you report the call."
      },
      "pending_action": {
        "$ref": "#/shapes/pending_action"
      },
      "approval_url": {
        "type": "string"
      },
      "detail": {
        "type": "string"
      }
    }
  }
}
```

## Shared contracts

- [Refusals](/cloud/reference/refusals/): every refusal, by surface, with its cause and its remedy
- [schemas/wire\_error\.schema\.json](/cloud/reference/sources/schemas/wire-error-schema/)
- [schemas/wire\_errors\.json](/cloud/reference/sources/schemas/wire-errors/)
- [schemas/action\_payloads\.json](/cloud/reference/sources/schemas/action-payloads/) (includes shared shapes)
- [management\_api\_contract\.md](/cloud/reference/sources/management-api-contract/)
