---
title: "Set body"
description: "Writes the live body of the store's home, a page, a product or an entry, or with `staged: true` its unpublished next body, which `publishBody` publishes; `from` names the body read, so a write over one changed since is refused. Ask `getBodySchema` for the blocks, props and values its kind takes before writing: anything else is refused, naming the block, the prop and what it takes."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.sherpo.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Set body

Needs the file:write scope.

Rich text (content) is HTML in a closed format: p, h1 to h3, br, strong, em, u, s, sup, sub, code, a (href), span (style color, background-color), text-align on p and h1 to h3, ul, ol, li (data-checked), table rows and cells, pre with code, blockquote, hr, details with summary, figure with figcaption, and <block type="…" props="{…}" /> for images, videos, audio, slideshows, formulas, diagrams and other blocks, their props as getBodySchema lists them; anything else is refused with its path and reason. E.g. <h2>Intro</h2><p>Read <strong>this</strong> first.</p> Set text\_format to "markdown" to write Markdown instead.

## Call

- Tool: `set_body`
- Scope: `file:write`
- Writes, and may change or remove what is there.
- Acts on a store.

## Arguments

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `store` | `string` | No | The store to act on. |
| `text_format` | `"html" or "markdown"` | No | The format the rich text fields are written in: the rich text format’s HTML, or Markdown converted into it before it is validated. A text already stored in the format (starting with `<rich-text`) is kept as it is either way. |
| `target` | `object` | Yes |  |
| `full` | `true` | No | Answers the texts, attachments and file lists the short answer leaves out. |
| `content` | `string` | Yes | The body's text, a blocks layout whose texts (a markdown block's `content`, and those its blocks nest) are rich texts, stored in its canonical form in 1 MiB of UTF-8; an image it starts showing is at most 15 MB. |
| `from` | `object or null` | Yes | The `asset.id` the body (or the staged body) held when the caller read it, never its `attachment.id`; null when it had none. |
| `staged` | `boolean` | No | Writes the unpublished next body instead of the live one. |
| `live` | `object or null` | No | On a staged write, the live body's `asset.id` the caller started from, never its `attachment.id`; null when there was none. |
| `unpublished` | `true` | No | On a live write, the caller saved it believing its page or product isn't live. |

```json
{
  "type": "object",
  "properties": {
    "store": {
      "type": "string",
      "description": "The store to act on."
    },
    "text_format": {
      "type": "string",
      "enum": [
        "html",
        "markdown"
      ],
      "default": "html",
      "description": "The format the rich text fields are written in: the rich text format’s HTML, or Markdown converted into it before it is validated. A text already stored in the format (starting with `<rich-text`) is kept as it is either way."
    },
    "target": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "product",
            "entry",
            "store",
            "page"
          ]
        },
        "id": {
          "description": "Required but for the store's home, which takes the store's own id or none.",
          "type": "string",
          "minLength": 1,
          "maxLength": 512
        }
      },
      "required": [
        "kind"
      ],
      "additionalProperties": false
    },
    "full": {
      "description": "Answers the texts, attachments and file lists the short answer leaves out.",
      "type": "boolean",
      "const": true
    },
    "content": {
      "description": "The body's text, a blocks layout whose texts (a markdown block's `content`, and those its blocks nest) are rich texts, stored in its canonical form in 1 MiB of UTF-8; an image it starts showing is at most 15 MB.",
      "type": "string",
      "x-rich-text": "body",
      "minLength": 1,
      "maxLength": 262144
    },
    "from": {
      "description": "The `asset.id` the body (or the staged body) held when the caller read it, never its `attachment.id`; null when it had none.",
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            }
          },
          "required": [
            "id"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "staged": {
      "description": "Writes the unpublished next body instead of the live one.",
      "type": "boolean"
    },
    "live": {
      "description": "On a staged write, the live body's `asset.id` the caller started from, never its `attachment.id`; null when there was none.",
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            }
          },
          "required": [
            "id"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "unpublished": {
      "description": "On a live write, the caller saved it believing its page or product isn't live.",
      "type": "boolean",
      "const": true
    }
  },
  "required": [
    "target",
    "content",
    "from"
  ],
  "additionalProperties": false
}
```

## Answer

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `attachment` | `object` | Yes |  |
| `asset` | `object` | Yes | The asset the body holds now: the next write's `from` (or a staged write's `live`). |
| `created` | `array of object` | Yes | The attachments the write bound: the embeds a live write or a publish derived. |
| `attachments` | `array of object` | No | Every attachment on the target with its asset whole; answered only with `full`. |
| `preview` | `object or null` | Yes | The body's page on the store with a token opening it, for an hour; null where none is answered. |

The answer's full shape is on [its API reference page](/merchant-api/reference/set-body).

## Errors

A refused call is a tool error. Its `structuredContent` holds a `code` and its `context`, except for `client-fault`. This tool may answer:

- `invalid`: an argument is malformed; `context.path` names it.
- `invalid` at `["store"]`: `store` is missing while the connection reaches more than one store, or names a store it doesn't reach.
- `not_found`: nothing matches a reference given.
- `conflict`: the call clashes with the current state; `context` names the field and, where it helps, its current value, and for a `from`, `live`, `expect` or version that no longer matches, the argument (`path`) and what it takes (`reason`).
- `not_permitted`: this connection may not make this call. When `context.reason` is `limit`, too many calls: `retry_after` says when to try again.
- `internal` or `unavailable`: the call failed inside Sherpo, and the write may have landed. This write takes no idempotency key, so read the state back before trying again.
- `client-fault`: the server failed around the call. `core_answer` `ok` means the write landed, so don't send it again. When `reached_core` is false, nothing happened and the call may be made again. Otherwise, this write takes no idempotency key, so read the state back before trying again.
- HTTP 403 with `insufficient_scope`: the connection lacks the scope this tool needs.
- HTTP 401 with `invalid_token`: the access token expired or the connection ended. Refresh the token, and connect again if the refresh fails or the new token is refused too.

Any other code may come back too, such as a `conflict` when the state changed under the call. When the answer was already streaming, a 401 or 403 comes back as a tool error with only its text. See [Errors](/merchant-mcp/errors) for every code and its context.

Source: https://docs.sherpo.io/merchant-mcp/tools/set_body/index.mdx
