By using the PATCH API, you can edit content via the API.
This is the authentication key required for PATCH API requests.
Please enable "PATCH" with default permissions or individual permissions and include it in the request header when sending.
If the X-MICROCMS-API-KEY is identifiable, it may allow unauthorized manipulation of content by third parties. Please handle it with care. For more details, please refer to "API Key (API Authentication and Authorization Management)".
Specifies the format of the data being sent.
Since microCMS only handles data in JSON format, please specify application/json.
This parameter is used to update or add draft content. Please add status=draft as a parameter.
For the behavior during updates, please refer to “Behavior for Each Status on Successful Requests.”
Please prepare the JSON of the content you want to send according to the API schema and pass it as a string.
Example:
{"title":"Sample Title","category": ["Sample Category"]}Please specify any string.
(Example: "Text 1")
You can specify a multi-line string using newline characters.
(Example: "Input multiple lines of text\nInput multiple lines of text")
You can specify decorations and images using HTML strings. For more details, please refer to the Rich Editor WRITE API.
(Example: "<h1>Heading</h1><p>You can submit in HTML like this</p>")
You can specify a multi-line string using newline characters.
(Example: "Input multiple lines of text\nInput multiple lines of text")
Registration with HTML tags is not supported.
※If HTML is registered, it will be escaped as follows.<p>Text 1</p> → &lt;p&gt;Text 1&lt;/p&gt;
Please specify the URL of the image uploaded to the same service of microCMS.
(Example: "https://images.microcms-assets.io/assets/xxxxxxxx/yyyyyyyy/sample.png")
If a custom domain for media is set, both the custom domain and the default domain (microcms-assets.io) are accepted.
Also, specifying an invalid URL as follows will result in an error.
Please specify the URLs of images uploaded to the same service of microCMS as an array.
(Example: ["https://images.microcms-assets.io/assets/xxxxxxxx/yyyyyyyy/sample1.png", "https://images.microcms-assets.io/assets/xxxxxxxx/yyyyyyyy/sample2.png"])
The specifications for image URLs are the same as for the image field.
Please specify as a string in ISO format (ISO 8601).
(Example: "2020-04-23T14:32:38.163Z")
Please specify a number.
(Example: 123)
Please specify a boolean value.
(Example: true)
Please specify the elements of the select field as an array.
(Example: ["Element 1","Element 2"])
Please specify the contentId of the referenced content.
(Example: "Referenced id")
Please specify the contentIds of the referenced contents as an array.
(Example: ["Referenced id 1","Referenced id 2"])
Please specify the content of the field you want to update in object format. Include fieldId and at least one value of the field you want to update.
(Example: { "fieldId": "YOURFIELDID", "some_value": "" })
Please specify the target data as an array of custom fields. Each element of the array should include fieldId and all field values.
Example:
[
{
"fieldId": "YOURFIRSTFIELDID",
"sometext_value": ""
},
{
"fieldId": "YOUR_SECOND_FIELD_ID",
"some_int_value": 10
}
]For implementation examples, please refer to the help site "How should I specify the value of a specific field when updating a repeated field using the PATCH API?".
Please specify the URL of the media uploaded to the same microCMS service.
(Example: "https://files.microcms-assets.io/assets/xxxxxxxx/yyyyyyyy/manual.pdf")
If a custom domain for media is set, both the custom domain and the default domain (microcms-assets.io) are accepted.
Additionally, specifying an invalid URL as follows will result in an error.
Please specify the target data (the message part) in object format. You can update only the properties you want to change.
For details on each value, please refer to Extended Fields.
Example:
{
"id": "some-id",
"title": "some-title",
"description": "some-description",
"imageUrl": "https://images.microcms-assets.io/assets/xxxx/yyyy/{fileName}.png",
"updatedAt": "2024-01-01T00:00:00Z",
"data": { "id": "123" }
}Please specify it as a string in ISO format (ISO 8601).
(Example: "2024-01-01T00:00:00Z")
If you want to register a field value as empty in the PATCH API, please specify the following values according to the field type and make the request.
Field Type | Value to Specify for Empty Registration |
|---|---|
Text Field |
|
Text Area |
|
Rich Editor |
|
Old Rich Editor (Deprecated) |
|
Image |
|
Multiple Images |
|
Date and Time |
|
Boolean |
|
Select Field |
|
Content Reference |
|
Multiple Content References |
|
Number |
|
Custom Field |
|
Repeating Field |
|
File |
|
Extended Field |
|
When updating content, you do not need to specify all fields. Please specify only the fields you want to update.
If the content is created successfully, a 200 response will be returned.
The response body when the request is executed successfully will be as follows:
{
"id": "someId"
}When a PATCH API request is successful, the behavior for each content status is as follows.
Content Status | Behavior After Update |
|---|---|
Published | The content will be updated while remaining in the published status. |
Published and Draft | The content in published status will be updated. The content in draft status will remain unchanged. |
Draft | The content will be updated while remaining in the draft status. |
Published Ended | Will not be updated. |
The behavior when requesting with status=draft is as follows.
Content Status | Behavior After Update |
|---|---|
Published | The status will change to "Published and Drafting." The published content will remain intact, while the updates will be saved as draft content. |
Published and Drafting | The status will remain "Published and Drafting." Only the draft content will be updated, while the published content will remain intact. |
Drafting | The status will remain "Drafting." The draft content will be updated. |
Published Ended | No updates will be made. |
Please refer to the Content API Error Response.
Contents