---
url: /en/build/internal-steps/cnb/destroy-token.md
description: >
  Destroys CNB_TOKEN early and removes the related environment variable, for
  revoking permissions as soon as a pipeline no longer needs the token, reducing
  misuse risk.
---
`cnb:destroy-token`

A [CNB\_TOKEN](../../build-in-env.md#cnb_token) is created before the pipeline starts and is destroyed after it ends.
Use this task to proactively destroy the CNB\_TOKEN and remove this environment variable.

**When to use it**: use it when the pipeline no longer needs the CNB\_TOKEN and you want to revoke
its permission as early as possible - for example destroying the token right after the operations
that required it, reducing the risk of it being misused by later tasks. The platform destroys the
token automatically when the pipeline ends; this task only moves the timing earlier.

* [Applicable Events](#cnb-destroy-token-applicable-events)
* [Parameters](#cnb-destroy-token-parameters)
* [Output](#cnb-destroy-token-output)
* [Configuration Examples](#cnb-destroy-token-configuration-examples)

## Applicable Events {#cnb-destroy-token-applicable-events}

[All Events](../../trigger-rule.md#trigger-event)

## Parameters {#cnb-destroy-token-parameters}

None

## Output {#cnb-destroy-token-output}

None

## Configuration Examples {#cnb-destroy-token-configuration-examples}

Proactively destroy the CNB\_TOKEN after use in the pipeline to reduce the risk of CNB\_TOKEN misuse.

```yaml title=".cnb.yml"
main:
  push:
    - stages:
        - name: use CNB_TOKEN
          script: echo "Make API calls using the CNB_TOKEN."
        - name: destroy token
          type: cnb:destroy-token
```
