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

# Create Template

> Creates a WhatsApp message template and sends it to Meta for approval.

The new template starts as `PENDING`. Meta then approves or rejects it, which can take some time. Check the result with Get Template.

Returns `422` with `meta_rejected` if Meta refuses the template straight away, for example because the name is already used.


## OpenAPI

````yaml /api-collection/chatflows-api-v1.json post /api/v1/templates
openapi: 3.1.0
info:
  title: ChatFlows REST API
  version: 1.0.0
  description: >-
    ChatFlows REST API (v1).


    **Base URL:** `https://app.chatflows.io/api/v1` — also shown, with a copy
    button, on your **Developer API Keys** page.


    **Auth:** every authenticated request sends `Authorization: Bearer <token>`,
    where the token is created under **Setup → Developer API Keys** in your
    dashboard.


    **What a token can see:** a token belongs to ONE workspace — your store's.
    Every endpoint returns only that workspace's data, and `/api/v1/account`
    describes your own workspace. A token created before tokens were tied to a
    workspace is refused with `401 token_not_scoped`; create a new one to
    replace it.


    **Scopes:** each endpoint's description lists the token ability it requires.
    Create your token with the matching scopes.


    **Pagination:** list endpoints return `{ data, links: { next, prev }, meta
    }`. Large/append-only collections (contacts, group members, webhooks) use
    opaque cursor pagination — follow `links.next` until it is `null`.
    `per_page` is clamped to 5–100.


    **Async sends:** message and OTP sends return `202` and are processed on the
    queue.


    **Error envelope:**

    ```json

    { "message": "...", "error_code": "...", "status": 4xx }

    ```


    **Modules:** Auth/Account · Channels · Contacts · Statuses · Sources ·
    Groups · Labels · Templates · Messages · Conversations · OTP.
servers:
  - url: https://app.chatflows.io
    description: ChatFlows
security:
  - bearerAuth: []
tags:
  - name: Root
    description: Unauthenticated service metadata.
  - name: Auth & Account
    description: Verify your token, and read workspace identity, plan and usage.
  - name: Channels
    description: Connected WhatsApp accounts and their phone numbers.
  - name: Customers
    description: Create, read, update, merge and bulk-manage customers.
  - name: Customer Statuses
    description: The pipeline statuses a contact can be assigned.
  - name: Customer Sources
    description: Where a contact originated (e.g. website, referral).
  - name: Customer Groups
    description: Named groups used to segment contacts and target campaigns.
  - name: Customer Labels
    description: Free-form labels for tagging contacts.
  - name: Templates
    description: WhatsApp message templates and their Meta approval status.
  - name: Messages
    description: Send template and free-form messages, and read delivery status.
  - name: Conversations
    description: Customer conversation threads and their message history.
  - name: OTP
    description: Send, verify and resend one-time passcodes over WhatsApp.
  - name: Error Examples
    description: Reference shapes for the errors any endpoint may return.
