# Zone

**1. Fetch Zone Details**

* **GET** `/api/v1/zones/{uuid}`
* Obtain details of a specific zone by its UUID.

**Request Headers**

| **Name**      | **Description**        |
| ------------- | ---------------------- |
| Authorization | Required: Bearer Token |

**Path Parameters**

| **Parameter** | **Type** | **Description**                                |
| ------------- | -------- | ---------------------------------------------- |
| uuid          | string   | **\[Required]** The UUID of the zone to fetch. |

**Response**

**200 OK**

```json
{
    "timestamp": "2024-05-29T08:36:46.576325",
    "data": {
        "uuid": "000d1482-dae2-4e05-aaa1-3988a14a1d5a",
        "status": "OK",
        "name": "selling.cryptocoin",
        "asciiName": "selling.cryptocoin",
        "records": [
            {
                "uuid": "772e7a11-e34c-46a2-99fd-69b2aaa90fb4",
                "type": "NS",
                "name": "@",
                "value": "ns2.noto.network.",
                "ttl": 21600
            },
            {
                "uuid": "4a3f2431-0e40-4029-8a3e-b5c1bee421c1",
                "type": "A",
                "name": "selling.cryptocoin.",
                "value": "34.22.218.53",
                "ttl": 60
            },
            {
                "uuid": "5ba5deba-c42e-43b1-b322-3139c7d1b865",
                "type": "NS",
                "name": "@",
                "value": "ns1.noto.network.",
                "ttl": 21600
            },
            {
                "uuid": "af1835ef-62aa-41b0-999e-59ec6552733f",
                "type": "A",
                "name": "selling.cryptocoin.",
                "value": "34.22.218.51",
                "ttl": 60
            },
            {
                "uuid": "89a0e534-8a13-4cbd-9100-ac156d93ed0b",
                "type": "A",
                "name": "selling.cryptocoin.",
                "value": "34.22.218.54",
                "ttl": 60
            },
            {
                "uuid": "f66d2d12-a837-4f8c-8db2-27f81fff58de",
                "type": "SOA",
                "name": "selling.cryptocoin.",
                "value": "",
                "ttl": 3600,
                "serial": 2020080302,
                "refresh": 7200,
                "retry": 3600,
                "expire": 1209600,
                "mname": "selling.cryptocoin.",
                "rname": "hostmaster.selling.cryptocoin."
            }
        ],
        "registrar": {
            "name": "Freename",
            "street": "Samstagernstrasse 41",
            "city": "Wollerau",
            "postalCode": "8832",
            "country": "Switzerland",
            "phone": "",
            "email": "info@freename.io",
            "web": "https://freename.io",
            "walletAddress": "0xA1E885789C85FEFc76CC30236608B4A19A77e988"
        },
        "registrant": {
            "name": "Freename",
            "street": "Samstagernstrasse 41",
            "city": "Wollerau",
            "postalCode": "8832",
            "country": "Switzerland",
            "phone": "",
            "email": "info@freename.io",
            "web": "https://freename.io",
            "walletAddress": "0xA1E885789C85FEFc76CC30236608B4A19A77e988"
        }
    }
}
```

**2. Fetch Zones with Pagination**

* **GET** `/api/v1/zones`
* Include query parameters for pagination and sorting: `page`, `pageSize`, and `sortBy`.
* Example: `/api/v1/zones?page=1&pageSize=3&sortBy=created_at`

| **Name**      | **Description**            |
| ------------- | -------------------------- |
| Authorization | **Required**: Bearer Token |

**Query Parameters**

| **Parameter** | **Type** | **Description**                                |
| ------------- | -------- | ---------------------------------------------- |
| page          | integer  | The page number to retrieve. Default is 0.     |
| pageSize      | integer  | The number of zones per page. Default is 25.   |
| sortBy        | string   | The field to sort zones by. Default is "name". |

**Response**

**200 OK**

