---
title: "Detaches a file from a resource, keeping the file."
---

> 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

`POST /v1/stores/{store}/attachments/{attachment}/detach`

## Authentication

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

## Path parameters

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

## Header parameters

- `Idempotency-Key` (`detachAttachment.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._

- `from` (`detachAttachment.from`; object, optional) — The asset the caller saw bound; any other refuses.
  - `id` (`detachAttachment.from.id`; string, required)
    - minLength 1; maxLength 512
- `from_role` (`detachAttachment.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"`
- `body` (`detachAttachment.body`; any of, optional) — The body the caller saw on the target, null for none; another refuses.
  - any of: `object`, `null`

## Example request

```json
{
  "from": {
    "id": "string"
  },
  "from_role": "body",
  "body": {
    "id": "string"
  }
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.sherpo.io/merchant/v1/stores/<store>/attachments/<attachment>/detach' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "from": {
    "id": "string"
  },
  "from_role": "body",
  "body": {
    "id": "string"
  }
}
'
```

### TypeScript

```typescript
const url = 'https://api.sherpo.io/merchant/v1/stores/<store>/attachments/<attachment>/detach';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({from: {id: 'string'}, from_role: 'body', body: {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>/detach"

payload = {
    "from": { "id": "string" },
    "from_role": "body",
    "body": { "id": "string" }
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

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

print(response.text)
```

## Responses

### 200

Detaches a file from a resource, keeping the file.

#### Example

```json
{
  "id": "string",
  "deleted": true
}
```

- `id` (`detachAttachment.response.200.id`; string, required)
- `deleted` (`detachAttachment.response.200.deleted`; boolean, required)

### 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` (`detachAttachment.response.default.type`; string, required)
  - format `uri`
- `title` (`detachAttachment.response.default.title`; string, required)
- `status` (`detachAttachment.response.default.status`; integer, required)
- `detail` (`detachAttachment.response.default.detail`; string, required)
- `code` (`detachAttachment.response.default.code`; string, optional)
- `context` (`detachAttachment.response.default.context`; object, optional)
- `reached_core` (`detachAttachment.response.default.reached_core`; boolean, optional)
- `core_answer` (`detachAttachment.response.default.core_answer`; string, optional)


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