Skip to main content

Attach an existing file

This guide attaches a file that already lives in your Broome workspace to a card, handles the one error unique to attachments — 409 file_not_ready — and detaches it again. Background: File attachments.

Three facts frame everything here:

  1. By default the API attaches, it does not upload. You reference an existing workspace file by its canonical file_id, and uploads happen in Broome's file surface. The one exception is attaching a new file to a card, which uploads bytes directly and needs no desktop sync token.
  2. Only files in an attachable trust state attach. Hostile-file scanning is disabled in production today (see File attachments), so "attachable" does not mean scanned clean — it means the file finished ingesting and was not independently flagged. A file that is still ingesting, or was flagged (quarantined or rejected), returns 409 with code file_not_ready, without revealing which of those it is.
  3. Detach never deletes. Removing an attachment only removes the card-file relationship; the file and its versions are untouched.

The endpoints​

cURL​

CARD_ID="<card-id>"
FILE_ID="<workspace-file-id>"

# Attach. A file still mid-ingestion (or flagged) returns 409 file_not_ready:
# {
# "error": {
# "code": "file_not_ready",
# "message": "...",
# "request_id": "..."
# }
# }
curl -sS -i -X PUT \
"$KANBAN_API_BASE_URL/cards/$CARD_ID/attachments/$FILE_ID" \
-H "Authorization: Bearer $KANBAN_API_TOKEN"

# Verify.
curl -sS "$KANBAN_API_BASE_URL/cards/$CARD_ID/attachments" \
-H "Authorization: Bearer $KANBAN_API_TOKEN"

# Detach (the file itself is untouched).
curl -sS -i -X DELETE \
"$KANBAN_API_BASE_URL/cards/$CARD_ID/attachments/$FILE_ID" \
-H "Authorization: Bearer $KANBAN_API_TOKEN"

JavaScript​

A freshly uploaded file may still be mid-ingestion, so retry file_not_ready with backoff for a bounded time:

const baseUrl =
process.env.KANBAN_API_BASE_URL ?? "https://app.broometech.com/api/kanban/v1";
const token = process.env.KANBAN_API_TOKEN;
const cardId = process.env.KANBAN_CARD_ID;
const fileId = process.env.KANBAN_FILE_ID;

const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

async function attachWhenReady(attempts = 6) {
for (let attempt = 1; attempt <= attempts; attempt += 1) {
const response = await fetch(
`${baseUrl}/cards/${cardId}/attachments/${fileId}`,
{ method: "PUT", headers: { Authorization: `Bearer ${token}` } }
);
const payload = await response.json();
if (response.ok) {
return payload.data;
}
if (payload.error.code !== "file_not_ready") {
throw new Error(
`${payload.error.code}: ${payload.error.message} (request ${payload.error.request_id})`
);
}
// Still ingesting (or not eligible). Back off and try again.
await sleep(5000 * attempt);
}
throw new Error(
"file still not ready; check it in Broome before retrying"
);
}

async function main() {
const attachment = await attachWhenReady();
console.log(
"attached",
attachment.name,
`(${attachment.size_bytes} bytes)`
);

const list = await fetch(`${baseUrl}/cards/${cardId}/attachments`, {
headers: { Authorization: `Bearer ${token}` },
});
const attachments = (await list.json()).data;
console.log(attachments.length, "attachment(s) on the card");

const detach = await fetch(
`${baseUrl}/cards/${cardId}/attachments/${fileId}`,
{ method: "DELETE", headers: { Authorization: `Bearer ${token}` } }
);
console.log("detached with status", detach.status); // 204; file untouched
}

main().catch((error) => {
console.error(error);
process.exit(1);
});

Python​

import json
import os
import time
import urllib.error
import urllib.request

BASE_URL = os.environ.get(
"KANBAN_API_BASE_URL", "https://app.broometech.com/api/kanban/v1"
)
TOKEN = os.environ["KANBAN_API_TOKEN"]
CARD_ID = os.environ["KANBAN_CARD_ID"]
FILE_ID = os.environ["KANBAN_FILE_ID"]
HEADERS = {"Authorization": f"Bearer {TOKEN}"}


def attach_when_ready(attempts=6):
for attempt in range(1, attempts + 1):
request = urllib.request.Request(
f"{BASE_URL}/cards/{CARD_ID}/attachments/{FILE_ID}",
method="PUT",
headers=HEADERS,
)
try:
with urllib.request.urlopen(request) as response:
return json.load(response)["data"]
except urllib.error.HTTPError as exc:
error = json.load(exc)["error"]
if error["code"] != "file_not_ready":
raise RuntimeError(
f"{error['code']}: {error['message']} "
f"(request {error['request_id']})"
) from exc
# Still ingesting (or not eligible). Back off and try again.
time.sleep(5 * attempt)
raise RuntimeError(
"file still not ready; check it in Broome before retrying"
)


attachment = attach_when_ready()
print("attached", attachment["name"], f"({attachment['size_bytes']} bytes)")

