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

# Send a templated email

> Renders `template_html` with `context` and sends it to `recipients` via the configured SMTP provider. Service-to-service only — requires a service-account bearer token.



## OpenAPI

````yaml /openapi/shared.yaml post /api/v1/mailer/send-mail
openapi: 3.0.3
info:
  title: Shared Service API
  version: 1.0.0
  description: |2-

        **Shared Service API** - Comprehensive shared service and management system.

        ## Versionings
        The API uses URL path versioning (e.g., `/api/v1/`, `/api/v2/`).
        Current version: **v1**
        
  contact:
    name: API Support
    email: thakacreations@gmail.com
  license:
    name: thakacreations
servers: []
security: []
paths:
  /api/v1/mailer/send-mail:
    post:
      tags:
        - mailer
      summary: Send a templated email
      description: >-
        Renders `template_html` with `context` and sends it to `recipients` via
        the configured SMTP provider. Service-to-service only — requires a
        service-account bearer token.
      operationId: mailer_send_mail
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MailRequest'
            examples:
              SendRequest:
                value:
                  recipients:
                    - user@example.com
                  subject: Your invoice is ready
                  template_html: <p>Hi {{ name }}, your invoice is ready.</p>
                  context:
                    name: Jane
                summary: Send request
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/MailRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/MailRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MailSendResponse'
              examples:
                Sent:
                  value:
                    success: true
                    message: Email sent
          description: ''
      security:
        - bearerAuth: []
components:
  schemas:
    MailRequest:
      type: object
      properties:
        recipients:
          type: array
          items:
            type: string
            format: email
            minLength: 1
        subject:
          type: string
          minLength: 1
          maxLength: 100
        template_html:
          type: string
          minLength: 1
        context:
          type: object
          additionalProperties: {}
      required:
        - recipients
        - subject
        - template_html
    MailSendResponse:
      type: object
      properties:
        success:
          type: boolean
        message:
          type: string
      required:
        - message
        - success
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Enter your JWT token in the format: Bearer <token>'

````