# Create Section

{% hint style="info" %}
How to create a new section.
{% endhint %}

{% hint style="warning" %}
Ensure to have read and write permissions.
{% endhint %}

You'll **need to supply a list of parameters whose name matches the name of the section elements**. For each element, you should give a value accordingly, or else the field would remain empty.

{% hint style="info" %}
You can find a list of all available elements in the [Available Data Types](https://docs.mburger.cloud/api-docs/going-deeper/available-elements) section!
{% endhint %}

This API accepts an arbitrary number of parameters.&#x20;

An overview on how to send data is present at [Common](https://app.gitbook.com/@mumble/s/mburger/~/drafts/-MDTbXsvnf7qyBZL7tcv/api-docs/common) section.

{% hint style="warning" %}
You'll always need to supply the locale in the elements key, even if your project has the Multi-language feature disabled.
{% endhint %}

For example, if you wish to populate a section that has the following elements:

* Title
* Description
* Image
* Link

The list of parameters for a single locale (for example, Italian `[it]`) should be:

* `elements[it][title]`
* `elements[it][description]`
* `elements[it][image][0]`
* `elements[it][link]`

{% hint style="info" %}
As you can see, every key of an element **must** be in the form of &#x20;

:small\_blue\_diamond: `elements[LOCALE][ELEMENT_NAME]`
{% endhint %}

{% hint style="info" %}
As you can see, every key of a media element (*image*, *audio*, *video*, *document*, *file*) **must** be in the form of&#x20;

:small\_blue\_diamond:`elements[LOCALE][ELEMENT_NAME][INDEX]`

Even if you add just a single image to a media element, it will always be considered as an array.&#x20;

An overview on how to send media files is presented in the [Multipart](https://docs.mburger.cloud/api-docs/common/post-bodies) section.
{% endhint %}

{% hint style="info" %}
Instead ***relation*** elements doesn't require a locale so the key **must** be in the form of&#x20;

:small\_blue\_diamond:`relation[BLOCK_INDEX]`
{% endhint %}

This API assigns the section creator based on which auth headers are present. If the **mobile** auth header is present the creator is the mobile user, otherwise it will be assigned to **project**.

{% tabs %}
{% tab title="Request" %}
`POST https://mburger.cloud/api/blocks/<id>/sections`

```bash
curl https://mburger.cloud/api/blocks/<id>/sections
-X POST 
-H "Accept: application/json" 
-H "Content-Type: application/x-www-form-urlencoded"
-H "X-MBurger-Token: <token>" 
-H "X-MBurger-Version: 3"
-d '<data>' 
```

#### &#x20;URL Parameters

| Name | Type | Required | Description |
| ---- | ---- | -------- | ----------- |
| id   | int  | Yes      | Block id    |

#### &#x20;Parameters

The parameters to create a section will depend on which elements the section is made of and how many locales are present.

| Name     | Type    | Required | Description                  |
| -------- | ------- | -------- | ---------------------------- |
| order    | int     | No       | To specify an order          |
| evidence | boolean | No       | Enable in\_evidence flag     |
| elements | array   | Yes      | An Array of block's elements |

{% hint style="info" %}
If evidence is true, is possible to set other two parameters:

{% endhint %}

| Name            | Type    | Required | Description              |
| --------------- | ------- | -------- | ------------------------ |
| evidence\_title | int     | No       | To specify an order      |
| evidence\_image | boolean | No       | Enable in\_evidence flag |
| {% endtab %}    |         |          |                          |

{% tab title="Response" %}
When successful, a HTTP 200 and JSON like this is returned:

```
{
  "status_code": 0,
  "body": {
    "id": 2,
    "order": 1,
    "all_locales": true,
    "visible": true,
    "in_evidence": false,
    "available_at": 1548343787,
    "updated_at": 1548343787
  }
}
```

{% endtab %}
{% endtabs %}
