# Actions Variables

Variables are non-encrypted configuration values available to workflows via the `vars` context. Unlike secrets, variable values **can be read** via the API.

## Repository Variables

### List Variables

```
GET /repos/{owner}/{repo}/actions/variables
```

```bash
curl -s -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}/actions/variables"
```

### Get Variable

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

```bash
curl -s -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}/actions/variables/{variable_name}"
```

### Create Variable

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

```bash
curl -s -X POST \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{"value": "{variable_value}"}' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}/actions/variables/{variable_name}"
```

### Update Variable

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

```bash
curl -s -X PUT \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{"value": "{variable_value}"}' \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}/actions/variables/{variable_name}"
```

### Delete Variable

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

```bash
curl -s -X DELETE \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/repos/{owner}/{repo}/actions/variables/{variable_name}"
```

## Organization Variables

### List Org Variables

```
GET /orgs/{org}/actions/variables
```

```bash
curl -s -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/actions/variables"
```

### Get Org Variable

```
GET /orgs/{org}/actions/variables/{variablename}
```

```bash
curl -s -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/actions/variables/{variable_name}"
```

### Create Org Variable

```
POST /orgs/{org}/actions/variables/{variablename}
```

```bash
curl -s -X POST \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{"value": "{variable_value}"}' \
  "${FORGEJO_URL}/api/v1/orgs/{org}/actions/variables/{variable_name}"
```

### Update Org Variable

```
PUT /orgs/{org}/actions/variables/{variablename}
```

```bash
curl -s -X PUT \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{"value": "{variable_value}"}' \
  "${FORGEJO_URL}/api/v1/orgs/{org}/actions/variables/{variable_name}"
```

### Delete Org Variable

```
DELETE /orgs/{org}/actions/variables/{variablename}
```

```bash
curl -s -X DELETE \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/actions/variables/{variable_name}"
```

## User Variables

### List User Variables

```
GET /user/actions/variables
```

```bash
curl -s -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/user/actions/variables"
```

### Get User Variable

```
GET /user/actions/variables/{variablename}
```

```bash
curl -s -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/user/actions/variables/{variable_name}"
```

### Create User Variable

```
POST /user/actions/variables/{variablename}
```

```bash
curl -s -X POST \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{"value": "{variable_value}"}' \
  "${FORGEJO_URL}/api/v1/user/actions/variables/{variable_name}"
```

### Update User Variable

```
PUT /user/actions/variables/{variablename}
```

```bash
curl -s -X PUT \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d '{"value": "{variable_value}"}' \
  "${FORGEJO_URL}/api/v1/user/actions/variables/{variable_name}"
```

### Delete User Variable

```
DELETE /user/actions/variables/{variablename}
```

```bash
curl -s -X DELETE \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/user/actions/variables/{variable_name}"
```

## Request Body

```json
{
  "value": "{variable_value}"
}
```

| Field | Type | Description |
|-------|------|-------------|
| `value` | string | The variable value (required) |

## Important Notes

- Variables are **not encrypted** — use secrets for sensitive data
- Variable values **can be read** via the API (unlike secrets)
- POST creates a new variable (fails if it already exists)
- PUT updates an existing variable (fails if it doesn't exist)
- Variables are available in workflows via `${{ vars.VARIABLE_NAME }}`
- Variable names are case-insensitive and typically use `UPPER_SNAKE_CASE`
