> For the complete documentation index, see [llms.txt](https://help.sdocs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sdocs.com/developer-hub/s-sign-system-architecture/how-s-sign-generates-envelopes.md).

# How S-Sign Generates Envelopes

This document describes the full **S-Sign** transaction from document generation through completion. **S-Docs** produces the S-Doc record; **S-Sign** owns the envelope, envelope documents, Files-based signing PDFs, the signing experience, and the final **signed** and **audit** outputs. (This is separate from **S-Docs eSignature** where product responsibilities differ.)

***

###

```mermaid
flowchart TD
    %% Styling classes to make it visually distinct
    classDef input fill:#e1f5fe,stroke:#0288d1,stroke-width:2px;
    classDef process fill:#fff3e0,stroke:#f57c00,stroke-width:2px;
    classDef output fill:#e8f5e9,stroke:#388e3c,stroke-width:2px;
    classDef ui fill:#fce4ec,stroke:#c2185b,stroke-width:2px;

    %% 1. Transaction Setup / Inputs
    subgraph Setup ["1. Transaction Setup & Context"]
        SFRecord["Base Salesforce Record<br/>(Signing Context)"]:::input
        SDoc["SDOC__SDoc__c<br/>(S-Docs Reference)"]:::input
        SSTemplate["SSIGN__SSTemplate__c<br/>(Signing Policy & Config)"]:::input
    end

    %% 2. The Engine
    Engine(("S-Sign<br/>Managed Package")):::process

    %% 3. Generated Envelope Structure (Hierarchical)
    subgraph EnvelopeStructure ["2. Envelope Hierarchy"]
        Envelope["S-Sign Envelope<br/>(Transaction Parent)"]:::output
        EnvDoc["Envelope Document(s)<br/>(One Per Signing Page)"]:::output
        PrepFiles["Signing File(s) / PDFs<br/>(Materialized for Signing)"]:::output
    end

    %% 4. The Experience
    SignUI(("Signing Experience Complete")):::ui

    %% 5. Final Artifacts
    subgraph Outputs ["3. Completion Artifacts"]
        SignedPDF["Signed PDF<br/>(Executed Document)"]:::output
        AuditPDF["Audit PDF<br/>(Evidence / Trail)"]:::output
    end

    %% Setup Inputs -> Engine
    SFRecord -->|Anchors| Engine
    SDoc -->|Referenced by| Engine
    SSTemplate -->|Configures| Engine

    %% The Direct Hierarchical Line
    Engine ==>|Creates<br/>Envelope<br/>Envelope Document<br/>Signing File| Envelope
    Envelope ==>|Parent of| EnvDoc
    EnvDoc ==>|Parent of / Materializes| PrepFiles

    %% UI and Output
    PrepFiles -->|Presented in| SignUI
    
    SignUI ==>|Produces| SignedPDF
    SignUI ==>|Produces| AuditPDF

    %% Relationships / Lookups (Dotted Lines)
    Envelope -.->|Lookup| SFRecord
    SignedPDF -.->|Child of| EnvDoc
    AuditPDF -.->|Child of| EnvDoc
```

### End-to-end flow

1. **Anchor on the base record**\
   Work starts from a Salesforce business record (the merge/signing context).
2. **Generate the S-Doc**\
   **S-Docs** creates **`SDOC__SDoc__c`** from the S-Docs template and that record. The S-Doc is the **reference** S-Sign uses for the signing transaction; S-Docs does not run the signing engine.
3. **Apply S-Sign configuration**\
   S-Sign resolves signing policy from **`SSIGN__SSTemplate__c`**, associated to **`SDOC__SDTemplate__c`** via **`SSign__SDTemplate__c`**. That template drives signer rules, tags/inputs, notifications, and output behavior when the envelope is prepared.
4. **Create the Envelope**\
   S-Sign creates an **S-Sign Envelope** that **junctions** the transaction to the base record and acts as the **parent** for everything in that signing request.
5. **Create Envelope Document(s)**\
   Under the envelope, S-Sign creates **Envelope Document** rows—one per signable document in the transaction.
6. **Materialize signing PDFs (Salesforce Files)**\
   For each envelope document, S-Sign **generates a PDF** and stores it as **Salesforce Files** (`ContentDocument` / `ContentVersion`). The signing experience **references** these files as what the signer sees and executes against.
7. **Run the signing experience**\
   Signers complete the flow in the **Signing Experience** UI, backed by the envelope, its envelope documents, and those PDF references.
8. **Complete and persist outputs**\
   When signing **finishes**, the S-Sign managed package produces:

   * A **signed** PDF (executed document), and
   * An **audit** PDF (evidence / trail).

   Artifacts are saved per package behavior (typically new Files, linked to the appropriate records).

***

#### Multiple documents in one experience

If several documents are **combined into a single signing experience**, one **Envelope** still holds **multiple Envelope Document** children. Each child carries its own signing PDF in Files; completion still yields the package’s **signed** and **audit** outputs for the finished transaction.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.sdocs.com/developer-hub/s-sign-system-architecture/how-s-sign-generates-envelopes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
