---
title: "Create Variable"
method: POST
path: "/api/variables/"
tags: ["Variables"]
---

# Create Variable

`POST /api/variables/`

## Request

- The document declares no server URL.
- Auth: none declared

## Headers

- `x-prefect-api-version` string

## Request body

- VariableCreate: Data used by the Prefect REST API to create a Variable.
  - `name` string, required: The name of the variable
  - `value` string, required: The value of the variable
  - `tags` string[]: A list of variable tags

## Response `201`

Successful Response

- Variable: A PrefectBaseModel with an auto-generated UUID ID value and created / updated timestamps, intended for compatibility with our standard ORM models. The ID, created, and updated fields are reset on copy() and not included in equality comparisons.
  - `id` string, uuid
  - `created` string, date-time
  - `updated` string, date-time
  - `name` string, required: The name of the variable
  - `value` string, required: The value of the variable
  - `tags` string[]: A list of variable tags

## Other responses

- `422`: Validation Error

## Changes

- **2024-04-03** `93ae2b3f2efd`: 2 breaking
  - the request property `name` became required
  - the request property `value` became required

[Operation history](https://skmtc.dev/prefecthq/apis/prefect-unreleased-api/changes/api/variables/post.md)

---

[API](https://skmtc.dev/prefecthq/apis/prefect-unreleased-api.md) - [All operations](https://skmtc.dev/prefecthq/apis/prefect-unreleased-api/llms.txt) - [OpenAPI document](https://skmtc.dev/prefecthq/apis/prefect-unreleased-api/revisions/29ba6c4f8837?raw)
