---
title: "Updates an attachment's role, delivery or preview flag."
---

> 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.

Path: Sherpo merchant API › file

`PATCH /v1/stores/{store}/attachments/{attachment}`

## Authentication

- `bearer`, http, header `Authorization`, scopes: `file:write`

## Path parameters

- `store` (`updateAttachment.path.store`; string, required) — The store's id.
- `attachment` (`updateAttachment.path.attachment`; string, required)
  - minLength 1

## Header parameters

- `Idempotency-Key` (`updateAttachment.header.Idempotency-Key`; string, optional) — Repeats within 24 hours answer the first result; the same key with other arguments is a conflict.
  - minLength 1; maxLength 255; pattern `^[\x21-\x7E]+$`

## Request body

_Optional._

- `asset` (`updateAttachment.asset`; object, optional) — Swapped in place; on the store's home only its body or stylesheet takes another file. A poster, and an image a product binds as `embed`, takes one of at most 15 MB.
  - `id` (`updateAttachment.asset.id`; string, required)
    - minLength 1; maxLength 512
- `from` (`updateAttachment.from`; object, optional) — The asset the caller saw bound; any other refuses.
  - `id` (`updateAttachment.from.id`; string, required)
    - minLength 1; maxLength 512
- `from_role` (`updateAttachment.from_role`; string, optional) — The role the caller saw it hold; another refuses.
  - one of `"body"`, `"staged"`, `"staged_file"`, `"prose"`, `"teaser"`, `"embed"`, `"deliverable"`, `"poster"`, `"logo"`, `"prompt"`, `"stylesheet"`
- `from_delivery` (`updateAttachment.from_delivery`; string, optional) — The delivery the caller saw it served by; another refuses.
  - one of `"inline"`, `"download"`, `"stream"`
- `body` (`updateAttachment.body`; any of, optional) — The body the caller saw on the target, null for none; another refuses.
  - any of: `object`, `null`
- `kind` (`updateAttachment.kind`; string, optional) — The file it holds after the write must be of this kind, as a lesson's video swapped, or it refuses `conflict` on `mime` with the reason.
  - one of `"video"`, `"audio"`, `"pdf"`
- `role` (`updateAttachment.role`; string, optional) — A move on the store's home lands only in `body` or `stylesheet`; a poster, or an image moved into a product's `embed`, is at most 15 MB.
  - one of `"body"`, `"staged"`, `"staged_file"`, `"prose"`, `"teaser"`, `"embed"`, `"deliverable"`, `"poster"`, `"logo"`, `"prompt"`, `"stylesheet"`
- `delivery` (`updateAttachment.delivery`; string, optional) — The seller's pick, which a save of the text no longer flips with its use.
  - one of `"inline"`, `"download"`, `"stream"`
- `preview_only` (`updateAttachment.preview_only`; boolean, optional) — True drops every gate row of the attachment's own, which takes the gate's scopes.
- `position` (`updateAttachment.position`; integer, optional)
  - min 0; max 1000000
- `download_tier` (`updateAttachment.download_tier`; any of, optional) — Who may download a lesson's slides bound as a download: a tier and above, or null for whoever opens them; takes the gate's scopes.
  - any of: `object`, `null`

## Example request

```json
{
  "asset": {
    "id": "string"
  },
  "from": {
    "id": "string"
  },
  "from_role": "body",
  "from_delivery": "inline",
  "body": {
    "id": "string"
  },
  "kind": "video",
  "role": "body",
  "delivery": "inline",
  "preview_only": true,
  "position": 1000000,
  "download_tier": {
    "id": "string"
  }
}
```

## Code samples

### cURL

```bash
curl --request PATCH \
  --url 'https://api.sherpo.io/merchant/v1/stores/<store>/attachments/<attachment>' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "asset": {
    "id": "string"
  },
  "from": {
    "id": "string"
  },
  "from_role": "body",
  "from_delivery": "inline",
  "body": {
    "id": "string"
  },
  "kind": "video",
  "role": "body",
  "delivery": "inline",
  "preview_only": true,
  "position": 1000000,
  "download_tier": {
    "id": "string"
  }
}
'
```

