Topolo Docs Topolo Platform
Open workspace

Attach file to journal draft

Attach one private file up to 10 MB to a journal draft. The file follows the draft when it is posted.

Outcome

Attach one private file up to 10 MB to a journal draft. The file follows the draft when it is posted.

Before you start

  • Verify the intended environment, authenticated identity and specifically approved organization context.
  • The published application permission is journals:write. Discover the exact granted canonical Books workspace and bind it separately from action input.
  • Approve the actual mutation, accounting inputs and any provider/recipient effects before CLI --confirm or MCP confirm:true. Fixture identifiers and simulated provider responses authorize no live operation.

Discover the target

topolo whoami --json
topolo actions get app_topolo_books.journals.drafts.attachments.create --detail --json
topolo resources topolo-books --json
topolo workspaces list topolo-books --json
  • Set BOOKS_WORKSPACE_ID to the exact granted workspace returned by discovery.
  • draftId: Exact draft.id from journals.drafts.list/get. Posting or discarding removes the mutable draft.

Request

POST /api/journal-drafts/{draftId}/attachments

Inspect and test this action. Save the reviewed input as payload.json; supply credential/resource context separately.

Input fields

FieldRequiredMeaningSchema and constraints
draftIdRequiredExact draft.id from journals.drafts.list/get. Posting or discarding removes the mutable draft.{"type":"string","minLength":1}
fileNameRequiredfile Name{"type":"string","minLength":1,"maxLength":255}
contentTypeRequiredcontent Type{"type":"string","minLength":3,"maxLength":120}
contentBase64Requiredcontent Base64{"type":"string","minLength":1}
idempotencyKeyOptionalRetained key for one intended operation. Reusing it for different attachment bytes or send details can conflict.{"type":"string","minLength":1,"maxLength":200}

Inspect nested fields and the complete input schema.

Effects

  • Stores one private attachment and links it to the draft; posting the draft transfers the same file to the resulting journal.

Interpret the response

Read $.attachment.id for the returned journal_attachment identifier. Empty collections and nullable fields do not discover a target.

Call app_topolo_books.journals.drafts.attachments.list and confirm the returned attachment metadata.

Inspect the success schema. CLI/MCP add their own transport envelope; CLI --detail requests the full result.

Worked examples

Actual Books route handlers and the exported Worker were exercised against five local SQLite D1 concern databases with all committed migrations, the real posting Durable Object and local R2. Route captures use synthetic verified Auth; Worker captures use synthetic Auth transports. Nexus, Brand, Notify, Pay, Mercury and Xero responses are explicitly simulated at the provider transport boundary. Captures prove local request/response behavior and canonical SDK projection, not live bank access, payment movement, email delivery, provider eligibility, tax compliance, encrypted custody, scheduled execution, deployment or production completion. Fixture identities, credentials, addresses and records authorize no live operation.

Run a reviewed request

Save the input from the selected worked example as payload.json. Validate and inspect the plan before calling the action; refused examples demonstrate errors and are not instructions to execute.

CLI:

topolo actions validate app_topolo_books.journals.drafts.attachments.create --data @payload.json --json
topolo actions plan app_topolo_books.journals.drafts.attachments.create --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --json
topolo actions call app_topolo_books.journals.drafts.attachments.create --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --confirm --detail --json

MCP tool and arguments for the first successful example:

{
  "tool": "topolo_call_action",
  "arguments": {
    "actionId": "app_topolo_books.journals.drafts.attachments.create",
    "input": {
      "draftId": "jd_52ec4f8955f3410e931b83667f29a3c0",
      "fileName": "fixture.txt",
      "contentType": "text/plain",
      "contentBase64": "Zml4dHVyZSBldmlkZW5jZQ=="
    },
    "resourceType": "workspace",
    "resourceId": "<exact granted workspace id>",
    "confirm": true,
    "detail": true
  }
}

Refused response · auth_error

Input · payload.json:

{
  "draftId": "jd_7f3c1b",
  "fileName": "working-paper.pdf",
  "contentType": "application/pdf",
  "contentBase64": "JVBERi0xLjQK",
  "idempotencyKey": "working-paper-v1"
}

Captured response · HTTP 401

{
  "error": "API key validation failed"
}

HTTP 401. SDK error code auth_error. Authenticate in the intended organization again. Verify whoami and the exact Books application/workspace binding before retrying; do not switch identity to work around a refusal.

Successful response · HTTP 201

Input · payload.json:

{
  "draftId": "jd_52ec4f8955f3410e931b83667f29a3c0",
  "fileName": "fixture.txt",
  "contentType": "text/plain",
  "contentBase64": "Zml4dHVyZSBldmlkZW5jZQ=="
}

Captured response · HTTP 201

{
  "attachment": {
    "id": "jatt_8262cf244a894c6ca200e5aee7949932",
    "draft_id": "jd_52ec4f8955f3410e931b83667f29a3c0",
    "journal_event_id": null,
    "file_name": "fixture.txt",
    "content_type": "text/plain",
    "size_bytes": 16,
    "checksum_sha256": "1f49789e450b42af7ccf193988a0205588ccef66bc28a165332c2e782b9b4959",
    "created_by": "usr_test",
    "created_at": "2026-10-05T19:42:39.452Z",
    "updated_at": "2026-10-05T19:42:39.452Z"
  }
}

