> ## Documentation Index
> Fetch the complete documentation index at: https://docs.launchmystore.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create / Update Theme Asset

> Create a new theme file or overwrite an existing one

Creates a theme file or replaces its contents. This is an **upsert** keyed by
`key` — writing the same `key` again overwrites the file.

**Auth:** OAuth access token with the `write_themes` scope.

<Note>
  Everything this endpoint does is also available in your dashboard under the
  theme code editor, with no app or access token required. Use the API when you
  are automating theme changes from an app; use the editor for one-off edits to
  your own store.
</Note>

<Warning>
  Writes apply to the theme you name in `theme_id`, and take effect immediately
  if that theme is the live one. To work safely, duplicate your theme first and
  write to the copy — only the active theme is served to customers.
</Warning>

## Path Parameters

<ParamField path="theme_id" type="string" required>
  The theme ID
</ParamField>

## Body Parameters

<ParamField body="key" type="string" required>
  Asset path within the theme, e.g. `snippets/custom-banner.aqua`,
  `templates/page.landing.json`, `assets/custom.css`
</ParamField>

<ParamField body="value" type="string" required>
  The file's text content
</ParamField>

<Note>
  `key` goes in the **body**, not the query string. The query `key` parameter is
  used only by [List](/api-reference/themes/assets) and
  [Delete](/api-reference/themes/asset-delete).
</Note>

## Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT "https://api.launchmystore.io/api/v1/themes/1f2e3d4c-5b6a-7980-a1b2-c3d4e5f60718/assets.json" \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "key": "snippets/custom-banner.aqua",
      "value": "<div class=\"custom-banner\">\n  {{ section.settings.text }}\n</div>"
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.launchmystore.io/api/v1/themes/1f2e3d4c-5b6a-7980-a1b2-c3d4e5f60718/assets.json', {
    method: 'PUT',
    headers: {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      key: 'snippets/custom-banner.aqua',
      value: '<div class="custom-banner">\n  {{ section.settings.text }}\n</div>'
    })
  });
  ```
</CodeGroup>

## Response

The created or updated asset is nested under `data.asset`.

```json theme={null}
{
  "status": 200,
  "state": "success",
  "message": null,
  "data": {
    "asset": {
      "key": "snippets/custom-banner.aqua",
      "value": "<div class=\"custom-banner\">\n  {{ section.settings.text }}\n</div>"
    }
  },
  "count": null,
  "pagination": null
}
```

## Errors

| Status | Description                               |
| ------ | ----------------------------------------- |
| `401`  | Invalid or missing access token           |
| `403`  | App doesn't have the `write_themes` scope |
| `404`  | Theme does not exist                      |
| `400`  | Invalid asset key or content              |

## See also

* [List theme assets](/api-reference/themes/assets)
* [Delete a theme asset](/api-reference/themes/asset-delete)
