Skip to content
DocsImport tasks

Guides

Import tasks

Import tasks from a spreadsheet or another tool in batches of up to 25, with idempotency keys that make re-runs safe and backoff on 429.

Updated View as Markdown

On this page

This guide imports a list of tasks into a project, safely enough to run twice. It uses create_tasks, which creates up to 25 tasks in one request, all or nothing. Prefer it to many create_task calls: each new task in a project takes the next key, so creates in one project are numbered one at a time and wait for each other, while a batch is numbered in one go.

You need tasks:write and the editor role in the project. To assign tasks you also need projects:read, to look up members.

Prepare the tasks

#

Each task takes the same fields as create_task:

FieldRules
titleRequired. One line, up to 180 characters.
descriptionUp to 20,000 characters. Text exported with Windows line endings (\r\n) is fine: every line break is stored as \n.
statusbacklog (the default), progress, review or done.
prioritylow, normal (the default), high or urgent.
assigneeMemberIdA member of this project (mem_…), me, or null.
dueDateYYYY-MM-DD.
checklistUp to 100 items: strings, or { "text": "…", "done": true }. Each up to 500 characters.
placementtop or bottom of its column.

Check these before you send anything: one invalid task fails its whole batch. The whole request is limited too, to 1 MiB of JSON, and 25 tasks near their limits can pass it (25 long descriptions in Chinese, for example, or 25 full checklists). The program below therefore puts fewer tasks in a batch when its JSON would be larger than 1,000,000 bytes.

Over the REST API, people are assigned by member id, not by email (the MCP tool create_tasks also takes an email or a name for assignee, as create_task does). Load the project's members once and map emails to ids:

Shell
curl "https://taskloader.com/api/v1/projects/$PROJECT_ID/members?limit=100" \
  -H "Authorization: Bearer $TASKLOADER_API_KEY" | jq '.data[] | {email, id}'

Send batches of up to 25

#
HTTP
POST /projects/{projectId}/tasks/batch
Idempotency-Key: import-3f9a1c0e2b7d4a56e81f07c2d9b4a6e1
JSON
{
  "tasks": [
    { "title": "Choose the launch date", "priority": "high", "dueDate": "2026-11-25" },
    {
      "title": "Draft the press release",
      "assigneeMemberId": "mem_6eeb754d7a80739034c6d9fa93e0a741",
      "checklist": ["Outline", "Quotes", "Review"]
    }
  ]
}

The answer is 201 Created with the new tasks, in the order you sent them:

HTTP
HTTP/1.1 201 Created
Content-Type: application/json

{
  "object": "list",
  "data": [
    {
      "object": "task",
      "id": "task_1b6f1d2a8c9e4f00a1b2c3d4e5f60718",
      "projectId": "prj_0b6f1d2a8c9e4f00a1b2c3d4e5f60718",
      "number": 13,
      "key": "TL-013",
      "ref": "northwind/website-launch/TL-013",
      "url": "https://taskloader.com/northwind/website-launch/TL-013",
      "title": "Book the launch-day photographer",
      "description": "",
      "status": "backlog",
      "priority": "normal",
      "assignee": null,
      "dueDate": null,
      "checklist": [],
      "checklistProgress": {
        "done": 0,
        "total": 0
      },
      "bookmark": null,
      "position": 4096,
      "version": 1,
      "attachmentCount": 0,
      "createdBy": {
        "userId": "usr_kq3Xb1W9pZ0aLm7c",
        "name": "Maya Chen"
      },
      "createdAt": "2026-11-18T10:00:00.123Z",
      "updatedAt": "2026-11-18T10:00:00.123Z",
      "completedAt": null
    },
    {
      "object": "task",
      "id": "task_2b6f1d2a8c9e4f00a1b2c3d4e5f60718",
      "projectId": "prj_0b6f1d2a8c9e4f00a1b2c3d4e5f60718",
      "number": 14,
      "key": "TL-014",
      "ref": "northwind/website-launch/TL-014",
      "url": "https://taskloader.com/northwind/website-launch/TL-014",
      "title": "Send the press kit",
      "description": "",
      "status": "backlog",
      "priority": "normal",
      "assignee": null,
      "dueDate": "2026-11-25",
      "checklist": [],
      "checklistProgress": {
        "done": 0,
        "total": 0
      },
      "bookmark": null,
      "position": 5120,
      "version": 1,
      "attachmentCount": 0,
      "createdBy": {
        "userId": "usr_kq3Xb1W9pZ0aLm7c",
        "name": "Maya Chen"
      },
      "createdAt": "2026-11-18T10:00:00.123Z",
      "updatedAt": "2026-11-18T10:00:00.123Z",
      "completedAt": null
    }
  ]
}

