---
title: "Expire Write Token"
method: PATCH
path: "/v1/projects/{project_id}/write-tokens/{token_id}/expire/"
tags: ["Projects"]
---

# Expire Write Token

`PATCH /v1/projects/{project_id}/write-tokens/{token_id}/expire/`

## Request

- Base URL: `https://logfire-api.pydantic.dev/api`
- URL: `https://logfire-api.pydantic.dev/api/v1/projects/{project_id}/write-tokens/{token_id}/expire/`
- Auth: OAuth 2
  - Authorization code: `api/oauth/authorize`
  - Token URL: `/api/oauth/token` scopes: `project:write_token`
- TypeScript: <https://skmtc.dev/pydantic/apis/pydantic-logfire-api/docs/v1/projects/:project_id/write-tokens/:token_id/expire/patch.ts> (a function with typed inputs; its response is checked against the schema)

Force-expire a write token immediately by setting its expiry to now.

Refused for a token belonging to a frontend application. This route mints nothing to replace the
token, and an application's token can only be attached by creating the application, so expiring
one leaves the application alive, configured, and unable to receive data until somebody rotates
it. Rotate it instead, with `grace_period_hours` if the bundle carrying it has to be rebuilt
first, or delete the application to retire the credential.

## Path parameters

- `token_id` string, uuid, required
- `project_id` string, uuid, required

## Response `204`

Successful Response

## Other responses

- `400`: Cannot expire a token belonging to a frontend application
- `404`: Project token not found
- `422`: Validation Error
- `429`: Rate limit exceeded

---

[API](https://skmtc.dev/pydantic/apis/pydantic-logfire-api.md) - [All operations](https://skmtc.dev/pydantic/apis/pydantic-logfire-api/llms.txt) - [OpenAPI document](https://skmtc.dev/pydantic/apis/pydantic-logfire-api/revisions/7996e45256f4?raw)
