# Design

> Brand tokens and the site stylesheet. 3 endpoints in the Unvop API.

Brand tokens and the site stylesheet.

## Get the design

`GET /v1/sites/{siteId}/design`

Scope: `content:read`.

The site’s look: brand tokens (with the theme’s token list and defaults), fonts, and the stylesheet (design.css) whole and split into its parts (sections/hero.css, layout/header.css and so on). Shows unpublished site-wide draft changes too, as the editor does.

### Path parameters

- `siteId` (string, required): The site’s id.

### Response 200

- `tokens` (map of string, required)
- `themeTokens` (array, required)
- `fonts` (array, required)
- `css` (string, required)
- `parts` (array of objects, required)
  - `path` (string, required)
  - `css` (string, required)

### Errors

- `401`: No key, or the key isn’t valid.
- `403`: The key lacks the scope (insufficient_scope) or the role this needs, or the site’s plan lacks the feature (feature_not_in_plan).
- `404`: Not found, or not reachable with this key.
- `429`: Too many requests; wait for RateLimit-Reset seconds.

### Example

```sh
curl https://api.unvop.com/v1/sites/site_123/design \
  -H "Authorization: Bearer $UNVOP_KEY"
```

## Change brand tokens

`PATCH /v1/sites/{siteId}/design/tokens`

Scope: `design:write`.

Set brand tokens (colours, fonts, radius) by name. Token names come from themeTokens in GET /sites/{siteId}/design. They save as a site-wide draft: the editor and draft previews show them on every page, and the live site changes when you publish (POST /sites/{siteId}/publish or any page publish).

### Path parameters

- `siteId` (string, required): The site’s id.

### Request body (JSON)

- `tokens` (map of string, required)

### Response 200

- `tokens` (map of string, required)

### Errors

- `401`: No key, or the key isn’t valid.
- `403`: The key lacks the scope (insufficient_scope) or the role this needs, or the site’s plan lacks the feature (feature_not_in_plan).
- `404`: Not found, or not reachable with this key.
- `422`: The body is invalid; details say which values.
- `429`: Too many requests; wait for RateLimit-Reset seconds.

### Example

```sh
curl -X PATCH https://api.unvop.com/v1/sites/site_123/design/tokens \
  -H "Authorization: Bearer $UNVOP_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tokens": {
      "signal": "#0f766e"
    }
  }'
```

## Save one part of the stylesheet

`PUT /v1/sites/{siteId}/design/styles/{file}`

Scope: `design:write`.

Replace one part of design.css, such as sections/hero.css, or add a new section part under sections/. The CSS must parse; unsafe rules are removed and listed in warnings. Send the version from a previous read to refuse the save if the part changed since. Editing CSS is limited to platform administrators, as in the dashboard’s Code area.

### Path parameters

- `siteId` (string, required): The site’s id.
- `file` (string, required): The part’s path inside site/styles/, like sections/hero.css.

### Request body (JSON)

- `content` (string, required)
- `version` (string)

### Response 200

- `path` (string, required)
- `content` (string, required)
- `version` (string, required)
- `warnings` (array of strings)

### Errors

- `401`: No key, or the key isn’t valid.
- `403`: The key lacks the scope (insufficient_scope) or the role this needs, or the site’s plan lacks the feature (feature_not_in_plan).
- `404`: Not found, or not reachable with this key.
- `409`: It conflicts with the current state.
- `422`: The body is invalid; details say which values.
- `429`: Too many requests; wait for RateLimit-Reset seconds.

### Example

```sh
curl -X PUT https://api.unvop.com/v1/sites/site_123/design/styles/sections/hero.css \
  -H "Authorization: Bearer $UNVOP_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": ".hero { padding-block: 6rem; }"
  }'
```