list_request = urllib.request.Request(
f"{BASE_URL}/cards/{CARD_ID}/attachments", headers=HEADERS
)
with urllib.request.urlopen(list_request) as response:
attachments = json.load(response)["data"]
print(len(attachments), "attachment(s) on the card")

detach = urllib.request.Request(
f"{BASE_URL}/cards/{CARD_ID}/attachments/{FILE_ID}",
method="DELETE",
headers=HEADERS,
)
with urllib.request.urlopen(detach) as response:
print("detached with status", response.status) # 204; file untouched

Attach a new file​

The three facts above describe attaching a file that already exists. To put a file on a card that exists nowhere yet — a screenshot an agent just took, a report it just wrote — use the two-step upload, which does not need a desktop sync token or a prior file_id:

  1. POST /cards/{card_id}/attachments/uploads authorizes the card, reserves the bytes and returns a signed upload_url and an opaque upload_id.
  2. PUT the raw bytes to that upload_url (no Authorization header — the URL carries its own short-lived token).
  3. POST /cards/{card_id}/attachments/uploads/{upload_id}/commit records the file and attaches it, returning the same attachment view attachFile returns.
CARD_ID="<card-id>"

# 1. Start. Capture upload_id and upload_url.
START=$(curl -sS -X POST \
"$KANBAN_API_BASE_URL/cards/$CARD_ID/attachments/uploads" \
-H "Authorization: Bearer $KANBAN_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"screenshot.png","size_bytes":48213,"mime_type":"image/png"}')
UPLOAD_ID=$(echo "$START" | jq -r .data.upload_id)
UPLOAD_URL=$(echo "$START" | jq -r .data.upload_url)

# 2. PUT the bytes to the signed URL.
curl -sS -X PUT "$UPLOAD_URL" \
-H "Content-Type: image/png" \
--data-binary @screenshot.png

# 3. Commit. Returns the attachment view.
curl -sS -X POST \
"$KANBAN_API_BASE_URL/cards/$CARD_ID/attachments/uploads/$UPLOAD_ID/commit" \
-H "Authorization: Bearer $KANBAN_API_TOKEN"

Things worth knowing before you build on this:

  • Use the two-step upload, not the desktop sync API, for a file that belongs on a card. A file uploaded through /api/sync/v1 is a library file: it lands at the root of the workspace and every member's desktop copies it into ~/Broome, even after you attach it to a card. This two-step upload (POST /cards/{card_id}/attachments/uploads, then …/commit) is the only API route that keeps a NEW file on the card, which is where the web app files a card upload too. It always creates a new file: to attach a file that is already in the workspace, use the attach route above, and the file keeps its place.

  • The upload is bound to the card and the token. The upload_id is signed and carries the size, the name and the storage path. Editing any of them invalidates it, and so does presenting it for a different card or from a different token. Every one of those answers 404 not_found, the same answer a handle that never existed gets.

  • A card you cannot open yields 404 and reserves nothing. Nothing is metered against storage for a request that could never have succeeded, so an agent cannot burn a workspace's allowance probing cards.

  • The file is task material. It stays on the card, out of the Files root and off the desktop sync feed. It is not offered by the workspace file picker, so it cannot be linked into a second comment or task.

  • size_bytes is a ceiling you must respect before uploading. The response carries max_bytes; a larger file is refused with 413. Declaring a size smaller than what you actually PUT does not make the upload fit.

  • Commit is retryable, but not idempotent across different bytes. Uploading again to the same signed URL and committing twice attaches one file; starting a fresh upload is a new handle and a new file. If the commit reports that the attachment failed, the recorded file is discarded for you.

  • Scanning must be off. While hostile-file scanning is enabled, a task upload is refused with 503 rather than published as a library file, because the scan-on publication path has no task-material shape. That is the state of production today (see File attachments).

Failure modes and what they mean​

ResponseMeaningWhat to do
404 not_foundThe file does not exist in your workspace or is not visible to you — indistinguishable by design; on the upload path, also a card you cannot open or an upload_id this token did not mint for this cardVerify the file_id/card_id and the file's sharing in Broome; start a fresh upload rather than editing a handle
409 file_not_readyThe file is not yet in an attachable trust stateRetry with backoff; surface to a human if it persists
413 validation_errorThe declared size_bytes is over the workspace upload ceilingSend a smaller file; the response's max_bytes is the limit
422 validation_errorMalformed IDs, an invalid name or size, an unknown body property, or (for covers) a non-image fileFix the request
503 internalUploads are unavailable — today, because file scanning is enabled and a task upload has no scan-on shapeDo not retry blindly; surface it to a human

Do not treat file_not_ready as permanent — a file still ingesting becomes attachable within moments. Do not treat it as transient forever either: a quarantined or rejected file will never become ready, which is why the loops above are bounded.

Covers work the same way​

PUT /cards/{card_id}/cover/{file_id} applies the same visibility + trust-state rules and additionally requires an image file. DELETE /cards/{card_id}/cover clears it, returning 204 even when there was no cover. Neither touches the card version. See Cards and completion.