**גרסאות API** · **V2 (Latest)** · [V1](/integrations/v1/docs?lang=he)

# Email Templates

OpenAPI 3.0.3 · API 2.0.0

```json
[
  {
    "url": "https://api.unisoft.world/integrations/v2",
    "description": "API"
  }
]
```

Reusable HTML email templates (collection email_templates). Full CRUD. Send a COMPLETE HTML email document following the email-client compatibility rules (see EmailTemplateContentInput). A template's id can be linked to a campaign as the donor thank-you email (`campagnes.config.donorEmailTemplate`). Scopes: `email_templates:read`/`email_templates:write`.

## פעולות

## GET /email-templates

List email templates

`list_email_templates`

Required scope: `email_templates:read`. Lists organisation email templates without the HTML. Each item returns a stable `previewUrl` when available. Offer this clickable link to the user to review the latest saved email in a browser before approval or sending.

### אימות

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### הרשאות נדרשות

```json
{
  "accepted": "email_templates:read",
  "additional": []
}
```

### פרמטרים

```json
{
  "name": "limit",
  "in": "query",
  "schema": {
    "type": "integer",
    "minimum": 1,
    "maximum": 200,
    "default": 50
  },
  "description": "Number of results per page"
}
```

```json
{
  "name": "cursor",
  "in": "query",
  "schema": {
    "type": "string"
  },
  "description": "Opaque cursor returned by the previous request"
}
```

### תגובות

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailTemplate"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      }
    }
  }
}
```

#### HTTP 401

```json
{
  "description": "ERROR",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "ERROR"
          }
        }
      }
    }
  }
}
```

#### HTTP 403

```json
{
  "description": "INSUFFICIENT_SCOPE",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "INSUFFICIENT_SCOPE"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "email_templates:read",
  "x-unisoft-mcp": {
    "category": "read",
    "readOnly": true,
    "destructive": false,
    "idempotent": true,
    "warn": false
  }
}
```

## POST /email-templates

Create an email template

`create_email_template`

Required scope: `email_templates:write`. Creates a template. `html` is optional (create empty then fill via PUT /{id}/content). Once created, link its id to a campaign as the donor thank-you email (`campagnes.config.donorEmailTemplate`).

### אימות

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### הרשאות נדרשות

```json
{
  "accepted": "email_templates:write",
  "additional": []
}
```

### גוף הבקשה

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Display name."
          },
          "editorType": {
            "type": "string",
            "enum": [
              "EDITOR",
              "AI"
            ],
            "description": "Defaults to AI.",
            "default": "AI"
          },
          "html": {
            "type": "string",
            "description": "Complete HTML email (see EmailTemplateContentInput rules)."
          }
        },
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "description": "Create an email template. `html` is optional (you may create an empty template then fill it via PUT /{id}/content). When provided, follow the email-client compatibility rules described in EmailTemplateContentInput."
      }
    }
  }
}
```

### תגובות

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/EmailTemplate"
          }
        }
      }
    }
  }
}
```

#### HTTP 400

```json
{
  "description": "VALIDATION_ERROR",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "VALIDATION_ERROR"
          }
        }
      }
    }
  }
}
```

#### HTTP 403

```json
{
  "description": "INSUFFICIENT_SCOPE",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "INSUFFICIENT_SCOPE"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "email_templates:write",
  "x-unisoft-mcp": {
    "category": "create",
    "readOnly": false,
    "destructive": false,
    "idempotent": false,
    "warn": false
  }
}
```

## GET /email-templates/{id}

Get an email template

`get_email_template`

Required scope: `email_templates:read`. Full template including HTML, design, assets and `previewUrl`. Offer the clickable `previewUrl` for the user to review the saved version with example data. Opening it sends no email and records no approval.

### אימות

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### הרשאות נדרשות

```json
{
  "accepted": "email_templates:read",
  "additional": []
}
```

### פרמטרים

```json
{
  "name": "id",
  "in": "path",
  "required": true,
  "schema": {
    "type": "string",
    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
    "format": "uuid"
  },
  "description": "Identifier of the existing target resource, returned by its authorised list or read operation. Never generate a new UUID to address an existing record."
}
```

### תגובות

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/EmailTemplate"
          }
        }
      }
    }
  }
}
```

