# Authentication

Include the following headers in your requests:

- **Access-Token**: The access token obtained from the "Create Access Token" endpoint.

- **x-api-key:** The API key provided by GenLogs. This header must be included in the request.

# Permissions

Make sure that your api user is created with a role that has `external-api-shipper-network-map` permission

# Endpoint

- **URL**: `https://api.genlogs.io/facility/<facility_id>/network-map`
- **Method**: `GET`

# Response

- **200 OK**: Returns the facility network map in GeoJSON format. The payload is normalized as a FeatureCollection.
- **400 Bad Request**: If required parameters are missing or invalid.
- **401 Unauthorized**: If the `Access-Token` or `x-api-key` is missing or invalid.
- **403 Forbidden**: If the user is not allowed to access this endpoint.
- **500 Internal Server Error**: If an error occurs on the server while processing the request.

# Response Body

When the request succeeds, the endpoint returns a GeoJSON `FeatureCollection` whose structure follows `FacilityNetworkMapSchema`:

- `type`: Always `FeatureCollection`.
- `features`: Array of GeoJSON `Feature` objects.

Each feature has:

- `geometry`: standard GeoJSON geometry (point, line, polygon) with coordinates relative to the facility.
  - `properties`: metadata about the lane (analysis window, history window, etc.).

# Request example

```bash
curl --location 'https://api.genlogs.io/facility/0x4Y4CTmYr6kauPugLT9k4zg/network-map' \
--header 'Content-Type: application/json' \
--header 'access-token: <access-token>' \
--header 'x-api-key: <x-api-key>'
```

# Retrieve the GeoJSON network map for a facility

```bash
get https://api.genlogs.io/facility/{facility_id}/network-map
```

Returns the GeoJSON network map associated with the specified facility.

**Path parameters**

- **facility_id**: string Required
  Trimble identifier for the facility.

**Responses**

- **200**: Facility GeoJSON network map (FeatureCollection)
- **401**: Missing or invalid token.
- **403**: Token expired or user lacks the required role.
- **500**: Unexpected error while fetching or parsing GeoJSON.

### Generic FeatureCollection layout

```json
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "<Point|LineString|Polygon>",
        "coordinates": [
          "..."
        ]
      },
      "properties": {
        "analysis_window": "<pre|post|all>",
        "history_window": "<90|180|360|all>",
        "direction": "<network|hub_spoke>",
        "additional_metadata": "..."
      }
    }
  ]
}
```
