## Get site template areas

`GET /v1/sites/:id/template-areas`

Returns the bindings of the site layout areas to pages: which page is inserted into the header, footer or sidebar. Page areas are not included; a separate method reads them.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `id` (path) | number | yes | Site ID. List: [`GET /v1/sites`](/docs/entities/sites/list) |
| `scope` (query) | string | no | Internal landing scope: `KNOWLEDGE` / `GROUP` / `MAINPAGE`. Specify it if the site belongs to the corresponding scope. Otherwise `404 ENTITY_NOT_FOUND` is returned. Omit it for an ordinary site |

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/sites/225/template-areas" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/sites/225/template-areas" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/sites/225/template-areas', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data } = await res.json()
for (const [area, pageId] of Object.entries(data.areas)) {
  console.log(`Area ${area} → page ${pageId}`)
}
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/sites/225/template-areas', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success, data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | Always `true` on success |
| `data.areas` | object | Area bindings. The key is the area number as a decimal string, the value is the page ID. Get the page: [`GET /v1/pages/:id`](/docs/entities/pages/get). A site without bindings returns an empty object `{}` |

## Response example

```json
{
  "success": true,
  "data": {
    "areas": {
      "1": 2383,
      "2": 2385
    }
  }
}
```

## Error response example

404 — no site with this ID was found:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Entity not found or not visible"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 404 | `ENTITY_NOT_FOUND` | No site with this ID was found, it is not accessible to the user, or it belongs to another scope: the wrong `scope` was passed |
| 400 | `INVALID_PARAMS` | `id must be a positive safe integer` — `id` is not a positive integer |
| 400 | `INVALID_PARAMS` | `Unsupported query parameter` — a query parameter the method does not accept was passed |
| 400 | `INVALID_SCOPE` | `scope` is not `KNOWLEDGE`, `GROUP` or `MAINPAGE` |
| 409 | `LANDING_MODULE_NOT_ENABLED` | The Sites module is not available on the Bitrix24 account. Ask a Bitrix24 account administrator to enable it — while the module is disabled, retrying the request returns the same refusal |
| 422 | `BITRIX_ERROR` | `Bitrix24 returned invalid template areas` — Bitrix24 returned the areas in an unexpected shape |
| 403 | `SCOPE_DENIED` | The API key does not have the `landing` scope |
| 401 | `TOKEN_MISSING` | The API key has no tokens configured |

Full list of common API errors — [Errors](/docs/errors).

## Known specifics

- **Page areas are not merged into the response.** The response contains only the bindings of the site itself. The page bindings are read by [`GET /v1/pages/:id/template-areas`](/docs/entities/pages/template-areas-list): for a page that has no areas of its own, it returns an empty object, even when its site has areas.

## See also

- [Site template areas](/docs/entities/sites/template-areas)
- [Update site template areas](/docs/entities/sites/template-areas-update)
- [Clear site template areas](/docs/entities/sites/template-areas-delete)
- [Page template areas](/docs/entities/pages/template-areas)
- [List pages](/docs/entities/pages/list)
