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

# Create Template

> Create a template scoped to the authenticated user's owner.



## OpenAPI

````yaml /api/openapi.json post /v1/templates
openapi: 3.1.0
info:
  title: MeshAPI
  description: One key, all AI models.
  version: 0.1.0
servers:
  - url: https://api.meshapi.ai
security:
  - BearerAuth: []
paths:
  /v1/templates:
    post:
      tags:
        - Templates
      summary: Create Template
      description: Create a template scoped to the authenticated user's owner.
      operationId: create_template
      parameters:
        - in: header
          name: X-Mesh-Version
          required: false
          schema:
            type: string
            enum:
              - 2026-08
            default: 2026-08
          example: 2026-08
          description: >-
            Dated version of the API contract to pin this request to. Omit it
            and the request is served under `2026-08` — the oldest supported
            version, so an existing integration is never moved by a release. A
            malformed or unsupported value is rejected with `400
            invalid_api_version` rather than falling back silently. The version
            actually served is echoed as `X-Mesh-Version` on every response,
            including errors.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTemplateRequest'
            examples:
              default:
                summary: Example request
                value:
                  name: support-reply
                  description: Short customer support replies with a friendly tone.
                  system: You are a concise customer support assistant.
                  messages:
                    - role: user
                      content: 'Reply to: {{ticket}}'
                  model: openai/gpt-4o-mini
                  params:
                    temperature: 0.3
                    max_tokens: 300
                  variables:
                    - ticket
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TemplateSummary'
              examples:
                default:
                  summary: Example response
                  value:
                    id: tmpl_01JZ0R6N9F8K7B6V3Q4A2Y1X0P
                    name: support-reply
                    owner: user_01JZ0Q9WZ7ZK3M9YF6R8D2C4B1
                    org_id: org_01JZ0QAW6MS7M6WTJ7HE4VK3DF
                    team_id: null
                    is_global: false
                    description: Short customer support replies with a friendly tone.
                    system: You are a concise customer support assistant.
                    messages:
                      - role: user
                        content: 'Reply to: {{ticket}}'
                    model: openai/gpt-4o-mini
                    params:
                      temperature: 0.3
                      max_tokens: 300
                    variables:
                      - ticket
                    creator_name: Asha Rao
                    creator_email: asha@example.com
                    created_at: '2026-07-02T10:15:30Z'
                    updated_at: '2026-07-02T10:15:30Z'
        '401':
          description: Missing or invalid credentials
          content:
            application/json:
              example:
                error:
                  code: unauthorized
                  message: Invalid or missing API key.
                request_id: req_01ARZ3NDEKTSV4RRFFQ69G5FAV
        '409':
          description: A template with this name already exists for this owner
          content:
            application/json:
              example:
                detail: >-
                  A template named 'my-prompt' already exists for owner
                  'user_abc123'.
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: Database write error
          content:
            application/json:
              example:
                detail: Internal Server Error
      security:
        - BearerAuth: []
components:
  schemas:
    CreateTemplateRequest:
      properties:
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        system:
          anyOf:
            - type: string
            - type: 'null'
          title: System
        messages:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: Messages
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
        params:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Params
        variables:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Variables
        team_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Team Id
      type: object
      required:
        - name
      title: CreateTemplateRequest
      example:
        name: Customer Support Template
    TemplateSummary:
      properties:
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        owner:
          anyOf:
            - type: string
            - type: 'null'
          title: Owner
        org_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Org Id
        team_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Team Id
        is_global:
          type: boolean
          title: Is Global
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        system:
          anyOf:
            - type: string
            - type: 'null'
          title: System
        messages:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: Messages
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
        params:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Params
        variables:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Variables
        category:
          anyOf:
            - type: string
            - type: 'null'
          title: Category
        version:
          anyOf:
            - type: string
            - type: 'null'
          title: Version
        is_beta:
          type: boolean
          title: Is Beta
        creator_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Creator Name
        creator_email:
          anyOf:
            - type: string
            - type: 'null'
          title: Creator Email
        created_at:
          type: string
          title: Created At
        updated_at:
          type: string
          title: Updated At
      type: object
      required:
        - id
        - name
        - owner
        - org_id
        - team_id
        - is_global
        - description
        - system
        - messages
        - model
        - params
        - variables
        - category
        - version
        - is_beta
        - creator_name
        - creator_email
        - created_at
        - updated_at
      title: TemplateSummary
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Enter your MeshAPI key (`rsk_...`) — sent as `Authorization: Bearer
        <key>`.

````