> ## Documentation Index
> Fetch the complete documentation index at: https://docs-beta.rebase.energy/llms.txt
> Use this file to discover all available pages before exploring further.

# Layer Endpoints

> Create and manage unified layers for maps and weather data

## Layer Endpoints

Create and manage both map and weather layers using the unified API with type discrimination.

## GET /layers

<Note>
  Retrieves all layers (both map and weather) for the authenticated user.
</Note>

```python theme={null}
# List all layers
layers = client.layers.list_layers()
```

<RequestExample>
  <RequestExample.Method>GET</RequestExample.Method>
  <RequestExample.URL>/layers</RequestExample.URL>
</RequestExample>

<ResponseExample>
  <ResponseExample.StatusCode>200</ResponseExample.StatusCode>

  <ResponseExample.Body>
    ```json theme={null}
    [
      {
        "id": "layer_123",
        "name": "Wind Speed Layer",
        "type": "wl:RasterLayer",
        "weather_model_id": "ECMWF_IFS",
        "variable": "WindSpeed",
        "altitude": 10,
        "run_hour": 12,
        "run_day": "2025-01-15",
        "deckgl_props": {
          "opacity": 0.8
        },
        "created_at": "2024-01-01T00:00:00Z",
        "updated_at": "2024-01-01T00:00:00Z"
      },
      {
        "id": "layer_456",
        "name": "Wind Turbines",
        "type": "ScatterPlotLayer",
        "dataset_id": "dataset_123",
        "deckgl_props": {
          "radiusScale": 500,
          "getFillColor": [255, 140, 0]
        },
        "created_at": "2024-01-01T00:00:00Z",
        "updated_at": "2024-01-01T00:00:00Z"
      }
    ]
    ```
  </ResponseExample.Body>
</ResponseExample>

## GET /layers/{layer_id}

<Note>Retrieves a specific layer by ID.</Note>

```python theme={null}
# Get a specific layer by ID string
layer = client.layers.get_layer("layer_123")

# Or if you have a layer object
layer = client.layers.get_layer(layer.id)
```

<RequestExample>
  <RequestExample.Method>GET</RequestExample.Method>
  <RequestExample.URL>/layers/{layer_id}</RequestExample.URL>
</RequestExample>

<ResponseExample>
  <ResponseExample.StatusCode>200</ResponseExample.StatusCode>

  <ResponseExample.Body>
    ```json theme={null}
    {
      "id": "layer_123",
      "name": "Wind Speed Layer",
      "type": "wl:RasterLayer",
      "weather_model_id": "ECMWF_IFS",
      "variable": "WindSpeed",
      "altitude": 10,
      "run_hour": 12,
      "run_day": "2025-01-15",
      "deckgl_props": {
        "opacity": 0.8
      },
      "ui_config": {
        "visible": true,
        "opacity": 0.8
      },
      "created_at": "2024-01-01T00:00:00Z",
      "updated_at": "2024-01-01T00:00:00Z"
    }
    ```
  </ResponseExample.Body>
</ResponseExample>

## POST /layers

<Note>
  Creates a new layer using the discriminator pattern. The type field determines
  required parameters.
</Note>

```python theme={null}
# Create a weather layer
weather_layer = client.layers.create_layer(
    name="Wind Speed at 100m",
    type="wl:RasterLayer",
    weather_model_id="ECMWF_IFS",
    variable="WindSpeed",
    altitude=100,
    run_hour=12,
    run_day="2025-01-15",
    deckgl_props={...}
)

# Create a map layer
map_layer = client.layers.create_layer(
    name="Wind Turbines",
    type="ScatterPlotLayer",
    dataset_id="dataset_123",
    deckgl_props={...}
)
```

<RequestExample>
  <RequestExample.Method>POST</RequestExample.Method>
  <RequestExample.URL>/layers</RequestExample.URL>

  <RequestExample.Body>
    ```json theme={null}
    {
      "name": "Wind Speed at 100m",
      "type": "wl:RasterLayer",
      "weather_model_id": "ECMWF_IFS",
      "variable": "WindSpeed",
      "altitude": 100,
      "run_hour": 12,
      "run_day": "2025-01-15",
      "deckgl_props": {
        "opacity": 0.7
      }
    }
    ```
  </RequestExample.Body>
</RequestExample>