The batch runs in one transaction. If any task in it fails, none is created. The problem points at the first task that failed, and its detail names every one:

JSON
{
  "status": 422,
  "code": "assignee_not_member",
  "detail": "No member of this project has task 4’s assignee id. Member ids belong to one project, and the same person has a different one in each: use one from this project’s members.",
  "pointer": "/tasks/3/assigneeMemberId",
  "…": "…"
}

Validation failures (400 validation_failed) list the first 20 problems in errors, each with a pointer such as /tasks/7/title, and moreErrors counts the rest. A large batch can have more problems than that, so check every row before you send it, not only the rows errors names.

Make re-runs safe

#

Imports get interrupted: a laptop sleeps, a network drops, a script is stopped, a row turns out to be invalid. The program below makes running it again safe, in two ways:

  • It records what it created. After every batch it writes which rows became which tasks to import-results-<project id>.json. A later run skips the rows already in that file, so fixing a row that failed, adding rows or removing rows never creates a task twice, even days later. (Editing a row that was already imported does: see below.) Keep the file next to your source.
  • Each batch's Idempotency-Key is built from its content: import- followed by the first 32 hex digits of the SHA-256 of the project id and the batch's tasks. If a batch went through but its answer (or the results file) was lost, the next run sends the same batch with the same key and gets the original answer back instead of a second set of tasks.

This works only while the batch stays the same. If a run stopped because a request got no answer (a timeout, a dropped connection, a crash), run it again before you change the source file: change the file first, and a batch whose answer was lost gets a new key, and its tasks are created again. A batch the API refused (400 or 422) created nothing, so fix its rows freely.

What the key does:

  • Same key, same batch, within 24 hours: you get the original answer back, with Idempotent-Replayed: true, even if some of its tasks were edited or deleted since. Nothing is created twice.
  • If Taskloader stopped after creating a batch but before answering, the retry rebuilds the answer from the tasks. Should one of them have been deleted in between, it answers 404 not_found naming that task ("Task 6 of the batch (TL-031) was deleted after the batch created it, …"), never a shorter list; nothing is created.
  • 409 idempotency_key_in_progress: the first attempt is still running. Wait a second and send it again.
  • 422 answers are stored under the key too. After you fix a row, its batch's content differs, so the batch gets a new key by itself.
  • Keys are kept for 24 hours. The results file covers the time after that.

Rows are recognized by their content. If you change a row that already became a task, the next run treats it as a new row and creates another task: change that task in Taskloader instead.

Retry the right failures

#
AnswerDo
429Wait Retry-After seconds, then send the same request with the same key.
5xx, or no answer at allWait a moment (1 s, then 2, 4, 8… up to 30), then send it again with the same key.
409 idempotency_key_in_progressWait Retry-After (1 second), then send it again with the same key.
400, 422Stop and fix the data. Sending the same batch again fails the same way.
413 payload_too_largeThe batch's JSON is over 1 MiB: send fewer tasks in each request.
401, 403Stop: the credential is wrong or lacks access.

Batches of up to 25 keep you far inside the write limit, which counts requests, not tasks. Send batches one after another rather than all at once.

The whole program

#

It reads tasks.json, an array of tasks with an optional assigneeEmail, and records what it created in import-results-<project id>.json after every batch.

JSON
[
  { "title": "Choose the launch date", "priority": "high", "dueDate": "2026-11-25" },
  {
    "title": "Draft the press release",
    "assigneeEmail": "[email protected]",
    "checklist": ["Outline", "Quotes", "Review"]
  }
]
// import.mjs: node import.mjs prj_… tasks.json   (Node.js 20 or later, no packages)
import { createHash } from 'node:crypto';
import { readFile, writeFile } from 'node:fs/promises';

const API = 'https://taskloader.com/api/v1';
const auth = { Authorization: `Bearer ${process.env.TASKLOADER_API_KEY}` };
const [projectId, sourceFile] = process.argv.slice(2);
const resultsFile = `import-results-${projectId}.json`;
const sleep = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds * 1000));
const sha256 = (text) => createHash('sha256').update(text).digest('hex');

const rows = JSON.parse(await readFile(sourceFile, 'utf8'));

// What earlier runs created, by row: { "<row id>": { "id": "task_…", "key": "TL-…" } }.
let imported = {};
try {
  imported = JSON.parse(await readFile(resultsFile, 'utf8'));
} catch {}

// A row's id is its content, numbered when the same row appears more than once.
const seen = new Map();
const rowIds = rows.map((row) => {
  const digest = sha256(JSON.stringify(row)).slice(0, 32);
  seen.set(digest, (seen.get(digest) ?? 0) + 1);
  return `${digest}-${seen.get(digest)}`;
});

