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

# Render document body

> Renders a document body from a template slug and variables and returns the JSON content. Variables can be strings or arrays of objects for table data.



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/samplehc/openapi.documented.yml post /api/v2/documents/templates/render
openapi: 3.0.3
info:
  title: Sample Healthcare API
  description: API for Sample Healthcare
  version: 1.0.0
servers: []
security: []
paths:
  /api/v2/documents/templates/render:
    post:
      tags:
        - Document
      summary: Render document body
      description: >-
        Renders a document body from a template slug and variables and returns
        the JSON content. Variables can be strings or arrays of objects for
        table data.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                slug:
                  type: string
                  description: The slug of the template to use.
                variables:
                  type: object
                  additionalProperties:
                    anyOf:
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - template
                          slug:
                            type: string
                          variables:
                            type: object
                            additionalProperties: {}
                        required:
                          - type
                          - slug
                          - variables
                        additionalProperties: false
                      - type: array
                        items:
                          type: object
                          additionalProperties:
                            type: string
                      - type: string
                  description: >-
                    Variables for the template. Accepts strings, arrays of
                    objects for tables, or nested templates via `{ type:
                    'template', slug, variables }`.
              required:
                - slug
                - variables
              additionalProperties: false
        required: true
      responses:
        '200':
          description: Successfully rendered document body.
          content:
            application/json:
              schema:
                type: object
                properties:
                  body:
                    description: The rendered document body.
                additionalProperties: false
        '400':
          description: Bad Request, e.g., invalid template slug or variables.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
                additionalProperties: false
        '404':
          description: The template was not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
                additionalProperties: false
        '500':
          description: An internal server error occurred while rendering the document body.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
                additionalProperties: false
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from samplehc import SampleHealthcare

            client = SampleHealthcare(
                api_key=os.environ.get("SAMPLEHC_API_KEY"),  # This is the default and can be omitted
            )
            response = client.v2.documents.templates.render_document(
                slug="slug",
                variables={
                    "foo": {
                        "slug": "slug",
                        "type": "template",
                        "variables": {
                            "foo": "bar"
                        },
                    }
                },
            )
            print(response.body)

````