Skip to main content
A product that needs documents signed is a consumer of the engine. The consumer owns its business record and decides when to sign; the engine owns the signature. This page lists what a consumer does, using digital contracting as the example.

What a consumer does

1

Resolve the workflow

Call resolveSignatureWorkflow with the scope (today the business unit) and the workflow assigned to the record, if any. It returns the company seats and the snapshot to store. See Workflows.
2

Create the group

Write the signature row with the snapshot, one signature_document per PDF (each pointing to a contract or an annex), and one signature_signer per seat: customer seats with side = customer and signing_mode = attended, company seats from the snapshot with side = enterprise. Store each original PDF and its SHA-256.
3

Open the request

Call createSignatureRequest with the documents (name, kind, storage path, SHA-256) and the signers (name, email, order). The engine records request_created and the provider request.
4

Route the gestures

Expose the signer’s code request and gesture through the signer routes, which check that the session user owns the seat, then call sendSignerOtp and registerSignerAction. Pass the request IP and user agent so they reach the evidence.
5

Drive the company phase

When the engine reports awaitingEnterpriseSignature, or right after opening the group with company_phase = first, start a job that calls applyUnattendedEnterpriseSignatures. The call is idempotent per seat and seals the group when both sides are complete.
6

Read the result

When the engine reports sealed: true (the group is signed), read each sealed PDF with getSignedDocument and update the business record. To stop a group, call cancelSignatureRequest and set the group cancelled.

Digital contracting as the example

The full contracting journey is in Digital contracting — Signing.

Rules for a new consumer

  • Call the engine, not the tables. Use the engine client (internalSignerClient, which implements SignatureProviderClient and adds applyUnattendedEnterpriseSignatures) and resolveSignatureWorkflow; never write codes or evidence directly.
  • Keep the workflow per scope. Add workflows for the new scope instead of changing another consumer’s workflows.
  • Check seat ownership. The engine signs the seat it is given; the consumer’s route must make sure the session user owns it.
  • Extend the document reference. Today each signature_document must point to a contract or an annex. A new kind of document needs that reference extended first.
A synthetic test harness runs the workflow helpers end to end for a fake consumer (internal-signer/__tests__/signature-engine-e4.harness.test.ts), which shows the engine can be reused outside contracting.

Code

Paths are relative to backend/horizon-api/.