The Slack import job — its budget, its receipts and its lease
A Slack import is one server-side job, not a process. The job holds the plan-sized daily budget, one receipt per committed batch and a lease that only one worker can hold. A channel is read, transformed and written one page at a time, and every sub-phase keeps its own cursor, so a crash or an app restart resumes at the first unwritten row; a batch whose answer the app never saw is replayed, never re-applied; files move one at a time against storage reserved when the job started, are stored once however often a run repeats, and a cancelled run keeps the objects it uploaded; and Cancel ends the job while keeping every row already imported.
On this page
What it is
A Slack import runs as one server-side job. The job, not the app window, owns the budget, the batch receipts and the lease, so a restart resumes where it stopped.
Where a job lives and what it freezes
importJobs/{jobId}, under the workspace (organizations/{id}orworkspaces/{id}). It is server-only:firestore.ruleshas no match for it, so the closing deny refuses every client read and write, exactly as it does forimportLedger. Only the relay writes it.- Frozen at creation: the Slack team and user, the lane, the target workspace, the channel selection, the window and the upper time bound, the dry-run flag, and the budget.
- The user mappings are frozen as a digest, not as a copy. A workspace can map 50,000 people and a Firestore document is 1 MB, so the job records the count and a SHA-256 of the mapping. A resume must present the same mapping or it is refused — the mapping a run started with can never be re-decided, which is the rule's whole point.
- No Slack token is ever written to a job, a checkpoint, a receipt or a report. The token stays where the connection keeps it.
- States:
planned→running→waiting→paused→done|cancelled|failed.
Where to find it
The job has no screen of its own: you meet it through the Slack import wizard, which starts, resumes and cancels it (see the wizard page under Related).
What the app sees
- Start opens the job and receives the lease.
- Resume names the job id (the wizard reads it from the workspace's newest job) and the same user mapping.
- Cancel calls the job, not the process.
- Status answers from the job record plus the live progress: state, checkpoint, budget charged against the allowance. The lease token is never part of a status answer.
How it behaves
The budget
| Setting | Free | Paid |
|---|---|---|
| Messages per workspace per day | 100,000 | 1,000,000 |
- The numbers live once, in
slack-import-job.ts(IMPORT_JOB_MAX_MESSAGES_PER_DAY_FREE,IMPORT_JOB_MAX_MESSAGES_PER_DAY_PAID), underIMPORT_JOB_ABUSE_CEILING_MESSAGES_PER_DAY— a fixed ceiling no plan or job can exceed. - The byte allowance derives from the message allowance
(
IMPORT_JOB_BYTES_PER_MESSAGE), and the upload mint charges it on the same job. - Charged to the job, not to the admin. The relay no longer spends a per-uid daily slot on an import batch; the job's allowance is the import's capacity, so one big channel is one job rather than a multi-day crawl across rotating admins.
- Charged after the ledger skip, so a row the ledger already records is never charged twice and a re-read of history a previous run wrote spends nothing.
- Refused at the cap, cleanly. The relay answers the first batch that would cross the cap with
resource-exhaustedand the reset time; the desktop stops, marks the jobpausedand tells the reader the import picks up after 00:00 UTC. No rows are lost.
Receipts: a replayed batch spends nothing
Every batch carries an id minted once, outside the retry loop.
- The relay claims the batch id inside one transaction: it reads the receipt, checks the lease, and charges the job and the workspace day together. A receipt that is already settled is answered from itself — nothing is written and nothing is charged.
- The settled receipt is written in the same Firestore batch as the rows, so a commit that landed always has its receipt and a commit that did not always lacks one. An unknown outcome is therefore never guessed.
- A claim the worker never settled is taken over after
IMPORT_JOB_CLAIM_TTL_MS; a claim that is still fresh refuses the duplicate with a retryable answer. - A batch that failed before its commit gives its charge back.
The lease
- One live worker per job. Starting or resuming mints a lease token, returned once to that window. Every batch and every checkpoint must present it.
- A second Resume is refused, never queued — the live lease answers
already-exists. - A quiet worker's lease expires (
IMPORT_JOB_LEASE_MS, renewed by every batch and checkpoint), so another admin can resume after a crash. - Cancel revokes the lease, so a worker that returns late is fenced at its next batch instead of writing.
A channel streams
- A channel is read, transformed and written as one bounded pipeline: a page of up to 200 Slack messages, that page's thread replies, a batch of at most 200 rows, a commit, then the next page. At most one raw page, one batch and the channel's id map are live at a time.
- Pagination ends when Slack's cursor ends. The import path has no page or item ceiling, so
"everything" means everything the connected account can read.
AMC_SLACK_IMPORT_MAX_PAGESis an operator brake only; when it stops a walk Slack had not finished, the report carries a problem row naming the channel and the count — never a silent success. - Archived Slack channels are imported and stored exactly like live ones. The listing asks for
them explicitly (
exclude_archived: false). - A reply inside the window pulls its parent in. When a thread reply falls inside the chosen period and its parent falls outside it, the parent is imported too and listed as pulled in by a reply, so a reply is never orphaned or flattened to the top level.
- Files move one at a time: each file of a page is asked about, downloaded, checked, uploaded and released before the next one starts, so neither the disk nor the memory ever holds more than one file, and an attachment is only recorded once its object landed. See Files below.
Files: one at a time, reserved, stored once, cleaned up
- One file in flight. For every file the app first asks the relay for that file alone, then downloads it, checks the bytes it actually received, uploads it, and deletes the download. The relay signs one upload at a time, so a signed link never sits unused while a long page uploads.
- Already stored is answered by the relay, not guessed by the app. A server-side file ledger records each imported file once, keyed by the source conversation and Slack's file id, with the one storage path that holds it and every message that points at it. A later run — the same admin resuming, or a second admin repairing the same conversation — is told "already imported" and spends no download, no upload and no storage, and the new message is recorded against the file. A file another window is storing right now is reported as in progress instead of being stored twice, and it stays in progress for as long as the upload link it was minted with is valid — timed from when the link was signed, so a slow upload never loses its place. The job that holds the claim may ask again early, which is what lets a file that grew past what Slack declared be minted a second time; before the new size is charged, the first charge is refunded three ways — the job's storage reservation, the job's charged bytes and the admin's daily byte allowance. The ledger keeps up to 200 referencing messages per file, far inside a document's size limit. A message may point at a file another importer stored only where the ledger records that exact path for that conversation and file; a batch reads those ledger rows in one round trip, and a path nobody stored is refused like a path in another channel.
- Storage is reserved when the job starts, not checked then. The trial run's storage estimate
becomes the job's reservation, frozen with the job in its own
storagefield. Every accepted file is charged against that reservation, and the workspace's remaining storage is read in the same request that mints its upload link, so a file the workspace cannot hold is refused before its object lands with both numbers in its report row — what the file needs and what is left. The reservation has a hard ceiling, the job's own byte allowance, so a request that names no reservation gets that ceiling rather than an unlimited one. The bytes are charged once, by the same storage guard every native upload goes through, when the object lands. - A file that cannot come is a report line. A refused file, an expired link, a file that grew past what Slack declared, a slow download and a failed upload each become one row in the report, named by the file, with copy a person can act on — never a silent gap and never an internal path.
- Cancel keeps the objects it uploaded. Cancel still deletes nothing: every object a cancelled run stored stays where it is, still charged to the workspace, and the ledger keeps its rows. That costs unused storage instead of risking a message that points at a file somebody removed — the failure this rule refuses. Reclaiming that storage is H-17139, a server-side scheduled collector that can wait out a grace period and check references properly; no import request ever deletes a stored object.
Resume
- The job's checkpoint carries
(phase, channel index, channel id, oldest ts, batches written)plus one entry per sub-phase —channel,messages,replies,reactions,pins,files— each with its own cursor, the newest Slack ts it committed, and its committed-batch count. It is saved after each committed page. - A resume starts at the first channel that is not finished, skips the sub-phases already done, and re-reads the unfinished one just below its newest committed message (the history walk runs newest to oldest), so an expired Slack cursor never matters.
- Every imported row has a deterministic id and every batch id is derived from the rows it carries, so a re-read is skipped by the ledger and a re-sent batch is answered from its receipt: a resume costs storage nothing and charges nothing.
- The window and upper bound come from the frozen job, never from the environment's current values.
Cancel
- A write into a Team Chat channel archived after the import began is refused by the reach check and becomes a problem row naming the channel; the rest of the batch still lands. The import never fails a whole batch over it.
- Cancel confirms first, then ends the job: state
cancelled, lease gone, checkpoint cleared. - Every written row stays. Starting again afterwards is a repair — an append-only run — which is what makes Cancel safe on a workspace-sized import. The objects and ledger rows of files it had already uploaded stay too; Cancel removes no storage.
- Receipts survive Cancel; they are the record of what already landed.
The one compatibility path
A run that names no job keeps the older per-account daily slot, and a run whose importer has no readable Slack identity (so no team id can be frozen) also keeps it. Both paths are still bounded by the per-uid and per-workspace caps; the job path is the one that carries the plan-sized budget.
Related
- The rules this page describes:
team-chat-slack-import-contract(SI40, SI41, SI47). - The wizard: slack-import.md.
Last verified 2026-11-27