---
type: api
title: Create a private location
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v8/operation/operation-post-private-location
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v8/operation/operation-post-private-location
products:
  - Kibana
---

# Create a private location

- Server: `https://{kibana_url}`

## Paths

- `POST` `/api/synthetics/private_locations`
- `POST` `/s/{space_id}/api/synthetics/private_locations`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/kibana/v8/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/kibana/v8/authentication#basicauth)

## Description

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

You must have `all` privileges for the Synthetics and Uptime feature in the Observability section of the Kibana feature privileges.

## Request Body

`application/json`

- `agentPolicyId` (string) — required
  The ID of the agent policy associated with the private location.
- `geo` (object) — optional
  Geographic coordinates (WGS84) for the location.
  - `lat` (number) — required
    The latitude of the location.
  - `lon` (number) — required
    The longitude of the location.
- `label` (string) — required
  A label for the private location.
- `spaces` ([] string) — optional
  An array of space IDs where the private location is available. If it is not provided, the private location is available in all spaces.
- `tags` ([] string) — optional
  An array of tags to categorize the private location.

## Responses

#### `200`

A successful response.

`application/json`

Type: `object`

#### `400`

If the `agentPolicyId` is already used by an existing private location or if the `label` already exists, the API will return a 400 Bad Request response with a corresponding error message.

## Code Examples

#### Console

```console
POST /api/synthetics/private_locations
{
  "label": "Private Location 1",
  "agentPolicyId": "abcd1234",
  "tags": ["private", "testing"],
  "geo": {
    "lat": 40.7128,
    "lon": -74.0060
  }
  "spaces": ["default"]
}
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/synthetics/private_locations" \
  -H "Content-Type: application/json" \
  -d '{
  "label": "Private Location 1",
  "agentPolicyId": "abcd1234",
  "tags": ["private", "testing"],
  "geo": {
    "lat": 40.7128,
    "lon": -74.0060
  }
  "spaces": ["default"]
}'
```

## Response Examples

#### Post private location response example1

```json
{
  "id": "abcd1234",
  "label": "Private Location 1",
  "agentPolicyId": "abcd1234",
  "tags": ["private", "testing"],
  "geo": {
    "lat": 40.7128,
    "lon": -74.0060
  }
}
```

