> ## 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.

# Delete Commuting Period

> Remove a commuting period from an employee

# Delete Commuting Period

Permanently delete a commuting period. This will remove the period's CO2e contribution from the employee's total emissions.

<Warning>
  **Irreversible Action**: Deleting a period permanently removes the commuting data and its CO2e calculations.
</Warning>

## Request

### Headers

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication

  **Example:** `sk_live_1234567890abcdef`
</ParamField>

<ParamField header="x-organization-id" type="string" required>
  Your organization UUID

  **Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`
</ParamField>

### Path Parameters

<ParamField path="employee_historic_id" type="string" required>
  The unique identifier (UUID) of the commuting period to delete

  **Example:** `660e8400-e29b-41d4-a716-446655440000`
</ParamField>

## Response

Returns `204 No Content` on successful deletion.

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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}"
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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")
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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');
    }
  });
  ```
</CodeGroup>

### Successful Response

```
HTTP/1.1 204 No Content
```

## Common Errors

### 404 Not Found

**Cause:** Period not found

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "code": "EMPLOYEE_HISTORIC_NOT_FOUND",
  "detail": "EmployeeHistoric with id=UUID('...') not found"
}
```

## Use Cases

### Delete Incorrect Period

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
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)

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
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

<CardGroup cols={2}>
  <Card title="Create Period" icon="plus" href="/api-reference/employees/commuting-periods/create">
    Add new period
  </Card>

  <Card title="List Periods" icon="list" href="/api-reference/employees/commuting-periods/list">
    View all periods
  </Card>
</CardGroup>
