# Kiteworks API — locations Operations

**4 endpoints** | [Browse interactive reference](https://developer.kiteworks.com/api-reference/locations.html) | [Download spec slice](https://developer.kiteworks.com/assets/specs/locations.json)

> **Authentication required.** All requests must include a Bearer access token in the
> `Authorization` header. See [Authentication](https://developer.kiteworks.com/authentication.md) for how to
> obtain a token using OAuth 2.0 Authorization Code (PKCE) or JWT Bearer flow.

---

## GET /rest/locations

**Summary:** Get locations

### Description:
  Returns a paginated list of available locations.
### Precondition:
  User must be authenticated.
### Response:
  Returns the list of locations.

**Parameters:**

| Name | In | Required | Description |
|------|----|----------|-------------|
| `limit` | query | no | Maximum number of locations to return. Must be between 1 and 10000. |
| `offset` | query | no | Number of locations to skip before returning results, for pagination. |
| `orderBy` | query | no | Sort order for the results. Default is `name:asc`. Allowed values: `name`, `name:asc`, `name:desc`. |

**Responses:**

| Code | Description |
|------|-------------|
| 200 | The locations have been successfully returned. |
| 401 | Unauthorized  <i>Possible error codes: </i>ERR_AUTH_INVALID_CSRF, ERR_AUTH_UNAUTHORIZED |
| 422 | Unprocessable Content  <i>Possible error codes: </i>ERR_INPUT_INVALID_FORMAT |
| 490 | Request blocked by WAF |

**Response Examples:**

**401 (ERR_AUTH_INVALID_CSRF):**

```json
{
  "errors": [
    {
      "code": "ERR_AUTH_INVALID_CSRF",
      "message": "Invalid CSRF Authentication"
    }
  ]
}
```

**401 (ERR_AUTH_UNAUTHORIZED):**

```json
{
  "errors": [
    {
      "code": "ERR_AUTH_UNAUTHORIZED",
      "message": "Unauthorized"
    }
  ]
}
```

**422 (ERR_INPUT_INVALID_FORMAT):**

```json
{
  "errors": [
    {
      "code": "ERR_INPUT_INVALID_FORMAT",
      "message": "The input is invalid."
    }
  ]
}
```

**Code Samples:**

**cURL:**

```shell
curl -X GET \
  "https://{instance}.kiteworks.com/rest/locations" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

**Python:**

```python
import requests

url = "https://{instance}.kiteworks.com/rest/locations"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
}
response = requests.get(url, headers=headers)
print(response.json())
```

---

## POST /rest/locations

**Summary:** Create a location entry.

Creates a new location entry with a name and optional domain. Requires system admin privileges.

**Parameters:**

| Name | In | Required | Description |
|------|----|----------|-------------|
| `returnEntity` | query | no | If set to `true`, returns information about the newly created entity. |
| `mode` | query | no | Determines the detail level of the response body. |

**Request Body:**

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `name` | string | yes | Location name. Ask administrator for location names for your server |
| `domain` | string | yes | A URL domain that can be used to access the servers in this location,                                  e.g. location.domain.com.                                     The domain should be registered in a DNS to point to the servers. |
| `addLinks` | boolean | no | Indicates whether HATEOAS links should be included in the response |

**Responses:**

| Code | Description |
|------|-------------|
| 200 | Location created successfully. |
| 403 | Forbidden  <i>Possible error codes: </i>ERR_ACCESS_SYSTEM_ADMIN |
| 409 | Conflict  <i>Possible error codes: </i>ERR_ENTITY_EXISTS |
| 422 | Unprocessable Content  <i>Possible error codes: </i>ERR_INPUT_INVALID_FORMAT, ERR_INPUT_REQUIRED |
| 490 | Request blocked by WAF |

**Response Examples:**

**200 (LocationCreated):**

```json
{
  "id": 3,
  "name": "EU Central",
  "dns": "eucentral.example.com"
}
```

**403 (ERR_ACCESS_SYSTEM_ADMIN):**

```json
{
  "errors": {
    "code": "ERR_ACCESS_SYSTEM_ADMIN",
    "message": "Authenticated user is not a System Admin"
  }
}
```

**409 (ERR_ENTITY_EXISTS):**

```json
{
  "errors": {
    "code": "ERR_ENTITY_EXISTS",
    "message": "Entity exists"
  }
}
```

**422 (ERR_INPUT_REQUIRED):**

```json
{
  "errors": {
    "code": "ERR_INPUT_REQUIRED",
    "message": "Field is required"
  }
}
```

**Code Samples:**

**cURL:**

```shell
curl -X POST \
  "https://{instance}.kiteworks.com/rest/locations" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
         "name": "string",
         "domain": "string",
         "addLinks": true
       }'
```

**Python:**

```python
import requests

url = "https://{instance}.kiteworks.com/rest/locations"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
  "name": "string",
  "domain": "string",
  "addLinks": true
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
```

---

## GET /rest/locations/{id}

**Summary:** Return location name.

Returns the details of the specified location, including its name and DNS URL.

**Parameters:**

| Name | In | Required | Description |
|------|----|----------|-------------|
| `id` | path | yes | ID of the location to be retrieved |

**Responses:**

| Code | Description |
|------|-------------|
| 200 | Location details retrieved successfully. |
| 490 | Request blocked by WAF |

**Response Examples:**

**200 (LocationInfo):**

```json
{
  "id": 1,
  "name": "US West",
  "dns": "uswest.example.com"
}
```

**Code Samples:**

**cURL:**

```shell
curl -X GET \
  "https://{instance}.kiteworks.com/rest/locations/:id" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

**Python:**

```python
import requests

id = "VALUE"  # ID of the location to be retrieved

url = f"https://{{instance}}.kiteworks.com/rest/locations/{id}"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
}
response = requests.get(url, headers=headers)
print(response.json())
```

---

## DELETE /rest/locations/{id}

**Summary:** Delete a location.

Permanently deletes the specified location. Requires system admin privileges.

**Parameters:**

| Name | In | Required | Description |
|------|----|----------|-------------|
| `id` | path | yes | ID of the location to remove from |

**Responses:**

| Code | Description |
|------|-------------|
| 204 | Location deleted successfully. |
| 403 | Forbidden  <i>Possible error codes: </i>ERR_ACCESS_SYSTEM_ADMIN, ERR_ACCESS_USER |
| 490 | Request blocked by WAF |

**Response Examples:**

**403 (ERR_ACCESS_SYSTEM_ADMIN):**

```json
{
  "errors": {
    "code": "ERR_ACCESS_SYSTEM_ADMIN",
    "message": "Authenticated user is not a System Admin"
  }
}
```

**403 (ERR_ACCESS_USER):**

```json
{
  "errors": {
    "code": "ERR_ACCESS_USER",
    "message": "Insufficient access permissions"
  }
}
```

**Code Samples:**

**cURL:**

```shell
curl -X DELETE \
  "https://{instance}.kiteworks.com/rest/locations/:id" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

**Python:**

```python
import requests

id = "VALUE"  # ID of the location to remove from

url = f"https://{{instance}}.kiteworks.com/rest/locations/{id}"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
}
response = requests.delete(url, headers=headers)
print(response.json())
```

---
