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

# Criar flow

> Crie um flow a partir do flow_json

## Conceituação

Cria um flow no WABA. O `flow_json` é a definição das telas, enviada como **string** — não como objeto.

Com `publish: true` o flow já nasce publicado. Sem isso, ele fica em `DRAFT`, que é o único status em que você ainda pode alterar o `flow_json`.

<Warning>
  Se alguma tela usar a ação `data_exchange`, o campo `endpoint_uri` é obrigatório.
</Warning>

<Note>
  A estrutura do `flow_json` e a lista de componentes estão na [Introdução](/flows/introduction).
</Note>


## OpenAPI

````yaml pt/flows/openapi.json POST /whatsapp/businesses/{wabaId}/flows
openapi: 3.1.0
info:
  title: Omni Z-API - Flows do WhatsApp
  description: >-
    API para criar e gerenciar WhatsApp Flows (formulários nativos dentro da
    conversa)
  version: 1.0.0
servers:
  - url: https://api.omni.z-api.io
security:
  - bearerAuth: []
paths:
  /whatsapp/businesses/{wabaId}/flows:
    post:
      tags:
        - Flows
      summary: Criar flow
      description: >-
        Cria um flow. O `flow_json` é a definição das telas em JSON, enviada
        como string. Com `publish: true` o flow já nasce publicado; sem isso,
        fica em `DRAFT`.
      operationId: createFlow
      parameters:
        - name: wabaId
          in: path
          required: true
          description: ID do WABA (obtido via Listar WABAs)
          schema:
            type: string
            example: '428083093730937'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFlowRequest'
            example:
              name: agendamento_consulta
              categories:
                - APPOINTMENT_BOOKING
              flow_json: >-
                {"version": "7.0", "routing_model": {"WELCOME": ["DONE"],
                "DONE": []}, "screens": [{"id": "WELCOME", "title":
                "Agendamento", "layout": {"type": "SingleColumnLayout",
                "children": [{"type": "TextHeading", "text": "Escolha um
                horario"}, {"type": "Form", "name": "form", "children":
                [{"type": "TextInput", "name": "nome", "label": "Seu nome",
                "input-type": "text", "required": true}, {"type": "DatePicker",
                "name": "data", "label": "Data"}, {"type": "Footer", "label":
                "Continuar", "on-click-action": {"name": "navigate", "next":
                {"type": "screen", "name": "DONE"}, "payload": {}}}]}]}}, {"id":
                "DONE", "title": "Pronto", "terminal": true, "success": true,
                "layout": {"type": "SingleColumnLayout", "children": [{"type":
                "TextBody", "text": "Agendamento confirmado."}, {"type":
                "Footer", "label": "Fechar", "on-click-action": {"name":
                "complete", "payload": {}}}]}}]}
              publish: false
      responses:
        '201':
          description: Flow criado
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Flow'
              example:
                id: '1122334455667788'
                name: agendamento_consulta
                categories:
                  - APPOINTMENT_BOOKING
                status: PUBLISHED
                endpoint_uri: null
                validation_errors: []
        '400':
          description: >-
            Requisição inválida — `flow_json` malformado ou categoria
            inexistente
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Token inválido ou ausente.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >-
            Regra de negócio violada — flow publicado não aceita alteração do
            `flow_json`, ou remoção de flow fora de `DRAFT`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CreateFlowRequest:
      type: object
      required:
        - name
        - categories
        - flow_json
      properties:
        name:
          type: string
          description: Nome do flow
          example: agendamento_consulta
        categories:
          type: array
          description: Categorias do flow (a Meta usa na revisão)
          items:
            type: string
            enum:
              - SIGN_UP
              - SIGN_IN
              - APPOINTMENT_BOOKING
              - LEAD_GENERATION
              - CONTACT_US
              - CUSTOMER_SUPPORT
              - SURVEY
              - OTHER
          example:
            - APPOINTMENT_BOOKING
        flow_json:
          type: string
          description: Definição das telas em JSON, enviada como **string**
        endpoint_uri:
          type: string
          description: >-
            URL do seu endpoint, obrigatória apenas para flows com
            `data_exchange`
          example: https://app.suaempresa.com/flows/callback
        publish:
          type: boolean
          description: Quando `true`, publica o flow já na criação
          default: false
    Flow:
      type: object
      properties:
        id:
          type: string
          description: ID do flow
        name:
          type: string
          description: Nome do flow
        categories:
          type: array
          description: Categorias do flow (a Meta usa na revisão)
          items:
            type: string
            enum:
              - SIGN_UP
              - SIGN_IN
              - APPOINTMENT_BOOKING
              - LEAD_GENERATION
              - CONTACT_US
              - CUSTOMER_SUPPORT
              - SURVEY
              - OTHER
        status:
          type: string
          enum:
            - DRAFT
            - PUBLISHED
            - DEPRECATED
            - BLOCKED
            - THROTTLED
          description: Status de publicação
        endpoint_uri:
          type: string
          nullable: true
          description: >-
            URL do seu endpoint, obrigatória apenas para flows com
            `data_exchange`
        flow_json:
          type: string
          description: Definição das telas em JSON, enviada como **string**
        validation_errors:
          type: array
          description: Pendências de validação devolvidas pela Meta
          items:
            type: object
            properties:
              key:
                type: string
                description: Chave da pendência
              value:
                type: string
                description: Detalhe da pendência
    Error:
      type: object
      properties:
        error:
          type: integer
        message:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````