> 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.

# Update a location

PATCH https://api.ocpplab.io/cpo/locations/{location_id}
Content-Type: application/json

Changes only the fields sent; send null to clear a field. Partner locations are read-only (409).

Reference: https://docs.ocpplab.io/api-reference/cpo/locations/update

## Authentication

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

## Request

### Path parameters

- `location_id` (string, required) — OCPI location id.

### Headers

- `If-Match` (string, optional, nullable) — Optional. The ``last_updated`` value you read; the write is refused with 412 if the object changed since.

### Body (application/json)

This endpoint expects a LocationPatch.

- `expected_revision` (integer, optional, nullable)
- `name` (string, optional, nullable)
- `postal_code` (string, optional, nullable)
- `state` (string, optional, nullable)
- `parking_type` (enum, optional, nullable) — Allowed parking_type values on ocpp.ocpp_locations.
  - Allowed values: `ALONG_MOTORWAY`, `PARKING_GARAGE`, `PARKING_LOT`, `ON_DRIVEWAY`, `ON_STREET`, `UNDERGROUND_GARAGE`
- `facilities` (list of string, optional, nullable)
- `opening_times` (OcpiOpeningTimesInput, optional, nullable)
- `charging_when_closed` (boolean, optional, nullable)
- `publish` (boolean, optional, nullable)
- `publish_allowed_to` (list of OcpiPublishToken, optional, nullable)
- `related_locations` (list of OcpiRelatedLocationInput, optional, nullable)
- `parking_places` (list of OcpiParkingPlaceInput, optional, nullable)
- `directions` (list of CpoOcpiDisplayTextInput, optional, nullable)
- `operator` (OcpiBusinessDetailsInput, optional, nullable)
- `suboperator` (OcpiBusinessDetailsInput, optional, nullable)
- `owner` (OcpiBusinessDetailsInput, optional, nullable)
- `images` (list of OcpiImageInput, optional, nullable)
- `energy_mix` (OcpiEnergyMixInput, optional, nullable)
- `help_phone` (string, optional, nullable)
- `address` (string, optional, nullable)
- `city` (string, optional, nullable)
- `country` (string, optional, nullable)
- `coordinates` (OcpiGeoLocation, optional, nullable)
- `time_zone` (string, optional, nullable)

## Response

### 200

The object after the update.

- `id` (integer, required)
- `location_id` (string, required)
- `publish` (boolean, required)
- `address` (string, required)
- `city` (string, required)
- `country` (string, required)
- `coordinates` (OcpiGeoLocation, required)
- `time_zone` (string, required)
- `last_updated` (datetime, required)
- `revision` (integer, required)
- `role` (CpoGatewaySchemaLocationsLocationOutRole, required)
- `origin` (CpoGatewaySchemaLocationsLocationOutOrigin, required)
- `country_code` (string, required)
- `party_id` (string, required)
- `ocpi_version` (CpoGatewaySchemaLocationsLocationOutOcpiVersion, required)
- `organization_id` (string, required)
- `created_at` (datetime, required)
- `updated_at` (datetime, required)
- `publish_allowed_to` (list of OcpiPublishToken, optional, nullable)
- `name` (string, optional, nullable)
- `postal_code` (string, optional, nullable)
- `state` (string, optional, nullable)
- `related_locations` (list of OcpiRelatedLocation, optional, nullable)
- `parking_type` (CpoGatewaySchemaLocationsLocationOutParkingType, optional, nullable)
- `parking_places` (list of OcpiParkingPlace, optional, nullable)
- `directions` (list of OcpiDisplayText, optional, nullable)
- `operator` (OcpiBusinessDetails, optional, nullable)
- `suboperator` (OcpiBusinessDetails, optional, nullable)
- `owner` (OcpiBusinessDetails, optional, nullable)
- `facilities` (list of string, optional, nullable)
- `opening_times` (OcpiOpeningTimes, optional, nullable)
- `charging_when_closed` (boolean, optional, nullable)
- `images` (list of OcpiImage, optional, nullable)
- `energy_mix` (OcpiEnergyMix, optional, nullable)
- `help_phone` (string, optional, nullable)
- `ocpp_version` (string, optional, nullable)

## Errors

### 400 Bad Request Error

If-Match is not a last_updated timestamp

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

### 401 Unauthorized Error

Missing or invalid Bearer token

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

### 404 Not Found Error

Location not found for your organization

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

### 409 Conflict Error

Received from a roaming partner; read-only; or: expected_revision is stale: the object changed since you read it

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

### 412 Precondition Failed Error

If-Match no longer matches: the object changed since you read it

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

### 422 Unprocessable Entity Error

