---
title: "Update a widget"
method: PATCH
path: "/v1/workspaces/{workspaceId}/widgets/{id}"
tags: ["WidgetService", "Widgets"]
---

# Update a widget

`PATCH /v1/workspaces/{workspaceId}/widgets/{id}`

Updates a widget's metadata or spec. The DNS label is immutable and cannot be updated. Re-pointing the agent affects new sessions only; in-flight conversations finish against the agent they started with.

## Path parameters

- `workspaceId` string, required
- `id` string, required

## Request body

- UpdateWidgetRequest — Update widget request.
  - `workspaceId` string — Workspace ID.
  - `id` string — Widget ID. Accepts the canonical `wgt_…` form or the `external_id:<value>` form.
  - `metadata` UpdateResourceMetadata — UpdateResourceMetadata contains the user-provided fields for updating a workspace-scoped resource. Read-only fields (id, account_id, workspace_id, profile_id, created_at) are excluded since they are set by the server.
    - `name` string, required — Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool")
    - `externalId` string — External ID for the resource (e.g., a workflow ID from an external system)
    - `labels` object — Key-value pairs for categorization and filtering. Values are 0-63 alphanumeric characters with "-", "_", or "." allowed between; keys follow the same shape and additionally accept an optional DNS-subdomain prefix (e.g. "cadenya.com/") of at most 253 characters. Examples: {"environment": "production", "team": "platform", "version": "v2"}
  - `spec` WidgetSpec — WidgetSpec is the user-provided configuration for a widget.
    - `agentId` string, required — Agent this widget is bound to. Accepts the canonical `agent_…` form or the `external_id:<value>` form. Sessions copy the agent at mint: re-pointing a widget's agent affects new sessions only.
    - `variationId` string — Optional explicit variation pin. Must belong to the widget's agent. When set, every objective created through the widget runs this variation — bypassing the agent's variation_selection_mode (staged rollout: pin in production, follow in staging, promote by clearing). When unset, the agent's selection mode chooses per conversation.
    - `originAllowlist` string[] — Web origins allowed to embed and use this widget, enforced at the edge on every browser request. Exact origins only (scheme + host + optional port), no paths, no wildcard subdomains.
  - `updateMask` string, field-mask — Fields to update.

## Response `200`

OK

- Widget — Widget is an embeddable chat surface bound to a single agent. Each widget owns a globally unique, immutable DNS label under the widgets domain (e.g. "k7m2xq9fp4wn.widgets.cadenya.com"): one widget = one hostname = one origin allowlist = one agent binding. Browsers talk to the widget host with session bearer tokens minted server-side via WidgetSessionService.
  - `metadata` ResourceMetadata, required — Standard metadata for persistent, named resources (e.g., agents, tools, prompts)
    - `id` string, required — Unique identifier for the resource (prefixed ULID, e.g., "agent_01HXK...")
    - `accountId` string, required — Account this resource belongs to for multi-tenant isolation (prefixed ULID)
    - `workspaceId` string, required — Workspace this resource belongs to for organizational grouping (prefixed ULID)
    - `name` string, required — Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool") Required for resources that users interact with directly
    - `externalId` string — External ID for the resource (e.g., a workflow ID from an external system)
    - `labels` object — Key-value pairs for categorization and filtering. Values are 0-63 alphanumeric characters with "-", "_", or "." allowed between; keys follow the same shape and additionally accept an optional DNS-subdomain prefix (e.g. "cadenya.com/") of at most 253 characters. Examples: {"environment": "production", "team": "platform", "version": "v2"}
    - `profileId` string, required — ID of the actor (user or service account) that created this resource
    - `createdAt` string, date-time, required — Timestamp when this resource was created
    - `updatedAt` string, date-time — Timestamp when this resource was last updated
  - `spec` WidgetSpec, required — WidgetSpec is the user-provided configuration for a widget.
    - `agentId` string, required — Agent this widget is bound to. Accepts the canonical `agent_…` form or the `external_id:<value>` form. Sessions copy the agent at mint: re-pointing a widget's agent affects new sessions only.
    - `variationId` string — Optional explicit variation pin. Must belong to the widget's agent. When set, every objective created through the widget runs this variation — bypassing the agent's variation_selection_mode (staged rollout: pin in production, follow in staging, promote by clearing). When unset, the agent's selection mode chooses per conversation.
    - `originAllowlist` string[] — Web origins allowed to embed and use this widget, enforced at the edge on every browser request. Exact origins only (scheme + host + optional port), no paths, no wildcard subdomains.
  - `info` WidgetInfo — WidgetInfo provides read-only server-derived data about a widget.
    - `dnsLabel` string — The widget's DNS label — the single hostname label under the widgets domain. Server-generated at creation, globally unique, immutable, and deliberately unrelated to the widget's id.
    - `host` string — The full hostname browsers talk to. Authoritative — clients must use this value rather than constructing the hostname themselves.
    - `agent` BareMetadata — BareMetadata contains the minimal metadata for a resource: the ID and an optional human-readable name. These are used for reference fields where the full metadata (account scoping, timestamps, labels, external IDs) is not needed — e.g., the tool references inside an agent variation spec or the tools assigned to an objective. Both fields are server-populated; clients provide IDs through sibling fields rather than by constructing a BareMetadata themselves.
      - `id` string
      - `name` string — Human-readable name of the referenced resource, populated by the server on reads for convenience. Absent on references to resources that do not have a name (e.g., objective tasks).
    - `createdBy` Profile — A profile identifies a user or non-human principal (such as an API key) at the account level. Profiles are account-scoped and can be granted access to multiple workspaces.
      - `metadata` AccountResourceMetadata, required — AccountResourceMetadata is used to represent a resource that is associated to an account but not to a workspace.
        - `id` string, required — Unique identifier for the resource (prefixed ULID, e.g., "apikey_01HXK...")
        - `accountId` string, required — Account this resource belongs to for multi-tenant isolation (prefixed ULID)
        - `name` string, required — Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool") Required for resources that users interact with directly
        - `externalId` string — External ID for the resource (e.g., a workflow ID from an external system)
        - `labels` object — Key-value pairs for categorization and filtering. Values are 0-63 alphanumeric characters with "-", "_", or "." allowed between; keys follow the same shape and additionally accept an optional DNS-subdomain prefix (e.g. "cadenya.com/") of at most 253 characters. Examples: {"environment": "production", "team": "platform", "version": "v2"}
        - `profileId` string, required
        - `createdAt` string, date-time
      - `spec` ProfileSpec, required — Configuration for a profile.
        - `email` string — Email address of the profile. Required and unique within an account for user profiles.
        - `name` string — Display name (e.g., "Bobby Tables").
        - `type` 'PROFILE_TYPE_UNSPECIFIED' | 'PROFILE_TYPE_USER' | 'PROFILE_TYPE_API_KEY' | 'PROFILE_TYPE_SYSTEM', enum, required — Whether this profile represents a human user, an API key, or a system principal.
  - `state` 'STATE_UNSPECIFIED' | 'STATE_ACTIVE' | 'STATE_ARCHIVED', enum, required — The current lifecycle state of the widget. Output only. Widgets are created STATE_ACTIVE; use the :archive and :unarchive actions to transition between states.

## Other responses

- `default` — Default error response

---

[API](https://skmtc.net/cadenya/apis/cadenya-api.md) · [All operations](https://skmtc.net/cadenya/apis/cadenya-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/cadenya/cadenya-api/revisions/ac1a7f084068/schema)
