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

# Criar campanha

> Cadastra um novo campanha.



## OpenAPI

````yaml /contacts-api/api-reference/openapi-contacts.json post /v1/campaigns
openapi: 3.0.3
info:
  title: Notifique API Contatos, tags e audiência
  description: >-
    API para **CRUD de contatos**, **tags**, **tópicos**, **segmentos** e
    **campanhas** (template + audiência + canais).


    **Contato:** pelo menos um de **phone** ou **email** (únicos por workspace).
    **Idiomas:** `languages` é um array de códigos BCP-47 permitidos (lista em
    **`GET /v1/meta/contact-locales`**); ordem = prioridade. **Telegram:** use
    **`telegramLinks`** (`instanceId` + `peer`) para várias instâncias Telegram
    no mesmo workspace; **`telegramPeer`** permanece como atalho legado
    (preenche a ligação na **instância Telegram padrão** do workspace). Na
    campanha, o peer usado é o da **`telegramInstanceId`** da campanha (ou
    default), com *fallback* para `telegramPeer`.


    **Campanhas:** `channels` pode incluir `whatsapp`, `sms`, `email`,
    `telegram`. Cada canal listado deve estar **habilitado no template**.
    **`instanceId`** = WhatsApp; **`telegramInstanceId`** = Telegram.


    **WhatsApp cartão:** `POST /v1/whatsapp/messages` com `type: "contact"` e
    `payload.contactId`.


    **Autenticação:** `Authorization: Bearer sk_live_xxxxx` ou `x-api-key`.


    **Escopos:** `contacts:*`, `tags:*`, `topics:*`, `segments:*`, `campaigns:*`
    (inclui `campaigns:run`).


    **Campanhas (extras):** `POST .../cancel` (DRAFT/SCHEDULED), `GET .../stats`
    e `GET .../recipients` (escopos update/read). Run devolve `runId`. Sending
    Pool WhatsApp: painel.
  version: 1.0.0
servers:
  - url: https://api.notifique.dev
    description: Produção
security:
  - ntfContactBearerAuth: []
  - ntfContactApiKeyHeader: []
tags:
  - name: Contatos
    description: CRUD de contatos do workspace (phone ou email; tags)
  - name: Tags
    description: Tags (rótulos) para vincular a contatos
  - name: Tópicos
    description: Tópicos de comunicação (marketing / opt-in por tema)
  - name: Segmentos
    description: >-
      Segmentos de audiencia (DSL v1). Regras: tag, property, contactField,
      topic, receiveMarketing. Escopos segments:read|create|update|delete.
  - name: Campanhas
    description: Campanhas multicanal com template; execução via POST .../run
paths:
  /v1/campaigns:
    post:
      tags:
        - Campanhas
      summary: Criar campanha
      description: Cadastra um novo campanha.
      operationId: ntfContact_postV1Campaigns
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NtfContact_CampaignCreate'
            example:
              name: Black Friday SMS+WA
              templateId: tpl_abc123
              channels:
                - whatsapp
                - sms
              segmentId: seg_xyz
              instanceId: wa_inst_1
              variables:
                discount: '10'
                campaign_name: bf_2026
      responses:
        '200':
          description: Criada.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfContact_CampaignOneResponse'
        '400':
          description: Erro
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfContact_ErrorResponse'
        '401':
          description: Erro
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfContact_ErrorResponse'
        '402':
          description: Erro
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfContact_ErrorResponse'
        '403':
          description: Erro
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfContact_ErrorResponse'
        '503':
          description: >-
            Serviço indisponível (ex.: resolução de instância Telegram retornou
            503).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfContact_ErrorResponse'
