---
title: "Update Variable"
method: PUT
path: "/v1/projects/{project_id}/variables/{name}/"
tags: ["Projects", "Variables"]
---

# Update Variable

`PUT /v1/projects/{project_id}/variables/{name}/`

## Request

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

Update an existing variable definition, optionally with labels and versions.

Fields present and set to None will be cleared.
Fields not present will not be changed.

Requires: User token with project:write_variables scope.

## Path parameters

- `name` string, required
- `project_id` string, uuid, required

## Request body

- VariableDefinitionUpdateRequest: Request model for updating a variable definition. Should be the same as `VariableDefinitionCreateRequest`, just with `total=False`.
  - `name` string
  - `description` string, nullable
  - `json_schema` object, nullable
  - `template_inputs_schema` object, nullable
  - `type_id` string, uuid, nullable
  - `rollout` RolloutData: Rollout configuration stored as JSONB.
    - `labels` object, required
    - `latest_weight` number
  - `overrides` OverrideData[]
    - `name` string, nullable
    - `description` string, nullable
    - `conditions` ConditionData[], required
      - `kind` string
      - `attribute` string
      - `value` unknown
      - `values` unknown[]
        - unknown
      - `pattern` string
    - `rollout` RolloutData, required: Rollout configuration stored as JSONB.
      - `labels` object, required
      - `latest_weight` number
  - `aliases` string[], nullable
  - `example` string, nullable
  - `external` boolean
  - `labels` object

## Response `200`

Successful Response

- VariableDefinitionRead: Variable definition with current labels and latest version assembled.
  - `id` string, uuid, required
  - `project_id` string, uuid, required
  - `type_id` string, uuid, nullable, required
  - `type_name` string, nullable, required
  - `kind` 'general' | 'prompt', required
  - `name` string, required
  - `display_name` string, nullable, required
  - `prompt_slug` string, nullable, required
  - `description` string, nullable, required
  - `json_schema` union, required
    - object
    - JSONBData[]
    - string
    - integer
    - boolean
    - number
  - `template_inputs_schema` union, required
    - object
    - JSONBData[]
    - string
    - integer
    - boolean
    - number
  - `labels` object, required
  - `latest_version` VersionRead, required: A version as read from the database.
    - `id` string, uuid, required
    - `variable_definition_id` string, uuid, required
    - `version` integer, required
    - `serialized_value` string, required
    - `description` string, nullable, required
    - `created_at` string, date-time, required
    - `created_by` string, uuid, nullable, required
    - `created_by_name` string, nullable, required
  - `rollout` RolloutData, required: Rollout configuration stored as JSONB.
    - `labels` object, required
    - `latest_weight` number
  - `overrides` OverrideData[], required
    - `name` string, nullable
    - `description` string, nullable
    - `conditions` ConditionData[], required
      - `kind` string
      - `attribute` string
      - `value` unknown
      - `values` unknown[]
        - unknown
      - `pattern` string
    - `rollout` RolloutData, required: Rollout configuration stored as JSONB.
      - `labels` object, required
      - `latest_weight` number
  - `aliases` string[], nullable, required
  - `example` string, nullable, required
  - `external` boolean, required
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required
  - `created_by_name` string, nullable, required
  - `updated_by_name` string, nullable, required

## Other responses

- `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)