<ResponseExample>
  <ResponseExample.StatusCode>201</ResponseExample.StatusCode>

  <ResponseExample.Body>
    ```json theme={null}
    {
      "id": "layer_123",
      "name": "Wind Speed at 100m",
      "type": "wl:RasterLayer",
      "weather_model_id": "ECMWF_IFS",
      "variable": "WindSpeed",
      "altitude": 100,
      "run_hour": 12,
      "run_day": "2025-01-15",
      "deckgl_props": {...},
      "created_at": "2024-01-01T00:00:00Z",
      "updated_at": "2024-01-01T00:00:00Z"
    }
    ```
  </ResponseExample.Body>
</ResponseExample>

## PUT /layers/{layer_id}

<Note>
  Updates an existing layer. All layer fields (name, type, and type-specific
  fields) are required.
</Note>

```python theme={null}
# Update a layer by ID string
updated_layer = client.layers.update_layer(
    "layer_123",
    name="Updated Wind Speed Layer",
    type="wl:RasterLayer",
    weather_model_id="ECMWF_IFS",
    variable="WindSpeed",
    altitude=100,
    run_hour=18,
    run_day="2025-01-15",
    deckgl_props={...}
)

# Or if you have a layer object
updated_layer = client.layers.update_layer(
    layer.id,
    name="Updated Wind Speed Layer",
    type="wl:RasterLayer",
    weather_model_id="ECMWF_IFS",
    variable="WindSpeed",
    altitude=100,
    run_hour=18,
    run_day="2025-01-15",
    deckgl_props={...}
)
```

<RequestExample>
  <RequestExample.Method>PUT</RequestExample.Method>
  <RequestExample.URL>/layers/{layer_id}</RequestExample.URL>

  <RequestExample.Body>
    ```json theme={null}
    {
      "name": "Updated Wind Speed Layer",
      "type": "wl:RasterLayer",
      "weather_model_id": "ECMWF_IFS",
      "variable": "WindSpeed",
      "altitude": 100,
      "run_hour": 18,
      "run_day": "2025-01-15",
      "deckgl_props": {
        "opacity": 0.9
      }
    }
    ```
  </RequestExample.Body>
</RequestExample>

<ResponseExample>
  <ResponseExample.StatusCode>200</ResponseExample.StatusCode>

  <ResponseExample.Body>
    ```json theme={null}
    {
      "id": "layer_123",
      "name": "Updated Wind Speed Layer",
      "type": "wl:RasterLayer",
      "weather_model_id": "ECMWF_IFS",
      "variable": "WindSpeed",
      "altitude": 100,
      "run_hour": 18,
      "run_day": "2025-01-15",
      "deckgl_props": {...},
      "created_at": "2024-01-01T00:00:00Z",
      "updated_at": "2024-01-01T12:00:00Z"
    }
    ```
  </ResponseExample.Body>
</ResponseExample>

## DELETE /layers/{layer_id}

<Note>Permanently deletes a layer by ID.</Note>

```python theme={null}
# Delete a layer by ID string
client.layers.delete_layer("layer_123")

# Or if you have a layer object
client.layers.delete_layer(layer.id)
```

<RequestExample>
  <RequestExample.Method>DELETE</RequestExample.Method>
  <RequestExample.URL>/layers/{layer_id}</RequestExample.URL>
</RequestExample>

<ResponseExample>
  <ResponseExample.StatusCode>204</ResponseExample.StatusCode>

  <ResponseExample.Body>
    ```json theme={null}
    {}
    ```
  </ResponseExample.Body>
</ResponseExample>

## Layer Types

### Weather Layer Types

* `wl:RasterLayer` - Raster weather data visualization
* `wl:ParticleLayer` - Particle-based weather visualization
* `wl:IsolineLayer` - Contour/isoline weather visualization

### Map Layer Types

* `ScatterPlotLayer` - Point-based geospatial data
* `GeoJsonLayer` - GeoJSON polygon/line data

### Required Parameters

#### Weather Layers

* **Common**: `name`, `type`, `weather_model_id`, `variable`, `altitude`
* **Forecast Models**: `run_hour`, `run_day` (YYYY-MM-DD format)
* **Historical Models (ERA5)**: No run parameters needed

#### Map Layers

* **Common**: `name`, `type`, `dataset_id`
* **Optional**: `deckgl_props`, `ui_config`
