# Setting Up Locations

The Flex Shape API groups every location by a **zone**, and optionally by **segmentation dimension groups**. The zone determines which price signal and optimization context apply to a location's assets. Dimensions let you split a zone's shape into groups you trade separately.Zones are derived automatically from your connected assets, so you can read a flex shape per zone without any setup. Assign zones explicitly when a location's automatic placement needs correcting, and assign dimension groups when you want segmented shapes.

## Assigning a Location to a Zone

```http
PUT /flex/locations/{locationId}
Content-Type: application/json

{
  "zoneId": "NO1"
}
```

**`zoneId`** must be a market bidding zone identifier — for example `NO1`, `SE3`, `GER`, `BE`. See [Listing Zones](https://flex.developers.enode.com/#listing-zones) below for the set of zones in which your client currently has assets.

## Listing Zones

```http
GET /flex/zones
```

Returns every zone where your client has connected vehicles.

```json
[{ "id": "NO1" }, { "id": "NO2" }, { "id": "SE3" }]
```

## Segmentation Dimensions

A **dimension** is a named way of splitting a zone's portfolio — grid region, metering class, tariff group, customer segment. Each dimension contains a set of **groups**, and a location belongs to at most one group per dimension. Dimensions and their groups are configured by Enode and agreed upfront with your organization.

Dimensions prefixed with `system:` are managed by Enode and cannot be modified. `system:asset_composition` classifies each household (Enode user) as `ev` (at least an EV) or `ev_pv` (an EV plus physical or virtual solar) from its connected assets.

Once locations are assigned to groups, you can read the shape [segmented by a dimension](https://flex.developers.enode.com/docs/flex-shape/flex-shape#reading-a-segmented-shape).

### Assigning a Location to a Group

```http
PUT /flex/locations/{locationId}/dimensions/region
Content-Type: application/json

{
  "groupId": "seg_oslo"
}
```

Assigning a new group replaces the location's previous assignment in that dimension; repeating an assignment is idempotent.

### Assigning Many Locations at Once

For initial onboarding or bulk re-tagging, assign up to 10,000 locations in one atomic request:

```http
PUT /flex/locations/dimensions/region/assignments
Content-Type: application/json

{
  "assignments": [
    {
      "locationId": "a39578d6-96f8-4f42-a6aa-6fdb1be06d03",
      "groupId": "seg_oslo"
    },
    {
      "locationId": "b7d2c1e0-4f3a-4b2c-9d1e-2f3a4b5c6d7e",
      "groupId": "seg_bergen"
    }
  ]
}
```

Each location may appear at most once. Validation failures reject the entire batch without partial writes; locations not included keep their current assignments.

### Listing a Location's Group Assignments

```http
GET /flex/locations/{locationId}/dimensions
```

```json
{
  "data": [{ "dimensionId": "region", "groupId": "seg_oslo" }]
}
```

Use this to verify your tagging before reading segmented shapes.

### Clearing a Group Assignment

```http
DELETE /flex/locations/{locationId}/dimensions/region
```

The location's assets then contribute to the `unassigned` bucket of that dimension's segmented shape.

## Endpoint Reference

| Task                               | Method | Endpoint                                                |
| ---------------------------------- | ------ | ------------------------------------------------------- |
| Assign location to zone            | PUT    | `/flex/locations/{locationId}`                          |
| List zones                         | GET    | `/flex/zones`                                           |
| Get zone                           | GET    | `/flex/zones/{zoneId}`                                  |
| Assign location to dimension group | PUT    | `/flex/locations/{locationId}/dimensions/{dimensionId}` |
| Batch assign dimension groups      | PUT    | `/flex/locations/dimensions/{dimensionId}/assignments`  |
| List location dimension groups     | GET    | `/flex/locations/{locationId}/dimensions`               |
| Clear location dimension group     | DELETE | `/flex/locations/{locationId}/dimensions/{dimensionId}` |


