Files API

The Files API allows you to list and retrieve files associated with migrations.

Authentication

All API requests require authentication using an API key. For details on API keys and authentication, see the API Authorization guide.

File Data Structure

File data is returned in a structured JSON format that includes:
{
  "object": "file",
  "id": "file-123",
  "created": "2023-05-19T10:30:00Z",
  "name": "Employee Roster",
  "type": "EmployeeRoster",
  "url": "https://storage.example.com/files/employee_roster.json",
  "size": 545024,
  "content_type": "application/json",
  "migration_id": "migration-456"
}

File Fields

The file object contains the following fields:
FieldDescription
objectThe type of object, always file
idThe unique identifier for the file
createdThe date and time the file was created
nameThe name of the file, unmodified from the original file
typeThe type of file (e.g., EmployeeRoster)
content_typeThe MIME type of the file
urlThe signed URL for the file
sizeThe size of the file in bytes
migration_idThe unique identifier for the migration that the file belongs to

File Types

Each file is downloaded from a specific source on the source system’s website. The “source” of each file can be inferred by the type field. Here is a subset of all possible file types:
  • CompanyInfo-EntityType-Screenshot
  • CompanyInfo-EntityType-HTML
  • ContractorInfo-Details-CSV
  • ContractorPayments-Report-CSV
  • Deductions-Benefits-Screenshot
  • Deductions-Benefits-HTML
  • Deductions-Pay-HTML
  • Deductions-Report-CSV
  • Deductions-Report-HTML
  • DirectDeposit-Report-CSV
  • EmployeeData-Report-CSV
  • FederalTax-Setup-Screenshot
  • FederalTax-Setup-HTML
  • FederalTax-Document-PDF
  • Location-Screenshot
  • Location-HTML
  • PayrollJournal-Report-CSV
  • PTOData-Policy-Screenshot
  • PTOData-Policy-HTML
  • PTOData-Policy-XLSX
  • SignatoryData-Screenshot
  • SignatoryData-HTML
  • StateTax-Setup-Screenshot
  • StateTax-Setup-HTML
  • StateTax-Document-PDF
  • TimeOffBalances-Report-CSV

API Endpoints

List Files

To list all files for a specific migration:
async function listFiles(migrationId) {
  const response = await fetch(`https://worker.anon.com/api/v1/files?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();
}

Get File Details

To retrieve details for a specific file:
async function getFile(fileId) {
  const response = await fetch(`https://worker.anon.com/api/v1/files/${fileId}`, {
    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();
}

Best Practices

  • Cache file metadata to minimize API calls
  • Implement proper error handling for API requests