Topolo Docs Topolo Platform
Open workspace

Attach file to journal

Attach one private file up to 10 MB to a posted journal. HTML, SVG and script content are refused; an idempotency key safely replays an upload.

Outcome

Attach one private file up to 10 MB to a posted journal. HTML, SVG and script content are refused; an idempotency key safely replays an upload.

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.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.
  • journalId: Exact posted journal.id from journals.list/get, distinct from a mutable draft id.

Request

POST /api/journals/{journalId}/attachments

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

Input fields

FieldRequiredMeaningSchema and constraints
journalIdRequiredExact posted journal.id from journals.list/get, distinct from a mutable draft id.{"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 in the Books evidence bucket and links checksum-verified metadata to the posted 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.attachments.list and confirm the returned attachment id, name, size and checksum.

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.attachments.create --data @payload.json --json
topolo actions plan app_topolo_books.journals.attachments.create --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --json
topolo actions call app_topolo_books.journals.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.attachments.create",
    "input": {
      "journalId": "je_d746fce95d864eb0b5a7aa3c3f1cee4f",
      "fileName": "approval.txt",
      "contentType": "text/plain",
      "contentBase64": "YXBwcm92ZWQ=",
      "idempotencyKey": "upload-2"
    },
    "resourceType": "workspace",
    "resourceId": "<exact granted workspace id>",
    "confirm": true,
    "detail": true
  }
}

Refused response · auth_error

Input · payload.json:

{
  "journalId": "je_9a12c4",
  "fileName": "accrual.pdf",
  "contentType": "application/pdf",
  "contentBase64": "JVBERi0xLjQK",
  "idempotencyKey": "accrual-evidence-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:

{
  "journalId": "je_d746fce95d864eb0b5a7aa3c3f1cee4f",
  "fileName": "approval.txt",
  "contentType": "text/plain",
  "contentBase64": "YXBwcm92ZWQ=",
  "idempotencyKey": "upload-2"
}

Captured response · HTTP 201

{
  "attachment": {
    "id": "jatt_ab89a47668c743b499ed530a581036b2",
    "draft_id": null,
    "journal_event_id": "je_d746fce95d864eb0b5a7aa3c3f1cee4f",
    "file_name": "approval.txt",
    "content_type": "text/plain",
    "size_bytes": 8,
    "checksum_sha256": "2687f86ed6784b8a5fca36e6c468e12aa44dc3c7e8137e3160d1a95079bdcd02",
    "created_by": "usr_evidence",
    "created_at": "2026-10-05T19:42:51.603Z",
    "updated_at": "2026-10-05T19:42:51.603Z"
  }
}

HTTP 201. Call app_topolo_books.journals.attachments.list and confirm the returned attachment id, name, size and checksum.

Verify the result

  • Call app_topolo_books.journals.attachments.list and confirm the returned attachment id, name, size and checksum.

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.

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

  • 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 journal attachment: Permanently delete one file and its journal attachment metadata. The immutable ledger event is unchanged.

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.