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

# Render Template

> Render an email template with provided variables. Returns HTML or React format based on request.



## OpenAPI

````yaml api-reference/openapi.json post /templates/{id}/render
openapi: 3.0.3
info:
  title: Senderr Email Template API
  description: >-
    API for accessing and managing email templates in your library. Supports
    both session-based authentication and API key authentication with rate
    limiting based on subscription plans.
  version: 1.0.0
  contact:
    name: Senderr Support
    url: https://senderr.dev/contact
    email: support@senderr.dev
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
  termsOfService: https://senderr.dev/terms
servers:
  - url: https://senderr.dev/api/v1
    description: Production server
  - url: http://localhost:3000/api/v1
    description: Development server
security:
  - BearerAuth: []
  - SessionAuth: []
tags:
  - name: Library
    description: Operations related to user's template library
  - name: Templates
    description: Operations for template rendering and source code access
  - name: Email
    description: Operations for sending emails using templates
  - name: Usage
    description: Operations for checking API usage and limits
paths:
  /templates/{id}/render:
    post:
      tags:
        - Templates
      summary: Render Template
      description: >-
        Render an email template with provided variables. Returns HTML or React
        format based on request.
      operationId: renderTemplate
      parameters:
        - name: id
          in: path
          required: true
          description: Template ID
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                variables:
                  type: object
                  additionalProperties: true
                  description: Template variables as key-value pairs
                format:
                  type: string
                  enum:
                    - html
                    - react
                  default: html
                  description: Output format
              required:
                - variables
            example:
              variables:
                name: John Doe
                email: john@example.com
                company: Acme Corp
              format: html
      responses:
        '200':
          description: Template rendered successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  html:
                    type: string
                    description: Rendered HTML output (when format=html)
                  react:
                    type: string
                    description: React component code (when format=react)
              example:
                success: true
                html: >-
                  <!DOCTYPE html><html><body><h1>Hello John
                  Doe</h1></body></html>
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/AccessDenied'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimitExceeded'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  responses:
    BadRequest:
      description: Bad request - invalid input data
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationErrorResponse'
          example:
            error: Invalid request body
            code: VALIDATION_ERROR
            success: false
            details:
              - field: variables
                message: Variables must be an object
    Unauthorized:
      description: Authentication required
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Authentication required
            success: false
    AccessDenied:
      description: Access denied - template not purchased
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: Template access denied
              code:
                type: string
                example: ACCESS_DENIED
              message:
                type: string
                example: You must purchase this template to render it
              template:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  title:
                    type: string
                  price:
                    type: string
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Template not found
            success: false
    RateLimitExceeded:
      description: Rate limit exceeded
      headers:
        X-RateLimit-Limit:
          description: The number of allowed requests in the current period
          schema:
            type: integer
        X-RateLimit-Remaining:
          description: The number of remaining requests in the current period
          schema:
            type: integer
            example: 0
        X-RateLimit-Reset:
          description: The time when the rate limit resets
          schema:
            type: string
            format: date-time
        X-RateLimit-Plan:
          description: The user's current subscription plan
          schema:
            type: string
            enum:
              - free
              - monthly
              - annual
        Retry-After:
          description: Number of seconds to wait before retrying
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitErrorResponse'
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Internal server error
            code: INTERNAL_ERROR
            success: false
  schemas:
    ValidationErrorResponse:
      allOf:
        - $ref: '#/components/schemas/ErrorResponse'
        - type: object
          properties:
            details:
              type: array
              items:
                type: object
                properties:
                  field:
                    type: string
                  message:
                    type: string
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Error message
        code:
          type: string
          description: Error code
        success:
          type: boolean
          example: false
        details:
          type: object
          description: Additional error details
      required:
        - error
        - success
    RateLimitErrorResponse:
      type: object
      properties:
        error:
          type: string
          example: API usage limit exceeded
        code:
          type: string
          example: RATE_LIMIT_EXCEEDED
        message:
          type: string
          description: Detailed error message with upgrade suggestions
        details:
          type: object
          properties:
            limit:
              type: integer
              description: Monthly API call limit
            remaining:
              type: integer
              example: 0
            reset:
              type: string
              format: date-time
              description: When the limit resets
            plan:
              type: string
              enum:
                - free
                - monthly
                - annual
            resetInSeconds:
              type: integer
              description: Seconds until limit resets
        upgrade_url:
          type: string
          nullable: true
          description: URL to upgrade plan (for free users)
        documentation:
          type: string
          format: uri
          description: Link to rate limiting documentation
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'Use your API key from the dashboard. Format: `Bearer your-api-key-here`'
    SessionAuth:
      type: apiKey
      in: cookie
      name: supabase-auth-token
      description: Session-based authentication using browser cookies

````