```json
{
    "timestamp": "2024-05-29T08:46:28.423894",
    "size": 3,
    "page": 1,
    "totalPages": 3927,
    "data": [
        {
            "uuid": "f21469c6-6ad5-4d8b-9332-3f0fb7cae879",
            "status": "OK",
            "name": "mattia.metaverse",
            "asciiName": "mattia.metaverse",
            "registry": {},
            "registrar": {
                "name": "Freename",
                "street": "Samstagernstrasse 41",
                "city": "Wollerau",
                "postalCode": "8832",
                "country": "Switzerland",
                "phone": "",
                "email": "info@freename.io",
                "web": "https://freename.io",
                "walletAddress": "0xA1E885789C85FEFc76CC30236608B4A19A77e988"
            },
            "registrant": {
                "name": "Freename",
                "street": "Samstagernstrasse 41",
                "city": "Wollerau",
                "postalCode": "8832",
                "country": "Switzerland",
                "phone": "",
                "email": "info@freename.io",
                "web": "https://freename.io",
                "walletAddress": "0xA1E885789C85FEFc76CC30236608B4A19A77e988"
            }
        },...
    ]
}
```

**3. Create Zone**

* **POST** `/api/v1/zones`
* Create a new zone with the provided details.
* Example: `/api/v1/zones?mint=false`

**Request Headers**

| **Name**      | **Description**        |
| ------------- | ---------------------- |
| Authorization | Required: Bearer Token |

**Query Parameters**

| Parameter | Type    | Description                                                             |
| --------- | ------- | ----------------------------------------------------------------------- |
| mint      | boolean | **\[Optional]** Indicates whether to mint the zone. Default is `false`. |

**Request Body**

```json
{
    "name": "test.metaverse",
    "status": "OK",
    "level": "TLD",
    "chain": "POLYGON",
    "description": "This is Test chain",
    "image": "https://picsum.photos/536/354",
    "url": "test.influencer",
    "records": [
        {
            "type": "SOA",
            "name": "test",
            "value": "10",
            "ttl": "1234"
        }
    ],
    "registryUuid": "1230a773-c74a-48ad-bb9a-fd4781774775",
    "registrarUuid": "5bbbbc79-2ead-4039-9b9d-d565cbbfcb2c",
    "registrantUuid": "5bbbbc79-2ead-4039-9b9d-d565cbbfcb2c",
    "mintingAddress": "0x204E7932A60A11c7001052169947f1e9D5CF1010",
    "registrationDate": "2024-07-10T08:30:00"
}
```

**Response**

**201 Created**

```json
{
    "timestamp": "2024-05-28T08:39:41.884582562",
    "data": {
        "uuid": "8ee6f423-a94a-4589-9e5c-9c5498829ca4",
        "status": "OK",
        "name": "test.metaverse",
        "asciiName": "test.metaverse",
        "chain": "ETH",
        "records": [
            {
                "uuid": "1edf299f-1471-423a-813c-020c935839bf",
                "type": "SOA",
                "name": "test",
                "value": "",
                "ttl": 1234,
                "serial": 2020080302,
                "refresh": 7200,
                "retry": 3600,
                "expire": 1209600,
                "mname": "test.metaverse.",
                "rname": "hostmaster.test.metaverse."
            }
        ],
        "registrar": {
            "name": "****",
            "city": "****",
            "country": "****",
            "email": "****"
        },
        "registrant": {
            "name": "****",
            "city": "****",
            "country": "****",
            "email": "****"
        },
        "registrationDate": "2024-07-10T08:30:00"
    }
}
```

Minting address and chain are mandatory if minting is set to true.

**4. Update Zone Status**

Modifies the status of a zone identified by the provided UUID. Acceptable statuses include 'OK', 'INACTIVE', 'LOCK', 'PENDING', and 'ERROR'.

* **PATCH** `/api/v1/zones/{uuid}/?status={new_status}`
* Update the status of a specific zone identified by its UUID.
* Example: `/api/v1/zones/{uuid}/?status=INACTIVE`

**Request Headers**

| **Name**      | **Description**        |
| ------------- | ---------------------- |
| Authorization | Required: Bearer Token |

**Path Parameters**

| **Parameter** | **Type** | **Description**                                 |
| ------------- | -------- | ----------------------------------------------- |
| uuid          | string   | **\[Required]** The UUID of the zone to modify. |

**Query Parameters**

| **Parameter** | **Type** | **Description**                                                                                                     |
| ------------- | -------- | ------------------------------------------------------------------------------------------------------------------- |
| status        | string   | **\[Required]** The new status of the zone. Acceptable values are 'OK', 'INACTIVE', 'LOCK', 'PENDING', and 'ERROR'. |

