Skip to main content
POST
/
v1
/
transports
/
bulk-delete-by-filters
Bulk Delete Transport Routes by Filters
const options = {
  method: 'POST',
  headers: {'x-organization-id': '<x-organization-id>', 'Content-Type': 'application/json'},
  body: JSON.stringify({filter_hash: '<string>'})
};

fetch('https://api.dcycle.io/v1/transports/bulk-delete-by-filters', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "success_count": 123,
  "success_ids": [
    {}
  ],
  "failed_count": 123,
  "failed_ids": [
    {}
  ],
  "message": "<string>"
}

Bulk Delete Transport Routes by Filters

Delete every transport route that matches a given set of filters — the same filters accepted by the GET /v1/transports list endpoint. This avoids having to collect IDs manually when you want to clear a whole date range, file upload, or status group. A filter_hash safety token (returned by the list endpoint) must be included in the request body. This confirms you are deleting exactly the set of records you previewed, and rejects the request if the filters changed in the meantime.
This operation is irreversible. All matching transport routes, their sections, and their total_impacts records are permanently deleted. Always call GET /v1/transports with the same filters first and review the results before proceeding.

Typical Flow

  1. Call GET /v1/transports with your desired filters.
  2. Save the filter_hash field from the response.
  3. Call POST /v1/transports/bulk-delete-by-filters with the same query parameters and the filter_hash in the request body.
If any filter parameter differs between steps 1 and 3, the server returns a 409 Conflict.

Request

Authentication

Supports both authentication methods:
x-api-key
string
Your API key (use this or Authorization)Example: sk_live_1234567890abcdef
Authorization
string
Bearer JWT token (use this or x-api-key)Example: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...

Headers

x-organization-id
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa

Query Parameters

At least one non-empty query parameter is required to prevent accidental mass deletion.
Free-text search against route name and supplier
from_date
date
Include only routes with a transport date on or after this date (YYYY-MM-DD)
to_date
date
Include only routes with a transport date on or before this date (YYYY-MM-DD)
status
array of string
Filter by route status. Allowed values: pending, active, error. Repeat the parameter to include multiple statuses.
transport_direction
string
downstream (outbound) or upstream (inbound)
file_id
array of UUID
Filter to routes created by a specific file upload. Repeat the parameter for multiple files.
created_at_from
datetime
Include only routes created on or after this ISO 8601 datetime
created_at_to
datetime
Include only routes created on or before this ISO 8601 datetime
co2e_status
string
calculated (routes with at least one impact) or not_calculated (routes with no impacts yet)

Body

filter_hash
string
required
The filter_hash value returned by GET /v1/transports with the same set of filters. Acts as a safety token: if the hash does not match the current filter combination a 409 Conflict is returned.Example: "a3f1c9e2d7b84056af19c3e0b1d72a84"

Response

success_count
integer
Number of transport routes successfully deleted
success_ids
array
UUIDs of the transport routes that were successfully deleted
failed_count
integer
Number of transport routes that could not be deleted
failed_ids
array
UUIDs of the transport routes that failed
message
string
Human-readable summary of the operation outcome

Example

# Step 1 — list and capture the filter_hash
curl -G "https://api.dcycle.io/v1/transports" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  --data-urlencode "from_date=2024-01-01" \
  --data-urlencode "to_date=2024-03-31" \
  --data-urlencode "status=error"

# Step 2 — delete using the same filters + the filter_hash from step 1
curl -X POST "https://api.dcycle.io/v1/transports/bulk-delete-by-filters?from_date=2024-01-01&to_date=2024-03-31&status=error" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{"filter_hash": "a3f1c9e2d7b84056af19c3e0b1d72a84"}'

Successful Response

{
  "success_count": 47,
  "success_ids": [
    "010ed3b6-b513-40f3-b9fe-0f0a338d9274",
    "550e8400-e29b-41d4-a716-446655440000"
  ],
  "failed_count": 0,
  "failed_ids": [],
  "message": "Successfully deleted 47 transport route(s)"
}

No matching records

{
  "success_count": 0,
  "success_ids": [],
  "failed_count": 0,
  "failed_ids": [],
  "message": "No records match the given filters"
}

Common Errors

401 Unauthorized

Cause: Missing or invalid API key / JWT token
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}

403 Forbidden

Cause: The authenticated user is not a member of the organization
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}

409 Conflict

Cause: The filter_hash does not match the current set of query parameters. This happens when the filters passed to this endpoint differ from the ones used when the list was fetched.
{
  "detail": "Filter hash mismatch. The filters have changed since the list was loaded. Please refresh and try again."
}
Solution: Re-fetch GET /v1/transports with your intended filters, copy the new filter_hash, and retry with exactly the same query parameters.

422 Unprocessable Entity

Cause: No query parameters were provided (all filters are empty)
{
  "detail": "At least one filter parameter is required for bulk delete by filters."
}

List Transport Routes

Retrieve all transport routes — the source of the filter_hash

Bulk Delete by IDs

Delete specific transport routes by their IDs

Delete Transport Route

Delete a single transport route by ID

Transport Overview

Full data model and distance calculation reference