Upload provider export
POST
https://app.speybooks.com/api/v1/migrations/{id}/upload-providerUpload a provider-specific export file for automated extraction and mapping. Currently supports FreeAgent .xlsx files only.
FreeAgent Flow
- Validate file: must be .xlsx, under 10MB
- Parse via
parseFreeAgentExport()— splits sheets into CSV buffers for contacts, trial balance, invoices, bills - Validate required sheets are present
- Determine clearing mode: if invoices or bills exist, opening balance uses clearing account reconciliation
- Call
uploadContacts()service directly (same transaction, same RLS context) - Call
uploadOpeningBalance()service directly - If invoices/bills sheets exist, store as base64 in
mapping_data.deferredSheetsfor later processing - Attach import IDs to the migration
- Advance migration status
Deferred Sheets
Invoices and bills are deferred because they depend on the opening balance being confirmed first (clearing account reconciliation). The frontend calls /upload-deferred after OB confirmation.
Request
Multipart file upload — the file field must contain a single .xlsx file.
Error responses:
400 { code: "validation_error" }— not FreeAgent provider, no file, or not .xlsx400 { code: "parse_error" }— XLSX parsing failed400 { code: "validation_error" }— required sheets missing413— file exceeds 10MB422 { code: "PROVIDER_PARSE_FAILED" }— required sheets (contacts or balances) failed to import422 { code: "INVALID_TRANSITION" }— migration is terminal
Path parameters
id string requiredMigration ID (e.g. mig_1). Must be FreeAgent provider.
Response
200 File parsed. Returns migration status, per-entity upload results (uploaded/deferred), and matched sheet names.
Show response fields
balancesImportId stringbillsImportId string nullablecompletedAt string nullablecontactsImportId stringcreatedAt string date-timecutoverDate stringid stringinvoicesImportId string nullableprovider stringproviderLabel stringreconciliation string nullablesheets array<string>status stringuploads objectShow child attributes
balances objectShow child attributes
importId stringstatus stringbills string nullablecontacts objectShow child attributes
importId stringstatus stringinvoices objectShow child attributes
importId string nullablestatus stringwarnings array<object>Error codes
400 Wrong file format, parse error, or missing required sheets.
404 Migration not found.
413 File exceeds 10MB limit.
422 Migration is terminal, or required sheets (contacts/balances) failed to parse.