# Content

Create, update and delete content items.

Create, update and delete content items.

## Create content

`POST /v1/content/`

Required scope: `content:write`

### Parameters

| Name | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string (uuid) | Yes | UUID4 identifying one intended write. Reuse it only when retrying that same write. |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `file_id` | string (uuid) \| null | No |  |
| `item_type` | string | Yes | one of `TEMPLATE`, `MEDIA`, `LINK`, `PROMPT` |
| `prompt_body` | string | No | max length 4000 |
| `steps` | object[] | No | max 50 items |
| `steps[].file_id` | string (uuid) \| null | No |  |
| `steps[].referenced_content_item_id` | string (uuid) \| null | No |  |
| `steps[].step_type` | string | Yes | one of `TEXT`, `IMAGE`, `VIDEO`, `VOICE`, `FILE` |
| `steps[].text` | string | No | max length 50000 |
| `steps[].text_variants` | string[] | No |  |
| `title` | string | Yes | max length 255 |
| `url` | string (uri) \| null | No | max length 2048 |

### Response (201)

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `created_at` | string (date-time) | No | read-only |
| `file_id` | string | No | read-only |
| `id` | string | No | read-only |
| `item_type` | string | No | read-only |
| `prompt_body` | string | No | read-only |
| `sort_order` | integer | No | read-only |
| `title` | string | No | read-only |
| `updated_at` | string (date-time) | No | read-only |
| `url` | string | No | read-only |

### Responses

- `201` Success
- `400` The request is invalid.
- `401` Authentication is missing, invalid, or revoked.
- `403` The authenticated identity lacks the required scope or capability.
- `404` The resource is unavailable or not visible to this organization.
- `409` The write conflicts with current state or an identical request is still running.
- `422` The write contains fields outside its closed input schema.
- `429` The request-rate budget is exhausted.

```bash
curl -X POST "https://api.themochi.app/v1/content/" \
  -H "Authorization: Bearer $MOCHI_API_KEY" \
  -H "Idempotency-Key: $(uuidgen | tr A-Z a-z)" \
  -H "Content-Type: application/json" \
  -d '{"item_type":"TEMPLATE","title":"string"}'
```

## Delete content

`DELETE /v1/content/{content_item_id}/`

Required scope: `content:write`

### Parameters

| Name | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `content_item_id` | path | string (uuid) | Yes |  |
| `Idempotency-Key` | header | string (uuid) | Yes | UUID4 identifying one intended write. Reuse it only when retrying that same write. |

### Responses

- `204` Success
- `400` The request is invalid.
- `401` Authentication is missing, invalid, or revoked.
- `403` The authenticated identity lacks the required scope or capability.
- `404` The resource is unavailable or not visible to this organization.
- `409` The write conflicts with current state or an identical request is still running.
- `422` The write contains fields outside its closed input schema.
- `429` The request-rate budget is exhausted.

```bash
curl -X DELETE "https://api.themochi.app/v1/content/<content_item_id>/" \
  -H "Authorization: Bearer $MOCHI_API_KEY" \
  -H "Idempotency-Key: $(uuidgen | tr A-Z a-z)"
```

## Update content

`PATCH /v1/content/{content_item_id}/`

Required scope: `content:write`

### Parameters

| Name | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `content_item_id` | path | string (uuid) | Yes |  |
| `Idempotency-Key` | header | string (uuid) | Yes | UUID4 identifying one intended write. Reuse it only when retrying that same write. |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `prompt_body` | string | No | max length 4000 |
| `sort_order` | integer | No |  |
| `steps` | object[] | No | max 50 items |
| `steps[].file_id` | string (uuid) \| null | No |  |
| `steps[].referenced_content_item_id` | string (uuid) \| null | No |  |
| `steps[].step_type` | string | Yes | one of `TEXT`, `IMAGE`, `VIDEO`, `VOICE`, `FILE` |
| `steps[].text` | string | No | max length 50000 |
| `steps[].text_variants` | string[] | No |  |
| `title` | string | No | max length 255 |
| `url` | string (uri) \| null | No | max length 2048 |

### Response (200)

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `created_at` | string (date-time) | No | read-only |
| `file_id` | string | No | read-only |
| `id` | string | No | read-only |
| `item_type` | string | No | read-only |
| `prompt_body` | string | No | read-only |
| `sort_order` | integer | No | read-only |
| `title` | string | No | read-only |
| `updated_at` | string (date-time) | No | read-only |
| `url` | string | No | read-only |

### Responses

- `200` Success
- `400` The request is invalid.
- `401` Authentication is missing, invalid, or revoked.
- `403` The authenticated identity lacks the required scope or capability.
- `404` The resource is unavailable or not visible to this organization.
- `409` The write conflicts with current state or an identical request is still running.
- `422` The write contains fields outside its closed input schema.
- `429` The request-rate budget is exhausted.

```bash
curl -X PATCH "https://api.themochi.app/v1/content/<content_item_id>/" \
  -H "Authorization: Bearer $MOCHI_API_KEY" \
  -H "Idempotency-Key: $(uuidgen | tr A-Z a-z)" \
  -H "Content-Type: application/json" \
  -d '{"prompt_body":"string","sort_order":1,"steps":[{"step_type":"TEXT"}],"title":"string","url":"string"}'
```

