> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ocpplab.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ocpplab.io/_mcp/server.

# Create location, optionally with chargers

POST https://api.ocpplab.io/evcharger/location
Content-Type: application/json

Returns 202 at once and deploys the chargers in the background. Follow progress with ``GET /evcharger/deployment-runtime-ops/status`` (``client.evcharger.deployment_runtime_ops.status()``) until every charger is online. With no chargers only the location is created; add chargers later with POST /evcharger/deployment and location_id. A failed charger does not abort the batch. Background work is not durable across restarts.

Reference: https://docs.ocpplab.io/api-reference/evcharger/location/create

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects an OcppVirtualDeploymentLocationRequest.

- `name` (string, required) — Location display name.
- `address` (string, required)
- `city` (string, required)
- `country` (string, required)
- `coordinates` (VirtualLocationCoordinates, required) — GPS coordinates; lat in [-90,90], lng in [-180,180].
- `timezone` (string, optional, nullable)
- `owner_name` (string, optional, nullable)
- `public` (boolean, optional, nullable)
- `chargers` (list of VirtualLocationChargerItem, optional) — Chargers to deploy at this location. Optional: an empty list creates the location only; add chargers later with POST /evcharger/deployment and its location_id.

## Response

### 202

Location creation accepted

- `detail` (string, required) — What was accepted and is running in the background.
- `location_id` (string, required) — Id of the location being created; pass it to ``DELETE /evcharger/location`` to remove the location and its chargers.
- `status` (string, optional, default: accepted) — Always 'accepted'.

## Errors

### 401 Unauthorized Error

Missing or invalid Bearer token

- `detail` (string, required) — Human-readable error message returned by the API.

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional) — One entry per invalid field.

## Types

### VirtualLocationCoordinates

GPS coordinates for a virtual-location request.

- `lat` (double, required)
- `lng` (double, required)

### VirtualLocationChargerItem

One charger inside a deployment-location request.

- `identity` (string, required) — Unique charge point identity.
- `brand_slug` (string, required)
- `model` (string, required)
- `connector_type` (string, required)
- `ws_url` (string, required)
- `ocpp_version` (string, optional, default: OCPP1.6)
- `security_profile` (integer, optional, nullable)
- `authorization_key` (string, optional, nullable)
- `charge_point_name` (string, optional, nullable)

### ValidationError

Why one field is invalid.

- `loc` (list of ValidationErrorLocItems, required) — Where the field is: ``body`` / ``query`` / ``path`` / ``header``, then its name.
- `msg` (string, required) — What is wrong, in English.
- `type` (string, required) — Machine-readable error code, e.g. ``missing``.
- `input` (any, optional) — The value that was sent.
- `ctx` (ValidationErrorCtx, optional) — Details of the rule that failed, e.g. `{"le": 200}`.

### ValidationErrorLocItems

### ValidationErrorCtx

Details of the rule that failed, e.g. `{"le": 200}`.

## Examples

### evcharger_location_create_example

**Response**

```json
{
  "detail": "Location creation accepted; chargers are deploying in the background.",
  "location_id": "3f129601-158b-47d6-aab9-489d4d6163fa",
  "status": "accepted"
}
```

**SDK Code**

```python evcharger_location_create_example
import requests

url = "https://api.ocpplab.io/evcharger/location"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript evcharger_location_create_example
const url = 'https://api.ocpplab.io/evcharger/location';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go evcharger_location_create_example
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.ocpplab.io/evcharger/location"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby evcharger_location_create_example
require 'uri'
require 'net/http'

url = URI("https://api.ocpplab.io/evcharger/location")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java evcharger_location_create_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.ocpplab.io/evcharger/location")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php evcharger_location_create_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.ocpplab.io/evcharger/location', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp evcharger_location_create_example
using RestSharp;

var client = new RestClient("https://api.ocpplab.io/evcharger/location");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift evcharger_location_create_example
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.ocpplab.io/evcharger/location")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Create a location with one charger

**Request**

```json
{
  "name": "La Defense Charging Hub",
  "address": "1 Parvis de la Defense",
  "city": "Puteaux",
  "country": "FRA",
  "coordinates": {
    "lat": 48.892,
    "lng": 2.238
  },
  "timezone": "Europe/Paris",
  "chargers": [
    {
      "identity": "CP-001",
      "brand_slug": "wallbox",
      "model": "wallbox-pulsar-plus",
      "connector_type": "Type2",
      "ws_url": "wss://evcharger.example.com"
    }
  ]
}
```

**Response**

```json
{
  "detail": "Location creation accepted; chargers are deploying in the background.",
  "location_id": "3f129601-158b-47d6-aab9-489d4d6163fa",
  "status": "accepted"
}
```

**SDK Code**

```python Create a location with one charger
import requests

url = "https://api.ocpplab.io/evcharger/location"

