# Design systems

> Nexus Design's design systems: the tokens and notes designs are made, served and checked with.

## List design systems

`GET /v1/design-systems`

The organization's design systems for Nexus Design: the built-in @nexus/brand (brand v5.0) first, then its own by name, and the default new designs use.

Permission: `chat.use` (Every member).

### Responses

- `200` The design systems (application/json, DesignSystemList)
  - `designSystems` (array of DesignSystem, required)
    - `id` (string, required): `ds_…`; the built-in is `ds_nexus_brand`
    - `name` (string, required): `@nexus/brand`, or the organization's own name (`acme`, `@acme/web`)
    - `builtIn` (boolean, required): Compiled into Gateway: it cannot be changed or deleted
    - `isDefault` (boolean, required): The organization's default: new designs use it
    - `source` (string, required): Where it came from, in words
    - `variableCount` (integer, required)
    - `componentCount` (integer, required)
    - `updatedAt` (string (date-time)): Unset for the built-in
  - `defaultId` (string, required)

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/design-systems" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fdesign-systems)

## Save design system

`POST /v1/design-systems`

Create the named design system, or replace its tokens, notes, components and source (what `nexus design-system sync` sends). Tokens come from `css` and from `files`: CSS custom properties (`:root`, `@theme`, `[data-theme]`, `.dark`, `.light`), a Tailwind config's literal theme, and `tokens.json`. Only custom properties are stored. 400 design_system_empty when none are found, 400 design_system_limit past 50 per organization. Audited as design_system.saved, with counts and never the tokens.

Permission: `org.settings` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Request body (application/json, required)

- `name` (string, required): Lowercase; `@nexus/` and `ds_` are reserved [pattern ^(@[a-z0-9][a-z0-9._-]{0,30}/)?[a-z0-9][a-z0-9._-]{0,63}$]
- `css` (string): CSS custom properties
- `files` (array of DesignSourceFile): At most 4 MiB together [at most 40 items]
  - `path` (string, required): Relative to the synced folder; the name says how it is read
  - `text` (string, required)
- `notes` (string): Markdown for the model [max length 65536]
- `components` (array of string) [at most 500 items]
- `source` (string) [max length 500]
- `makeDefault` (boolean): Make it the organization's default too

### Responses

- `200` Replaced (application/json, DesignSystemSaved)
  - `designSystem` (DesignSystem, required): A design system for Nexus Design, as the organization lists it.
    - `id` (string, required): `ds_…`; the built-in is `ds_nexus_brand`
    - `name` (string, required): `@nexus/brand`, or the organization's own name (`acme`, `@acme/web`)
    - `builtIn` (boolean, required): Compiled into Gateway: it cannot be changed or deleted
    - `isDefault` (boolean, required): The organization's default: new designs use it
    - `source` (string, required): Where it came from, in words
    - `variableCount` (integer, required)
    - `componentCount` (integer, required)
    - `updatedAt` (string (date-time)): Unset for the built-in
  - `created` (boolean, required): False when it replaced one of the same name
  - `read` (array of string, required): What each file gave, in words
- `201` Created (application/json, DesignSystemSaved)
  - `designSystem` (DesignSystem, required): A design system for Nexus Design, as the organization lists it.
    - `id` (string, required): `ds_…`; the built-in is `ds_nexus_brand`
    - `name` (string, required): `@nexus/brand`, or the organization's own name (`acme`, `@acme/web`)
    - `builtIn` (boolean, required): Compiled into Gateway: it cannot be changed or deleted
    - `isDefault` (boolean, required): The organization's default: new designs use it
    - `source` (string, required): Where it came from, in words
    - `variableCount` (integer, required)
    - `componentCount` (integer, required)
    - `updatedAt` (string (date-time)): Unset for the built-in
  - `created` (boolean, required): False when it replaced one of the same name
  - `read` (array of string, required): What each file gave, in words
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/design-systems" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Platform"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdesign-systems)

## Get design system

`GET /v1/design-systems/{id}`

A design system: its tokens as CSS and as a map of variables, its notes and its components. 404 design_system_not_found.

Permission: `chat.use` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The design system's id (`ds_…`; the built-in is `ds_nexus_brand`), or its name when it has no `/` |

### Responses

- `200` The design system (application/json, DesignSystemDetail)
  - `id` (string, required): `ds_…`; the built-in is `ds_nexus_brand`
  - `name` (string, required): `@nexus/brand`, or the organization's own name (`acme`, `@acme/web`)
  - `builtIn` (boolean, required): Compiled into Gateway: it cannot be changed or deleted
  - `isDefault` (boolean, required): The organization's default: new designs use it
  - `source` (string, required): Where it came from, in words
  - `variableCount` (integer, required)
  - `componentCount` (integer, required)
  - `updatedAt` (string (date-time)): Unset for the built-in
  - `css` (string, required): The tokens as CSS: `selector { --name: value; }` blocks and nothing else
  - `variables` (array of DesignVariable, required)
    - `name` (string, required): `--nx-page`
    - `value` (string, required)
    - `selector` (string, required): `:root`, or a theme such as `[data-theme="light"]`
    - `kind` ("color" | "length" | "font" | "other", required)
  - `notes` (string, required): Markdown for the model
  - `components` (array of string, required)

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/design-systems/<id>" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fdesign-systems%2F%7Bid%7D)

## Delete design system

`DELETE /v1/design-systems/{id}`

Delete a design system. When it was the default, the built-in is the default again; pages that link it are served without its tokens. 400 design_system_built_in for @nexus/brand. Audited as design_system.deleted.

Permission: `org.settings` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The design system's id (`ds_…`; the built-in is `ds_nexus_brand`), or its name when it has no `/` |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Responses

- `200` Deleted (application/json, DesignSystemDeleted)
  - `id` (string, required)
  - `deleted` (boolean, required)
  - `defaultId` (string, required): The default now

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X DELETE "$NEXUS_URL/v1/design-systems/<id>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fdesign-systems%2F%7Bid%7D)

## Set default design system

`POST /v1/design-systems/{id}/default`

Make a design system the organization's default for new designs (the built-in too). Audited as design_system.default_set, with the default before and after.

Permission: `org.settings` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The design system's id (`ds_…`; the built-in is `ds_nexus_brand`), or its name when it has no `/` |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Responses

- `200` The new default (application/json, DesignSystem)
  - `id` (string, required): `ds_…`; the built-in is `ds_nexus_brand`
  - `name` (string, required): `@nexus/brand`, or the organization's own name (`acme`, `@acme/web`)
  - `builtIn` (boolean, required): Compiled into Gateway: it cannot be changed or deleted
  - `isDefault` (boolean, required): The organization's default: new designs use it
  - `source` (string, required): Where it came from, in words
  - `variableCount` (integer, required)
  - `componentCount` (integer, required)
  - `updatedAt` (string (date-time)): Unset for the built-in

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/design-systems/<id>/default" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdesign-systems%2F%7Bid%7D%2Fdefault)