#### HTTP 404

```json
{
  "description": "NOT_FOUND",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "NOT_FOUND"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "email_templates:read",
  "x-unisoft-mcp": {
    "category": "read",
    "readOnly": true,
    "destructive": false,
    "idempotent": true,
    "warn": false
  }
}
```

## PATCH /email-templates/{id}

Rename an email template

`update_email_template`

Required scope: `email_templates:write`. Renames the template (metadata only; use PUT /{id}/content to change the HTML).

### אימות

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### הרשאות נדרשות

```json
{
  "accepted": "email_templates:write",
  "additional": []
}
```

### פרמטרים

```json
{
  "name": "id",
  "in": "path",
  "required": true,
  "schema": {
    "type": "string",
    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
    "format": "uuid"
  },
  "description": "Identifier of the existing target resource, returned by its authorised list or read operation. Never generate a new UUID to address an existing record."
}
```

### גוף הבקשה

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "description": "Rename an email template (metadata only; does not touch the HTML)."
      }
    }
  }
}
```

### תגובות

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          }
        }
      }
    }
  }
}
```

#### HTTP 400

```json
{
  "description": "VALIDATION_ERROR",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "VALIDATION_ERROR"
          }
        }
      }
    }
  }
}
```

#### HTTP 404

```json
{
  "description": "NOT_FOUND",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "NOT_FOUND"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "email_templates:write",
  "x-unisoft-mcp": {
    "category": "update",
    "readOnly": false,
    "destructive": false,
    "idempotent": true,
    "warn": false
  }
}
```

## DELETE /email-templates/{id}

Delete an email template

`delete_email_template`

Required scope: `email_templates:write`. Soft-deletes the template.

### אימות

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### הרשאות נדרשות

```json
{
  "accepted": "email_templates:write",
  "additional": []
}
```

### פרמטרים

```json
{
  "name": "id",
  "in": "path",
  "required": true,
  "schema": {
    "type": "string",
    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
    "format": "uuid"
  },
  "description": "Identifier of the existing target resource, returned by its authorised list or read operation. Never generate a new UUID to address an existing record."
}
```

### תגובות

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          }
        }
      }
    }
  }
}
```

#### HTTP 404

```json
{
  "description": "NOT_FOUND",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "NOT_FOUND"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "email_templates:write",
  "x-unisoft-mcp": {
    "category": "delete",
    "readOnly": false,
    "destructive": true,
    "idempotent": true,
    "warn": false
  }
}
```

## PUT /email-templates/{id}/content

Set the HTML content of a template

`update_email_template_content`

Required scope: `email_templates:write`. Sets the template HTML and updates its thumbnail when possible. Offer the returned `previewUrl` to review the saved update before sending. Follow the email-client compatibility rules in EmailTemplateContentInput.

### אימות

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### הרשאות נדרשות

```json
{
  "accepted": "email_templates:write",
  "additional": []
}
```

### פרמטרים

```json
{
  "name": "id",
  "in": "path",
  "required": true,
  "schema": {
    "type": "string",
    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
    "format": "uuid"
  },
  "description": "Identifier of the existing target resource, returned by its authorised list or read operation. Never generate a new UUID to address an existing record."
}
```

### גוף הבקשה

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/UnisoftRequest_05f32f19f7e008006752"
      }
    }
  }
}
```

