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

# Add Section

> Add a section to a template

Adds a section to a template, with the section's preset (or default)
settings and blocks. Requires the `write_themes` scope.

## Request

```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", "position": 1 }'
```

```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', position: 1 })
});
```

## Path Parameters

**theme\_id** `string` *required*

The theme id.

**template** `string` *required*

The template to add to. Templates are named as in the theme's `templates/` folder: `index`,
`product`, `product.alternate`, `customers/account` (URL-encode the `/` in a
path segment), and section groups such as `header-group`. A path such as
`templates/index.json` is accepted too.

## Body Parameters

**sectionType** `string` *required*

The section to add: a file name in the theme's `sections/` folder, without
the extension (e.g. `rich-text`). Which section types exist depends on the
theme — list them with [Theme Assets](https://docs.launchmystore.io/api-reference/themes/assets.md).

**position** `integer`

Zero-based position in the template's section order. Omit to add the
section at the end.

## Response

`201 Created` with the new section's id under `data.sectionId`. Use it with
[Update Section Settings](https://docs.launchmystore.io/api-reference/themes/section-settings-update.md) and
[Delete Section](https://docs.launchmystore.io/api-reference/themes/section-delete.md).

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

## Error Codes

| Status | Description |
| - | - |
| `404` | Theme, template or section type not found |
| `422` | `sectionType` missing or an invalid template name |
| `401` | Invalid or missing access token |
| `403` | App doesn't have the `write_themes` scope |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.