**Response**

**200 OK**

```json
{
    "timestamp": "2024-05-28T14:21:23.152861",
    "data": {
        "uuid": "8ee6f423-a94a-4589-9e5c-9c5498829ca4",
        "status": "INACTIVE",
        "name": "test.metaverse",
        "asciiName": "test.metaverse",
        "chain": "ETH",
        "records": [
            {
                "uuid": "1edf299f-1471-423a-813c-020c935839bf",
                "type": "SOA",
                "name": "test",
                "value": "",
                "ttl": 1234,
                "serial": 2020080302,
                "refresh": 7200,
                "retry": 3600,
                "expire": 1209600,
                "mname": "test.metaverse.",
                "rname": "hostmaster.test.metaverse."
            }
        ],
        "registrar": {
            "name": "****",
            "city": "****",
            "country": "****",
            "email": "****"
        },
        "registrant": {
            "name": "****",
            "city": "****",
            "country": "****",
            "email": "****"
        },
        "registrationDate": "2024-07-10T08:30:00"
    }
}
```

**5. Fetch Zones of Logged User**

* **GET** `/api/v1/zones/self`
* Retrieve zones owned by the logged-in user.
* Example: `/api/v1/zones/self?page=1&pageSize=3&sortBy=name`

**Request Headers**

| **Name**      | **Description**        |
| ------------- | ---------------------- |
| Authorization | Required: Bearer Token |

**Query Parameters**

| **Parameter** | **Type** | **Description**                                |
| ------------- | -------- | ---------------------------------------------- |
| page          | integer  | The page number to retrieve. Default is 0.     |
| pageSize      | integer  | The number of zones per page. Default is 25.   |
| sortBy        | string   | The field to sort zones by. Default is "name". |

**Response**

**200 OK**

```json
{
    "timestamp": "2024-05-29T09:11:15.624976",
    "size": 3,
    "page": 1,
    "totalElements": 7,
    "totalPages": 3,
    "data": [
        {
            "uuid": "85a8eede-2efa-4976-93b4-8582bdcd57d0",
            "status": "OK",
            "name": "Test0",
            "asciiName": "Test0",
            "chain": "ETH",
            "registry": {},
            "registrar": {
                "name": "****",
                "city": "****",
                "country": "****",
                "email": "info@****.com"
            },
            "registrant": {
                "name": "****",
                "city": "Bengaluru",
                "country": "India",
                "email": "info@****.com"
            },
            "registrationDate": "2024-07-10T08:30:00"
        },
        {
            "uuid": "00ba86bb-e845-4cec-a8af-381124b32807",
            "status": "OK",
            "name": "Test01",
            "asciiName": "Test01",
            "chain": "ETH",
            "registry": {},
            "registrar": {
                "name": "****",
                "city": "Bengaluru",
                "country": "India",
                "email": "info@****.com"
            },
            "registrant": {
                "name": "****",
                "city": "Bengaluru",
                "country": "India",
                "email": "info@****.com"
            },
            "registrationDate": "2024-07-10T08:30:00"
        },
        {
            "uuid": "4da7db6a-df19-4a0f-9d77-ef1fdf3ec300",
            "status": "OK",
            "name": "Test16",
            "asciiName": "Test16",
            "chain": "ETH",
            "registry": {},
            "registrar": {
                "name": "****",
                "city": "Bengaluru",
                "country": "India",
                "email": "info@****.com"
            },
            "registrant": {
                "name": "****",
                "city": "Bengaluru",
                "country": "India",
                "email": "info@****.com"
            },
            "registrationDate": "2024-07-10T08:30:00"
        }
    ]
}
```

**6. Fetch Zone by Name**

Given that this endpoint will function as a 'Whois' controller, we can discontinue the use of the custom 'Whois' controller we previously implemented.

* **GET** `/api/v1/zones/name/{zone_name}`
* Retrieve zone details by its name.
* Example `/api/v1/zones/name/selling.cryptocoin`

**Request Headers**

| **Name**      | **Description**        |
| ------------- | ---------------------- |
| Authorization | Required: Bearer Token |

**Path Parameters**