payload = {
    "name": "La Defense Charging Hub",
    "address": "1 Parvis de la Defense",
    "city": "Puteaux",
    "country": "FRA",
    "coordinates": {
        "lat": 48.892,
        "lng": 2.238
    },
    "timezone": "Europe/Paris",
    "chargers": [
        {
            "identity": "CP-001",
            "brand_slug": "wallbox",
            "model": "wallbox-pulsar-plus",
            "connector_type": "Type2",
            "ws_url": "wss://evcharger.example.com"
        }
    ]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Create a location with one charger
const url = 'https://api.ocpplab.io/evcharger/location';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"La Defense Charging Hub","address":"1 Parvis de la Defense","city":"Puteaux","country":"FRA","coordinates":{"lat":48.892,"lng":2.238},"timezone":"Europe/Paris","chargers":[{"identity":"CP-001","brand_slug":"wallbox","model":"wallbox-pulsar-plus","connector_type":"Type2","ws_url":"wss://evcharger.example.com"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Create a location with one charger
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.ocpplab.io/evcharger/location"

	payload := strings.NewReader("{\n  \"name\": \"La Defense Charging Hub\",\n  \"address\": \"1 Parvis de la Defense\",\n  \"city\": \"Puteaux\",\n  \"country\": \"FRA\",\n  \"coordinates\": {\n    \"lat\": 48.892,\n    \"lng\": 2.238\n  },\n  \"timezone\": \"Europe/Paris\",\n  \"chargers\": [\n    {\n      \"identity\": \"CP-001\",\n      \"brand_slug\": \"wallbox\",\n      \"model\": \"wallbox-pulsar-plus\",\n      \"connector_type\": \"Type2\",\n      \"ws_url\": \"wss://evcharger.example.com\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Create a location with one charger
require 'uri'
require 'net/http'

url = URI("https://api.ocpplab.io/evcharger/location")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"La Defense Charging Hub\",\n  \"address\": \"1 Parvis de la Defense\",\n  \"city\": \"Puteaux\",\n  \"country\": \"FRA\",\n  \"coordinates\": {\n    \"lat\": 48.892,\n    \"lng\": 2.238\n  },\n  \"timezone\": \"Europe/Paris\",\n  \"chargers\": [\n    {\n      \"identity\": \"CP-001\",\n      \"brand_slug\": \"wallbox\",\n      \"model\": \"wallbox-pulsar-plus\",\n      \"connector_type\": \"Type2\",\n      \"ws_url\": \"wss://evcharger.example.com\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Create a location with one charger
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.ocpplab.io/evcharger/location")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"La Defense Charging Hub\",\n  \"address\": \"1 Parvis de la Defense\",\n  \"city\": \"Puteaux\",\n  \"country\": \"FRA\",\n  \"coordinates\": {\n    \"lat\": 48.892,\n    \"lng\": 2.238\n  },\n  \"timezone\": \"Europe/Paris\",\n  \"chargers\": [\n    {\n      \"identity\": \"CP-001\",\n      \"brand_slug\": \"wallbox\",\n      \"model\": \"wallbox-pulsar-plus\",\n      \"connector_type\": \"Type2\",\n      \"ws_url\": \"wss://evcharger.example.com\"\n    }\n  ]\n}")
  .asString();
```

```php Create a location with one charger
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.ocpplab.io/evcharger/location', [
  'body' => '{
  "name": "La Defense Charging Hub",
  "address": "1 Parvis de la Defense",
  "city": "Puteaux",
  "country": "FRA",
  "coordinates": {
    "lat": 48.892,
    "lng": 2.238
  },
  "timezone": "Europe/Paris",
  "chargers": [
    {
      "identity": "CP-001",
      "brand_slug": "wallbox",
      "model": "wallbox-pulsar-plus",
      "connector_type": "Type2",
      "ws_url": "wss://evcharger.example.com"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Create a location with one charger
using RestSharp;

var client = new RestClient("https://api.ocpplab.io/evcharger/location");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"La Defense Charging Hub\",\n  \"address\": \"1 Parvis de la Defense\",\n  \"city\": \"Puteaux\",\n  \"country\": \"FRA\",\n  \"coordinates\": {\n    \"lat\": 48.892,\n    \"lng\": 2.238\n  },\n  \"timezone\": \"Europe/Paris\",\n  \"chargers\": [\n    {\n      \"identity\": \"CP-001\",\n      \"brand_slug\": \"wallbox\",\n      \"model\": \"wallbox-pulsar-plus\",\n      \"connector_type\": \"Type2\",\n      \"ws_url\": \"wss://evcharger.example.com\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Create a location with one charger
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "La Defense Charging Hub",
  "address": "1 Parvis de la Defense",
  "city": "Puteaux",
  "country": "FRA",
  "coordinates": [
    "lat": 48.892,
    "lng": 2.238
  ],
  "timezone": "Europe/Paris",
  "chargers": [
    [
      "identity": "CP-001",
      "brand_slug": "wallbox",
      "model": "wallbox-pulsar-plus",
      "connector_type": "Type2",
      "ws_url": "wss://evcharger.example.com"
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.ocpplab.io/evcharger/location")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```