Skip to content
DocsConflicts and retries

Guides

Conflicts and retries

Never overwrite someone's change and never do anything twice: versions, ETags, 412 and 428, idempotency keys, and a retry policy for every status.

Updated View as Markdown

On this page

Two things go wrong in every integration that writes:

  1. Someone else changed it first. You read a task, a teammate edits it, then you save your change. Taskloader refuses to overwrite their edit without you seeing it: 412 version_conflict.
  2. The answer got lost. You sent a request and the connection dropped. Did it happen? With an Idempotency-Key, you can simply send it again.

This guide handles both, and ends with a retry policy for every status.

Versions

#

Tasks, projects and organizations have a version that goes up with every change. Responses carry it in the body. A change also answers with ETag: "<version>"; a read's ETag is weak and adds a digest of the answer (W/"<version>-<digest>").

Changing one of them requires the version you read, as If-Match ("<version>", or a read's ETag exactly as you got it) or a version field in the body (?version=<version> on delete_task and remove_bookmark, which take no body):

OperationNeeds a version
update_task, move_task, delete_task, remove_bookmarkYes
update_project, update_organizationYes
edit_checklistOptional: checked when you send it
Comments, files, roles, members, invitationsNo

Without a version you get 428 precondition_required. If-Match: * gets the same answer: a version is always needed, so nothing is ever overwritten blind. The 428 carries no copy of the resource: read the resource to learn its version. MCP tools that need a version take it as a required argument (edit_checklist takes it optionally), so a call without one is refused with validation_failed at /version: read the task (or project) first.

The loop

#
  1. Read the task (or use the copy you have, with its version).
  2. Send your change with If-Match.
  3. On 412, the problem carries currentVersion and the whole task as it is now in current. Decide whether your change still makes sense for that task, then send it again with current.version. No extra read is needed.

Decide, do not just retry. If you wanted to move a task to review and someone has already marked it done, moving it back is probably wrong. If you wanted to raise its priority and someone renamed it, your change is still fine.

# Someone changed the task after you read version 1, so it is now at 2.
# This sends your change with the stale version 1 and gets a 412:
curl -s -X PATCH https://taskloader.com/api/v1/tasks/$TASK_ID \
  -H "Authorization: Bearer $TASKLOADER_API_KEY" \
  -H "Content-Type: application/json" \
  -H 'If-Match: "1"' \
  -d '{"priority":"urgent"}' | jq '{status, code, currentVersion, current: {status: .current.status, priority: .current.priority}}'

A 412 looks like this; current is the whole task:

HTTP
HTTP/1.1 412 Precondition Failed
Content-Type: application/problem+json
ETag: "5"

{
  "type": "https://taskloader.com/docs/api/errors#version_conflict",
  "title": "The resource changed since you read it",
  "status": 412,
  "code": "version_conflict",
  "detail": "TL-012 is at version 5. You sent version 3. Nothing was changed. Read the task, check the change still makes sense, and retry with version 5 (over HTTP, If-Match: \"5\" works too).",
  "instance": "/api/v1/tasks/task_0b6f1d2a8c9e4f00a1b2c3d4e5f60718",
  "requestId": "req_0K7ZQ4M9TN2V6B8C1D3E5F7G9H",
  "currentVersion": 5,
  "current": {
    "object": "task",
    "id": "task_0b6f1d2a8c9e4f00a1b2c3d4e5f60718",
    "projectId": "prj_0b6f1d2a8c9e4f00a1b2c3d4e5f60718",
    "number": 12,
    "key": "TL-012",
    "ref": "northwind/website-launch/TL-012",
    "url": "https://taskloader.com/northwind/website-launch/TL-012",
    "title": "Write the launch announcement",
    "description": "Draft the blog post and the newsletter. The press kit is in the shared folder.",
    "status": "progress",
    "priority": "high",
    "assignee": {
      "memberId": "mem_0b6f1d2a8c9e4f00a1b2c3d4e5f60718",
      "userId": "usr_kq3Xb1W9pZ0aLm7c",
      "name": "Maya Chen"
    },
    "dueDate": "2026-11-27",
    "checklist": [
      {
        "id": "chk_0b6f1d2a8c9e4f00a1b2c3d4e5f60718",
        "text": "Outline",
        "done": true
      },
      {
        "id": "chk_1b6f1d2a8c9e4f00a1b2c3d4e5f60718",
        "text": "First draft",
        "done": false
      }
    ],
    "checklistProgress": {
      "done": 1,
      "total": 2
    },
    "bookmark": null,
    "position": 3072,
    "version": 5,
    "attachmentCount": 1,
    "createdBy": {
      "userId": "usr_kq3Xb1W9pZ0aLm7c",
      "name": "Maya Chen"
    },
    "createdAt": "2026-11-16T09:30:00.000Z",
    "updatedAt": "2026-11-18T10:00:00.123Z",
    "completedAt": null
  }
}

Send only what changes

#

A PATCH changes only the fields you send. Sending the whole task back would overwrite fields you did not mean to touch; sending one field leaves everything else as it is now.

Checklists are a list, so update_task with checklist replaces the whole list. To tick, add or rename single items, use edit_checklist: its operations name items by id, lock the task while they apply, and merge with edits other people made at the same time. Its version is optional.

Moves

#

move_task needs a version like any change. It can also answer 409 neighbors_changed when the after or before task you named has moved away or is gone, or the two are now the wrong way round (after below before): reload the target place and choose the neighbours again. See Build a board.

Bookmarks change their own version

#

When you create a task from a link with add_bookmark, the answer has bookmark.preview.status: "queued". Soon after (within seconds, or hours later when many pages were read for the project or for you in the last hour: see Limits), Taskloader reads the page and renames the task to the page's title, which raises its version by one (a task.updated event with via.channel system). A change sent with the version from the create answer may then get a 412; its current shows the new title. That is expected: decide and retry as usual.

When the page cannot be read, the task is renamed after the words of its link instead (if it has any), and its preview is failed. Taskloader tries the page again later, and if a read then succeeds, it renames the task once more after the page's title, raising its version again. A title someone gave the task is never replaced.

Polling one resource cheaply

#

To poll a single task, project or organization, send the ETag of your last read as If-None-Match. While nothing in that answer has changed, a task's attachmentCount, its bookmark's preview and your own role included, you get 304 Not Modified with no body. Send the ETag back exactly as you got it: If-None-Match: "<version>" never matches a read. A task read with include has no ETag. To follow many tasks, use the changes feed instead.

Idempotency keys

#

Send an Idempotency-Key with every POST, PATCH, PUT and DELETE, and reuse it for every retry of that request:

Shell
curl https://taskloader.com/api/v1/tasks/$TASK_ID/comments \
  -H "Authorization: Bearer $TASKLOADER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 0f8e4a2c-6b1d-4e3f-9a7c-5d2b8e1f4a6c" \
  -d '{"body":"Draft is ready for review."}'
What happensAnswer
First requestThe normal answer, recorded under the key for 24 hours.
The same request again, same keyThe recorded answer, as the credential's scopes show it now (Conventions), with Idempotent-Replayed: true. Nothing is done twice.
Again while the first is still running409 idempotency_key_in_progress with Retry-After: 1.
A different request with the same key422 idempotency_key_reused.

Make a new key (a random UUID) for each new action, not for each attempt. Keys belong to your credential, so they never clash with anyone else's.

What is recorded: successes, and failures that a retry cannot change (404, 409, 412, 422). Not recorded, so a retry with the same key runs again: 400, 401, 403, 429 and 5xx answers, and the 409s that ask you to come back later (assistant_busy, upload_incomplete, idempotency_key_in_progress). A 5xx means nothing was saved.

Removals honour the key too: remove_project_member, remove_organization_member, leave_project, leave_organization, delete_attachment and cancel_upload. With the same key, a retry gets the first answer back; without one, a retry after the change went through answers 404. Revoking an invitation (revoke_project_invitation, revoke_organization_invitation) succeeds again when repeated, with or without a key. delete_assistant_thread ignores the key: a retry after the first one went through answers 404, which you can treat as done.

Changes that need a version

#

update_task, move_task, delete_task and the other versioned changes are protected by their version instead of a key. If the answer to one is lost and you send it again, you may get 412 version_conflict. Compare current with your change: if it already shows your change, you are done. If it does not, someone else changed the resource or your first request never arrived: decide again and resend with current.version. A retried delete_task that already went through answers 404 not_found.

Uploads

#

A one-shot upload with an Idempotency-Key must also send Content-Digest with the SHA-256 of the bytes. See Files.

A retry policy

#
Status and codeRetry?How
400 (other codes), 413, 415, 416NoFix the request.
400 digest_mismatchYesSend the same bytes again; if it fails twice, compute the digest again.
400 part_length_mismatchAfter fixingSend exactly expectedBytes bytes for that part.
401 invalid_token with reason: "expired"After refreshingOAuth: refresh the access token, then retry. API key: extend or replace the key.
401 otherwise, 403NoThe credential is invalid or lacks access. Tell the person.
404NoIt does not exist or is not visible to this credential.
409 idempotency_key_in_progressYesAfter Retry-After (1 second), with the same key.
409 neighbors_changedYes, with new neighboursReload the target place first.
409 upload_incompleteYes, after sending the missing partsSend missingParts, then complete again.
409 assistant_busyYes, laterWait for the answer in progress (messageId), then ask again, or apply or dismiss what it proposes; deleting a conversation whose changes are being applied answers it too: delete it once they are done.
409, other codesNoThe state does not allow it (already a member, already applied).
410 cursor_expiredNoTake a new cursor with after=now first, then reread the lists, then follow the feed from that cursor. See Resyncing after a 410.
412 version_conflictYes, after deciding againWith current.version.
422 search_too_broadAfter narrowingThe search with words took too long. Add filters (status, assignee, dates, one project) or more specific words.
422NoA rule was broken; fix the data.
428 precondition_requiredYes, with a versionRead the resource, send its version.
429 rate_limited, daily_limit_reached, assistant_hourly_limitYesAfter Retry-After seconds, never sooner. A daily cap can ask for hours: tell the person instead of waiting.
429 too_many_open_uploadsAfter actingComplete or cancel unfinished uploads, then try again. There is no Retry-After.
413 storage_quota_exceededAfter actingDelete files (or cancel unfinished uploads) first: the person's or the organization's files are at their storage quota. There is no Retry-After.
429 too_many_transfersYesAfter Retry-After seconds, with fewer file requests at once.
429 too_many_invitationsNoRevoke an unused invitation link first. Waiting does not help.
429 too_many_projectsNoThe person is in as many projects as one person can be. They leave one they no longer need first. Waiting does not help.
500 internal_errorYes, a few timesWith backoff, the same Idempotency-Key, and log requestId.
503 assistant_unavailableNoThe assistant is not set up on this server.
503, other codesYesAfter Retry-After when it is sent; otherwise with backoff.
No answer (timeout, connection reset)YesWith backoff and the same Idempotency-Key. For versioned changes, a 412 afterwards may mean your change went through: compare current with it. A retried delete that went through answers 404.

For backoff, wait 1 second, then 2, 4, 8 and so on up to about 30 seconds, adding a little randomness so many clients do not retry in step. Give up after a handful of attempts and report the requestId.

The error reference marks every code that can succeed on retry. Some of them succeed only after you act, as the table says: send the missing parts (upload_incomplete), complete or cancel an upload (too_many_open_uploads), delete files (storage_quota_exceeded), or send a part of the right length (part_length_mismatch). Waiting alone does not help with those.

A request helper

#

One function that applies the policy above to any request. It keeps one Idempotency-Key across all attempts of the same request, and retries only what can succeed when sent again unchanged:

  • 429 and 409 answers that carry Retry-After (request limits, daily caps, the assistant's hourly limit, a request still running under the same key), after waiting that long. It waits at most a minute: a longer wait, such as a daily cap, is thrown, so you can tell the person instead of hanging.
  • Server errors (500, 502, 503, 504), with backoff, except 503 assistant_unavailable, which retrying cannot fix.
  • Requests that got no answer at all, with backoff.

Everything else is thrown with the problem attached, at once.

import { randomUUID } from 'node:crypto';

const sleep = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds * 1000));
const backoff = (attempt) => Math.min(30, 2 ** attempt) * (0.5 + Math.random() / 2);
const MAX_WAIT = 60; // Seconds. A longer Retry-After (a daily cap) is thrown, not slept through.

