---
title: "Create a repo-level variable"
method: POST
path: "/repos/{owner}/{repo}/actions/variables/{variablename}"
tags: ["repository"]
---

# Create a repo-level variable

`POST /repos/{owner}/{repo}/actions/variables/{variablename}`

## Request

- Base URL: `https://demo.gitea.com/api/v1`
- URL: `https://demo.gitea.com/api/v1/repos/{owner}/{repo}/actions/variables/{variablename}`
- Auth: one of:
  - HTTP basic
  - API key in query parameter `token`
  - API key in query parameter `access_token`
  - API key in header `Authorization`
  - API key in query parameter `sudo`
  - API key in header `Sudo`
  - API key in header `X-GITEA-OTP`
- TypeScript: <https://skmtc.dev/gitea/apis/gitea-api/docs/repos/:owner/:repo/actions/variables/:variablename/post.ts> (a function with typed inputs; its response is checked against the schema)

## Path parameters

- `owner` string, required
- `repo` string, required
- `variablename` string, required

## Request body

- CreateVariableOption: CreateVariableOption the option when creating variable
  - `description` string: Description of the variable to create
  - `value` string, required: Value of the variable to create

## Response `201`

response when creating a repo-level variable

## Other responses

- `default`: APIError is error format response

## Changes

- **2026-10-28** `7ef50c4c527f`: 3 info
  - removed the non-success response with the status `400`
  - removed the non-success response with the status `409`
  - removed the non-success response with the status `500`
- **2026-07-13** `4df6be504c96`: 1 breaking, 3 info
  - removed the success response with the status `204`
  - added the non-success response with the status `409`
  - added the non-success response with the status `500`
  - removed the non-success response with the status `404`

[Operation history](https://skmtc.dev/gitea/apis/gitea-api/changes/repos/:owner/:repo/actions/variables/:variablename/post.md)

---

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