// Map emails to member ids.
const memberIds = new Map();
for (let cursor = null; ;) {
  const url = new URL(`${API}/projects/${projectId}/members`);
  url.searchParams.set('limit', '100');
  if (cursor) url.searchParams.set('cursor', cursor);
  const page = await (await fetch(url, { headers: auth })).json();
  if (!page.data) throw new Error(`${page.code}: ${page.detail}`);
  for (const member of page.data) memberIds.set(member.email.toLowerCase(), member.id);
  if (!(cursor = page.nextCursor)) break;
}

const toTask = ({ assigneeEmail, ...task }) => {
  if (!assigneeEmail) return task;
  const memberId = memberIds.get(assigneeEmail.toLowerCase());
  if (!memberId) throw new Error(`${assigneeEmail} is not a member of this project.`);
  return { ...task, assigneeMemberId: memberId };
};

// Up to 25 tasks per request, and less than 1 MiB of JSON: 25 long tasks can be more.
const MAX_BATCH_BYTES = 1_000_000;
const bodyOf = (tasks) => JSON.stringify({ tasks });

/** Sends one batch, retrying limits, server errors and network failures with the same key. */
async function sendBatch(tasks, key) {
  for (let attempt = 0; ; attempt++) {
    if (attempt === 8) throw new Error('Taskloader keeps failing; run the import again later.');
    let response;
    try {
      response = await fetch(`${API}/projects/${projectId}/tasks/batch`, {
        method: 'POST',
        headers: { ...auth, 'Content-Type': 'application/json', 'Idempotency-Key': key },
        body: bodyOf(tasks),
      });
    } catch {
      await sleep(Math.min(30, 2 ** attempt));
      continue;
    }
    // A proxy's 502 or 504 page is HTML, not JSON: it is retried like any server error.
    const body = await response.json().catch(() => ({}));
    if (response.ok) return body.data;
    const retryAfter = Number(response.headers.get('retry-after'));
    if (
      response.status === 429 ||
      response.status === 503 ||
      body.code === 'idempotency_key_in_progress'
    )
      await sleep(retryAfter || Math.min(30, 2 ** attempt));
    else if (response.status >= 500) await sleep(Math.min(30, 2 ** attempt));
    else
      throw new Error(
        `${body.code}: ${body.detail} ${JSON.stringify(body.errors ?? body.pointer ?? '')}`,
      );
  }
}

// Skip rows an earlier run imported; check every other row before creating anything.
const pending = rows
  .map((row, index) => ({ rowId: rowIds[index], row }))
  .filter(({ rowId }) => !imported[rowId])
  .map(({ rowId, row }) => ({ rowId, task: toTask(row) }));
console.log(`${rows.length - pending.length} of ${rows.length} rows were imported before.`);

// Batches in row order, each closed at 25 tasks or before its JSON passes the limit.
const batches = [];
for (const item of pending) {
  const last = batches.at(-1);
  const joined = last && [...last, item].map((each) => each.task);
  if (joined && joined.length <= 25 && Buffer.byteLength(bodyOf(joined)) <= MAX_BATCH_BYTES)
    last.push(item);
  else batches.push([item]);
}

let done = 0;
for (const batch of batches) {
  const tasks = batch.map((item) => item.task);
  // Built from the batch's content: the same batch sent again is answered from the
  // first time, and a fixed row gives its batch a new key.
  const key = `import-${sha256(projectId + JSON.stringify(tasks)).slice(0, 32)}`;
  const created = await sendBatch(tasks, key);
  created.forEach((task, index) => {
    imported[batch[index].rowId] = { id: task.id, key: task.key };
  });
  await writeFile(resultsFile, JSON.stringify(imported, null, 2)); // After every batch.
  done += created.length;
  console.log(`Created ${done} of ${pending.length}`);
}

Run it again and it creates nothing new: rows in the results file are skipped, and a batch whose answer was lost is answered from the first run. Fix a failed row, or add rows, and the next run creates only those.

Beyond tasks

#
  • Comments: POST /tasks/{taskId}/comments with { "body": "…" } (needs comments:write), one per request, each with its own Idempotency-Key.
  • Files: see Files.
  • Links: POST /projects/{projectId}/bookmarks with { "url": "…" } creates a task that bookmarks a page. Taskloader reads the page and renames the task after it (after the words of its link when the page cannot be read, and again if a later read succeeds). A large import's pages are read at up to 100 an hour per project (150 per person), the rest about one a minute, so renames can arrive over an hour or more.
  • History: imported tasks are created now, by you, and their history says they came through your API key. The API cannot backdate tasks or create them in someone else's name.