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

# Preview template

> Generates a preview of an invoice template with customizable data.
    - Uses template ID to get layout and components
    - Accepts optional preview data to customize all aspects of the preview
    - Returns PDF buffer of preview invoice



## OpenAPI

````yaml specs/billing_api_docs.json post /api/v1/invoices-templates/preview
openapi: 3.0.1
info:
  title: Billing API
  description: Billing service for managing subscriptions, payments, and entitlements
  contact: {}
  version: '1.0'
servers:
  - url: https://dev-billing-api.iqraa.ai/api/v1
security: []
tags:
  - name: Customers
    description: Customers related endpoints
  - name: Subscriptions
    description: Subscription related endpoints
  - name: Plans
    description: Plans related endpoints
  - name: Entitlements
    description: Entitlements related endpoints
  - name: Payments
    description: Payments related endpoints
  - name: Emails
    description: Email related endpoints
paths:
  /api/v1/invoices-templates/preview:
    post:
      tags:
        - Invoice Templates
      summary: Preview template
      description: |-
        Generates a preview of an invoice template with customizable data.
            - Uses template ID to get layout and components
            - Accepts optional preview data to customize all aspects of the preview
            - Returns PDF buffer of preview invoice
      operationId: InvoiceTemplatesController_previewTemplate
      parameters:
        - name: x-admin-api-key
          in: header
          description: The API key to access the admin API
          required: true
          schema:
            type: string
        - name: X-Preferred-Language
          required: true
          in: header
          description: Language for the PDF preview
          schema:
            enum:
              - ar
              - en
            type: string
      requestBody:
        required: true
        description: Template ID and optional preview data for customization
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PreviewTemplateDto'
      responses:
        '200':
          description: Template preview generated successfully
          content:
            application/json:
              schema:
                type: string
                format: binary
                description: PDF buffer of the preview invoice
        '400':
          description: Bad request - Missing template ID or invalid preview data
        '404':
          description: Template not found
components:
  schemas:
    PreviewTemplateDto:
      type: object
      properties:
        templateId:
          type: string
          description: ID of the invoice template to preview
          example: 550e8400-e29b-41d4-a716-446655440000
        previewData:
          description: Preview data to customize the invoice preview
          allOf:
            - $ref: '#/components/schemas/PreviewInvoiceData'
      required:
        - templateId
    PreviewInvoiceData:
      type: object
      properties:
        invoiceNumber:
          type: string
          description: Custom invoice number for preview
          example: INV-2023-001
        description:
          type: string
          description: Description of the invoice
          example: Monthly subscription fee
        amount:
          type: number
          description: Total amount of the invoice
          example: 99.99
        currency:
          type: string
          description: Currency code for the invoice amount
          example: USD
        planName:
          type: string
          description: Name of the subscription plan
          example: Premium Plan
        customerName:
          type: string
          description: Name of the customer
          example: John Doe
        customerEmail:
          type: string
          description: Email address of the customer
          example: john.doe@example.com
        startDate:
          format: date-time
          type: string
          description: Start date of the billing period
          example: '2023-01-01T00:00:00Z'
        renewalDate:
          format: date-time
          type: string
          description: Renewal date for the subscription
          example: '2023-02-01T00:00:00Z'
        paymentTerms:
          type: number
          description: Number of days until payment is due
          example: 30

````