Update Theme File

🔒

Requires write_themes access scope. More access scope

The Update Theme File API allows users to update the content of a specific theme file in the selected theme. This enables users to modify existing files, such as layouts, templates, or assets, to customize the shop's design and functionality.

This API is especially useful for:

  1. Updating theme assets like CSS, JS, or Liquid files.
  2. Modifying layout or template files for customization.
  3. Implementing dynamic changes in the theme files directly through API.

Request Parameters

Public Request Parameters

📘

Public Request Parameters

Path Parameters

NameTypeRequiredDescriptionExample
theme_idStringYesThe unique ID of the theme.1500021b-88ed-4750-bbc5-97ec98351dc0

Body Parameters

FieldTypeRequiredDescriptionExample
docObjectYesContains details about the type, location, and content to update.
doc.typeStringYesThe type of file being updated (assets, layout, etc.).assets
doc.locationStringYesThe file's location within the theme.test.js
doc.contentStringYesThe updated content to apply to the file."console.log('Hello');"

Response Explanation

Public Response Parameters

📘

Public Response Parameters

Successful Response

FieldTypeDescriptionExample
ObjectA successful response returns an empty object {} indicating the update was successful.{}

Error Response

Error responses in the API can be represented using two different fields: errors and error. Both fields provide details about issues encountered during request processing. Below is an explanation of the fields with their respective examples and descriptions.

FieldTypeExampleDescription
errorString "store is not active"Indicates an error encountered during the process

Error Detail

Status CodeMessagePossible ReasonExample Response
400Bad RequestInvalid input format or request structure (e.g., missing required fields or incorrect data types).Bad Request
UnauthorizedThe request is missing valid authentication credentials or the credentials provided are invalid.Unauthorized

API Structure Overview

Language
Credentials
Header
URL
Click Try It! to start a request and see the response here!