| **Parameter** | **Type** | **Description**                                |
| ------------- | -------- | ---------------------------------------------- |
| name          | string   | **\[Required]** The name of the zone to fetch. |

**Response**

**200 OK**

```json
{
    "timestamp": "2024-05-29T09:15:02.894655",
    "data": {
        "uuid": "000d1482-dae2-4e05-aaa1-3988a14a1d5a",
        "status": "OK",
        "name": "selling.cryptocoin",
        "asciiName": "selling.cryptocoin",
        "records": [
            {
                "uuid": "89a0e534-8a13-4cbd-9100-ac156d93ed0b",
                "type": "A",
                "name": "selling.cryptocoin.",
                "value": "34.22.218.54",
                "ttl": 60
            },
            {
                "uuid": "4a3f2431-0e40-4029-8a3e-b5c1bee421c1",
                "type": "A",
                "name": "selling.cryptocoin.",
                "value": "34.22.218.53",
                "ttl": 60
            },
            {
                "uuid": "5ba5deba-c42e-43b1-b322-3139c7d1b865",
                "type": "NS",
                "name": "@",
                "value": "ns1.noto.network.",
                "ttl": 21600
            },
            {
                "uuid": "f66d2d12-a837-4f8c-8db2-27f81fff58de",
                "type": "SOA",
                "name": "selling.cryptocoin.",
                "value": "",
                "ttl": 3600,
                "serial": 2020080302,
                "refresh": 7200,
                "retry": 3600,
                "expire": 1209600,
                "mname": "selling.cryptocoin.",
                "rname": "hostmaster.selling.cryptocoin."
            },
            {
                "uuid": "af1835ef-62aa-41b0-999e-59ec6552733f",
                "type": "A",
                "name": "selling.cryptocoin.",
                "value": "34.22.218.51",
                "ttl": 60
            },
            {
                "uuid": "772e7a11-e34c-46a2-99fd-69b2aaa90fb4",
                "type": "NS",
                "name": "@",
                "value": "ns2.noto.network.",
                "ttl": 21600
            }
        ],
        "registrar": {
            "name": "Freename",
            "street": "Samstagernstrasse 41",
            "city": "Wollerau",
            "postalCode": "8832",
            "country": "Switzerland",
            "phone": "",
            "email": "info@freename.io",
            "web": "https://freename.io",
            "walletAddress": "0xA1E885789C85FEFc76CC30236608B4A19A77e988"
        },
        "registrant": {
            "name": "Freename",
            "street": "Samstagernstrasse 41",
            "city": "Wollerau",
            "postalCode": "8832",
            "country": "Switzerland",
            "phone": "",
            "email": "info@freename.io",
            "web": "https://freename.io",
            "walletAddress": "0xA1E885789C85FEFc76CC30236608B4A19A77e988"
        }
    }
}
```

**7. Check Name Availability**

* **GET** `/api/v1/zones/availability/{zone_name}`
* Check the availability of a zone name.
* Example: `api/v1/zones/availability/selling.cryptocoin`

**Path Parameters**

| **Parameter** | **Type** | **Description**                                                 |
| ------------- | -------- | --------------------------------------------------------------- |
| name          | string   | **\[Required]** The name of the zone to check availability for. |

**Response**

**200 OK**

```json
{
    "timestamp": "2024-05-29T09:21:12.87402",
    "data": false
}
```

**8. Transfer Zone**

* **PATCH** `/api/v1/zones/transfer/{uuid}`
* Transfers zone from one registrar/registrant to another by uuid.

**Request Headers**

| **Name**      | **Description**        |
| ------------- | ---------------------- |
| Authorization | Required: Bearer Token |

**Path Parameters**

| **Parameter** | **Type** | **Description**                                   |
| ------------- | -------- | ------------------------------------------------- |
| uuid          | string   | **\[Required]** The UUID of the zone to transfer. |

**Request Body**

```json
{
    "registrar" : "1230a773-c74a-48ad-bb9a-fd4781774775",
    "registrant" : "1230a773-c74a-48ad-bb9a-fd4781774775"
}
```

**Response**

**200 OK**

