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

# Queue Pending Mobility Survey Export

> Queue an async Excel export of employees pending a mobility survey response across a holding's whole organization tree

# Queue Pending Mobility Survey Export

Queues an asynchronous export listing every employee who has not yet responded to a mobility survey, across the header organization plus every accepted, enabled descendant in its organization tree (recursively). Intended for a holding organization checking on outstanding responses across all of its subsidiaries at once — the group scope is always applied and cannot be narrowed to a single organization.

"Pending" means the employee record has `status = loading` and `enabled = true` — the state a survey send/resend leaves an employee in until they respond. Employees without an email are excluded, since there is no way to follow up with them.

This endpoint only enqueues the export — it creates a `PENDING` processing job, fires an event for a background worker to build the `.xlsx` and upload it, and returns immediately with `processing_job_id`. Poll the processing job (or wait for the in-app notification / email) to retrieve the download link once it completes. If there are no pending employees, the export still completes with a file containing just the header row.

## 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>
  UUID of the holding (or any) organization. The export always spans this organization plus its whole descendant tree.

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

## Response

<ResponseField name="processing_job_id" type="string">
  UUID of the created processing job. Poll `GET /processing_jobs/{processing_job_id}/download-url` until the job completes to retrieve a presigned download URL for the `.xlsx` file.
</ResponseField>

The completed workbook has a single sheet with columns:

| Column           | Description                                                        |
| ---------------- | ------------------------------------------------------------------ |
| Email            | Employee's email address                                           |
| Name             | Employee's name                                                    |
| Organization     | Name of the organization (within the tree) the employee belongs to |
| Survey sent date | Date the survey was sent (date only, no time)                      |

Column headers and the worksheet name are localized to the requesting user's stored language (Spanish or English currently; Spanish is the fallback).

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X GET "https://api.dcycle.io/v2/employees/pending-survey/download" \
    -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/v2/employees/pending-survey/download",
      headers={
          "x-api-key": os.getenv("DCYCLE_API_KEY"),
          "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
      },
  )

  processing_job_id = response.json()["processing_job_id"]
  print(f"Queued export: {processing_job_id}")
  ```

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

  axios.get('https://api.dcycle.io/v2/employees/pending-survey/download', {
    headers: {
      'x-api-key': process.env.DCYCLE_API_KEY,
      'x-organization-id': process.env.DCYCLE_ORG_ID,
    },
  })
  .then(({ data }) => {
    console.log(`Queued export: ${data.processing_job_id}`);
  });
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "processing_job_id": "550e8400-e29b-41d4-a716-446655440000"
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

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

### 403 Forbidden

**Cause:** The authenticated user is not a member of the organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}
```

### 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"}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="List Employees (V2)" icon="list" href="/api-reference/employees/list-v2">
    List employees with group-view filtering, including by status
  </Card>

  <Card title="Bulk Delete by Filters" icon="trash" href="/api-reference/employees/bulk-delete-by-filters">
    Bulk-delete employees matching the same group-view filters
  </Card>
</CardGroup>
