> ## Documentation Index
> Fetch the complete documentation index at: https://code.dcycle.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Logistic Hub

> Modify an existing logistic hub's details

# Update Logistic Hub

Update an existing logistic hub in your organization. Only include the fields you want to change — all other fields remain unchanged.

<Warning>
  **Auto-creation**: If you change `type` to `owned` on a hub that has no linked facility and provide an `address`, a new facility will be automatically created and linked.
</Warning>

## Request

### Path Parameters

<ParamField path="hub_id" type="uuid" required>
  The UUID of the logistic hub to update

  **Example:** `550e8400-e29b-41d4-a716-446655440000`
</ParamField>

### Headers

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication

  **Example:** `sk_live_1234567890abcdef`
</ParamField>

<ParamField header="x-organization-id" type="string" required>
  Your organization UUID

  **Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`
</ParamField>

### Body Parameters

All fields are optional — only include what you want to change.

<ParamField body="name" type="string">Hub name</ParamField>
<ParamField body="address" type="string">Physical address</ParamField>
<ParamField body="country" type="string">ISO country code</ParamField>
<ParamField body="type" type="string">Hub type: `owned` or `subcontracted`</ParamField>
<ParamField body="category" type="string">Hub category</ParamField>
<ParamField body="facility_id" type="uuid">Linked facility ID</ParamField>
<ParamField body="supercharger" type="boolean">Whether hub is a supercharger</ParamField>

## Response

Returns the updated logistic hub object.

<ResponseField name="id" type="string">
  Logistic hub UUID
</ResponseField>

<ResponseField name="name" type="string">
  Hub name
</ResponseField>

<ResponseField name="type" type="string">
  Hub type: `owned` or `subcontracted`
</ResponseField>

<ResponseField name="category" type="string | null">
  Hub category classification (e.g. `warehouse_ambient`, `warehouse_mixed`)
</ResponseField>

<ResponseField name="address" type="string | null">
  Physical address
</ResponseField>

<ResponseField name="country" type="string | null">
  ISO country code
</ResponseField>

<ResponseField name="status" type="string">
  Hub status: `active` or `archived`
</ResponseField>

<ResponseField name="supercharger" type="boolean">
  Whether the hub is a supercharger
</ResponseField>

<ResponseField name="facility_id" type="string | null">
  UUID of the linked facility (only for `owned` hubs)
</ResponseField>

<ResponseField name="co2e" type="number | null">
  CO2e emissions from the linked facility (tCO2e)
</ResponseField>

<ResponseField name="created_at" type="datetime">
  Creation timestamp (ISO 8601)
</ResponseField>

<ResponseField name="updated_at" type="string | null">
  Last update timestamp (ISO 8601)
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X PUT "https://api.dcycle.io/v1/logistic-hubs/550e8400-e29b-41d4-a716-446655440000" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Madrid Distribution Center",
      "category": "warehouse_mixed"
    }'
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import requests
  import os

  headers = {
      "x-api-key": os.getenv("DCYCLE_API_KEY"),
      "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
      "Content-Type": "application/json"
  }

  hub_id = "550e8400-e29b-41d4-a716-446655440000"
  response = requests.put(
      f"https://api.dcycle.io/v1/logistic-hubs/{hub_id}",
      headers=headers,
      json={"name": "Madrid Distribution Center", "category": "warehouse_mixed"}
  )

  print(f"Updated: {response.json()['name']}")
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const axios = require('axios');

  const headers = {
    'x-api-key': process.env.DCYCLE_API_KEY,
    'x-organization-id': process.env.DCYCLE_ORG_ID,
    'Content-Type': 'application/json'
  };

  const hubId = '550e8400-e29b-41d4-a716-446655440000';
  axios.put(`https://api.dcycle.io/v1/logistic-hubs/${hubId}`, {
    name: "Madrid Distribution Center",
    category: "warehouse_mixed"
  }, { headers })
  .then(response => console.log(`Updated: ${response.data.name}`));
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Madrid Distribution Center",
  "type": "owned",
  "category": "warehouse_mixed",
  "address": "Calle Industrial 5, Madrid",
  "country": "ES",
  "status": "active",
  "supercharger": false,
  "facility_id": "660e8400-e29b-41d4-a716-446655440000",
  "co2e": 1250.5,
  "created_at": "2024-11-24T10:30:00Z",
  "updated_at": "2024-12-01T15:45:00Z"
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}
```

### 403 Forbidden

**Cause:** The authenticated user is not a member of the organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}
```

### 404 Not Found

**Cause:** The logistic hub does not exist or belongs to another organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Logistic hub not found"}
```

### 422 Unprocessable Entity

**Cause:** Invalid field value (e.g. invalid country code or UUID format)

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": [
    {
      "loc": ["body", "facility_id"],
      "msg": "value is not a valid uuid",
      "type": "type_error.uuid"
    }
  ]
}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Get Logistic Hub" icon="warehouse" href="/api-reference/logistic-hubs/get">
    Retrieve logistic hub details
  </Card>

  <Card title="Delete Logistic Hub" icon="trash" href="/api-reference/logistic-hubs/delete">
    Remove a logistic hub
  </Card>
</CardGroup>