paths:
  /api/v1/templates:
    post:
      tags:
        - Templates
      summary: Create Template
      operationId: templatesCreateTemplate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                channel_id:
                  type: integer
                  description: Must reference an existing `channels` record.
                name:
                  type: string
                  maxLength: 512
                  pattern: ^[a-z0-9_]+$
                language:
                  type: string
                  maxLength: 20
                category:
                  type: string
                  enum:
                    - MARKETING
                    - UTILITY
                    - AUTHENTICATION
                header:
                  type:
                    - object
                    - 'null'
                  properties:
                    format:
                      type: string
                    text:
                      type: string
                  additionalProperties: true
                body:
                  type: string
                  maxLength: 1024
                footer:
                  type:
                    - string
                    - 'null'
                  maxLength: 60
                buttons:
                  type:
                    - array
                    - 'null'
                  items:
                    type: object
                    properties:
                      type:
                        type: string
                      text:
                        type: string
                      url:
                        type: string
                  maxItems: 10
              required:
                - channel_id
                - name
                - language
                - category
                - body
            examples:
              Create Template:
                summary: Create Template
                value:
                  channel_id: 1
                  name: order_confirmation
                  language: en_US
                  category: UTILITY
                  header:
                    format: TEXT
                    text: Order update
                  body: Your order {{1}} has shipped.
                  footer: Thanks for shopping with us
                  buttons:
                    - type: QUICK_REPLY
                      text: Track order
                    - type: URL
                      text: Shop again
                      url: https://example.com
      responses:
        '201':
          description: 201 Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      channel_id:
                        type: integer
                      platform:
                        type: string
                      platform_template_id:
                        type: string
                      name:
                        type: string
                      language:
                        type: string
                      category:
                        type: string
                      sub_type: {}
                      status:
                        type: string
                      quality_rating: {}
                      components:
                        type: array
                        items:
                          type: object
                          properties:
                            type:
                              type: string
                            text:
                              type: string
                      example_values:
                        type: object
                        properties:
                          body:
                            type: array
                            items:
                              type: string
                      rejected_reason: {}
                      last_synced_at:
                        type: string
                      created_at:
                        type: string
                      updated_at:
                        type: string
              examples:
                201 Created:
                  summary: 201 Created
                  value:
                    data:
                      id: 1
                      channel_id: 1
                      platform: whatsapp
                      platform_template_id: '987654321'
                      name: order_confirmation
                      language: en_US
                      category: utility
                      sub_type: null
                      status: PENDING
                      quality_rating: null
                      components:
                        - type: BODY
                          text: Your order {{1}} has shipped.
                        - type: FOOTER
                          text: Thanks for shopping with us
                      example_values:
                        body:
                          - '#A123'
                      rejected_reason: null
                      last_synced_at: '2026-06-27T09:00:00+00:00'
                      created_at: '2026-06-27T09:00:00+00:00'
                      updated_at: '2026-06-27T09:00:00+00:00'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          description: 422 Meta Rejected
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  error_code:
                    type: string
                  errors:
                    type: object
                    properties:
                      name:
                        type: array
                        items:
                          type: string
                  status:
                    type: integer
              examples:
                422 Meta Rejected:
                  summary: 422 Meta Rejected
                  value:
                    message: Template name already exists.
                    error_code: meta_rejected
                    status: 422
                422 Validation:
                  summary: 422 Validation
                  value:
                    message: The given data was invalid.
                    error_code: validation_failed
                    errors:
                      name:
                        - The name format is invalid.
                    status: 422
        '429':
          $ref: '#/components/responses/QuotaExhausted'
      security:
        - bearerAuth:
            - templates:write
components:
  responses:
    Unauthorized:
      description: >-
        Missing, invalid or expired API token — or an older token that is not
        tied to a workspace (`token_not_scoped`), in which case create a new one
        on the Developer API Keys page.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            message: Missing API token.
            error_code: unauthenticated
            status: 401
    PaymentRequired:
      description: >-
        Your workspace has no active subscription, or its first payment is still
        pending.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            message: Subscription required or expired.
            error_code: subscription_required
            status: 402
    Forbidden:
      description: >-
        The token lacks the required scope, or the account is suspended or on
        hold.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            message: 'This token is missing the required scope: contacts:write.'
            error_code: insufficient_scope
            status: 403
    QuotaExhausted:
      description: The monthly API request quota for the workspace is exhausted.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            message: API request quota exhausted for this billing period.
            error_code: quota_exhausted
            status: 429
      headers:
        RateLimit-Limit:
          schema:
            type: integer
          description: Your API request quota for the current billing period.
        RateLimit-Remaining:
          schema:
            type: integer
          description: Requests remaining in the current billing period.
        RateLimit-Reset:
          schema:
            type: integer
          description: Seconds until the quota resets.
  schemas:
    Error:
      type: object
      description: Standard error envelope returned by every endpoint.
      properties:
        message:
          type: string
          description: Human-readable explanation.
        error_code:
          type: string
          description: Stable machine-readable code — branch on this, not the message.
        status:
          type: integer
          description: HTTP status code.
      required:
        - message
        - error_code
        - status
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your API key. Create one under **Setup → Developer API Keys** and select
        the permissions this endpoint needs.

````

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