# Documenso Upload Guide

# Documenso Template Upload Guide

**Purpose:** Manual upload instructions for ALAI AI Services legal templates to Documenso (sign.basicconsulting.no).

**Date:** 2026-05-01 | **Prepared by:** Lexicon

---

## Templates to Upload

The following three templates must be uploaded as **DRAFT templates** ready for client signing:

1. **Mutual NDA** (Gjensidig Taushetserklæring)
2. **Retainer Contract** (Ramme-avtale)
3. **Data Processing Agreement (DPA)**

---

## Pre-Upload Preparation

### Step 1: Convert Markdown to PDF

Use Pandoc or LibreOffice to convert `.md` files to `.pdf`:

```bash
# Using Pandoc (if installed)
pandoc ~/Public/legal/ai-services/MUTUAL-NDA-template-v1.md \
  -o ~/Public/legal/ai-services/MUTUAL-NDA-template-v1.pdf \
  --pdf-engine=xelatex \
  -V geometry:margin=2.5cm \
  -V fontsize=11pt

pandoc ~/Public/legal/ai-services/RETAINER-CONTRACT-template-v1.md \
  -o ~/Public/legal/ai-services/RETAINER-CONTRACT-template-v1.pdf \
  --pdf-engine=xelatex \
  -V geometry:margin=2.5cm \
  -V fontsize=11pt

pandoc ~/Public/legal/ai-services/DPA-template-v1.md \
  -o ~/Public/legal/ai-services/DPA-template-v1.pdf \
  --pdf-engine=xelatex \
  -V geometry:margin=2.5cm \
  -V fontsize=11pt

```

**Alternative:** Open `.md` files in text editor, copy content to Google Docs or LibreOffice, export as PDF.

---

## Documenso Upload Workflow

### Step 2: Log in to Documenso

1. Navigate to: **https://sign.basicconsulting.no**
2. Log in with ALAI admin credentials (use Bitwarden: `bw get item "Documenso - sign.basicconsulting.no"`)

### Step 3: Create Template (for each document)

**For MUTUAL-NDA-template-v1.pdf:**

1. Click **"Templates"** in left sidebar
2. Click **"Create Template"**
3. **Upload PDF:** Select `MUTUAL-NDA-template-v1.pdf`
4. **Template Name:** `AI Services - Mutual NDA (NO/EN)`
5. **Add Signature Fields:**
    - **Signer 1 (ALAI Holding AS):**
        - Signature field at "For ALAI Holding AS" signature line
        - Name field at "Navn / Name" line
        - Date field at "Dato / Date" line
    - **Signer 2 (Client):**
        - Signature field at "For \[PART\_2\_NAME\]" signature line
        - Name field at "Navn / Name" line
        - Date field at "Dato / Date" line
6. **Add Text Fields for Variables:**
    - `[PART_2_NAME]` — Text field at top (Part 2 section)
    - `[PART_2_ORG_NUMBER]` — Text field
    - `[PART_2_ADDRESS]` — Text field
    - `[PART_2_CONTACT_PERSON]` — Text field
    - `[PART_2_EMAIL]` — Email field
    - `[BESKRIVELSE AV FORMÅL]` — Large text area (NO version, section 2)
    - `[DESCRIPTION OF PURPOSE]` — Large text area (EN version, section 2)
7. **Save as Draft Template**
8. **Test:** Create a test submission to verify all fields populate correctly

**Repeat for RETAINER-CONTRACT-template-v1.pdf:**

- Template Name: `AI Services - Retainer Contract (NO/EN)`
- Variables: `[KUNDE_NAVN]`, `[KUNDE_ORG_NUMMER]`, `[KUNDE_ADRESSE]`, `[KUNDE_KONTAKTPERSON]`, `[KUNDE_EPOST]`, `[BELØP]`, `[ANTALL]`, `[TIMEPRIS]`
- Signature fields: ALAI + Client

**Repeat for DPA-template-v1.pdf:**

- Template Name: `AI Services - Data Processing Agreement (DPA)`
- Variables: `[KUNDE_NAVN]`, `[KUNDE_ORG_NUMMER]`, etc., `[DATO]`
- Signature fields: Data Controller (Client) + Data Processor (ALAI)

---

## Step 4: Archive Templates

After templates are created in Documenso:

1. **Export templates as PDFs** from Documenso (if possible)
2. **Upload to archive.alai.no** (Paperless-ngx):
    - Tag: `legal-template`, `ai-services`, `documenso`
    - Correspondent: `ALAI Holding AS`
    - Document type: `Contract Template`
3. **Update ledger:** Append to `~/system/state/archive-first-ledger.jsonl`

---

## Step 5: Test Workflow

1. Create a **test submission** with dummy client data:
    - Test Client Name: "Test AS"
    - Test Email: post@alai.no (CEO mailbox)
2. Send signature request
3. Verify:
    - Email branding is correct
    - All fields populate
    - Signature flow works
    - Signed PDF is retrievable
4. **Delete test submission** after verification

---

## Alternative: API Upload (Future Enhancement)

**Current blocker:** Documenso API authentication not yet tested in CLI context.

**Future workflow (when API ready):**

```bash
# Get Documenso API key from Bitwarden
DOCUMENSO_API_KEY=$(bw get password "Documenso API Key")

# Upload template via API (endpoint TBD — check Documenso docs)
curl -X POST https://sign.basicconsulting.no/api/v1/templates \
  -H "Authorization: Bearer $DOCUMENSO_API_KEY" \
  -F "file=@~/Public/legal/ai-services/MUTUAL-NDA-template-v1.pdf" \
  -F "name=AI Services - Mutual NDA"

```

**Task for future:** Create `~/system/tools/documenso-template-upload.js` to automate this.

---

## Notes

**Bismillah and ALAI branding:**  
Ensure PDF templates include:

- ALAI logo in header (if Documenso supports custom branding)
- Bismillah invocation at top of first page (already in Markdown source)

**Signature notification:**  
Documenso webhook at `https://api.basicconsulting.no/webhooks/documenso` will trigger on `DOCUMENT_COMPLETED` event. Webhook will:

- Post to Slack #exec
- Comment on MC task (if `#XXXX` in document title)
- Emit event to event-bus

**Future automation:**  
Once signed, document should be auto-uploaded to archive.alai.no (see SENTINEL v3 audit Wire 2+3). Current state: manual upload required.

---

**Full Source File:** `~/Public/legal/ai-services/documenso-upload-guide.md`