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

# Criar nova campanha



## OpenAPI

````yaml https://api.nuvia.ai/api/docs/user-json post /v1/campaigns
openapi: 3.0.0
info:
  title: Nuvia API - Empresa
  description: Documentação da API para empresas
  version: '1.0'
  contact: {}
servers:
  - url: https://api.nuvia.ai
security: []
tags:
  - name: auth
    description: Autenticação
paths:
  /v1/campaigns:
    post:
      tags:
        - campaigns
      summary: Criar nova campanha
      operationId: CampaignController_create
      parameters:
        - name: x-company-id
          in: header
          description: >-
            Identificador da empresa-alvo. Obrigatório apenas para API Keys
            globais (type=global). Ignorado para API Keys de empresa e usuários
            humanos.
          required: false
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCampaignDto'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CampaignEntity'
      security:
        - JWT-auth: []
components:
  schemas:
    CreateCampaignDto:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 100
        description:
          type: string
          maxLength: 500
        channel_type:
          type: string
          enum:
            - WAP_AUTO_CLOSER
            - WEB_V2
            - EVOLUTION_API
            - LINKEDIN
            - MULTI_CHANNEL
        trigger_type:
          type: string
          enum:
            - MANUAL
            - SCHEDULED
            - RECURRING
            - EXTERNAL_TRIGGER
        trigger_config:
          type: object
          default: {}
          properties:
            trigger_event:
              type: string
              enum:
                - CONTACT_CREATED
                - CONTACT_UPDATED
                - DEAL_CREATED
                - DEAL_UPDATED
                - LEAD_CREATED
                - LEAD_UPDATED
            trigger_events:
              minItems: 1
              type: array
              items:
                type: string
                enum:
                  - CONTACT_CREATED
                  - CONTACT_UPDATED
                  - DEAL_CREATED
                  - DEAL_UPDATED
                  - LEAD_CREATED
                  - LEAD_UPDATED
            scheduled_at:
              type: string
              format: date-time
              pattern: >-
                ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
            recurring_pattern:
              type: string
            recurring_timezone:
              type: string
            recurring_end_at:
              type: string
              format: date-time
              pattern: >-
                ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        audience_config:
          type: object
          properties:
            type:
              type: string
              enum:
                - STATIC
                - DYNAMIC
                - EXTERNAL
                - LIST
                - FUNNEL
            filters:
              type: object
              properties:
                agent_step_ids:
                  type: array
                  items:
                    type: string
                agent_ids:
                  type: array
                  items:
                    type: string
                conversation_status:
                  type: array
                  items:
                    type: string
                user_ids:
                  type: array
                  items:
                    type: string
            match_criteria:
              type: object
              properties:
                match_logic:
                  default: AND
                  description: Lógica de combinação entre grupos
                  type: string
                  enum:
                    - AND
                    - OR
                filter_groups:
                  minItems: 1
                  type: array
                  items:
                    type: object
                    properties:
                      logic:
                        type: string
                        enum:
                          - AND
                          - OR
                        description: Lógica de combinação das condições
                      conditions:
                        minItems: 1
                        type: array
                        items:
                          anyOf:
                            - type: object
                              properties:
                                field_id:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    ID do campo personalizado ou path fixo (ex:
                                    contact.name, contact.email)
                                operator:
                                  type: string
                                  enum:
                                    - eq
                                    - neq
                                    - gt
                                    - gte
                                    - lt
                                    - lte
                                    - contains
                                    - not_contains
                                    - starts_with
                                    - ends_with
                                    - is_empty
                                    - is_not_empty
                                    - in
                                    - not_in
                                  description: Operador de comparação
                                value:
                                  description: Valor para comparação
                                  anyOf:
                                    - type: string
                                      nullable: true
                                    - type: number
                                      nullable: true
                                    - type: boolean
                                      nullable: true
                                    - type: array
                                      items:
                                        type: string
                                      nullable: true
                              required:
                                - field_id
                                - operator
                            - type: object
                              properties:
                                logic:
                                  type: string
                                  enum:
                                    - AND
                                    - OR
                                  description: Lógica de combinação das condições
                                conditions:
                                  minItems: 1
                                  type: array
                                  items:
                                    anyOf:
                                      - type: object
                                        properties:
                                          field_id:
                                            type: string
                                            minLength: 1
                                            description: >-
                                              ID do campo personalizado ou path fixo
                                              (ex: contact.name, contact.email)
                                          operator:
                                            type: string
                                            enum:
                                              - eq
                                              - neq
                                              - gt
                                              - gte
                                              - lt
                                              - lte
                                              - contains
                                              - not_contains
                                              - starts_with
                                              - ends_with
                                              - is_empty
                                              - is_not_empty
                                              - in
                                              - not_in
                                            description: Operador de comparação
                                          value:
                                            description: Valor para comparação
                                            anyOf:
                                              - type: string
                                                nullable: true
                                              - type: number
                                                nullable: true
                                              - type: boolean
                                                nullable: true
                                              - type: array
                                                items:
                                                  type: string
                                                nullable: true
                                        required:
                                          - field_id
                                          - operator
                                      - type: object
                                        properties:
                                          logic:
                                            type: string
                                            enum:
                                              - AND
                                              - OR
                                            description: Lógica de combinação das condições
                                          conditions:
                                            minItems: 1
                                            type: array
                                            items:
                                              anyOf:
                                                - type: object
                                                  properties:
                                                    field_id:
                                                      type: string
                                                      minLength: 1
                                                      description: >-
                                                        ID do campo personalizado ou path fixo
                                                        (ex: contact.name, contact.email)
                                                    operator:
                                                      type: string
                                                      enum:
                                                        - eq
                                                        - neq
                                                        - gt
                                                        - gte
                                                        - lt
                                                        - lte
                                                        - contains
                                                        - not_contains
                                                        - starts_with
                                                        - ends_with
                                                        - is_empty
                                                        - is_not_empty
                                                        - in
                                                        - not_in
                                                      description: Operador de comparação
                                                    value:
                                                      description: Valor para comparação
                                                      anyOf:
                                                        - type: string
                                                          nullable: true
                                                        - type: number
                                                          nullable: true
                                                        - type: boolean
                                                          nullable: true
                                                        - type: array
                                                          items:
                                                            type: string
                                                          nullable: true
                                                  required:
                                                    - field_id
                                                    - operator
                                                - type: object
                                                  properties:
                                                    logic:
                                                      type: string
                                                      enum:
                                                        - AND
                                                        - OR
                                                      description: Lógica de combinação das condições
                                                    conditions:
                                                      minItems: 1
                                                      type: array
                                                      items:
                                                        anyOf:
                                                          - type: object
                                                            properties:
                                                              field_id:
                                                                type: string
                                                                minLength: 1
                                                                description: >-
                                                                  ID do campo personalizado ou path fixo
                                                                  (ex: contact.name, contact.email)
                                                              operator:
                                                                type: string
                                                                enum:
                                                                  - eq
                                                                  - neq
                                                                  - gt
                                                                  - gte
                                                                  - lt
                                                                  - lte
                                                                  - contains
                                                                  - not_contains
                                                                  - starts_with
                                                                  - ends_with
                                                                  - is_empty
                                                                  - is_not_empty
                                                                  - in
                                                                  - not_in
                                                                description: Operador de comparação
                                                              value:
                                                                description: Valor para comparação
                                                                anyOf:
                                                                  - type: string
                                                                    nullable: true
                                                                  - type: number
                                                                    nullable: true
                                                                  - type: boolean
                                                                    nullable: true
                                                                  - type: array
                                                                    items: {}
                                                                    nullable: true
                                                            required:
                                                              - field_id
                                                              - operator
                                                          - type: object
                                                            properties:
                                                              logic:
                                                                type: string
                                                                enum:
                                                                  - AND
                                                                  - OR
                                                                description: Lógica de combinação das condições
                                                              conditions:
                                                                minItems: 1
                                                                type: array
                                                                items:
                                                                  anyOf:
                                                                    - {}
                                                                    - {}
                                                            required:
                                                              - logic
                                                              - conditions
                                                  required:
                                                    - logic
                                                    - conditions
                                        required:
                                          - logic
                                          - conditions
                              required:
                                - logic
                                - conditions
                    required:
                      - logic
                      - conditions
              required:
                - filter_groups
            contact_ids:
              type: array
              items:
                type: string
            lists:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    minLength: 1
                  views:
                    type: array
                    items:
                      type: string
                required:
                  - id
            funnel_config:
              type: object
              properties:
                agent_id:
                  type: string
                  minLength: 1
                agent_step_id:
                  type: string
              required:
                - agent_id
          required:
            - type
        behavior_config:
          type: object
          properties:
            ignore_business_hours:
              type: boolean
        linkedin_config:
          type: object
          properties:
            first_step_as_invitation:
              type: boolean
            send_invite_note:
              type: boolean
            invite_note:
              type: string
        sender_config:
          type: object
          properties:
            linkedin_inbox_id:
              type: string
              minLength: 1
            whatsapp_inbox_id:
              type: string
              minLength: 1
      required:
        - name
        - channel_type
        - trigger_type
        - audience_config
    CampaignEntity:
      type: object
      properties:
        _id:
          $ref: '#/components/schemas/ObjectId'
        company:
          type: object
        name:
          type: string
        description:
          type: string
        channel_type:
          type: object
        trigger_type:
          type: string
          enum:
            - MANUAL
            - SCHEDULED
            - RECURRING
            - EXTERNAL_TRIGGER
        trigger_config:
          type: object
        audience_config:
          type: object
        behavior_config:
          type: object
        linkedin_config:
          type: object
        sender_config:
          type: object
        status:
          enum:
            - DRAFT
            - ACTIVE
            - PAUSED
            - COMPLETED
            - ARCHIVED
          type: string
        metrics:
          type: object
        last_execution_at:
          format: date-time
          type: string
        createdAt:
          format: date-time
          type: string
        updatedAt:
          format: date-time
          type: string
      required:
        - _id
        - company
        - name
        - channel_type
        - trigger_type
        - trigger_config
        - audience_config
        - status
        - metrics
    ObjectId:
      type: object
      properties: {}
  securitySchemes:
    JWT-auth:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: Token JWT de autenticação

````