Skip to article

Import and export Customers through durable operations

Review files explicitly, poll real batch and export identities, and recover existing TaskWorker operations safely.

Use the Customers import and export APIs when several records or a background PDF need durable processing. They reuse Prastav's existing TaskWorker and retained batch/job state. There is no general-purpose incoming API queue. Choose authentication and minimum scopes before using these artificial examples.

Discover and upload a file

  1. Read /api/v1/customers/imports/limits and /fields/{importType}. Download the supported CSV template from /templates/{importType} when useful.

  2. For an XLSX with several usable visible sheets, use the multipart /worksheets preview and select one.

  3. Upload multipart form fields importType, file and optional worksheet to /upload.

  4. Retain the returned batch id, status, headers, mapping, preview issues and revision.

Types are Businesses, Contacts, Leads and Combined. Source limits are 5 MiB, 10,000 rows, 128 columns and 32,768 characters per cell; XLSX expansion is limited to 32 MiB and 512 entries. Native parsers reject macros, malformed CSV/XML, external/hidden sheet use and invalid structures. Formulas use saved values and are not evaluated.

Customers.Import and current View access to the selected record families are required for external review. Every batch read and command is restricted to the uploading actor in the authenticated workspace. Confirmation and worker chunks additionally require current target Create permissions, relationship Create if requested, and subscription Write. Changes in authority can stop later chunks without undoing earlier completed rows.

Map, validate and confirm explicitly

Save mapping with PUT /batches/{id}/mapping. The body is {expectedVersion, record:{mapping:[...]}}; expectedVersion is the current batch revision. Reference actual source column names and discovered target fields. Duplicate source/target mappings reject; unmapped columns are ignored.

POST /batches/{id}/validate takes {expectedVersion} and returns the current preview and revision. Validation creates no customer records. Inspect row errors, warnings and duplicate candidates through detail and the paged /rows read. Duplicate rows default to Skip. CreateNew deliberately permits another record; it does not merge with a candidate.

Confirm only the reviewed, validated batch:

{
  "expectedVersion": 3,
  "record": {
    "duplicateAction": "Skip",
    "createCombinedRelationships": false
  }
}

POST this body to /api/v1/customers/imports/batches/{id}/confirm, replacing the artificial version with the current one. The response retains a real batch identity and queued state. It does not report completion merely because submission succeeded. Combined relationship creation is an explicit choice with its own permission; Contacts-only import never invents Business links. Imported Leads start Pending.

Poll and recover the same import

Read /batches/{id}/progress for status, processed/imported/skipped/failed counts and CanResume. Read /rows for retained row outcomes and created record IDs. Download issues or error rows from /export/issues and /export/error-rows. These return the native file DTO with content, content type and filename.

Queued/Processing means work remains. Imported and the durable row outcomes establish completion. A closed or queued batch cannot be remapped or revalidated. Before confirmation, the explicit /cancel command takes the current expectedVersion. Cancellation is not a generic rollback of completed customers.

If confirmation or enqueue is uncertain, inspect this same batch. An eligible POST /resume reuses its frozen native command, requester, duplicate choice and completed row evidence. A live lease, closed state or lost authority rejects recovery. Never reconfirm or upload the same file solely because a response was lost. The worker claims bounded fenced chunks and excludes completed rows on resume.

Request an export

Use the typed Business, Contact or Site Visit /export endpoint with native filters, selection scope and format. The original core resource create envelope is not used for exports. Selected, CurrentPage, AllMatching, AllWorkspace and CurrentRecord have distinct meanings; review explicit IDs and filters.

Business/Contact tables offer their supported CSV/Excel/PDF formats, Contacts also VCF, and Site Visits their native table formats. Follow-up text/PDF is per chain. A Lead table exporter is not invented by this contract.

A synchronous CustomerTableExportDto contains file content and encoding information. A non-null exportJobId means durable work; follow its status. Explicit Business and Follow-up background PDF routes return the requester-owned customer export projection. Direct single-record PDF GETs return a file, create no background task, and retain native rendering limits and deadlines.

Inspect and download a durable export

GET /api/v1/customers/exports/{id} returns a safe customer-only projection: id, resource, format, status, requested/completed UTC times, error code, optional download path and native command identity. It omits storage keys, raw provider exceptions and internal attempt/fence controls. The bounded collection read returns only the current requester's authorized customer jobs.

Only Completed with a registered result enables /download. Download checks workspace, requester, current source View/Export, commercial Export access and the exact retained generated-document/job association. It streams through the approved document storage service; it does not return a signed storage URL or provider secret.

Queued and Processing are not downloadable results. NotConfigured needs configuration correction. Failed or uncertain rendering may require operator reconciliation rather than another attempt. POST /retry takes the native command GUID and follows the existing eligibility rules: recovery never blindly rerenders an uncertain upload or creates another document. Keep the same job and inspect its outcome first.

Troubleshoot without unsafe replay

Refresh a stale import revision and review mapping/preview again. Correct row errors in a deliberate new file after checking completed results. Follow native lease and recovery eligibility; neither Idempotency-Key nor a new arbitrary operation identity bypasses those checks.

Respect the application's current body, search, paging, range, rate and concurrent-request limits. Use positive Retry-After when throttled. For an uncertain command, retain the real batch/job id and request/correlation reference and inspect API Activity. Never include credentials or full customer files in ordinary support logs.

Read the user import, export, background task and recovery guides for the corresponding human workflow. Provider imports, external delivery, worker callbacks and connection recovery remain separately governed private operations.

Copy this link

Clipboard access is unavailable. Select and copy the link below.