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

# Link a location to a voucher group

POST https://api.ocpplab.io/cpo/voucher-groups/{id}/locations/{location_id}

Link one of your OCPI locations to the group, for your records; chargers do not apply vouchers.

Reference: https://docs.ocpplab.io/api-reference/cpo/voucher-groups/add-location

## Authentication

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

## Request

### Path parameters

- `id` (integer, required) — The voucher group's ``id``.
- `location_id` (string, required) — OCPI location id.

### Query parameters

- `country_code` (string, optional, nullable) — OCPI party country code, e.g. NL. Pass it with ``party_id`` when the location id is used by more than one party.
- `party_id` (string, optional, nullable) — OCPI party id, e.g. OCP. Pass it with ``country_code`` when the location id is used by more than one party.

## Response

### 200

The linked location.

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

### 401 Unauthorized Error

Missing or invalid Bearer token

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

### 404 Not Found Error

Location 'LOC-AMS-01' not found for your organization

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

### 409 Conflict Error

The location id is used by more than one party; pass country_code and party_id; or: Already exists (unique key)

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

### OcpiGeoLocation

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

### CpoGatewaySchemaLocationsLocationOutRole

### CpoGatewaySchemaLocationsLocationOutOrigin

### CpoGatewaySchemaLocationsLocationOutOcpiVersion

### OcpiPublishToken

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

### 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}`.

### OcpiRegularHours

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

### OcpiExceptionalPeriod

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

### OcpiEnergySource

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

### OcpiEnvironmentalImpact

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

### ValidationErrorLocItems

### ValidationErrorCtx

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

## Examples

**Response**

```json
{
  "id": 12,
  "location_id": "LOC-AMS-01",
  "publish": true,
  "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": 1,
  "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-30T10: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/voucher-groups/12/locations/LOC-AMS-01"

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

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

print(response.json())
```

```javascript
const url = 'https://api.ocpplab.io/cpo/voucher-groups/12/locations/LOC-AMS-01';
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
package main

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

func main() {

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

	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
require 'uri'
require 'net/http'

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

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
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.ocpplab.io/cpo/voucher-groups/12/locations/LOC-AMS-01")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.ocpplab.io/cpo/voucher-groups/12/locations/LOC-AMS-01', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.ocpplab.io/cpo/voucher-groups/12/locations/LOC-AMS-01");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.ocpplab.io/cpo/voucher-groups/12/locations/LOC-AMS-01")! 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()
```