Move Transport Routes
const options = {
method: 'POST',
headers: {
Authorization: '<authorization>',
'x-organization-id': '<x-organization-id>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
organization_id: '<string>',
transport_ids: ['<string>'],
consolidate_group: true,
filter_hash: '<string>'
})
};
fetch('https://api.dcycle.io/v1/transports/move', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/transports/move"
payload = {
"organization_id": "<string>",
"transport_ids": ["<string>"],
"consolidate_group": True,
"filter_hash": "<string>"
}
headers = {
"Authorization": "<authorization>",
"x-organization-id": "<x-organization-id>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api.dcycle.io/v1/transports/move \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--header 'x-organization-id: <x-organization-id>' \
--data '
{
"organization_id": "<string>",
"transport_ids": [
"<string>"
],
"consolidate_group": true,
"filter_hash": "<string>"
}
'{
"organization_id": "<string>",
"moved_count": 123,
"unchanged_count": 123,
"not_found_ids": [
"<string>"
],
"recalculating_section_count": 123,
"processing_job_id": {}
}Move Transport Routes
Move many transport routes, by id or by the list’s filters, to another organization of the group
POST
/
v1
/
transports
/
move
Move Transport Routes
const options = {
method: 'POST',
headers: {
Authorization: '<authorization>',
'x-organization-id': '<x-organization-id>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
organization_id: '<string>',
transport_ids: ['<string>'],
consolidate_group: true,
filter_hash: '<string>'
})
};
fetch('https://api.dcycle.io/v1/transports/move', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/transports/move"
payload = {
"organization_id": "<string>",
"transport_ids": ["<string>"],
"consolidate_group": True,
"filter_hash": "<string>"
}
headers = {
"Authorization": "<authorization>",
"x-organization-id": "<x-organization-id>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api.dcycle.io/v1/transports/move \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--header 'x-organization-id: <x-organization-id>' \
--data '
{
"organization_id": "<string>",
"transport_ids": [
"<string>"
],
"consolidate_group": true,
"filter_hash": "<string>"
}
'{
"organization_id": "<string>",
"moved_count": 123,
"unchanged_count": 123,
"not_found_ids": [
"<string>"
],
"recalculating_section_count": 123,
"processing_job_id": {}
}Move transport routes to another organization of your group: the header organization or one of its accepted, enabled
descendant organizations. Each route moves as with the
Query Parameters (
The filters of List Transport Routes, exactly as sent to it, including
organization_id of
Update Transport Route Attachment or Organization: it keeps its id, its
sections (ids and distances), the file it was read from, its custom-column values and its history; the emissions of
its sections are re-attributed to the target at once, and its sections are recalculated there (status: pending until
then) with the target’s default emission factor database, GWP and country.
Two endpoints, one contract:
POST /v1/transports/movetakes the routes’ ids, at most 1,000.POST /v1/transports/move-by-filterstakes the query parameters of List Transport Routes and thefilter_hashthat list answered, and moves every route it matches, with no limit. Afilter_hashthat no longer matches the parameters answers409, so the move reaches exactly the routes the list showed.
409, 422), none moves. Then the routes are written in batches of 500, each committed, and their sections are queued
for recalculation. Routes the target already owns are left alone, so sending the same request again after a failure
finishes the move; those of them still pending are queued for recalculation again, in case the failure came between
writing a batch and queuing it.
Request
Headers
A user session. An API key without a user is refused (
403): a move writes into another organization.The header organization. You need a non-Viewer membership in it.Example:
a8315ef3-dd50-43f8-b7ce-d839e68d51faQuery Parameters (/move-by-filters)
The filters of List Transport Routes, exactly as sent to it, including
consolidate_group, organization_id[] and the column filters (filter_by, filter_match, filter_or_fields).
Body
/move only: let the routes belong to the header organization’s descendants. Without it only the header
organization’s own routes are found.Response
HTTP 200 once every route is written. While it runs, its progress is kept on aBULK_MOVE processing job
(items_success out of items_total).
Requested routes that do not exist, or that the header organization may not write (a subsidiary’s route without
consolidate_group, another company’s): not moved.Example
curl -X POST "https://api.dcycle.io/v1/transports/move-by-filters?transport_direction=downstream&consolidate_group=true&organization_id[]=5ab8d102-2bd6-4642-a79f-519ee472f94f" \
-H "Authorization: Bearer ${DCYCLE_TOKEN}" \
-H "x-organization-id: ${DCYCLE_ORG_ID}" \
-H "Content-Type: application/json" \
-d '{"organization_id": "a056c9e7-6a6e-4361-a313-d029997ddd22", "filter_hash": "3f1c..."}'
Response (200)
{
"organization_id": "a056c9e7-6a6e-4361-a313-d029997ddd22",
"moved_count": 26719,
"unchanged_count": 0,
"not_found_ids": [],
"recalculating_section_count": 26719,
"processing_job_id": "0b8f8a3e-27f5-4b8e-9d0e-2f3c1f6a9c11"
}
Common Errors
403 Forbidden
Cause:organization_id is not the header organization or one of its accepted, enabled descendants, or the caller
may not write into it: an API key without a user (CROSS_ORG_WRITE_REQUIRES_USER), a Viewer, or no membership in the
header organization.
409 Conflict
Cause:TRANSPORT_MOVE_CUSTOM_COLUMN_CONFLICT: a custom-column value of a route has a column of another type in
the target organization, or points at data of its current organization. With /move-by-filters, also a filter_hash
that no longer matches the parameters: list again and retry.
422 Unprocessable Entity
Cause:MULTIDB_CUSTOM_RECORD_NOT_FOUND_OR_DISABLED: a section uses a custom emission factor the target
organization may not use (its database is private to another organization, or the record is disabled). Also a body
that is not valid: more than 1,000 transport_ids, a field that is not a UUID, or an unknown field.Was this page helpful?