Delete Commuting Period
const options = {
method: 'DELETE',
headers: {'x-api-key': '<x-api-key>', 'x-organization-id': '<x-organization-id>'}
};
fetch('https://api.dcycle.io/v1/employee-historic/{employee_historic_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/employee-historic/{employee_historic_id}"
headers = {
"x-api-key": "<x-api-key>",
"x-organization-id": "<x-organization-id>"
}
response = requests.delete(url, headers=headers)
print(response.text)curl --request DELETE \
--url https://api.dcycle.io/v1/employee-historic/{employee_historic_id} \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>'Delete Commuting Period
Remove a commuting period from an employee
DELETE
/
v1
/
employee-historic
/
{employee_historic_id}
Delete Commuting Period
const options = {
method: 'DELETE',
headers: {'x-api-key': '<x-api-key>', 'x-organization-id': '<x-organization-id>'}
};
fetch('https://api.dcycle.io/v1/employee-historic/{employee_historic_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/employee-historic/{employee_historic_id}"
headers = {
"x-api-key": "<x-api-key>",
"x-organization-id": "<x-organization-id>"
}
response = requests.delete(url, headers=headers)
print(response.text)curl --request DELETE \
--url https://api.dcycle.io/v1/employee-historic/{employee_historic_id} \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>'Delete Commuting Period
Permanently delete a commuting period. This will remove the period’s CO2e contribution from the employee’s total emissions.Irreversible Action: Deleting a period permanently removes the commuting data and its CO2e calculations.
Request
Headers
string
required
Your API key for authenticationExample:
sk_live_1234567890abcdefstring
required
Your organization UUIDExample:
a8315ef3-dd50-43f8-b7ce-d839e68d51faPath Parameters
string
required
The unique identifier (UUID) of the commuting period to deleteExample:
660e8400-e29b-41d4-a716-446655440000Response
Returns204 No Content on successful deletion.
Example
curl -X DELETE "https://api.dcycle.io/v1/employee-historic/660e8400-e29b-41d4-a716-446655440000" \
-H "x-api-key: ${DCYCLE_API_KEY}" \
-H "x-organization-id: ${DCYCLE_ORG_ID}"
import requests
import os
headers = {
"x-api-key": os.getenv("DCYCLE_API_KEY"),
"x-organization-id": os.getenv("DCYCLE_ORG_ID")
}
period_id = "660e8400-e29b-41d4-a716-446655440000"
response = requests.delete(
f"https://api.dcycle.io/v1/employee-historic/{period_id}",
headers=headers
)
if response.status_code == 204:
print("Period deleted successfully")
const axios = require('axios');
const headers = {
'x-api-key': process.env.DCYCLE_API_KEY,
'x-organization-id': process.env.DCYCLE_ORG_ID
};
const periodId = '660e8400-e29b-41d4-a716-446655440000';
axios.delete(
`https://api.dcycle.io/v1/employee-historic/${periodId}`,
{ headers }
)
.then(response => {
if (response.status === 204) {
console.log('Period deleted successfully');
}
});
Successful Response
HTTP/1.1 204 No Content
Common Errors
404 Not Found
Cause: Period not found{
"code": "EMPLOYEE_HISTORIC_NOT_FOUND",
"detail": "EmployeeHistoric with id=UUID('...') not found"
}
Use Cases
Delete Incorrect Period
def delete_period(period_id):
"""Delete a commuting period"""
response = requests.delete(
f"https://api.dcycle.io/v1/employee-historic/{period_id}",
headers=headers
)
return response.status_code == 204
success = delete_period("660e8400-e29b-41d4-a716-446655440000")
Replace Period (Delete + Create)
def replace_period(old_period_id, new_period_data):
"""Replace a period with new data"""
# Delete old
requests.delete(
f"https://api.dcycle.io/v1/employee-historic/{old_period_id}",
headers=headers
)
# Create new
response = requests.post(
"https://api.dcycle.io/v1/employee-historic",
headers=headers,
json=new_period_data
)
return response.json()
Related Endpoints
Create Period
Add new period
List Periods
View all periods
Was this page helpful?