/** Whether a failed answer can succeed if sent again unchanged, by the policy above. */
function canRetry(status, code, retryAfter) {
  if (status === 429 || status === 409) return retryAfter > 0 && retryAfter <= MAX_WAIT;
  return status >= 500 && code !== 'assistant_unavailable';
}

/** Sends a request to the Taskloader API, retrying only what can succeed on retry. */
export async function taskloader(method, path, { body, headers = {}, attempts = 5 } = {}) {
  const key = method === 'GET' ? undefined : randomUUID(); // One key for every attempt.
  for (let attempt = 0; ; attempt++) {
    let response;
    try {
      response = await fetch(`https://taskloader.com/api/v1${path}`, {
        method,
        headers: {
          Authorization: `Bearer ${process.env.TASKLOADER_API_KEY}`,
          ...(body !== undefined && { 'Content-Type': 'application/json' }),
          ...(key && { 'Idempotency-Key': key }),
          ...headers,
        },
        body: body === undefined ? undefined : JSON.stringify(body),
        signal: AbortSignal.timeout(30_000),
      });
    } catch (error) {
      if (attempt + 1 >= attempts) throw error;
      await sleep(backoff(attempt));
      continue;
    }
    if (response.ok) return response.status === 204 ? null : response.json();
    // A proxy in between can answer a 502 or 504 without a problem body.
    const problem = await response.json().catch(() => null);
    const retryAfter = Number(response.headers.get('retry-after')) || 0;
    if (attempt + 1 < attempts && canRetry(response.status, problem?.code, retryAfter)) {
      await sleep(retryAfter || backoff(attempt));
      continue;
    }
    const message = problem ? `${problem.code}: ${problem.detail}` : `HTTP ${response.status}`;
    throw Object.assign(new Error(message), { status: response.status, problem });
  }
}

Use it with the version loop above for changes, and with the changes feed to keep copies fresh.