Replace a form draft’s logic document with the given calculations — the ONLY valid logic structure; any other shape is stored but silently ignored by the engine and invisible in the builder. A calculation runs on every change of the submission: when every `conditions[].expression` is true, the `then` effects apply; otherwise the `otherwise` effects. Expression syntax (identical for field formulas): field references MUST be wrapped in backticks and text values quoted — `amount` > 1000, `region` = "west" AND `age` >= 18. Bare identifiers are rejected. Functions: MAX, MIN, ROUND, ABS, FLOOR, CEIL, and for multi-value/composite fields CONTAINS(`group`, "option") (membership; substring on text; any cell of a table's rows), CONTAINS(`table`, "column", "value") (membership in one column), COUNT(`group`) (items or table rows), SUM(`table`, "column") or SUM(`list`), PART(`address`, "city") (absent parts are ""), ISBLANK(`field`) (true while the field has no answer; the one function tolerant of a missing reference — use it for is-empty/is-filled conditions, with = FALSE for filled). No others. Effect operators: VARIABLE {target, expression} computes into a field slug; SHOW/HIDE {fields: [slugs]} for rule-driven visibility (the static field property `visible` is separate); FUNCTION {target, function e.g. FORMAT_TO_CURRENCY, fields: [source slug]}; SET_OUTCOME {target, message?, severity?}; SET_WORKFLOW_STATE {target}; SEND {notification, documents?, emails?}; REFERENCE_NUMBER {target, generator: sequence slug}; SEND_TO_ZAPIER {connection: slug of a connection the organization configured under Settings → Integrations — NOT a URL, and you cannot create connections; queued only when a submission actually saves, never on previews}; COLLECT_PAYMENT {payment: {amountExpression: formula for the total, currency?, description?, recipients: [{account: payment-account slug from Settings → Payments, percent? XOR amountExpression?}]} — at most ONE per form; amounts are always priced server-side and the customer pays before the submission lands}; DELIVER_OBJECT {objects: [numeric ids from list_objects]} — hands the submitter the named library files through a per-submission download link (and a {{download_link}} merge value in notification templates); when the form also collects a payment the files unlock only after it succeeds, automatically. SEND.emails entries may be literal addresses or the recipient descriptors assignee|owner|creator|field:<slug> — field: is how an anonymous submitter’s own address is reached. Slugs come from get_form_fields; read get_form_logic first because this replaces the whole document. To change or delete individual calculations on a form that already has logic, prefer patch_form_logic — it applies a diff and cannot drop the calculations you did not mention. Requires form:write.