Skip to main content
POST
/
v1
/
logistics
/
recharges
Create Logistics Recharge
const options = {
  method: 'POST',
  headers: {
    'x-api-key': '<x-api-key>',
    'x-organization-id': '<x-organization-id>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    fuel_id: '<string>',
    country: '<string>',
    date: '<string>',
    quantity: 123,
    vehicle_license_plate: '<string>',
    toc_id: '<string>',
    project_id: '<string>'
  })
};

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

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.

Create Logistics Recharge

Create a new fuel consumption record for a logistics vehicle. A recharge records fuel usage (diesel, electric, etc.) linked to a specific fuel type and optionally a vehicle and project.

Request

Headers

x-api-key
string
required
Your API key for authenticationExample: sk_live_1234567890abcdef
x-organization-id
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa

Body Parameters

fuel_id
string
required
UUID of the fuel type from the logistic_fuels table. Use GET /recharges/unique-values?field=fuel_name to list available fuel IDs and their labels.Example: 550e8400-e29b-41d4-a716-446655440000
country
string
required
Country ISO 3166-1 alpha-2 code where the recharge took place.Example: ES
date
string
required
Date of the recharge in YYYY-MM-DD format.Example: 2025-06-15
quantity
number
Amount of fuel consumed, in the fuel’s unit (e.g., liters for diesel, kWh for electricity).Example: 50.0
vehicle_license_plate
string
License plate of the vehicle that was refueled.Example: 1234-ABC
toc_id
string
UUID of the vehicle type (TOC) associated with this recharge. Use the GET /tocs endpoint to get available TOC IDs.
project_id
string
UUID of a project to associate this recharge with.

Response

Returns the created recharge object with 200 OK.
{
  "id": "660e8400-e29b-41d4-a716-446655440000",
  "fuel_id": "550e8400-e29b-41d4-a716-446655440000",
  "fuel_name": "Diesel",
  "country": "ES",
  "date": "2025-06-15T00:00:00",
  "quantity": 50.0,
  "vehicle_license_plate": "1234-ABC",
  "toc_id": null,
  "unit_name": "liters",
  "status": "active",
  "created_at": "2025-06-15T10:30:00",
  "updated_at": "2025-06-15T10:30:00"
}

Upsert Behavior

If a recharge with the same combination of country, date, quantity, and vehicle_license_plate already exists within the organization, the existing record is updated instead of creating a duplicate.

Example

curl -X POST "https://api.dcycle.io/v1/logistics/recharges" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{
    "fuel_id": "550e8400-e29b-41d4-a716-446655440000",
    "country": "ES",
    "date": "2025-06-15",
    "quantity": 50.0,
    "vehicle_license_plate": "1234-ABC"
  }'

Common Errors

404 Not Found

Cause: The fuel_id does not exist or is inactive.
{
  "code": "NOT_FOUND",
  "detail": "Fuel with id '550e8400-e29b-41d4-a716-446655440000' not found or inactive"
}
Solution: Use GET /recharges/unique-values?field=fuel_name to get valid fuel IDs.

422 Validation Error

Cause: Missing required fields or invalid country code.
{
  "detail": [
    {
      "loc": ["body", "country"],
      "msg": "Not Valid Country Code, must be ISO 3166-1 alpha-2"
    }
  ]
}

Create Recharges (Bulk)

Create up to 5,000 recharges in one request

List Recharges

Retrieve fuel consumption records

Delete Recharge

Delete a single recharge

Get Vehicle Types (TOCs)

List available vehicle types