# stensul-update-segment-content

> Writes the content of one segment created by `stensul-apply-segment-set`. All of that segment's elements go in one call.

Source: https://stensul.com/developers/reference/stensul-update-segment-content/ · From the live server's tool list, 2026-09-28

- Scope: `dynamic-content:write`
- Access: write

Same content shapes as `stensul-update-email-content`. Only styling the template allows is applied; the rest is dropped and reported under `warnings`.

## Inputs

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `dynamicElementId` | string | yes | Dynamic element ID returned by `stensul-apply-segment-set`. |
| `segmentId` | string | yes | Segment to write. |
| `elements` | array (≥1) | yes | `[{ elementInstanceId, elementType, content?, imageContent?, link?, style?, visibility? }]`. |
| `isHiddenSegment` | boolean | no | Hide this whole segment. Omit to keep its current visibility. |

## Example request

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "stensul-update-segment-content",
    "arguments": {
      "dynamicElementId": "dyn_01",
      "segmentId": "seg_gold",
      "elements": [
        {
          "elementInstanceId": 5,
          "elementType": "button",
          "content": [
            {
              "content": [
                {
                  "text": {
                    "content": "Claim free shipping"
                  }
                }
              ]
            }
          ],
          "link": {
            "url": "https://northwind.example/gold"
          }
        }
      ]
    }
  }
}
```

## Response

The updated segment, with warnings for anything the template didn't allow.

## Errors

| Status | Message | Cause | Fix |
| --- | --- | --- | --- |
| 401 | Authentication expired or missing | The session's authorization expired. | Sign in again when the host prompts. On a 401 or 403, the server's instructions tell the model to re-check sign-in first. |
| 403 | Insufficient OAuth scope (403): The token lacks the required scope | The API connection doesn't have the scope this tool needs. | An admin adds the scope to the API connection. Then sign in again: adding a scope revokes existing tokens. |
| 403 | API error (403): Action is unauthorized. | The signed-in user's role lacks the permission, for example `edit_campaign`. | Grant the permission to the user's role in Admin > Users & Roles. It works for other users on the same connection. |
| declined | Content declined by a guardrail | A value is outside what the template allows: an off-palette color, a size out of range, locked text. | Keep the value within the guardrail or make no change. Guardrails are enforced by Stensul and cannot be overridden from a chat. |
