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

# Create location

POST https://host.com/ocpp/locations
Content-Type: application/json

Create a bare OCPP location row. No OCPI projection is written — use ``POST /ocpi/cpos/{cpo_id}/locations`` if the location should be advertised via OCPI.

Reference: https://docs.ocpplab.com/api-reference/ocpplab-gateway-api/core-resources/locations/create

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: OCPPLab SDK
  version: 1.0.0
paths:
  /ocpp/locations:
    post:
      operationId: create
      summary: Create location
      description: >-
        Create a bare OCPP location row. No OCPI projection is written — use
        ``POST /ocpi/cpos/{cpo_id}/locations`` if the location should be
        advertised via OCPI.
      tags:
        - subpackage_locations
      parameters:
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '201':
          description: Location created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LocationResponse'
        '400':
          description: Invalid location payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HttpErrorResponse'
        '401':
          description: Missing or invalid bearer token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HttpErrorResponse'
        '403':
          description: Insufficient permissions or missing required claims
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HttpErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HttpErrorResponse'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateLocationRequest'
servers:
  - url: https://host.com
components:
  schemas:
    Coordinates:
      type: object
      properties:
        latitude:
          type: number
          format: double
          description: Latitude in decimal degrees.
        longitude:
          type: number
          format: double
          description: Longitude in decimal degrees.
      required:
        - latitude
        - longitude
      description: Normalized latitude/longitude pair accepted by the location API.
      title: Coordinates
    CreateLocationRequest:
      type: object
      properties:
        name:
          type: string
          description: >-
            Human-readable location name. The backend derives the slug from this
            value and appends a random hex suffix for uniqueness.
        address:
          type: string
          description: Street address for the site.
        city:
          type: string
          description: City or locality.
        country:
          type: string
          description: ISO 3166-1 alpha-2 country code.
        coordinates:
          $ref: '#/components/schemas/Coordinates'
        timezone:
          type:
            - string
            - 'null'
        owner_name:
          type:
            - string
            - 'null'
        public:
          type:
            - boolean
            - 'null'
      required:
        - name
        - address
        - city
        - country
        - coordinates
      description: Request body used to create one charging location.
      title: CreateLocationRequest
    LocationResponseCoordinates:
      oneOf:
        - $ref: '#/components/schemas/Coordinates'
        - type: object
          additionalProperties:
            description: Any type
      title: LocationResponseCoordinates
    LocationResponse:
      type: object
      properties:
        id:
          type: string
        slug:
          type:
            - string
            - 'null'
        name:
          type:
            - string
            - 'null'
        address:
          type:
            - string
            - 'null'
        city:
          type:
            - string
            - 'null'
        country:
          type:
            - string
            - 'null'
        coordinates:
          oneOf:
            - $ref: '#/components/schemas/LocationResponseCoordinates'
            - type: 'null'
        timezone:
          type:
            - string
            - 'null'
        owner_name:
          type:
            - string
            - 'null'
        public:
          type:
            - boolean
            - 'null'
        status:
          type:
            - string
            - 'null'
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
      description: Location payload returned by the CRUD endpoints.
      title: LocationResponse
    HttpErrorResponse:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message returned by the API.
      required:
        - detail
      description: Standard HTTP error payload returned by the API.
      title: HttpErrorResponse
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationErrorCtx:
      type: object
      properties: {}
      title: ValidationErrorCtx
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
        input:
          description: Any type
        ctx:
          $ref: '#/components/schemas/ValidationErrorCtx'
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

```

## SDK Code Examples

```python A newly created location
import requests

url = "https://host.com/ocpp/locations"

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript A newly created location
const url = 'https://host.com/ocpp/locations';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: undefined
};

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

```go A newly created location
package main

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

func main() {

	url := "https://host.com/ocpp/locations"

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

	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 A newly created location
require 'uri'
require 'net/http'

url = URI("https://host.com/ocpp/locations")

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'

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

```java A newly created location
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://host.com/ocpp/locations")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .asString();
```

```php A newly created location
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://host.com/ocpp/locations', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp A newly created location
using RestSharp;

