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

# Export Detailed Report

> Queue an async, line-level (row-per-leg) logistics export emailed as a download link

# Export Detailed Report

Queue an asynchronous line-level logistics export — one row per request leg, including company name, movement/leg/package IDs, origin/destination, distance, load, tkm, vehicle type and kgCO2e. Unlike [`GET /report`](/api-reference/logistics/get-report), which returns an aggregated ISO 14083 summary inline, this endpoint streams the full detail and is built to scale to organizations with millions of requests. It returns `202` immediately; a background worker generates the file and emails a download link (valid 7 days) when ready.

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

### Query Parameters

<ParamField query="start_date" type="string" required>
  Period start date as a Unix timestamp (seconds)

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

<ParamField query="end_date" type="string" required>
  Period end date as a Unix timestamp (seconds). Must be after `start_date`. Multi-year ranges are allowed.

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

<ParamField query="clients[]" type="string[]">
  Client name(s) to include. Omit to export the whole organization (all clients).
</ParamField>

<ParamField query="per_client" type="boolean" default="false">
  If `true`, generate one file per client (selected, or all) bundled into a single ZIP.
</ParamField>

<ParamField query="output_format" type="string" default="csv">
  Output file format: `excel`, `csv`, or `json`. Large csv/json exports arrive inside a `.zip`; Excel is refused above \~5M rows — use `csv` for very large windows.
</ParamField>

<ParamField query="lang" type="string" default="es">
  Language for the column headers: `es` or `en`.
</ParamField>

<ParamField query="project_id" type="uuid">
  Filter the export by project UUID
</ParamField>

## Response (202 Accepted)

<ResponseField name="processing_job_id" type="string">
  UUID of the processing job for tracking progress
</ResponseField>

<ResponseField name="message" type="string">
  Confirmation message
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X GET "https://api.dcycle.io/v1/logistics/report/export?start_date=1735689600&end_date=1767139200&output_format=csv&lang=en" \
    -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

  response = requests.get(
      "https://api.dcycle.io/v1/logistics/report/export",
      headers={
          "x-api-key": os.getenv("DCYCLE_API_KEY"),
          "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
      },
      params={
          "start_date": "1735689600",
          "end_date": "1767139200",
          "output_format": "csv",
          "lang": "en",
      },
  )

  result = response.json()
  print(f"Export queued — job ID: {result['processing_job_id']}")
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const axios = require('axios');

  const response = await axios.get(
    'https://api.dcycle.io/v1/logistics/report/export',
    {
      headers: {
        'x-api-key': process.env.DCYCLE_API_KEY,
        'x-organization-id': process.env.DCYCLE_ORG_ID,
      },
      params: {
        start_date: '1735689600',
        end_date: '1767139200',
        output_format: 'csv',
        lang: 'en',
      },
    }
  );

  console.log(`Export queued — job ID: ${response.data.processing_job_id}`);
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "processing_job_id": "job-uuid",
  "message": "Logistics report export queued. You will receive an email with the download link when it is ready."
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Invalid API key", "code": "INVALID_API_KEY"}
```

### 404 Not Found

**Cause:** Organization not found

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

### 422 Unprocessable Entity

**Cause:** Invalid or inverted date range

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"code": "INVALID_DATE_RANGE", "detail": "start_date and end_date must be Unix timestamps (seconds)."}
```

**Solution:** Pass `start_date`/`end_date` as Unix timestamps in seconds, with `end_date` after `start_date`.

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Generate Report" icon="chart-line" href="/api-reference/logistics/get-report">
    Get the aggregated ISO 14083 summary inline
  </Card>

  <Card title="List Clients" icon="list" href="/api-reference/logistics/get-clients">
    Get available clients for filtering
  </Card>
</CardGroup>
