Documentation Index
Fetch the complete documentation index at: https://docs.spitshake.io/llms.txt
Use this file to discover all available pages before exploring further.
Formula Fields
Formula fields automatically compute their value from other fields in the template using arithmetic expressions. Use them for totals, taxes, discounts, commissions, and any other calculated values that depend on signer input.How formulas work
- Add a
formulaproperty to anynumberorpaymentfield in the template schema. - Reference other fields by name using
{Field Name}syntax. - DocuTrust evaluates the formula in real time as the signer fills in referenced fields.
- The computed value updates instantly in the signing form.
Formula syntax
Field references
Reference any field by wrapping its name in curly braces:name property exactly. If the referenced field is empty or has a non-numeric value, it evaluates to 0.
Supported operators
| Operator | Description | Precedence | Example |
|---|---|---|---|
( ) | Grouping | Highest | ({Price} + {Tax}) * {Quantity} |
* | Multiplication | High | {Quantity} * {Unit Price} |
/ | Division | High | {Total} / {Installments} |
+ | Addition | Low | {Subtotal} + {Shipping} |
- | Subtraction | Low | {Total} - {Discount} |
Numeric literals
You can include numeric constants in formulas:Schema example
A complete field with a formula:Full invoice example
An invoice template with quantity, unit price, subtotal, tax, and grand total fields. The last three are formula fields that compute automatically.Quantity = 10 and Unit Price = 25, the computed values update instantly:
| Field | Formula | Computed Value |
|---|---|---|
| Subtotal | {Quantity} * {Unit Price} | 250 |
| Tax (8.75%) | {Subtotal} * 0.0875 | 21.88 |
| Grand Total | {Subtotal} + {Tax (8.75%)} | 271.88 |
Dynamic payment pricing
Combine formula fields with thepayment field type to charge signers a dynamically computed amount based on their input.
Payment fields require payment configuration to be set up in your account settings. See the Payments feature guide for setup instructions.
Creating formulas via API
Add formula fields when creating or updating a template viaPUT /api/templates/:id:
Safe evaluation
Formula evaluation is sandboxed and safe:- No code execution — only arithmetic expressions are parsed. JavaScript, Ruby, or any other code is rejected.
- No external access — formulas cannot access variables, functions, or data outside the template fields.
- Division by zero — dividing by zero returns
0instead of throwing an error. - Non-numeric values — if a referenced field contains a non-numeric value (or is empty), it evaluates to
0. - Circular references — if field A references field B and field B references field A, both evaluate to
0to prevent infinite loops. - Maximum length — formulas are limited to 500 characters.