The request does not match the schema

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

### 429 Too Many Requests Error

Gateway rate limit reached; retry after the given seconds

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

### 502 Bad Gateway Error

Gateway unreachable, failing, or misconfigured

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

### 504 Gateway Timeout Error

Gateway timed out

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

## Types

### OcpiOpeningTimesInput

- `twentyfourseven` (boolean, optional, nullable)
- `regular_hours` (list of OcpiRegularHoursInput, optional, nullable)
- `exceptional_openings` (list of OcpiExceptionalPeriod, optional, nullable)
- `exceptional_closings` (list of OcpiExceptionalPeriod, optional, nullable)

### OcpiPublishToken

- `uid` (string, required)
- `type` (string, required)
- `visual_number` (string, optional, nullable)
- `issuer` (string, optional, nullable)
- `group_id` (string, optional, nullable)

### OcpiRelatedLocationInput

- `latitude` (string, required)
- `longitude` (string, required)
- `name` (CpoOcpiDisplayTextInput, optional, nullable)

### OcpiParkingPlaceInput

- `id` (string, required)
- `vehicle_types` (list of string, required)
- `restricted_to_type` (boolean, required)
- `reservation_required` (boolean, required)
- `physical_reference` (string, optional, nullable)
- `max_vehicle_weight` (double, optional, nullable)
- `max_vehicle_height` (double, optional, nullable)
- `max_vehicle_length` (double, optional, nullable)
- `max_vehicle_width` (double, optional, nullable)
- `parking_space_length` (double, optional, nullable)
- `parking_space_width` (double, optional, nullable)
- `dangerous_goods_allowed` (boolean, optional, nullable)
- `direction` (string, optional, nullable)
- `drive_through` (boolean, optional, nullable)
- `time_limit` (double, optional, nullable)
- `roofed` (boolean, optional, nullable)
- `images` (list of OcpiImageInput, optional, nullable)
- `lighting` (boolean, optional, nullable)
- `refrigeration_outlet` (boolean, optional, nullable)
- `standards` (list of string, optional, nullable)
- `apds_reference` (string, optional, nullable)

### CpoOcpiDisplayTextInput

- `language` (string, required)
- `text` (string, required)

### OcpiBusinessDetailsInput

- `name` (string, required)
- `website` (string, optional, nullable)
- `logo` (OcpiImageInput, optional, nullable)

### OcpiImageInput

- `url` (string, required)
- `category` (string, required)
- `type` (string, required)
- `thumbnail` (string, optional, nullable)
- `width` (integer, optional, nullable)
- `height` (integer, optional, nullable)

### OcpiEnergyMixInput

- `is_green_energy` (boolean, required)
- `energy_sources` (list of OcpiEnergySourceInput, optional, nullable)
- `environ_impact` (list of OcpiEnvironmentalImpact, optional, nullable)
- `supplier_name` (string, optional, nullable)
- `energy_product_name` (string, optional, nullable)

### OcpiGeoLocation

- `latitude` (string, required)
- `longitude` (string, required)

### CpoGatewaySchemaLocationsLocationOutRole

### CpoGatewaySchemaLocationsLocationOutOrigin

### CpoGatewaySchemaLocationsLocationOutOcpiVersion

### OcpiRelatedLocation

- `latitude` (string, required)
- `longitude` (string, required)
- `name` (OcpiDisplayText, optional, nullable)

### CpoGatewaySchemaLocationsLocationOutParkingType

### OcpiParkingPlace

- `id` (string, required)
- `vehicle_types` (list of string, required)
- `restricted_to_type` (boolean, required)
- `reservation_required` (boolean, required)
- `physical_reference` (string, optional, nullable)
- `max_vehicle_weight` (double, optional, nullable)
- `max_vehicle_height` (double, optional, nullable)
- `max_vehicle_length` (double, optional, nullable)
- `max_vehicle_width` (double, optional, nullable)
- `parking_space_length` (double, optional, nullable)
- `parking_space_width` (double, optional, nullable)
- `dangerous_goods_allowed` (boolean, optional, nullable)
- `direction` (string, optional, nullable)
- `drive_through` (boolean, optional, nullable)
- `time_limit` (double, optional, nullable)
- `roofed` (boolean, optional, nullable)
- `images` (list of OcpiImage, optional, nullable)
- `lighting` (boolean, optional, nullable)
- `refrigeration_outlet` (boolean, optional, nullable)
- `standards` (list of string, optional, nullable)
- `apds_reference` (string, optional, nullable)

### OcpiDisplayText

- `language` (string, required)
- `text` (string, required)

### OcpiBusinessDetails

