---
title: "Patch a content with JSON Patch"
method: POST
path: "/v2beta/cms/content/patch"
tags: ["Contents"]
---

# Patch a content with JSON Patch

`POST /v2beta/cms/content/patch`

## Request

- Base URL: `https://api.karte.io`
- URL: `https://api.karte.io/v2beta/cms/content/patch`
- Auth: HTTP bearer

Craft Cross CMSのコンテンツをJSON Patchを使って部分更新します。

#### Required Scope
APIの実行に必要なScopeです。
```
beta.cms.content.patch
```

#### Required Role
管理画面でScopeを追加する際に必要な権限です。
```
Craft Cross CMS > CMSの編集
```

## Headers

- `x-karte-api` string
- `authorization` string
- `content-type` string

## Request body

- object
  - `modelId` string, required: コンテンツが所属するモデルのID
  - `contentId` string, required: 更新するコンテンツのID
  - `operations` union[], required: JSON Patch操作の配列。複数の操作を順に適用できます。 ### 操作の種類 - `add`: 指定したパスに値を追加 - `remove`: 指定したパスの値を削除（注: モデルで定義されたフィールドは、フィールドタイプの空値にリセットされます。例: text型は空文字''、number型は0） - `replace`: 指定したパスの値を置換 - `move`: 指定したパスから別のパスへ値を移動 - `copy`: 指定したパスから別のパスへ値をコピー - `test`: 指定したパスの値が期待値と一致するか検証（一致しない場合はエラー） ### パスの指定方法 パスはJSON Pointerフォーマット（RFC 6901）で指定します。 例： - トップレベルのフィールド: `/title` - ネストしたフィールド: `/author/name` - 配列の要素: `/tags/0` ### 使用例 ```json [ { "op": "replace", "path": "/title", "value": "Updated Title" }, { "op": "add", "path": "/tags/-", "value": "new-tag" }, { "op": "remove", "path": "/oldField" } ] ``` ### リッチテキストフィールドの指定方法 リッチテキストフィールドの値は `json` 要素のみ有効です。 `text` および `html` は無視されます。 例: ID `richtext` のリッチテキストフィールドに、 `<h1>RichText</h1>` という内容を指定する場合、次のように指定します。 ```json { "op": "replace", "path": "/richtext", "value": { "json": { "type": "doc", "content": [ { "type": "heading", "attrs": { "level": 1 }, "content": [ { "type": "text", "text": "RichText" } ] } ] } } } ``` ### 画像フィールドの指定方法 画像フィールドの値は、メディアライブラリの画像のIDを文字列として指定してください。 例：`image` というIDの画像フィールドに、`6347f05d5d18d4536af5f336` というIDの画像を指定する場合、次のように指定します。 ```json { "op": "replace", "path": "/image", "value": "6347f05d5d18d4536af5f336" } ```
    - union
      - object
        - `op` 'add', required: add operation
        - `path` string, required: JSON Pointer path to the target location
        - `value` union, required: The value to add
          - string
          - number
          - boolean
          - object
          - unknown[]
            - unknown
      - object
        - `op` 'remove', required: remove operation
        - `path` string, required: JSON Pointer path to the target location
      - object
        - `op` 'replace', required: replace operation
        - `path` string, required: JSON Pointer path to the target location
        - `value` union, required: The new value
          - string
          - number
          - boolean
          - object
          - unknown[]
            - unknown
      - object
        - `op` 'move', required: move operation
        - `from` string, required: JSON Pointer path to the source location
        - `path` string, required: JSON Pointer path to the target location
      - object
        - `op` 'copy', required: copy operation
        - `from` string, required: JSON Pointer path to the source location
        - `path` string, required: JSON Pointer path to the target location
      - object
        - `op` 'test', required: test operation
        - `path` string, required: JSON Pointer path to the target location
        - `value` union, required: The value to test against
          - string
          - number
          - boolean
          - object
          - unknown[]
            - unknown
  - `kickHookV2` boolean: この操作でHook V2のトリガーを発火するかどうか。（[参照](https://developers.karte.io/reference/hook-v2-karte-craft-channel)）

## Response `200`

A successful response.

- Content: コンテンツの情報を表します。
  - `id` string, required: コンテンツのIDです。
  - `sys` SysData: システム側で自動で設定された情報が入ります。 sys.customOrderには、管理画面にてコンテンツの手動並び替えを行った際の順序値（Number型）が入ります。
    - `customOrder` integer
    - `modelId` string
    - `ownerId` string
    - `raw` RawData: コンテンツの生データを表します。
      - `createdAt` string: コンテンツの作成日時です。
      - `createdBy` string: コンテンツの作成者です。
      - `updatedAt` string: コンテンツの更新日時です。
      - `updatedBy` string: コンテンツの更新者です。
      - `firstPublishedAt` string, nullable: コンテンツの初回公開日時です。
      - `publishedAt` string, nullable: コンテンツの公開日時です。
      - `contentId` string: コンテンツのIDです。
      - `revisionId` string: コンテンツのリビジョンIDです。
      - `publishedRevisionId` string, nullable: コンテンツの公開済リビジョンIDです。

## Other responses

- `400`: Bad Request. CMS Management API 400 responses include a non-empty detail.
- `422`: Unprocessable Content. CMS model or custom field type structure validation failed.

---

[API](https://skmtc.dev/karte/apis/cms-management.md) - [All operations](https://skmtc.dev/karte/apis/cms-management/llms.txt) - [OpenAPI document](https://skmtc.dev/karte/apis/cms-management/revisions/275f2d6496ec?raw)