```json
{
    "timestamp": "2024-05-29T09:25:34.595517",
    "data": {
        "uuid": "000d1482-dae2-4e05-aaa1-3988a14a1d5a",
        "status": "OK",
        "name": "selling.cryptocoin",
        "asciiName": "selling.cryptocoin",
        "records": [
            {
                "uuid": "4a3f2431-0e40-4029-8a3e-b5c1bee421c1",
                "type": "A",
                "name": "selling.cryptocoin.",
                "value": "34.22.218.53",
                "ttl": 60
            },
            {
                "uuid": "89a0e534-8a13-4cbd-9100-ac156d93ed0b",
                "type": "A",
                "name": "selling.cryptocoin.",
                "value": "34.22.218.54",
                "ttl": 60
            },
            {
                "uuid": "5ba5deba-c42e-43b1-b322-3139c7d1b865",
                "type": "NS",
                "name": "@",
                "value": "ns1.noto.network.",
                "ttl": 21600
            },
            {
                "uuid": "af1835ef-62aa-41b0-999e-59ec6552733f",
                "type": "A",
                "name": "selling.cryptocoin.",
                "value": "34.22.218.51",
                "ttl": 60
            },
            {
                "uuid": "f66d2d12-a837-4f8c-8db2-27f81fff58de",
                "type": "SOA",
                "name": "selling.cryptocoin.",
                "value": "",
                "ttl": 3600,
                "serial": 2020080302,
                "refresh": 7200,
                "retry": 3600,
                "expire": 1209600,
                "mname": "selling.cryptocoin.",
                "rname": "hostmaster.selling.cryptocoin."
            },
            {
                "uuid": "772e7a11-e34c-46a2-99fd-69b2aaa90fb4",
                "type": "NS",
                "name": "@",
                "value": "ns2.noto.network.",
                "ttl": 21600
            }
        ],
        "registrar": {
            "name": "Freename",
            "street": "Samstagernstrasse 41",
            "city": "Wollerau",
            "postalCode": "8832",
            "country": "Switzerland",
            "phone": "",
            "email": "info@freename.io",
            "web": "https://freename.io",
            "walletAddress": "0xA1E885789C85FEFc76CC30236608B4A19A77e988"
        },
        "registrant": {
            "name": "Freename",
            "street": "Samstagernstrasse 41",
            "city": "Wollerau",
            "postalCode": "8832",
            "country": "Switzerland",
            "phone": "",
            "email": "info@freename.io",
            "web": "https://freename.io",
            "walletAddress": "0xA1E885789C85FEFc76CC30236608B4A19A77e988"
        }
    }
}
```

**9. Search Zone**

* **POST** `/api/v1/zones/search`
* Fetches zones based on the provided search criteria.
* Example: `/api/v1/zones/search?page=1&pageSize=2&sortBy=zone.created_at`

**Request Headers**

| **Name**      | **Description**        |
| ------------- | ---------------------- |
| Authorization | Required: Bearer Token |

**Request Body**

```json
[
    {
        "field": "registrant.postal_code",
        "value": "8832",
        "criteria": "EQUAL"
    }
]
```

**Request Body Parameters**

| **Parameter** | **Type** | **Description**                                                                                                                                                         |
| ------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| field         | string   | The field name to search for (e.g. `zone.uuid` , `registry.name` , `registrar.postal_code` , …)                                                                         |
| value         | string   | The value to search for.                                                                                                                                                |
| criteria      | enum     | The criteria type for the search. Possible values: LIKE, NOT\_LIKE, EQUAL, NOT\_EQUAL, GREATER\_THAN, GREATER\_EQUAL, LESS\_THAN, LESS\_EQUAL, IS\_NULL, IS\_NOT\_NULL. |

**List of fields available to search**

```
zone.uuid
zone.name
zone.status
zone.registration_date
zone.expire_date
zone.grace_end_date
info.ascii_name
info.chain
info.token_id
info.contract
registry.name
registry.street
registry.postal_code
registry.city
registry.country
registry.email
registry.phone
registry.web
registry.wallet_address
registrar.name
registrar.street
registrar.postal_code
registrar.city
registrar.country
registrar.email
registrar.phone
registrar.web
registrar.wallet_address
registrant.name
registrant.street
registrant.postal_code
registrant.city
registrant.country
registrant.email
registrant.phone
registrant.web
registrant.wallet_address
```

