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

# Compile content for a contact

> Compiles Liquid template content in the context of a specific contact. If no contact ID is provided, a dummy contact is used. Useful for previewing personalized messages before sending.

See the [Liquid syntax guide](/guides/liquid-syntax) for available variables and filters.

Requires the **`contacts`** permission on the service account that owns your API key. A key whose service account lacks it fails with `"Lacking necessary permission contacts"`.

**A missing record does not return 404.** This handler reports the failure without a status code, and the error envelope defaults to HTTP `200` — you get `200` with `status: "failed"`. Branch on `status`, not on the HTTP code.



## OpenAPI

````yaml /api-reference/specs/contacts.json post /api/contacts/compile/{id}
openapi: 3.1.0
info:
  title: ConveYour API — Contacts
  description: >-
    Contacts are the core data object in ConveYour. Every person in your system
    — a learner, rep, or prospect — is a contact.
  version: 1.0.0
servers:
  - url: https://{subdomain}.conveyour.com
    description: Your organization's ConveYour instance
    variables:
      subdomain:
        default: acme
        description: >-
          Your organization's slug — the subdomain you sign in on. Replace
          `acme` with yours: if you sign in at `bigco.conveyour.com`, enter
          `bigco`.
security:
  - conveyourToken: []
tags:
  - name: Contacts
    description: >-
      Contacts are the core data object in ConveYour. Every person in your
      system — a learner, rep, or prospect — is a contact.
paths:
  /api/contacts/compile/{id}:
    post:
      tags:
        - Contacts
      summary: Compile content for a contact
      description: >-
        Compiles Liquid template content in the context of a specific contact.
        If no contact ID is provided, a dummy contact is used. Useful for
        previewing personalized messages before sending.


        See the [Liquid syntax guide](/guides/liquid-syntax) for available
        variables and filters.


        Requires the **`contacts`** permission on the service account that owns
        your API key. A key whose service account lacks it fails with `"Lacking
        necessary permission contacts"`.


        **A missing record does not return 404.** This handler reports the
        failure without a status code, and the error envelope defaults to HTTP
        `200` — you get `200` with `status: "failed"`. Branch on `status`, not
        on the HTTP code.
      operationId: compileContactContent
      parameters:
        - name: id
          in: path
          required: true
          description: >-
            The contact to compile in the context of. Pass any placeholder to
            compile against a dummy contact.
          schema:
            type: string
        - $ref: '#/components/parameters/teams'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - content
              properties:
                content:
                  type: string
                  description: The Liquid template string to compile.
                format:
                  type: string
                  enum:
                    - text
                    - html
                  default: text
                  description: Output format.
                inputs:
                  type: object
                  additionalProperties: true
                  description: >-
                    Optional key/value inputs available inside the template as
                    variables.
            example:
              content: >-
                Hi {{ contact.first_name }}, your badge is {{
                contact.badge_number }}.
              format: text
              inputs: {}
      responses:
        '200':
          description: The compiled content.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Envelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/CompiledContent'
              example:
                status: ok
                message: Content compiled
                data:
                  content: Hi Jane, your badge is 1234.
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  parameters:
    teams:
      name: teams[]
      in: query
      description: >-
        Team scope for the request, as one or more team ObjectIds. The brackets
        are required: PHP keeps only the last value for a repeated plain key, so
        `teams=A&teams=B` silently resolves to B alone. On requests with a JSON
        body you may send `teams` (no brackets) in the body instead.


        **Values that are not valid ObjectIds are silently ignored** — a
        mistyped team ID behaves as if no team was sent. See the [teams section
        of the API conventions guide](/guides/api-conventions#team-scoping).
      style: form
      explode: true
      schema:
        type: array
        items:
          type: string
      example:
        - 64a1b2c3d4e5f6a7b8c9d0ff
  schemas:
    Envelope:
      type: object
      description: The common response envelope shared by all ConveYour endpoints.
      properties:
        status:
          type: string
          enum:
            - ok
            - failed
          description: '`ok` on success, `failed` on error.'
        message:
          type: string
          description: Human-readable description of the result.
        data:
          description: >-
            The response payload — an object or an array depending on the
            endpoint.
    CompiledContent:
      type: object
      description: The submitted template rendered against the contact.
      properties:
        content:
          type: string
          description: The compiled output.
      required:
        - content
  responses:
    Forbidden:
      description: >-
        The token is missing or invalid, or the service account behind it lacks
        the permission this endpoint requires.
      content:
        application/json:
          example:
            status: failed
            message: Lacking necessary permission add_contacts
            data:
              permission: add_contacts
  securitySchemes:
    conveyourToken:
      type: apiKey
      in: header
      name: x-conveyour-token
      description: >-
        Your API key token. Contacts endpoints require a **Server-only — Full
        API** key — see [Authentication](/quickstart).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.