var client = new RestClient("https://host.com/ocpp/locations");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift A newly created location
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://host.com/ocpp/locations")! 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()
```

```python A Paris charging hub
import requests

url = "https://host.com/ocpp/locations"

payload = {
    "name": "La Defense Charging Hub",
    "address": "14 Rue de la Paix",
    "city": "Paris",
    "country": "FR",
    "coordinates": {
        "latitude": 48.8566,
        "longitude": 2.3522
    },
    "timezone": "Europe/Paris",
    "owner_name": "VINCI Autoroutes",
    "public": True
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript A Paris charging hub
const url = 'https://host.com/ocpp/locations';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"La Defense Charging Hub","address":"14 Rue de la Paix","city":"Paris","country":"FR","coordinates":{"latitude":48.8566,"longitude":2.3522},"timezone":"Europe/Paris","owner_name":"VINCI Autoroutes","public":true}'
};

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

```go A Paris charging hub
package main

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

func main() {

	url := "https://host.com/ocpp/locations"

	payload := strings.NewReader("{\n  \"name\": \"La Defense Charging Hub\",\n  \"address\": \"14 Rue de la Paix\",\n  \"city\": \"Paris\",\n  \"country\": \"FR\",\n  \"coordinates\": {\n    \"latitude\": 48.8566,\n    \"longitude\": 2.3522\n  },\n  \"timezone\": \"Europe/Paris\",\n  \"owner_name\": \"VINCI Autoroutes\",\n  \"public\": true\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 A Paris charging hub
require 'uri'
require 'net/http'

url = URI("https://host.com/ocpp/locations")

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\": \"14 Rue de la Paix\",\n  \"city\": \"Paris\",\n  \"country\": \"FR\",\n  \"coordinates\": {\n    \"latitude\": 48.8566,\n    \"longitude\": 2.3522\n  },\n  \"timezone\": \"Europe/Paris\",\n  \"owner_name\": \"VINCI Autoroutes\",\n  \"public\": true\n}"

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

```java A Paris charging hub
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://host.com/ocpp/locations")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"La Defense Charging Hub\",\n  \"address\": \"14 Rue de la Paix\",\n  \"city\": \"Paris\",\n  \"country\": \"FR\",\n  \"coordinates\": {\n    \"latitude\": 48.8566,\n    \"longitude\": 2.3522\n  },\n  \"timezone\": \"Europe/Paris\",\n  \"owner_name\": \"VINCI Autoroutes\",\n  \"public\": true\n}")
  .asString();
```

```php A Paris charging hub
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://host.com/ocpp/locations', [
  'body' => '{
  "name": "La Defense Charging Hub",
  "address": "14 Rue de la Paix",
  "city": "Paris",
  "country": "FR",
  "coordinates": {
    "latitude": 48.8566,
    "longitude": 2.3522
  },
  "timezone": "Europe/Paris",
  "owner_name": "VINCI Autoroutes",
  "public": true
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp A Paris charging hub
using RestSharp;

var client = new RestClient("https://host.com/ocpp/locations");
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\": \"14 Rue de la Paix\",\n  \"city\": \"Paris\",\n  \"country\": \"FR\",\n  \"coordinates\": {\n    \"latitude\": 48.8566,\n    \"longitude\": 2.3522\n  },\n  \"timezone\": \"Europe/Paris\",\n  \"owner_name\": \"VINCI Autoroutes\",\n  \"public\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift A Paris charging hub
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "La Defense Charging Hub",
  "address": "14 Rue de la Paix",
  "city": "Paris",
  "country": "FR",
  "coordinates": [
    "latitude": 48.8566,
    "longitude": 2.3522
  ],
  "timezone": "Europe/Paris",
  "owner_name": "VINCI Autoroutes",
  "public": true
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://host.com/ocpp/locations")! 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()
```