- `name` (string, required)
- `website` (string, optional, nullable)
- `logo` (OcpiImage, optional, nullable)

### OcpiOpeningTimes

- `twentyfourseven` (boolean, optional, nullable)
- `regular_hours` (list of OcpiRegularHours, optional, nullable)
- `exceptional_openings` (list of OcpiExceptionalPeriod, optional, nullable)
- `exceptional_closings` (list of OcpiExceptionalPeriod, optional, nullable)

### OcpiImage

- `url` (string, required)
- `category` (string, required)
- `type` (string, required)
- `thumbnail` (string, optional, nullable)
- `width` (integer, optional, nullable)
- `height` (integer, optional, nullable)

### OcpiEnergyMix

- `is_green_energy` (boolean, required)
- `energy_sources` (list of OcpiEnergySource, optional, nullable)
- `environ_impact` (list of OcpiEnvironmentalImpact, optional, nullable)
- `supplier_name` (string, optional, nullable)
- `energy_product_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}`.

### OcpiRegularHoursInput

- `weekday` (integer, required)
- `period_begin` (string, required)
- `period_end` (string, required)

### OcpiExceptionalPeriod

- `period_begin` (datetime, required)
- `period_end` (datetime, required)

### OcpiEnergySourceInput

- `source` (string, required)
- `percentage` (double, required)

### OcpiEnvironmentalImpact

- `category` (string, required)
- `amount` (double, required)

### OcpiRegularHours

- `weekday` (integer, required)
- `period_begin` (string, required)
- `period_end` (string, required)

### OcpiEnergySource

- `source` (string, required)
- `percentage` (double, required)

### ValidationErrorLocItems

### ValidationErrorCtx

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

## Examples

**Request**

```json
{
  "expected_revision": 1,
  "publish": false
}
```

**Response**

```json
{
  "id": 12,
  "location_id": "LOC-AMS-01",
  "publish": false,
  "address": "Stationsplein 1",
  "city": "Amsterdam",
  "country": "NLD",
  "coordinates": {
    "latitude": "52.37310",
    "longitude": "4.88970"
  },
  "time_zone": "Europe/Amsterdam",
  "last_updated": "2026-09-30T10:00:00Z",
  "revision": 2,
  "role": "CPO",
  "origin": "LOCAL",
  "country_code": "NL",
  "party_id": "OCP",
  "ocpi_version": "2.2.1",
  "organization_id": "550e8400-e29b-41d4-a716-446655440000",
  "created_at": "2026-09-01T09:00:00Z",
  "updated_at": "2026-09-30T10:00:00Z",
  "name": "Amsterdam depot",
  "postal_code": "1012AB",
  "parking_type": "PARKING_LOT",
  "facilities": [
    "TRAIN_STATION"
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.ocpplab.io/cpo/locations/LOC-AMS-01"

payload = {
    "expected_revision": 1,
    "publish": False
}
headers = {
    "If-Match": "2026-09-30T10:00:00Z",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.ocpplab.io/cpo/locations/LOC-AMS-01';
const options = {
  method: 'PATCH',
  headers: {
    'If-Match': '2026-09-30T10:00:00Z',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: '{"expected_revision":1,"publish":false}'
};

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

```go
package main

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

func main() {

	url := "https://api.ocpplab.io/cpo/locations/LOC-AMS-01"

	payload := strings.NewReader("{\n  \"expected_revision\": 1,\n  \"publish\": false\n}")

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

	req.Header.Add("If-Match", "2026-09-30T10:00:00Z")
	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
require 'uri'
require 'net/http'

url = URI("https://api.ocpplab.io/cpo/locations/LOC-AMS-01")

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

request = Net::HTTP::Patch.new(url)
request["If-Match"] = '2026-09-30T10:00:00Z'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"expected_revision\": 1,\n  \"publish\": false\n}"

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

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

HttpResponse<String> response = Unirest.patch("https://api.ocpplab.io/cpo/locations/LOC-AMS-01")
  .header("If-Match", "2026-09-30T10:00:00Z")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"expected_revision\": 1,\n  \"publish\": false\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.ocpplab.io/cpo/locations/LOC-AMS-01', [
  'body' => '{
  "expected_revision": 1,
  "publish": false
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'If-Match' => '2026-09-30T10:00:00Z',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.ocpplab.io/cpo/locations/LOC-AMS-01");
var request = new RestRequest(Method.PATCH);
request.AddHeader("If-Match", "2026-09-30T10:00:00Z");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"expected_revision\": 1,\n  \"publish\": false\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "If-Match": "2026-09-30T10:00:00Z",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "expected_revision": 1,
  "publish": false
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.ocpplab.io/cpo/locations/LOC-AMS-01")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```