> ## 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.

# Crear flow

> Crea un flow a partir de su flow_json

## Conceptos

Crea un flow en la WABA. El `flow_json` es la definición de las pantallas, enviada como **string**, no como objeto.

Con `publish: true` el flow nace publicado. Si no, queda en `DRAFT`, que es el único estado en el que todavía puedes cambiar el `flow_json`.

<Warning>
  Si alguna pantalla usa la acción `data_exchange`, el campo `endpoint_uri` es obligatorio.
</Warning>

<Note>
  La estructura del `flow_json` y la lista de componentes están en la [Introducción](/es/flows/introduction).
</Note>


## OpenAPI

````yaml es/flows/openapi.json POST /whatsapp/businesses/{wabaId}/flows
openapi: 3.1.0
info:
  title: Omni Z-API - Flows de WhatsApp
  description: >-
    API para crear y gestionar WhatsApp Flows (formularios nativos dentro de la
    conversación)
  version: 1.0.0
servers:
  - url: https://api.omni.z-api.io
security:
  - bearerAuth: []
paths:
  /whatsapp/businesses/{wabaId}/flows:
    post:
      tags:
        - Flows
      summary: Crear flow
      description: >-
        Crea un flow. El `flow_json` es la definición de las pantallas en JSON,
        enviada como string. Con `publish: true` el flow nace publicado; si no,
        queda en `DRAFT`.
      operationId: createFlow
      parameters:
        - name: wabaId
          in: path
          required: true
          description: ID de la WABA (obtenido con 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 creado
          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: 'Petición no válida: `flow_json` mal formado o categoría inexistente'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Token no válido o ausente.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >-
            Regla de negocio incumplida: un flow publicado no admite cambios en
            el `flow_json`, o eliminación de un flow fuera 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: Nombre del flow
          example: agendamento_consulta
        categories:
          type: array
          description: Categorías del flow (Meta las usa en la revisión)
          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: Definición de las pantallas en JSON, enviada como **string**
        endpoint_uri:
          type: string
          description: >-
            URL de tu endpoint, obligatoria solo para los flows con
            `data_exchange`
          example: https://app.suempresa.com/flows/callback
        publish:
          type: boolean
          description: Cuando es `true`, publica el flow ya en la creación
          default: false
    Flow:
      type: object
      properties:
        id:
          type: string
          description: ID del flow
        name:
          type: string
          description: Nombre del flow
        categories:
          type: array
          description: Categorías del flow (Meta las usa en la revisión)
          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: Estado de publicación
        endpoint_uri:
          type: string
          nullable: true
          description: >-
            URL de tu endpoint, obligatoria solo para los flows con
            `data_exchange`
        flow_json:
          type: string
          description: Definición de las pantallas en JSON, enviada como **string**
        validation_errors:
          type: array
          description: Incidencias de validación devueltas por Meta
          items:
            type: object
            properties:
              key:
                type: string
                description: Clave de la incidencia
              value:
                type: string
                description: Detalle de la incidencia
    Error:
      type: object
      properties:
        error:
          type: integer
        message:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````