> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Migration Tasks

> Access migration tasks and their status

<Warning>This feature is under development and may not be stable. Changes may occur at any time without notice.</Warning>

# Migration Tasks API

The Migration Tasks API allows you to **list** tasks associated with migrations.

## Authentication

All API requests require authentication using an API key. For details on API keys and authentication, see the [API Authorization](/v1/guides/auth) guide.

## Migration Task Data Structure

Migration task data is returned in a structured JSON format that includes:

```json theme={"system"}
{
  "object": "migration_task",
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created": "2025-01-01T12:00:00.000000",
  "status": "COMPLETE",
  "migration_id": "456e7890-e89b-12d3-a456-426614174000",
  "data_category": "COMPANY",
  "data_type": "EntityType",
  "completed_at": "2025-01-01T12:00:01.000000+00:00"
}
```

### Migration Task Fields

The migration task object contains the following fields:

| Field           | Description                                                                      |
| --------------- | -------------------------------------------------------------------------------- |
| `object`        | The type of object, always `migration_task`                                      |
| `id`            | The unique identifier for the migration task (UUID format)                       |
| `created`       | The date and time the migration task was created                                 |
| `status`        | The current status of the migration task (e.g., COMPLETE, PENDING, IN\_PROGRESS) |
| `migration_id`  | The unique identifier for the migration that the task belongs to (UUID format)   |
| `data_category` | The category of data being processed (e.g., COMPANY, EMPLOYEE, TAX)              |
| `data_type`     | The specific type of data being processed (e.g., EntityType, EmployeeRoster)     |
| `completed_at`  | The date and time the migration task was completed (null if not completed)       |

### Migration Task Statuses

Migration tasks can have the following statuses:

* `PENDING`: The migration task is waiting to be processed
* `IN_PROGRESS`: The migration task is currently being processed
* `COMPLETE`: The migration task has finished successfully
* `FAILED`: The migration task encountered an error and could not complete
* `AWAITING_USER_INPUT`: The migration task requires additional information from the user
* `NO_DATA`: No data was found for this migration task

### Data Categories

Migration tasks are organized into the following categories:

* `EMPLOYEE`: Employee-related data (e.g., EmployeeRoster, ContractorPayments)
* `COMPENSATION`: Compensation-related data (e.g., PayrollJournal)
* `TAX`: Tax-related data (e.g., FederalTax, StateTax)
* `COMPANY`: Company-related data (e.g., EntityType, Location, Signatory)
* `DEDUCTION_SETUP`: Deduction setup data

## API Endpoints

### List Migration Tasks

To list all migration tasks for a specific migration:

<CodeGroup>
  ```javascript listMigrationTasks.js theme={"system"}
  async function listMigrationTasks(migrationId) {
    const response = await fetch(`https://worker.anon.com/api/v1/migration-tasks?migration_id=${migrationId}`, {
      method: 'GET',
      headers: {
        'Authorization': `Bearer ${ANON_API_KEY}`,
        'Content-Type': 'application/json'
      }
    });
    
    if (!response.ok) {
      throw new Error(`Error: ${response.status}`);
    }
    
    return await response.json();
  }
  ```

  ```shell listMigrationTasks.sh theme={"system"}
  curl -X GET "https://worker.anon.com/api/v1/migration-tasks?migration_id=${MIGRATION_ID}" \
    -H "Authorization: Bearer ${ANON_API_KEY}" \
    -H "Content-Type: application/json"
  ```
</CodeGroup>

## Best Practices

* Monitor migration task status to track migration progress
* Implement proper error handling for API requests
* Cache migration task metadata to minimize API calls
