> ## Documentation Index
> Fetch the complete documentation index at: https://docs.authforge.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Variables API Reference

> Manage app variables and license variables via the AuthForge Developer API.

Variables are key-value pairs delivered to SDK clients during authentication. App variables go to every user; license variables go to a specific license holder.

**Limits:** Max 50 keys, 4 KB total JSON size, flat values only (string, number, boolean). Key max length: 64 characters.

***

## Get app variables

<ParamField path="GET" body="/v1/apps/:appId/variables">
  Retrieve all variables for an application.
</ParamField>

### Path parameters

| Param   | Type   | Description        |
| ------- | ------ | ------------------ |
| `appId` | string | The application ID |

### Example

```bash theme={null}
curl https://api.authforge.cc/v1/apps/YOUR_APP_ID/variables \
  -H "Authorization: Bearer af_live_your_key"
```

### Response (200)

```json theme={null}
{
  "maintenanceMode": false,
  "maxUploadSizeMb": 50,
  "motd": "Welcome to v2.0!",
  "minVersion": "1.5.0"
}
```

Returns an empty object `{}` if no variables are set.

***

## Set app variables

<ParamField path="PUT" body="/v1/apps/:appId/variables">
  Replace all variables for an application. This is a full replacement; omitted keys are removed.
</ParamField>

### Path parameters

| Param   | Type   | Description        |
| ------- | ------ | ------------------ |
| `appId` | string | The application ID |

### Request body

A JSON object of key-value pairs. Values must be strings, numbers, or booleans.

```bash theme={null}
curl -X PUT https://api.authforge.cc/v1/apps/YOUR_APP_ID/variables \
  -H "Authorization: Bearer af_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "maintenanceMode": false,
    "maxUploadSizeMb": 100,
    "motd": "New features available!",
    "minVersion": "2.0.0"
  }'
```

### Response (200)

```json theme={null}
{
  "maintenanceMode": false,
  "maxUploadSizeMb": 100,
  "motd": "New features available!",
  "minVersion": "2.0.0"
}
```

### Errors

| HTTP | Code          | Cause                                                                  |
| ---- | ------------- | ---------------------------------------------------------------------- |
| 400  | `bad_request` | Invalid body, too many keys (>50), exceeds 4 KB, or invalid value type |
| 403  | `forbidden`   | The app doesn't belong to your account                                 |

### Clearing all variables

Send an empty object to remove all variables:

```bash theme={null}
curl -X PUT https://api.authforge.cc/v1/apps/YOUR_APP_ID/variables \
  -H "Authorization: Bearer af_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{}'
```

***

## Get license variables

<ParamField path="GET" body="/v1/licenses/:licenseKey/variables">
  Retrieve all variables for a specific license.
</ParamField>

### Path parameters

| Param        | Type   | Description                             |
| ------------ | ------ | --------------------------------------- |
| `licenseKey` | string | The license key (URL-encoded if needed) |

### Example

```bash theme={null}
curl https://api.authforge.cc/v1/licenses/A3K9-BFWX-7NP2-QHDT/variables \
  -H "Authorization: Bearer af_live_your_key"
```

### Response (200)

```json theme={null}
{
  "plan": "pro",
  "maxProjects": 10,
  "customerName": "Acme Corp"
}
```

***

## Set license variables

<ParamField path="PUT" body="/v1/licenses/:licenseKey/variables">
  Replace all variables for a specific license. Full replacement; omitted keys are removed.
</ParamField>

### Path parameters

| Param        | Type   | Description     |
| ------------ | ------ | --------------- |
| `licenseKey` | string | The license key |

### Request body

A JSON object of key-value pairs.

```bash theme={null}
curl -X PUT https://api.authforge.cc/v1/licenses/A3K9-BFWX-7NP2-QHDT/variables \
  -H "Authorization: Bearer af_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "plan": "enterprise",
    "maxProjects": 50,
    "customerName": "Acme Corp",
    "features": "export,api,priority-support,sso"
  }'
```

### Response (200)

```json theme={null}
{
  "plan": "enterprise",
  "maxProjects": 50,
  "customerName": "Acme Corp",
  "features": "export,api,priority-support,sso"
}
```

### Errors

| HTTP | Code          | Cause                                                                  |
| ---- | ------------- | ---------------------------------------------------------------------- |
| 400  | `bad_request` | Invalid body, too many keys (>50), exceeds 4 KB, or invalid value type |
| 403  | `forbidden`   | The license's app doesn't belong to your account                       |
| 404  | `not_found`   | License key doesn't exist                                              |

***

## Validation rules

| Rule                      | Constraint                     |
| ------------------------- | ------------------------------ |
| Max keys                  | 50 per variable set            |
| Max total JSON size       | 4,096 bytes                    |
| Key max length            | 64 characters                  |
| Allowed value types       | `string`, `number`, `boolean`  |
| Nesting                   | Not allowed (flat values only) |
| Arrays, objects as values | Not allowed                    |
