# Create Share

To create a share within the Network File Storage's cluster, via the API, perform a POST request with the `clusterId`. The request automatically creates a share within the respective cluster.

{% hint style="info" %}
**Prerequisites:** Only contract administrators, owners, and users with **accessAndManageNFS** privileges can create and manage clusters.
{% endhint %}

## Endpoints

Use a [<mark style="color:blue;">region-specific endpoint</mark>](https://docs.ionos.com/sections-test/guides/storage-and-backup/network-file-storage/api-how-tos/..#endpoints) to create a share: `https://nfs.{region}.ionos.com/clusters/{clusterId}/shares`

## Request

{% hint style="info" %}
**Note:** The following request contains sample values. Remember to replace them with the relevant information.
{% endhint %}

```json
curl -X 'POST' \
  'https://nfs.de-txl.ionos.com/clusters/e69b22a5-8fee-56b1-b6fb-4a07e4205ead/shares' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "metadata": {},
  "properties": {
    "name": "example-export",
    "quota": 512,
    "clientGroups": [
      {
        "ipNetworks": [
          "10.234.50.0/24"
        ],
        "hosts": [
          "10.234.62.123"
        ],
        "nfs": {
          "squash": "all-anonymous"
        }
      }
    ]
  }
}'
```

{% tabs %}
{% tab title="Request Header Parameters" %}
To make authenticated requests to the API, the following fields are mandatory in the request header:

| Header Parameters | Required |  Type  | Description                                                                                                                                                                          |
| ----------------- | :------: | :----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Authorization`   |    yes   | string | Use a `Bearer token`. For more information, see [Authentication](https://docs.ionos.com/sections-test/guides/storage-and-backup/network-file-storage/api-how-tos/..#authentication). |
| `Content-Type`    |    yes   | string | Set this to `application/json`.                                                                                                                                                      |
| {% endtab %}      |          |        |                                                                                                                                                                                      |

{% tab title="Request Path Parameters" %}
Below is the list of mandatory path parameter:

| Body Parameters | Type   | Description                   | Example                                |
| --------------- | ------ | ----------------------------- | -------------------------------------- |
| `clusterId`     | string | The ID (UUID) of the Cluster. | `e69b22a5-8fee-56b1-b6fb-4a07e4205ead` |
| {% endtab %}    |        |                               |                                        |
| {% endtabs %}   |        |                               |                                        |

## Response

A **201** message confirms that the share creation is successful. Your values will differ from those in the sample code. It may contain different IDs, timestamps etc.

```json
{
  "id": "7b1ef56d-dfc6-51fe-aff0-7af2d6747868",
  "type": "share",
  "href": "/clusters/{clusterId}/shares/7b1ef56d-dfc6-51fe-aff0-7af2d6747868",
  "metadata": {
    "createdDate": "2020-12-10T13:37:50+01:00",
    "createdBy": "ionos:identity:::users/87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
    "createdByUserId": "87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
    "lastModifiedDate": "2020-12-11T13:37:50+01:00",
    "lastModifiedBy": "ionos:identity:::users/87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
    "lastModifiedByUserId": "87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
    "resourceURN": "ionos:<product>:<location>:<contract>:<resource-path>",
    "status": "AVAILABLE",
    "statusMessage": null,
    "nfsPath": "/7b1ef56d-dfc6-51fe-aff0-7af2d6747868"
  },
  "properties": {
    "name": "example-export",
    "quota": 512,
    "clientGroups": [
      {
        "ipNetworks": [
          "10.234.50.0/24"
        ],
        "hosts": [
          "10.234.62.123"
        ],
        "nfs": {
          "squash": "all-anonymous"
        }
      }
    ]
  }
} 
```