### תגובות

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/EmailTemplate"
          }
        }
      }
    }
  }
}
```

#### HTTP 400

```json
{
  "description": "VALIDATION_ERROR",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "VALIDATION_ERROR"
          }
        }
      }
    }
  }
}
```

#### HTTP 404

```json
{
  "description": "NOT_FOUND",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "NOT_FOUND"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "email_templates:write",
  "x-unisoft-mcp": {
    "category": "update",
    "readOnly": false,
    "destructive": false,
    "idempotent": true,
    "warn": false
  }
}
```

## סכמות

```json
{
  "components": {
    "schemas": {
      "EmailTemplate": {
        "type": "object",
        "description": "A reusable HTML email template (collection email_templates). The full HTML email an org can reuse — e.g. linked to a campaign as the donor thank-you email (`campagnes.config.donorEmailTemplate`). `design`/`assets` are the internal editor structures (exposed read-only).",
        "properties": {
          "id": {
            "type": "string"
          },
          "organisation": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "description": "Display name of the template."
          },
          "editorType": {
            "type": "string",
            "enum": [
              "EDITOR",
              "AI"
            ],
            "description": "Which editor produced it: EDITOR (visual builder, stores `design`) or AI (AI editor, stores `assets`)."
          },
          "html": {
            "type": "string",
            "nullable": true,
            "description": "The complete HTML email."
          },
          "design": {
            "type": "object",
            "nullable": true,
            "readOnly": true,
            "description": "Visual-builder serialization (read-only; EDITOR templates only).",
            "additionalProperties": true
          },
          "assets": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "readOnly": true,
            "description": "Asset identifiers embedded by the AI editor (read-only)."
          },
          "thumbnailUrl": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "readOnly": true,
            "description": "Public URL of the auto-generated PNG preview (best-effort; null if not generated)."
          },
          "previewUrl": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "readOnly": true,
            "description": "Stable, shareable browser preview of the latest saved HTML with example data. Anyone with the link can open it without signing in."
          },
          "datetime": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "editDatetime": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "readOnly": true
          }
        }
      },
      "Pagination": {
        "type": "object",
        "properties": {
          "nextCursor": {
            "type": "string",
            "nullable": true
          },
          "hasMore": {
            "type": "boolean"
          },
          "count": {
            "type": "integer"
          }
        }
      },
      "UnisoftRequest_05f32f19f7e008006752": {
        "type": "object",
        "properties": {
          "html": {
            "type": "string",
            "description": "The complete HTML email. Follow the rules above."
          }
        },
        "required": [
          "html"
        ],
        "additionalProperties": false,
        "description": "Complete HTML for an email template. Unlike a content block, this is a FULL HTML email document (<!DOCTYPE html><html>…</html> is expected).\nAn auto-generated PNG preview is produced best-effort (may be null).\n\nEMAIL-CLIENT COMPATIBILITY RULES the HTML MUST follow (same as the in-app AI email editor, since there is no editor to enforce them here):\n• Layout in <table>/<tr>/<td> ONLY (no flexbox/grid — Outlook ignores them).\n• INLINE styles only — no external <style> block, no CSS classes (Outlook strips them).\n• Max width 600px, centred, neutral page background (#f4f4f4).\n• Fonts: Arial, Helvetica, sans-serif ONLY (web fonts are not supported).\n• Images with EXPLICIT width/height as HTML attributes (not only CSS).\n• No JavaScript, no complex forms; link colours inline, no :hover.\n• MANDATORY structure: Header (coloured band with the org logo/name) + Body (white zone) + Footer (legal mentions, the unsubscribe link {{mailing_unsubscribe}} — REQUIRED — and contacts).\n• Interpolated variables available: {{firstname}}, {{lastname}}, {{hebrewname}}, {{mailing_unsubscribe}} (legacy aliases {{prenom}}, {{nom}}, {{prenomHE}} remain supported; org variables like {{org.name}} also exist).\n• This is a JEWISH community email: NEVER introduce a symbol/emoji of another religion (✝️ ✝ ⛪ ☦️ ☪️ 🕌 🛕 ☸️ 🔯). Jewish symbols (✡️ 🕎) and neutral emojis are fine."
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API Key",
        "description": "Format: `ke_live_xxx`"
      },
      "apiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    }
  }
}
```