HTTP 201. Call app_topolo_books.journals.drafts.attachments.list and confirm the returned attachment metadata.

Successful response · HTTP 201

Input · payload.json:

{
  "draftId": "jd_ef8abf153ae14b6491d2a0374121e096",
  "fileName": "../engagement-letter.pdf",
  "contentType": "application/pdf",
  "contentBase64": "cHJpdmF0ZSBldmlkZW5jZQ==",
  "idempotencyKey": "upload-1"
}

Captured response · HTTP 201

{
  "attachment": {
    "id": "jatt_fe0e6b7bfd6d4be3bceb5c3be7dd4556",
    "draft_id": "jd_ef8abf153ae14b6491d2a0374121e096",
    "journal_event_id": null,
    "file_name": "engagement-letter.pdf",
    "content_type": "application/pdf",
    "size_bytes": 16,
    "checksum_sha256": "f7711d1542c029371e0ad7159632c392465700aed13126774e9e8a9575b20078",
    "created_by": "usr_evidence",
    "created_at": "2026-10-05T19:42:51.577Z",
    "updated_at": "2026-10-05T19:42:51.577Z"
  }
}

HTTP 201. Call app_topolo_books.journals.drafts.attachments.list and confirm the returned attachment metadata.

Refused response · attachment_idempotency_conflict

Input · payload.json:

{
  "draftId": "jd_ef8abf153ae14b6491d2a0374121e096",
  "fileName": "../engagement-letter.pdf",
  "contentType": "application/pdf",
  "contentBase64": "ZGlmZmVyZW50",
  "idempotencyKey": "upload-1"
}

Captured response · HTTP 409

{
  "error": "attachment_idempotency_conflict",
  "message": "This idempotency key was already used for a different attachment"
}

HTTP 409. SDK error code attachment_idempotency_conflict. The retained upload key belongs to different bytes or metadata. Read the attachment first; use a new specifically reviewed idempotency key only for an intended distinct upload.

Refused response · unsafe_attachment_type

Input · payload.json:

{
  "draftId": "jd_ef8abf153ae14b6491d2a0374121e096",
  "fileName": "unsafe.svg",
  "contentType": "image/svg+xml",
  "contentBase64": "cHJpdmF0ZSBldmlkZW5jZQ==",
  "idempotencyKey": "unsafe"
}

Captured response · HTTP 400

{
  "error": "unsafe_attachment_type",
  "message": "image/svg+xml attachments are not allowed"
}

HTTP 400. SDK error code unsafe_attachment_type. Choose a supported source-document format. HTML, SVG and executable/script attachment content are refused; do not relabel bytes to evade validation.

Successful response · HTTP 201

Input · payload.json:

{
  "draftId": "jd_9a337c24f65c4d7ea15e66e30ce5ee52",
  "fileName": "working.txt",
  "contentType": "text/plain",
  "contentBase64": "dGVtcG9yYXJ5"
}

Captured response · HTTP 201

{
  "attachment": {
    "id": "jatt_673cf957f72f499e91c21478aee1fe89",
    "draft_id": "jd_9a337c24f65c4d7ea15e66e30ce5ee52",
    "journal_event_id": null,
    "file_name": "working.txt",
    "content_type": "text/plain",
    "size_bytes": 9,
    "checksum_sha256": "ea8b82a5c42a33f042e3f6c8d0f750226bf9e0ac8268e8e8ac9ab02cc1d99dff",
    "created_by": "usr_evidence",
    "created_at": "2026-10-05T19:42:51.620Z",
    "updated_at": "2026-10-05T19:42:51.620Z"
  }
}

HTTP 201. Call app_topolo_books.journals.drafts.attachments.list and confirm the returned attachment metadata.

Verify the result

  • Call app_topolo_books.journals.drafts.attachments.list and confirm the returned attachment metadata.

Errors and recovery

  • auth_error (HTTP 401): Authenticate in the intended organization again. Verify whoami and the exact Books application/workspace binding before retrying; do not switch identity to work around a refusal.
  • attachment_idempotency_conflict (HTTP 409): The retained upload key belongs to different bytes or metadata. Read the attachment first; use a new specifically reviewed idempotency key only for an intended distinct upload.
  • unsafe_attachment_type (HTTP 400): Choose a supported source-document format. HTML, SVG and executable/script attachment content are refused; do not relabel bytes to evade validation.

These are observed local refusals. Shared authentication, schema validation and resource authorization can also refuse before the route. Preserve the actual error, details and request id.

Recovery boundary

Delete the returned attachmentId from the draft.

  • Get journal draft: Read one editable journal draft with its ordered lines.
  • List journals: List posted journal events, filtered by date range or period, searched across description, reference and journal type, and sorted by sequence, posted date, description or amount. Newest first unless you say otherwise.
  • Delete draft attachment: Permanently delete one file and its draft attachment metadata.

Evidence

Actual Books route handlers and the exported Worker were exercised against five local SQLite D1 concern databases with all committed migrations, the real posting Durable Object and local R2. Route captures use synthetic verified Auth; Worker captures use synthetic Auth transports. Nexus, Brand, Notify, Pay, Mercury and Xero responses are explicitly simulated at the provider transport boundary. Captures prove local request/response behavior and canonical SDK projection, not live bank access, payment movement, email delivery, provider eligibility, tax compliance, encrypted custody, scheduled execution, deployment or production completion. Fixture identities, credentials, addresses and records authorize no live operation.