---
title: "Save a Site Variable"
method: PUT
path: "/api/v1/site/variable"
tags: ["Site"]
---

# Save a Site Variable

`PUT /api/v1/site/variable`

Creates or updates a site variable for the specified site. If an ID or matching key is provided, the existing variable is updated; otherwise a new one is created.

## Response `200`

Site variable saved successfully

- ResponseHostVariableEntityView
  - `errors` ErrorEntity[]
    - `errorCode` string
    - `message` string
    - `fieldName` string
  - `entity` HostVariable
    - `id` string
    - `hostId` string
    - `name` string
    - `key` string
    - `value` string
    - `lastModifierId` string
    - `lastModDate` string, date-time
  - `messages` MessageEntity[]
    - `message` string
  - `i18nMessagesMap` object
  - `permissions` string[]
  - `pagination` Pagination
    - `currentPage` integer
    - `perPage` integer
    - `totalEntries` integer

## Other responses

- `400` — When a required value is not sent
- `401` — Unauthorized access
- `403` — User does not have permission to manage site variables

---

[API](https://skmtc.dev/jostens/apis/dotcms-rest-api.md) · [All operations](https://skmtc.dev/jostens/apis/dotcms-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/jostens/dotcms-rest-api/revisions/a088fe9f515c/schema)