**Query Parameters**

| **Parameter** | **Type** | **Description**                                           |
| ------------- | -------- | --------------------------------------------------------- |
| page          | integer  | The page number to retrieve. Default is 0.                |
| pageSize      | integer  | The number of zones per page. Default is 25.              |
| sortBy        | string   | The field to sort the results by. Default is 'zone.name'. |

**Response**

**200 OK**

```json
{
    "timestamp": "2024-05-29T09:34:42.694977",
    "size": 2,
    "page": 1,
    "totalElements": 11722,
    "totalPages": 5861,
    "data": [
        {
            "uuid": "e5497e32-43b0-48ab-9461-97bada6881fa",
            "status": "OK",
            "name": "davide.lion",
            "asciiName": "davide.lion",
            "registry": {},
            "registrar": {
                "name": "Freename",
                "street": "Samstagernstrasse 41",
                "city": "Wollerau",
                "postalCode": "8832",
                "country": "Switzerland",
                "phone": "",
                "email": "info@freename.io",
                "web": "https://freename.io",
                "walletAddress": "0xA1E885789C85FEFc76CC30236608B4A19A77e988"
            },
            "registrant": {
                "name": "Freename",
                "street": "Samstagernstrasse 41",
                "city": "Wollerau",
                "postalCode": "8832",
                "country": "Switzerland",
                "phone": "",
                "email": "info@freename.io",
                "web": "https://freename.io",
                "walletAddress": "0xA1E885789C85FEFc76CC30236608B4A19A77e988"
            }
        },
        {
            "uuid": "f21469c6-6ad5-4d8b-9332-3f0fb7cae879",
            "status": "OK",
            "name": "mattia.metaverse",
            "asciiName": "mattia.metaverse",
            "registry": {},
            "registrar": {
                "name": "Freename",
                "street": "Samstagernstrasse 41",
                "city": "Wollerau",
                "postalCode": "8832",
                "country": "Switzerland",
                "phone": "",
                "email": "info@freename.io",
                "web": "https://freename.io",
                "walletAddress": "0xA1E885789C85FEFc76CC30236608B4A19A77e988"
            },
            "registrant": {
                "name": "Freename",
                "street": "Samstagernstrasse 41",
                "city": "Wollerau",
                "postalCode": "8832",
                "country": "Switzerland",
                "phone": "",
                "email": "info@freename.io",
                "web": "https://freename.io",
                "walletAddress": "0xA1E885789C85FEFc76CC30236608B4A19A77e988"
            }
        }
    ]
}
```

**10. Mint Zone**

* **POST** `/api/v1/zones/minting`
* Starts minting process of a zone

**Request Headers**

| **Name**      | **Description**        |
| ------------- | ---------------------- |
| Authorization | Required: Bearer Token |

**Request Body**

```json
{
  "mintDetail": [
    {
      "blockchain": "POLYGON",
      "name": "test.test"
    }
  ]
}
```

**Response Body**

```json
{
    "timestamp": "2024-06-18T16:13:49.711173",
    "data": [
        {
            "blockchain": "polygon-mumbai",
            "name": "test.test"
        }
    ]
}
```

11. **Check Minting Status**

* **GET** `/api/v1/zones/minting/{zoneName}`

This API endpoint allows users to check the status of the minting process for a specific zone identified by its name. By sending a GET request with the zone name as a parameter, the response will indicate the current status of the minting process.

**Request Headers**

<table data-header-hidden><thead><tr><th width="189"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td><strong>Description</strong></td></tr><tr><td>Bearer Token</td><td>[<strong>Required</strong>] The authorization token for accessing the API.</td></tr></tbody></table>

**Response**

```json
{
    "timestamp": "2024-06-05T14:58:29.051037",
    "data": {
        "zoneName": "test.test",
        "status": "PENDING"
    }
}
```

If the status is in `PENDING`, the transaction hash is not displayed. Once the transaction is `COMPLETE`, the transaction hash is also provided.

```json
{
    "timestamp": "2024-06-05T14:59:34.473077",
    "data": {
        "zoneName": "test.test",
        "status": "COMPLETE",
        "transactionHash": "0xd72495d373...94d5cc62123g9fcba6e9c04zff3"
    }
}
```
