# Create Primary Zones

{% hint style="info" %}
**Note:** Only contract administrators, owners, and users with "accessAndManageDns" privilege can create and manage primary zones and DNS records via API. You can also set User privileges in the [<mark style="color:blue;">DCD</mark>](../dcd-how-tos/set-user-privileges).
{% endhint %}

{% hint style="info" %}
**Prerequisite:** You need an IONOS Cloud account with API credentials configured with the appropriate permissions.
{% endhint %}

To create a primary zone with [<mark style="color:blue;">Cloud DNS API</mark>](https://api.ionos.com/docs/dns/v1/), follow this step:

* Perform a POST request with the domain or subdomain, a description of your primary zone (optional), and the primary zone status (enable), true or false.

{% hint style="success" %}
**Result:** On a successful POST request, you receive a response containing the primary zone UUID, Name Servers, and the request status.
{% endhint %}

### Request

```bash
curl --location \  
--request POST  'https://dns.de-fra.ionos.com/zones' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJraWQiO' \
--header 'Content-Type: application/json' \
--data '{
   "properties": {
    "zoneName": "example.com",
     "description": "example of zone creation",
     "enabled": true
    }
}'
```

### Response

**202 Successful operation**

```json
{
    "id": "2a4428b3-dbe0-4357-9c02-609025b3a40f",
    "type": "zone",
    "href": "<RESOURCE-URI>",
    "metadata": {
        "createdDate": "2022-08-21T15:52:53Z",
        "createdBy": "ionos:iam:cloud:31960002:users/87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
        "createdByUserId": "87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
        "lastModifiedDate": "2022-08-21T15:52:53Z",
        "lastModifiedBy": "ionos:iam:cloud:31960002:users/87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
        "lastModifiedByUserId": "63cef532-26fe-4a64-a4e0-de7c8a506c90",
        "resourceURN": "ionos:<product>:<location>:<contract>:<resource-path>",
        "nameservers": [
            "ns-ic.ui-dns.com",
            "ns-ic.ui-dns.de",
            "ns-ic.ui-dns.org",
            "ns-ic.ui-dns.biz"
        ],
        "state": "CREATED"
    },
    "properties": {
	      "zoneName": "example.com",
        "description": "example of zone creation",
        "enabled": true
    }
}
```

#### Response Fields

| Field                    | Type   | Description                                           | Example                                                                                       |
| ------------------------ | ------ | ----------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| **id**                   | string | UUID of the newly created primary zone                | 2a4428b3-dbe0-4357-9c02-609025b3a40f                                                          |
| **type**                 | string | Type of the resource                                  | zone                                                                                          |
| **href**                 | string | Absolute path to the newly created primary zone       |                                                                                               |
| **createdDate**          | string | Primary zone creation timestamp                       | 2023-03-15T09:58:59.147746133Z                                                                |
| **createdBy**            | string | Unique name of the identity that created the resource | ionos:iam:cloud:31960002:users/87f9a82e-b28d-49ed-9d04-fba2c0459cd3                           |
| **createdByUserId**      | string | The unique ID of the user who created the resource    | 87f9a82e-b28d-49ed-9d04-fba2c0459cd3                                                          |
| **lastModifiedDate**     | string | Primary zone update timestamp                         | 2023-03-15T09:58:59.147746133Z                                                                |
| **lastModifiedBy**       | string | Unique ID of the user has last modified the resource  | ionos:iam:cloud:31960002:users/87f9a82e-b28d-49ed-9d04-fba2c0459cd3                           |
| **lastModifiedByUserId** | string | Primary zone update timestamp                         | 63cef532-26fe-4a64-a4e0-de7c8a506c90                                                          |
| **resourceURN**          | string | Unique name of the resource                           | `ionos:<product>:<location>:<contract>:<resource-path>`                                       |
| **nameservers**          | array  | Name Servers assigned to the primary zone             | <p>"ns-ic.ui-dns.com",<br>"ns-ic.ui-dns.de",<br>"ns-ic.ui-dns.org",<br>"ns-ic.ui-dns.biz"</p> |
| **state**                | string | State of the request                                  | CREATED                                                                                       |

## Quota

To retrieve the quota of primary zones, perform a GET request to the `/quota` endpoint.

{% hint style="success" %}
**Result:** On a successful GET request, you receive a response containing the quota limits and quota usage for your contract.
{% endhint %}

### Request

```bash
curl --location 'https://dns.de-fra.ionos.com/quota' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJraWQiO' \
--header 'Content-Type: application/json'
```

### Response

**200 OK**

```json
{
  "quotaLimits": {
    "records": 100000,
    "reverseRecords": 5000,
    "secondaryZones": 100000,
    "zones": 50000
  },
  "quotaUsage": {
    "records": 9,
    "reverseRecords": 1,
    "secondaryZones": 6,
    "zones": 5
  }
}
```

#### Response Fields

| Field              | Type   | Description                        | Example |
| ------------------ | ------ | ---------------------------------- | ------- |
| **records**        | string | Number of DNS records              | 100000  |
| **reverseRecords** | string | Number of reverse DNS records      | 5000    |
| **secondaryZones** | string | Number of secondary primary zones  | 100000  |
| **zones**          | string | Number of primary zones            | 50000   |
| **records**        | string | Number of DNS records used         | 9       |
| **reverseRecords** | string | Number of reverse DNS records used | 1       |
| **secondaryZones** | string | Number of secondary zones used     | 6       |
| **zones**          | string | Number of primary zones used       | 5       |
