> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hiveku.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Contracts & E-Signatures

> Send MSAs, SOWs, NDAs, and other contracts for legally binding electronic signature with full audit trail

The Contracts module at `/dashboard/commerce/contracts/` is a DocuSign-equivalent built into Hiveku. Manage reusable templates (MSA, SOW, NDA, mutual NDA, employment offer letters), inject variable fields at send time, route documents through multi-signer workflows, capture legally binding e-signatures, and store the executed PDFs alongside the rest of your client record. Templates and contracts live in `crm_contracts`; in-flight signature workflows live in `crm_signature_envelopes`.

## What you can do

* **Templates** — Reusable contract bodies with variable placeholders. Build once, send hundreds of times.
* **Variable fields** — `{{client_name}}`, `{{scope}}`, `{{fees}}`, `{{start_date}}` injected at send time.
* **Multi-signer workflows** — One signer, many signers, sequential or parallel routing.
* **Audit trail** — Timestamps, IP addresses, email events, and signature completion captured per signer.
* **Executed PDF storage** — Final, signed PDF stored against the client record for download anytime.

## Templates

Templates are the reusable backbone. Common ones to set up first:

<Tabs>
  <Tab title="Master Services Agreement (MSA)">
    The umbrella legal terms governing your relationship with a client. Signed once; future SOWs reference it. Variables typically include client name, address, governing-law jurisdiction, and effective date.
  </Tab>

  <Tab title="Statement of Work (SOW)">
    Per-engagement scope. References the MSA, lists deliverables, fees, timeline, and acceptance criteria. Signed per project. Variables: project name, scope description, fees, timeline.
  </Tab>

  <Tab title="Non-Disclosure Agreement (NDA)">
    Mutual or one-way confidentiality. Often signed before sharing detailed proposals. Variables: counterparty name, effective date, term length.
  </Tab>

  <Tab title="Custom templates">
    Anything else — employment offer letters, contractor agreements, licensing terms, mutual partnership agreements. Same template + variables + signature workflow.
  </Tab>
</Tabs>

### Building a template

<Steps>
  <Step title="Upload or paste the contract body">
    Templates support rich text and PDF upload. For PDFs, the editor lets you drop signature, initial, and date fields onto the page.
  </Step>

  <Step title="Define variables">
    Wrap dynamic fields in `{{double_braces}}`. Common variables: `{{client_name}}`, `{{client_address}}`, `{{effective_date}}`, `{{fees}}`, `{{scope}}`, `{{term_length}}`.
  </Step>

  <Step title="Place signature blocks">
    For each signer, mark where their signature, initials, and date go. The editor uses drag-and-drop on PDFs or named tags on text-based templates.
  </Step>

  <Step title="Set the signer roles">
    Define roles (e.g., "Client", "Hiveku Rep") so when you send, you assign actual people to each role rather than re-mapping fields each time.
  </Step>

  <Step title="Save and test">
    Save the template, then send a test envelope to your own email to verify the rendered output looks right before using it on a real client.
  </Step>
</Steps>

## Sending a contract

<Steps>
  <Step title="Pick the template">
    From `/dashboard/commerce/contracts/`, click **New Contract**, select a template.
  </Step>

  <Step title="Fill variables">
    Populate the `{{variables}}` for this specific send — pulling from CRM contact data when available so client name and address auto-fill.
  </Step>

  <Step title="Assign signers">
    Map each role to a real person (name + email). Add additional signers if needed beyond the template's defaults.
  </Step>

  <Step title="Choose routing">
    **Sequential** sends to signer 1, waits for completion, then sends to signer 2. **Parallel** sends to all signers at once. Sequential is the default for client-facing contracts (their signature first, then yours).
  </Step>

  <Step title="Review and send">
    Preview the rendered PDF. If it looks right, click **Send**. Each signer gets an email with a link to their signing page.
  </Step>
</Steps>

## The signature workflow

```
draft → sent → signers receive email → click to sign →
  fully executed → PDF stored
```

Each signer sees:

1. The full contract content
2. A consent prompt for electronic signature (legal requirement under ESIGN / UETA in the US, eIDAS in EU)
3. Their assigned signature, initial, and date fields
4. A **Finish & Submit** button when all required fields are complete

Once the last signer submits, the envelope transitions to `executed`, the final PDF is generated with all signatures embedded, and an email goes to all parties with the signed copy attached.

## Audit trail

Every signature envelope captures:

* **Send timestamp** — When you clicked Send
* **Per-signer email events** — Sent, delivered, opened, signing-link clicked
* **IP address** — Captured at the moment of signature submission
* **User-agent** — Browser and device used to sign
* **Signature timestamp** — When the signer clicked Finish & Submit
* **Final-execution timestamp** — When the last signature completed the envelope

The audit trail is downloadable as a separate PDF and is admissible as evidence of intent under most jurisdictions' e-signature law.

<Info>
  E-signature law in the US (ESIGN Act, UETA) and EU (eIDAS Regulation) recognizes electronic signatures as legally binding when (1) the signer consented to electronic signing, (2) the signer's intent to sign is clear, and (3) the audit trail captures association of the signature with the signer. Hiveku's signing flow handles all three.
</Info>

## Storage and retrieval

Executed contracts are stored:

* On the **contract record itself** — viewable from `/dashboard/commerce/contracts/`
* On the **client record** — visible in the contact's or company's profile
* Optionally on the **deal record** if the contract was tied to a deal

Download the executed PDF or the audit-trail PDF anytime. Both are immutable once executed — to amend the agreement, you create a new contract (an amendment) rather than editing the original.

## Voiding a sent contract

If you sent a contract by mistake (wrong signer, wrong scope), use **Void** from the contract's actions menu. The signing links go inactive, signers see "this contract has been voided," and the envelope is locked to the `voided` status. Voided contracts stay in your records for audit purposes but don't count toward active agreements.

## Reminders and expiry

* **Reminders** — Auto-emailed to signers who haven't completed signing after a configurable interval (default: 3 days, then weekly).
* **Expiry** — Contracts can have an expiry date (default: 30 days after send). Past expiry, the signing links return "expired"; you'll need to clone and resend.

## Pairing with estimates and invoices

A typical service-business flow:

1. **Estimate** — Send a quote with scope and pricing for client review and approval.
2. **Contract** — Once the estimate is verbally accepted, send the SOW for legal sign-off.
3. **Invoice** — Once the contract is executed, convert the estimate to an invoice and bill the deposit.

You can also link a contract to an estimate or deal so the records cross-reference each other in audit and reporting views.

## API patterns

Common API operations against `/api/crm/contracts` and `/api/crm/signature-envelopes`:

* `POST /api/crm/contracts` — create a contract from a template with variables filled
* `POST /api/crm/signature-envelopes` — initiate a signature workflow for a contract
* `GET /api/crm/signature-envelopes/:id` — current envelope status and signer states
* `POST /api/crm/signature-envelopes/:id/void` — void an in-flight envelope
* `GET /api/crm/contracts/:id/audit-trail` — download the audit-trail PDF

## Troubleshooting

<AccordionGroup>
  <Accordion title="Signer didn't receive the email">
    Check the envelope's activity log — you'll see whether the email sent and any bounce reason. Common causes: typo in signer email, corporate spam filters blocking unknown senders, or your sending domain isn't verified — see [Email Domains](/email/domains). Resend the link from the envelope's actions menu.
  </Accordion>

  <Accordion title="Signer started signing but didn't finish">
    The envelope shows their progress — you can see which fields they completed. Send a reminder from the envelope's actions menu, or call them. The signing link stays valid until expiry.
  </Accordion>

  <Accordion title="Variable showed as `{{client_name}}` literal in the PDF">
    The variable wasn't filled at send time, or there's a typo in the template's placeholder vs. the variable name. Always preview the rendered PDF before clicking Send — the preview catches this immediately.
  </Accordion>

  <Accordion title="Need to amend an executed contract">
    Don't edit the original — it's immutable for audit reasons. Create a new contract (an amendment), reference the original by name and date in the body, and route it through the same signers. Both records stay in the file.
  </Accordion>

  <Accordion title="Audit trail PDF is missing data">
    Audit data is captured at signing time. If you're missing IP or user-agent for a particular signer, they may have signed through an email client preview pane that didn't fully load the signing page. Re-send and ask them to sign in a browser.
  </Accordion>
</AccordionGroup>

## What's next?

<CardGroup cols={2}>
  <Card title="Send a Contract for E-Signature" icon="rocket" href="/how-tos/send-contract-for-signing">
    End-to-end walkthrough from template to executed PDF.
  </Card>

  <Card title="Estimates" icon="file-signature" href="/commerce/estimates">
    Pair estimates with contracts for full pre-sales coverage.
  </Card>

  <Card title="Client Portal" icon="user-tie" href="/commerce/client-portal">
    Where clients see their executed contracts.
  </Card>

  <Card title="Invoices" icon="file-invoice-dollar" href="/commerce/invoices">
    The next step after the contract is signed.
  </Card>
</CardGroup>
