> ## 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.

# Template Sections

> Manage sections within page templates

# Template Sections

Manage sections (modular content blocks) within page templates.

All endpoints use the standard response envelope (`status`, `state`, `message`,
`data`).

## Get Template Sections

List all sections in a template with their settings.

### Request

```bash theme={null}
curl -X GET "https://api.launchmystore.io/api/v1/themes/1f2e3d4c-5b6a-7980-a1b2-c3d4e5f60718/templates/index/sections.json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
```

### Path Parameters

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

<ParamField path="template" type="string" required>
  Template name (e.g., `index`, `product`, `collection`, `page`, `cart`)
</ParamField>

### Response

`data.sections` is an **array** of section objects, in render order. Each object
includes the section's settings, blocks and block order, plus its location
(`header`, `template`, or `footer`).

<ResponseField name="data.sections" type="array">
  Array of section objects

  <Expandable title="Section Object">
    <ResponseField name="id" type="string">
      Section ID used by render/AJAX endpoints
    </ResponseField>

    <ResponseField name="type" type="string">
      Section type (matches the section file name)
    </ResponseField>

    <ResponseField name="name" type="string">
      Display name resolved from the section schema
    </ResponseField>

    <ResponseField name="location" type="string">
      Where the section lives: `header`, `template`, or `footer`
    </ResponseField>

    <ResponseField name="templatePath" type="string">
      Path of the file the section is stored in
    </ResponseField>

    <ResponseField name="settings" type="object">
      Section settings
    </ResponseField>

    <ResponseField name="blocks" type="object">
      Section blocks keyed by block ID
    </ResponseField>

    <ResponseField name="block_order" type="array">
      Order of block IDs
    </ResponseField>

    <ResponseField name="isMainSection" type="boolean">
      `true` for main sections, which cannot be deleted
    </ResponseField>
  </Expandable>
</ResponseField>

```json theme={null}
{
  "status": 200,
  "state": "success",
  "message": null,
  "data": {
    "success": true,
    "template": "templates/index.json",
    "sections": [
      {
        "id": "template--homepage__image-banner",
        "key": "image-banner",
        "type": "image-banner",
        "name": "Image banner",
        "location": "template",
        "templatePath": "templates/index.json",
        "settings": {
          "heading": "Welcome to our store",
          "button_label": "Shop Now",
          "button_link": "/collections/all"
        },
        "blocks": {},
        "block_order": [],
        "isMainSection": false
      },
      {
        "id": "template--homepage__featured-collection",
        "key": "featured-collection",
        "type": "featured-collection",
        "name": "Featured collection",
        "location": "template",
        "templatePath": "templates/index.json",
        "settings": {
          "title": "Featured Products",
          "products_to_show": 8
        },
        "blocks": {},
        "block_order": [],
        "isMainSection": false
      }
    ]
  },
  "count": null,
  "pagination": null
}
```

***

## Update Section Settings

Update settings for a specific section.

### Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT "https://api.launchmystore.io/api/v1/themes/1f2e3d4c-5b6a-7980-a1b2-c3d4e5f60718/sections/image-banner/settings.json" \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "templatePath": "templates/index.json",
      "settings": {
        "heading": "Summer Sale",
        "button_label": "Shop Collection"
      }
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.launchmystore.io/api/v1/themes/1f2e3d4c-5b6a-7980-a1b2-c3d4e5f60718/sections/image-banner/settings.json', {
    method: 'PUT',
    headers: {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      templatePath: 'templates/index.json',
      settings: {
        heading: 'Summer Sale',
        button_label: 'Shop Collection'
      }
    })
  });
  ```
</CodeGroup>

### Body Parameters

<ParamField body="templatePath" type="string" required>
  Path of the template/file containing the section (e.g., `templates/index.json`)
</ParamField>

<ParamField body="settings" type="object" required>
  Section settings to save
</ParamField>

### Response

The saved settings are returned under `data.settings`.

```json theme={null}
{
  "status": 200,
  "state": "success",
  "message": null,
  "data": {
    "success": true,
    "message": "Settings saved successfully",
    "settings": {
      "heading": "Summer Sale",
      "button_label": "Shop Collection",
      "button_link": "/collections/all"
    }
  },
  "count": null,
  "pagination": null
}
```

***

## Add Section

Add a new section to a template. The new section is appended to the end of the
template's section order.

### Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.launchmystore.io/api/v1/themes/1f2e3d4c-5b6a-7980-a1b2-c3d4e5f60718/templates/index/sections.json" \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "sectionType": "rich-text"
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.launchmystore.io/api/v1/themes/1f2e3d4c-5b6a-7980-a1b2-c3d4e5f60718/templates/index/sections.json', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      sectionType: 'rich-text'
    })
  });
  ```
</CodeGroup>

### Body Parameters

<ParamField body="sectionType" type="string" required>
  Section type to add (must exist in the theme's sections folder)
</ParamField>

### Response

Returns `201` with the generated section ID under `data.sectionId`.

```json theme={null}
{
  "status": 201,
  "state": "success",
  "message": null,
  "data": {
    "success": true,
    "sectionId": "rich-text",
    "message": "Section 'rich-text' added successfully"
  },
  "count": null,
  "pagination": null
}
```

***

## Delete Section

Remove a section from a template.

### Request

```bash theme={null}
curl -X DELETE "https://api.launchmystore.io/api/v1/themes/1f2e3d4c-5b6a-7980-a1b2-c3d4e5f60718/sections/rich-text.json?templateName=index" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
```

### Query Parameters

<ParamField query="templateName" type="string" required>
  Template containing the section
</ParamField>

### Response

Delete returns a message envelope (no `data` payload).

```json theme={null}
{
  "status": 200,
  "state": "success",
  "message": "Section deleted successfully",
  "data": null
}
```

***

## Common Section Types

| Section Type          | Description                     |
| --------------------- | ------------------------------- |
| `image-banner`        | Hero banner with image and text |
| `featured-collection` | Product grid from collection    |
| `rich-text`           | Text content block              |
| `image-with-text`     | Side-by-side image and text     |
| `slideshow`           | Image carousel                  |
| `video`               | Embedded video                  |
| `newsletter`          | Email signup form               |
| `contact-form`        | Contact form                    |
| `multicolumn`         | Multiple columns of content     |
| `collage`             | Image collage layout            |
| `collection-list`     | Grid of collection cards        |

## Error Response

Errors return the envelope with `state: "error"`, a numeric HTTP `status`, and a
message.

```json theme={null}
{
  "status": 404,
  "state": "error",
  "message": "Section type 'rich-text' not found",
  "data": null
}
```

| Status | Description                                                        |
| ------ | ------------------------------------------------------------------ |
| `401`  | Invalid or missing access token                                    |
| `403`  | App doesn't have the required `read_themes` / `write_themes` scope |
| `404`  | Theme, template, or section not found                              |
| `400`  | Missing or invalid parameters                                      |
