# Create a site block

**Publié le** : 2026-05-08
**Catégorie** : Core CMS

## `POST /site-blocks`

**Create a site block**

Creates a new site block with a name, type, and optional schema.
The slug is auto-generated from the name.

Required permissions: `site_blocks.create`

### Responses

| Status | Description |
| --- | --- |
| `201` | Successful response |
| `401` | Unauthorized — invalid or missing API token |
| `403` | Forbidden — insufficient permissions |
| `422` | Validation error |


> **Notes:** - For `page` type, set `path` to define the URL (e.g., `/about`).
> 
> - Schema can be added later via `PUT /site-blocks/{slug}/schema`.

### Examples

```bash
curl -X POST https://api.lynkow.com/v1/site-blocks \
  -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Sidebar",
    "type": "global",
    "schema": [
      {"name": "title", "type": "string", "label": "Title"},
      {"name": "links", "type": "array", "label": "Links", "items": {"type": "object", "fields": [{"name": "label", "type": "string"}, {"name": "url", "type": "url"}]}}
    ]
  }'
```

### Response Example

```json
{
  "data": {
    "id": 4,
    "name": "Sidebar",
    "slug": "sidebar",
    "type": "global",
    "status": "draft",
    "locale": "en",
    "schema": [
      {
        "name": "title",
        "type": "string",
        "label": "Title"
      },
      {
        "name": "links",
        "type": "array",
        "label": "Links"
      }
    ],
    "data": {},
    "createdAt": "2025-04-06T12:00:00.000Z",
    "updatedAt": "2025-04-06T12:00:00.000Z"
  }
}
```

---