---
title: "Update layer"
method: PATCH
path: "/v2/layers/{layer}"
tags: ["layers"]
---

# Update layer

`PATCH /v2/layers/{layer}`

Update a layer. This is the key operation for bulk environment variable updates.

All fields are optional. `env_vars` performs a deep merge with existing variables: update by ID, update by key+contexts match, or create new. Set `delete: true` to remove a variable.

Running isolates will restart to pick up the new configuration.

## Path parameters

- `layer` string, required

## Request body

- object
  - `slug` string — New layer slug
  - `description` string — New description
  - `layers` LayerRefInput[] — Replace all included layers
    - union
      - string — Layer ID to reference
      - string — Layer slug to reference
  - `env_vars` EnvVarUpdate[] — Deep merge with existing environment variables
    - `id` string — ID of the existing variable to update or delete
    - `key` string — Variable name. Used for matching when `id` is not provided
    - `value` string — New value for the variable
    - `secret` boolean — Whether to mask the value in API responses
    - `contexts` union — Deployment contexts this variable applies to
      - 'all'
      - string[]
    - `delete` boolean — Set to true to remove this variable

## Response `200`

OK

- Layer
  - `id` string, required — Unique layer identifier
  - `slug` string, required — Human-readable layer slug
  - `description` string — Optional description of the layer's purpose
  - `layers` LayerRef[], required — Base layers included by this layer, in priority order (later overrides earlier). The including layer's own env vars take precedence over all its bases
    - `id` string, required — Unique layer identifier
    - `slug` string, required — Human-readable layer slug
  - `env_vars` EnvVar[], required — Environment variables defined in this layer
    - `id` string, required — Unique identifier for the environment variable
    - `key` string, required — The environment variable name
    - `value` string — The value. Omitted when `secret` is true
    - `secret` boolean, required — Whether the value is masked in API responses
    - `contexts` union, required — Deployment contexts this variable applies to. `"all"` means every context.
      - 'all'
      - string[]
  - `app_count` integer, required — Number of apps that reference this layer
  - `created_at` string, required — ISO 8601 timestamp of creation
  - `updated_at` string, required — ISO 8601 timestamp of last modification

---

[API](https://skmtc.net/deno/apis/deploy.md) · [All operations](https://skmtc.net/deno/apis/deploy/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/deno/deploy/versions/5a56038d108e/schema)
