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

# Create a template

> Creates a template and submits it to Meta for approval.



## OpenAPI

````yaml /openapi/escrybe.en.yaml post /api/whatsapp/v1/templates/post
openapi: 3.1.0
info:
  title: Escrybe API
  version: 1.0.0
  description: >
    REST API for the Escrybe platform — send physical letters, registered
    letters, telegrams and e-Carta through Brazilian Correios, dispatch legally
    registered e-mails, and send WhatsApp messages with certified timestamps.


    ## Authentication

    Every account has a personal **`securityToken`** (find it in the panel under
    *Account → API*). Three products use it differently:


    | Product | Scheme | How | |---------|--------|-----| | Letters / Telegram /
    e-Carta, Registered E-mail, Receipts | API token | Send `userSecurityToken`
    as a query/body parameter, or `securityToken` as a header | | WhatsApp |
    HTTP Basic | `Authorization: Basic base64(email:securityToken)` |


    > The letter and e-mail **read** routes (`get`, `balance`, `download`, >
    `delete`) take the token as the first URL **path** segment — e.g. >
    `/api/v2/get/{securityToken}/{job_id}`.


    ## Response envelopes

    Most endpoints reply with the standard envelope `{"status": <http code>,
    "status_message": "...", "data": ...}` — this covers Letters/Telegram,
    Registered E-mail, and the WhatsApp message and sender endpoints. The
    WhatsApp **template** endpoints (and template sync) use `{"code": <http
    code>, "status": "success|error", "message": "...", "data": ...,
    "request_id": "..."}`; the logo endpoint uses the same shape without
    `request_id`. See the schema of each endpoint.


    A request that is accepted returns an HTTP `200` with a success payload;
    validation problems return `400`, bad credentials `401`, and forbidden
    access `403`. Unsupported HTTP methods return `405`, repeated failed
    authentication attempts return `429`, and the letter and e-mail endpoints
    return `503` during maintenance windows.
  contact:
    name: Escrybe Support
    url: https://escrybe.com.br
servers:
  - url: https://app.escrybe.com.br
    description: Production
  - url: https://homolog.escrybe.com.br
    description: Staging
security:
  - securityTokenQuery: []
tags:
  - name: Letters & Telegram
    description: Create and manage letter, telegram and e-Carta orders (Correios).
  - name: Account & Favorites
    description: Account balance, saved contacts and sender logo.
  - name: Registered E-mail
    description: Send and track legally registered e-mails.
  - name: WhatsApp Messages
    description: Send WhatsApp messages and download certified-timestamp attestations.
  - name: WhatsApp Senders
    description: Manage WhatsApp Business numbers (senders).
  - name: WhatsApp Templates
    description: Create, sync and manage WhatsApp message templates.
  - name: Receipts
    description: Download legal receipts for any order.
paths:
  /api/whatsapp/v1/templates/post:
    post:
      tags:
        - WhatsApp Templates
      summary: Create a template
      description: Creates a template and submits it to Meta for approval.
      operationId: createTemplate
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CreateTemplateRequest'
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTemplateRequest'
      responses:
        '200':
          description: Created and submitted (the envelope's `code` field reads 201)
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/WaEnvelope'
                  - properties:
                      data:
                        $ref: '#/components/schemas/TemplateCreateResult'
        '400':
          $ref: '#/components/responses/WaBadRequest'
        '401':
          $ref: '#/components/responses/WaUnauthorized'
        '403':
          $ref: '#/components/responses/WaForbidden'
        '404':
          $ref: '#/components/responses/WaNotFound'
      security:
        - basicAuth: []
components:
  schemas:
    CreateTemplateRequest:
      type: object
      required:
        - sender_id
        - name
        - body_text
      properties:
        sender_id:
          type: integer
        name:
          type: string
          description: >
            Normalized server-side (lowercased, spaces become underscores,
            invalid characters and leading digits stripped) and prefixed with
            `user{id}_`. The response returns the final `name` and your original
            text as `display_name`.
        body_text:
          type: string
          description: >
            May contain {{1}}, {{2}} placeholders. A sender-identification
            footer is automatically appended, adding the reserved variables
            {{sender_name}}, {{sender_doc}} and {{sender_phone}} (substituted at
            send time).
        category:
          type: string
          enum:
            - UTILITY
            - MARKETING
            - AUTHENTICATION
          default: UTILITY
        language:
          type: string
          default: pt_BR
        header_text:
          type: string
        footer_text:
          type: string
        header_format:
          type: string
          enum:
            - NONE
            - TEXT
            - IMAGE
            - DOCUMENT
          default: NONE
        header_media:
          type: string
          format: binary
          description: >-
            For IMAGE/DOCUMENT headers. When no media is provided, a default
            Escrybe sample file is submitted to Meta for approval.
        header_media_base64:
          type: string
        header_media_url:
          type: string
        header_media_filename:
          type: string
        variable_examples:
          type: array
          items:
            type: string
          description: >-
            Examples for Meta approval. Auto-filled from your profile when
            omitted.
    WaEnvelope:
      type: object
      description: Envelope used by the WhatsApp template endpoints and template sync.
      properties:
        code:
          type: integer
          example: 200
        status:
          type: string
          example: success
        message:
          type: string
          nullable: true
        data: {}
        request_id:
          type: string
    TemplateCreateResult:
      type: object
      properties:
        template_id:
          type: integer
        meta_template_id:
          type: string
        name:
          type: string
        display_name:
          type: string
        status:
          type: string
          example: pending
        sender_id:
          type: integer
        sender_name:
          type: string
  responses:
    WaBadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WaEnvelope'
          example:
            code: 400
            status: error
            message: Campos obrigatórios não preenchidos
            data: null
    WaUnauthorized:
      description: Unauthorized — invalid credentials
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WaEnvelope'
          example:
            code: 401
            status: error
            message: Não autorizado — credenciais inválidas
            data: null
    WaForbidden:
      description: Access denied
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WaEnvelope'
    WaNotFound:
      description: Not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WaEnvelope'
  securitySchemes:
    securityTokenQuery:
      type: apiKey
      in: query
      name: userSecurityToken
      description: >-
        Your account security token, sent as the `userSecurityToken` query or
        form parameter.
    basicAuth:
      type: http
      scheme: basic
      description: >-
        HTTP Basic where username is your account e-mail and password is your
        security token.

````