### TypeScript

```typescript
const url = 'https://api.sherpo.io/merchant/v1/stores/<store>/attachments/<attachment>';
const options = {
  method: 'PATCH',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    asset: {id: 'string'},
    from: {id: 'string'},
    from_role: 'body',
    from_delivery: 'inline',
    body: {id: 'string'},
    kind: 'video',
    role: 'body',
    delivery: 'inline',
    preview_only: true,
    position: 1000000,
    download_tier: {id: 'string'}
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.sherpo.io/merchant/v1/stores/<store>/attachments/<attachment>"

payload = {
    "asset": { "id": "string" },
    "from": { "id": "string" },
    "from_role": "body",
    "from_delivery": "inline",
    "body": { "id": "string" },
    "kind": "video",
    "role": "body",
    "delivery": "inline",
    "preview_only": True,
    "position": 1000000,
    "download_tier": { "id": "string" }
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

Updates an attachment's role, delivery or preview flag.

#### Example

```json
{
  "id": "string",
  "target": {
    "kind": "string",
    "id": "string"
  },
  "role": "string",
  "delivery": "string",
  "preview_only": true,
  "from_body": true,
  "release_file": true,
  "position": 0,
  "asset": {
    "id": "string",
    "locator": "string",
    "origin": "string",
    "custodian": "string",
    "enforcement": "string",
    "mime": "string",
    "bytes": 0,
    "quota_bytes": 0,
    "name": "string",
    "title": "string",
    "ext": "string",
    "status": "string",
    "optimized": true,
    "parent_id": "string",
    "redacted": true,
    "security": "string",
    "description": "string",
    "processed_at": "string",
    "metadata": {
      "width": 0,
      "height": 0,
      "duration": 0,
      "pages": 0,
      "waveform": "string",
      "transcript": {
        "language": "string",
        "confidence": 0
      },
      "arguments": [
        {
          "name": "string",
          "description": "string",
          "required": true,
          "default": "string",
          "match": "string",
          "flags": "string",
          "message": "string",
          "lenient": true
        }
      ],
      "property1": true,
      "property2": true
    },
    "created_at": "string"
  }
}
```

- `id` (`updateAttachment.response.200.id`; string, required)
- `target` (`updateAttachment.response.200.target`; object, required)
  - `kind` (`updateAttachment.response.200.target.kind`; string, required)
  - `id` (`updateAttachment.response.200.target.id`; string, required)
- `role` (`updateAttachment.response.200.role`; string, required)
- `delivery` (`updateAttachment.response.200.delivery`; string, required)
- `preview_only` (`updateAttachment.response.200.preview_only`; boolean, required)
- `from_body` (`updateAttachment.response.200.from_body`; boolean, required)
- `release_file` (`updateAttachment.response.200.release_file`; boolean, required) — A file a software release ships, which its release edits and the product's own list leaves out.
- `position` (`updateAttachment.response.200.position`; number, required)
- `asset` (`updateAttachment.response.200.asset`; object, required)
  - `id` (`updateAttachment.response.200.asset.id`; string, required)
  - `locator` (`updateAttachment.response.200.asset.locator`; any of, required)
    - any of: `string`, `null`
  - `origin` (`updateAttachment.response.200.asset.origin`; string, required)
  - `custodian` (`updateAttachment.response.200.asset.custodian`; string, required)
  - `enforcement` (`updateAttachment.response.200.asset.enforcement`; string, required)
  - `mime` (`updateAttachment.response.200.asset.mime`; any of, required)
    - any of: `string`, `null`
  - `bytes` (`updateAttachment.response.200.asset.bytes`; any of, required) — The file's size in bytes; null when it is charged nothing.
    - any of: `number`, `null`
  - `quota_bytes` (`updateAttachment.response.200.asset.quota_bytes`; number, required) — The file's size in bytes; zero when it is charged nothing.
  - `name` (`updateAttachment.response.200.asset.name`; string, required)
  - `title` (`updateAttachment.response.200.asset.title`; any of, required)
    - any of: `string`, `null`
  - `ext` (`updateAttachment.response.200.asset.ext`; any of, required)
    - any of: `string`, `null`
  - `status` (`updateAttachment.response.200.asset.status`; string, required)
  - `optimized` (`updateAttachment.response.200.asset.optimized`; boolean, required)
  - `parent_id` (`updateAttachment.response.200.asset.parent_id`; any of, required)
    - any of: `string`, `null`
  - `redacted` (`updateAttachment.response.200.asset.redacted`; boolean, required)
  - `security` (`updateAttachment.response.200.asset.security`; any of, required)
    - any of: `string`, `null`
  - `description` (`updateAttachment.response.200.asset.description`; any of, required)
    - any of: `string`, `null`
  - `processed_at` (`updateAttachment.response.200.asset.processed_at`; any of, required)
    - any of: `string`, `null`
  - `metadata` (`updateAttachment.response.200.asset.metadata`; object, required)
    - `width` (`updateAttachment.response.200.asset.metadata.width`; integer, optional)
      - min 0
    - `height` (`updateAttachment.response.200.asset.metadata.height`; integer, optional)
      - min 0
    - `duration` (`updateAttachment.response.200.asset.metadata.duration`; number, optional) — Seconds, measured, so rarely whole.
    - `pages` (`updateAttachment.response.200.asset.metadata.pages`; integer, optional)
      - min 0
    - `waveform` (`updateAttachment.response.200.asset.metadata.waveform`; any of, optional) — An audio file's waveform: 256 levels from 0 to 255, base64; null when it can't be drawn.
      - any of: `string`, `null`
    - `transcript` (`updateAttachment.response.200.asset.metadata.transcript`; object, optional)
      - `language` (`updateAttachment.response.200.asset.metadata.transcript.language`; string, optional)
      - `confidence` (`updateAttachment.response.200.asset.metadata.transcript.confidence`; number, optional)
    - `arguments` (`updateAttachment.response.200.asset.metadata.arguments`; array<object>, optional) — What an MCP prompt asks for; only an authored prompt carries it.
      - `name` (`updateAttachment.response.200.asset.metadata.arguments.name`; string, required)
      - `description` (`updateAttachment.response.200.asset.metadata.arguments.description`; any of, required)
        - any of: `string`, `null`
      - `required` (`updateAttachment.response.200.asset.metadata.arguments.required`; boolean, required)
      - `default` (`updateAttachment.response.200.asset.metadata.arguments.default`; any of, required)
        - any of: `string`, `null`
      - `match` (`updateAttachment.response.200.asset.metadata.arguments.match`; any of, required) — Pattern the whole value must match, diacritic-insensitive.
        - any of: `string`, `null`
      - `flags` (`updateAttachment.response.200.asset.metadata.arguments.flags`; any of, required) — Flags among `i`, `s` and `u` the pattern runs with; null for `i` alone.
        - any of: `string`, `null`
      - `message` (`updateAttachment.response.200.asset.metadata.arguments.message`; any of, required) — What a refused value is told instead of the default reason.
        - any of: `string`, `null`
      - `lenient` (`updateAttachment.response.200.asset.metadata.arguments.lenient`; boolean, required)
  - `created_at` (`updateAttachment.response.200.asset.created_at`; any of, required)
    - any of: `string`, `null`

### default

A problem; see https://api.sherpo.io/merchant/docs/errors.

#### Example

```json
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "context": {},
  "reached_core": true,
  "core_answer": "string"
}
```

- `type` (`updateAttachment.response.default.type`; string, required)
  - format `uri`
- `title` (`updateAttachment.response.default.title`; string, required)
- `status` (`updateAttachment.response.default.status`; integer, required)
- `detail` (`updateAttachment.response.default.detail`; string, required)
- `code` (`updateAttachment.response.default.code`; string, optional)
- `context` (`updateAttachment.response.default.context`; object, optional)
- `reached_core` (`updateAttachment.response.default.reached_core`; boolean, optional)
- `core_answer` (`updateAttachment.response.default.core_answer`; string, optional)


Source: https://docs.sherpo.io/merchant-api/reference/update-attachment/index.md