components:
  schemas:
    NtfContact_CampaignCreate:
      type: object
      required:
        - name
        - templateId
        - channels
      description: >-
        **templateId** obrigatório. **channels** ⊆ enabledChannels do template
        (whatsapp, sms, email, telegram). Com **scheduledFor** (≥ ~2 min),
        status inicial SCHEDULED. Sending Pool WhatsApp: configure no **painel**
        (a API v1 de create ainda não envia sendingPoolId).
      properties:
        name:
          type: string
          maxLength: 128
        templateId:
          type: string
          minLength: 1
          description: Template cujo conjunto de canais habilitados restringe **channels**.
        channels:
          type: array
          items:
            $ref: '#/components/schemas/NtfContact_CampaignChannel'
          minItems: 1
        segmentId:
          type: string
        audienceContactIds:
          type: array
          items:
            type: string
        scheduledFor:
          type: string
          format: date-time
          description: ISO-8601. Mínimo ~2 minutos no futuro → status SCHEDULED.
        instanceId:
          type: string
          nullable: true
          description: >-
            Instância WhatsApp (obrigatória na prática se incluir **whatsapp** e
            não houver padrão no workspace).
        telegramInstanceId:
          type: string
          nullable: true
          description: >-
            Instância Telegram (obrigatória na prática se incluir **telegram** e
            não houver padrão no workspace).
        fromEmail:
          type: string
          nullable: true
        variables:
          type: object
          additionalProperties:
            type: string
          description: Mesclado por cima das propriedades do contato no render do template.
    NtfContact_CampaignOneResponse:
      type: object
      properties:
        success:
          type: boolean
        data:
          $ref: '#/components/schemas/NtfContact_Campaign'
    NtfContact_ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          description: 'Rótulo HTTP do erro (ex.: Unauthorized, Bad Request, Not Found).'
        message:
          type: string
          description: >-
            Mensagem legível para exibir ao usuário (localizada via
            Accept-Language / x-locale quando aplicável).
        code:
          type: string
          description: >-
            Código estável da API v1 (enum). Sempre presente em erros. Use com o
            status HTTP para decidir retry ou correção. Ver [Respostas de
            erro](/guides/conceitos/resposta-de-erros).
      required:
        - success
        - error
        - message
        - code
    NtfContact_CampaignChannel:
      type: string
      description: >-
        Canal na campanha (create/update): `whatsapp`, `sms`, `email`,
        `telegram`. Deve ser subconjunto dos canais habilitados no template.
        Templates podem habilitar RCS/Push/voz; a campanha via API/painel usa
        estes quatro.
      enum:
        - whatsapp
        - sms
        - email
        - telegram
    NtfContact_Campaign:
      type: object
      description: >-
        Campanha multicanal. **channels** ⊆ canais habilitados do **template**
        (`whatsapp`|`sms`|`email`|`telegram`). Status: DRAFT, SCHEDULED,
        RUNNING, COMPLETED, FAILED, CANCELLED.
      properties:
        id:
          type: string
        name:
          type: string
        status:
          type: string
          enum:
            - DRAFT
            - SCHEDULED
            - RUNNING
            - COMPLETED
            - FAILED
            - CANCELLED
        templateId:
          type: string
          nullable: true
        channels:
          type: array
          items:
            $ref: '#/components/schemas/NtfContact_CampaignChannel'
          description: Subconjunto dos canais ativos no template.
        segmentId:
          type: string
          nullable: true
        audienceContactIds:
          type: array
          items:
            type: string
          nullable: true
        scheduledFor:
          type: string
          format: date-time
          nullable: true
        instanceId:
          type: string
          nullable: true
          description: Instância **WhatsApp** usada quando `whatsapp` ∈ channels.
        telegramInstanceId:
          type: string
          nullable: true
          description: Instância **Telegram** (bot) usada quando `telegram` ∈ channels.
        fromEmail:
          type: string
          nullable: true
        variables:
          type: object
          additionalProperties: true
          nullable: true
        startedAt:
          type: string
          format: date-time
          nullable: true
        completedAt:
          type: string
          format: date-time
          nullable: true
        errorMessage:
          type: string
          nullable: true
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        audienceCount:
          type: integer
          nullable: true
          description: Contatos na última execução
        lastRunAt:
          type: string
          format: date-time
          nullable: true
  securitySchemes:
    ntfContactBearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'Authorization: Bearer sk_live_xxxxx'
    ntfContactApiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: 'x-api-key: sk_live_xxxxx'

````