---
title: "Create a variable for a repository"
method: POST
path: "/repositories/{workspace}/{repo_slug}/pipelines_config/variables"
tags: ["Pipelines"]
---

# Create a variable for a repository

`POST /repositories/{workspace}/{repo_slug}/pipelines_config/variables`

## Request

- Base URL: `https://api.bitbucket.org/2.0`
- URL: `https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pipelines_config/variables`
- Auth: one of:
  - OAuth 2
    - Authorization code: `https://bitbucket.org/site/oauth2/authorize`
    - Token URL: `https://bitbucket.org/site/oauth2/access_token` scopes: `pipeline:variable`
  - HTTP basic
  - API key in header `Authorization`

Create a repository level variable.

## Path parameters

- `workspace` string, required
- `repo_slug` string, required

## Request body

- PipelineVariable: A Pipelines variable.
  - `type` string, required
  - `uuid` string: The UUID identifying the variable.
  - `key` string: The unique name of the variable.
  - `value` string: The value of the variable. If the variable is secured, this will be empty.
  - `secured` boolean: If true, this variable will be treated as secured. The value will never be exposed in the logs or the REST API.

## Response `201`

The variable was created.

- PipelineVariable: A Pipelines variable.
  - `type` string, required
  - `uuid` string: The UUID identifying the variable.
  - `key` string: The unique name of the variable.
  - `value` string: The value of the variable. If the variable is secured, this will be empty.
  - `secured` boolean: If true, this variable will be treated as secured. The value will never be exposed in the logs or the REST API.

## Other responses

- `404`: The account or repository does not exist.
- `409`: A variable with the provided key already exists.

---

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