---
title: "Import tasks"
summary: "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: "2026-12-01"
url: "https://taskloader.com/docs/guides/import-tasks"
---

> Documentation index: https://taskloader.com/llms.txt

# 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.

This guide imports a list of tasks into a project, safely enough to run twice. It uses [`create_tasks`](https://taskloader.com/docs/api/reference/tasks.md#create_tasks), which creates up to 25 tasks in one request, all or nothing. Prefer it to many [`create_task`](https://taskloader.com/docs/api/reference/tasks.md#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`](https://taskloader.com/docs/api/reference/tasks.md#create_task):

| Field              | Rules                                                                                                                  |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------- |
| `title`            | Required. One line, up to 180 characters.                                                                              |
| `description`      | Up to 20,000 characters. Text exported with Windows line endings (`\r\n`) is fine: every line break is stored as `\n`. |
| `status`           | `backlog` (the default), `progress`, `review` or `done`.                                                               |
| `priority`         | `low`, `normal` (the default), `high` or `urgent`.                                                                     |
| `assigneeMemberId` | A member of this project (`mem_…`), `me`, or `null`.                                                                   |
| `dueDate`          | `YYYY-MM-DD`.                                                                                                          |
| `checklist`        | Up to 100 items: strings, or `{ "text": "…", "done": true }`. Each up to 500 characters.                               |
| `placement`        | `top` 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`](https://taskloader.com/docs/api/reference/tasks.md#create_tasks) also takes an email or a name for `assignee`, as [`create_task`](https://taskloader.com/docs/api/reference/tasks.md#create_task) does). Load the project's members once and map emails to ids:

```bash
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

| Answer                            | Do                                                                                 |
| --------------------------------- | ---------------------------------------------------------------------------------- |
| `429`                             | Wait `Retry-After` seconds, then send the same request with the same key.          |
| `5xx`, or no answer at all        | Wait a moment (1 s, then 2, 4, 8… up to 30), then send it again with the same key. |
| `409 idempotency_key_in_progress` | Wait `Retry-After` (1 second), then send it again with the same key.               |
| `400`, `422`                      | Stop and fix the data. Sending the same batch again fails the same way.            |
| `413 payload_too_large`           | The batch's JSON is over 1 MiB: send fewer tasks in each request.                  |
| `401`, `403`                      | Stop: 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": "maya@northwind.example",
    "checklist": ["Outline", "Quotes", "Review"]
  }
]
```

```js
// 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}`);
}
```

```python
# import.py: python3 import.py prj_… tasks.json   (needs requests)
import hashlib
import json
import os
import sys
import time

import requests

API = "https://taskloader.com/api/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['TASKLOADER_API_KEY']}"
project_id, source_file = sys.argv[1:3]
results_file = f"import-results-{project_id}.json"


def sha256(text):
    return hashlib.sha256(text.encode()).hexdigest()


def compact(value):
    """JSON without spaces, as JavaScript's JSON.stringify writes it."""
    return json.dumps(value, separators=(",", ":"), ensure_ascii=False)


with open(source_file, encoding="utf-8") as file:
    rows = json.load(file)

# What earlier runs created, by row: {"<row id>": {"id": "task_…", "key": "TL-…"}}.
try:
    with open(results_file, encoding="utf-8") as file:
        imported = json.load(file)
except FileNotFoundError:
    imported = {}

# A row's id is its content, numbered when the same row appears more than once.
seen, row_ids = {}, []
for row in rows:
    digest = sha256(compact(row))[:32]
    seen[digest] = seen.get(digest, 0) + 1
    row_ids.append(f"{digest}-{seen[digest]}")

# Map emails to member ids.
member_ids, cursor = {}, None
while True:
    params = {"limit": 100, **({"cursor": cursor} if cursor else {})}
    page = session.get(f"{API}/projects/{project_id}/members", params=params, timeout=30).json()
    if "data" not in page:
        raise SystemExit(f"{page['code']}: {page['detail']}")
    member_ids.update({member["email"].lower(): member["id"] for member in page["data"]})
    cursor = page["nextCursor"]
    if not cursor:
        break


def to_task(row):
    task = {key: value for key, value in row.items() if key != "assigneeEmail"}
    email = row.get("assigneeEmail")
    if email:
        if email.lower() not in member_ids:
            raise SystemExit(f"{email} is not a member of this project.")
        task["assigneeMemberId"] = member_ids[email.lower()]
    return task


# Up to 25 tasks per request, and less than 1 MiB of JSON: 25 long tasks can be more.
MAX_BATCH_BYTES = 1_000_000


def body_of(tasks):
    return compact({"tasks": tasks}).encode("utf-8")


def send_batch(tasks, key):
    """Sends one batch, retrying limits, server errors and network failures with the same key."""
    for attempt in range(8):
        try:
            response = session.post(
                f"{API}/projects/{project_id}/tasks/batch",
                headers={"Content-Type": "application/json", "Idempotency-Key": key},
                data=body_of(tasks),
                timeout=60,
            )
        except requests.RequestException:
            time.sleep(min(30, 2**attempt))
            continue
        try:
            body = response.json()
        except ValueError:
            body = {}  # A proxy's 502 or 504 page is HTML, not JSON: retried below.
        if response.ok:
            return body["data"]
        retry_after = int(response.headers.get("Retry-After", "0"))
        if response.status_code in (429, 503) or body.get("code") == "idempotency_key_in_progress":
            time.sleep(retry_after or min(30, 2**attempt))
        elif response.status_code >= 500:
            time.sleep(min(30, 2**attempt))
        else:
            raise SystemExit(f"{body['code']}: {body['detail']} {body.get('errors') or body.get('pointer') or ''}")
    raise SystemExit("Taskloader keeps failing; run the import again later.")


# Skip rows an earlier run imported; check every other row before creating anything.
pending = [(row_id, to_task(row)) for row_id, row in zip(row_ids, rows) if row_id not in imported]
print(f"{len(rows) - len(pending)} of {len(rows)} rows were imported before.")

# Batches in row order, each closed at 25 tasks or before its JSON passes the limit.
batches = []
for item in pending:
    joined = [task for _, task in batches[-1] + [item]] if batches else None
    if joined and len(joined) <= 25 and len(body_of(joined)) <= MAX_BATCH_BYTES:
        batches[-1].append(item)
    else:
        batches.append([item])

done = 0
for batch in batches:
    tasks = [task for _, task in batch]
    # 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.
    key = "import-" + sha256(project_id + compact(tasks))[:32]
    created = send_batch(tasks, key)
    for (row_id, _), task in zip(batch, created):
        imported[row_id] = {"id": task["id"], "key": task["key"]}
    with open(results_file, "w", encoding="utf-8") as file:  # After every batch.
        json.dump(imported, file, indent=2)
    done += len(created)
    print(f"Created {done} of {len(pending)}")
```

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](https://taskloader.com/docs/api/files.md).
- **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.
