Skip to main content
POST
/
v1
/
logistic-hubs
Create Logistic Hub
const options = {
  method: 'POST',
  headers: {
    'x-api-key': '<x-api-key>',
    'x-organization-id': '<x-organization-id>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: '<string>',
    type: '<string>',
    category: '<string>',
    address: '<string>',
    supercharger: true,
    facility_id: '<string>'
  })
};

fetch('https://api.dcycle.io/v1/logistic-hubs', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

Create Logistic Hub

Create a new logistic hub in your organization. Hubs can be either owned (linked to a facility for emissions tracking) or subcontracted (external logistics provider).
Owned vs Subcontracted: When type is owned, you must provide a facility_id. When type is subcontracted, facility_id is ignored and set to null.

Request

Headers

x-api-key
string
required
Your API key for authentication
x-organization-id
string
required
Your organization UUID

Body Parameters

name
string
required
Name of the logistic hub (must be unique within the organization)Example: "Madrid Warehouse"
type
string
required
Hub type: owned or subcontractedExample: "owned"
category
string
Hub category classificationExample: "warehouse_ambient"
address
string
Physical address of the hub. If provided, country is automatically geocoded.Example: "Calle Industrial 5, Madrid, Spain"
supercharger
boolean
default:"false"
Whether the hub is a supercharger
facility_id
uuid
Linked facility ID. Required when type is owned.Example: "660e8400-e29b-41d4-a716-446655440000"

Response

Returns the created logistic hub object with HTTP 201.

Example

curl -X POST "https://api.dcycle.io/v1/logistic-hubs" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Madrid Warehouse",
    "type": "subcontracted",
    "category": "warehouse_ambient",
    "supercharger": false
  }'

Successful Response

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Madrid Warehouse",
  "type": "subcontracted",
  "category": "warehouse_ambient",
  "address": null,
  "country": null,
  "status": "active",
  "supercharger": false,
  "facility_id": null,
  "co2e": null,
  "created_at": "2024-11-24T10:30:00Z",
  "updated_at": "2024-11-24T10:30:00Z"
}

Common Errors

409 Conflict

Cause: A hub with the same name already exists in the organization
{
  "detail": "This logistic hub name already exists"
}

422 Validation Error

Cause: facility_id not provided for owned hub
{
  "detail": "facility_id is required for owned logistic hubs"
}