> ## 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 instância Instagram

> Conecta uma conta Instagram ao seu workspace — o perfil por onde você envia e recebe DMs.

Escolha o exemplo:

- **Não oficial: login com senha** — usuário e senha do Instagram (aceite os termos).
- **Não oficial: retomada com 2FA** — quando a Meta pede código de verificação.
- **Oficial: link para o cliente** — envia um link; o cliente faz login Meta e vincula a conta.
- **Oficial: credenciais Meta na hora** — cadastro Meta já feito no navegador.
- **Oficial: token Meta próprio (BYOK)** — token, Page ID e Instagram Business ID que você já possui.

Escopo: **instagram:instances:create**.



## OpenAPI

````yaml /instagram-api/api-reference/openapi-instagram.json post /v1/instagram/instances
openapi: 3.0.3
info:
  title: Notifique API — Instagram
  version: 1.0.0
  description: >-
    Envie DMs Instagram e gerencie conexões. Autentique com `Authorization:
    Bearer sk_live_...` ou `x-api-key`.
servers:
  - url: https://api.notifique.dev
    description: Produção
security:
  - ntfIgBearerAuth: []
  - ntfIgApiKeyHeader: []
tags:
  - name: 'Instagram: instâncias'
    description: Criar, listar, desconectar e remover conexões Instagram.
  - name: 'Instagram: mensagens'
    description: Enviar, listar, editar, cancelar, apagar e inbound.
  - name: 'Instagram: comentários'
    description: Listar, responder e moderar comentários.
paths:
  /v1/instagram/instances:
    post:
      tags:
        - 'Instagram: instâncias'
      summary: Criar instância Instagram
      description: >-
        Conecta uma conta Instagram ao seu workspace — o perfil por onde você
        envia e recebe DMs.


        Escolha o exemplo:


        - **Não oficial: login com senha** — usuário e senha do Instagram
        (aceite os termos).

        - **Não oficial: retomada com 2FA** — quando a Meta pede código de
        verificação.

        - **Oficial: link para o cliente** — envia um link; o cliente faz login
        Meta e vincula a conta.

        - **Oficial: credenciais Meta na hora** — cadastro Meta já feito no
        navegador.

        - **Oficial: token Meta próprio (BYOK)** — token, Page ID e Instagram
        Business ID que você já possui.


        Escopo: **instagram:instances:create**.
      operationId: ntfIg_createInstance
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NtfIg_CreateInstanceBody'
            examples:
              unofficialPassword:
                summary: 'Não oficial: login com senha'
                description: Conexão por usuário e senha. Obrigatório aceitar os termos.
                value:
                  name: Instagram atendimento
                  acceptInstagramTerms: true
                  auth:
                    mode: password
                    username: seu_usuario
                    password: sua_senha
                  expectedUsername: seu_usuario
              unofficialTwoFactor:
                summary: 'Não oficial: retomada com 2FA'
                description: >-
                  Quando o Instagram pede código de verificação após
                  usuário/senha.
                value:
                  name: Instagram atendimento
                  acceptInstagramTerms: true
                  auth:
                    mode: password
                    username: seu_usuario
                    password: sua_senha
                    verificationCode: '123456'
              officialLinkForCustomer:
                summary: 'Oficial: link para o cliente conectar Meta'
                description: O cliente abre o link e conclui o login Meta.
                value:
                  name: Instagram oficial
                  mode: OFFICIAL
                  generateShareableLink: true
              officialWithMetaCredentials:
                summary: 'Oficial: credenciais Meta na hora'
                description: Use quando o Facebook Login já foi concluído no navegador.
                value:
                  name: Instagram oficial
                  mode: OFFICIAL
                  metaEmbeddedCode: CODE_DO_EMBEDDED_SIGNUP
                  facebookPageId: '123456789012345'
                  igBusinessAccountId: '17841400000000000'
              officialByok:
                summary: 'Oficial: token Meta próprio (BYOK)'
                description: Linha oficial com token e IDs da sua conta Meta.
                value:
                  name: Instagram BYOK
                  mode: OFFICIAL_BYOK
                  metaAccessToken: EAAG...
                  facebookPageId: '123456789012345'
                  igBusinessAccountId: '17841400000000000'
      responses:
        '200':
          description: Instância criada (ACTIVE ou PENDING com shareableLink).
          content:
            application/json:
              examples:
                active:
                  summary: Conexão ACTIVE
                  value:
                    success: true
                    data:
                      id: inst_abc
                      name: Instagram atendimento
                      status: ACTIVE
                      mode: UNOFFICIAL
                      username: seu_usuario
                      igUserPk: '17841'
                officialShareable:
                  summary: Draft oficial com link (pending_signup)
                  value:
                    success: true
                    data:
                      id: inst_abc
                      name: Instagram oficial
                      status: PENDING
                      mode: OFFICIAL
                      connectionKind: META_EMBEDDED
                      instagramOfficialCloud: true
                      connection:
                        status: pending_signup
                        message: >-
                          Open shareableLink.hostedUrl for the customer to
                          complete Meta login.
                      shareableLink:
                        hostedUrl: >-
                          https://api.notifique.dev/w/instance-connect/...?token=...
                        embedUrl: >-
                          https://api.notifique.dev/w/embed/instance-connect/...?token=...
                        publicId: ...
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        example: inst_abc
                      name:
                        type: string
                        example: Instagram atendimento
                      status:
                        type: string
                        example: ACTIVE
                      mode:
                        type: string
                        example: UNOFFICIAL
                      username:
                        type: string
                        example: seu_usuario
                      igUserPk:
                        type: string
                        example: '17841'
        '400':
          description: Validação ou login falhou.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfIg_ErrorResponse'
              examples:
                terms:
                  summary: Termos
                  value:
                    success: false
                    error: Bad Request
                    message: 'acceptInstagramTerms: true is required.'
                    code: INSTAGRAM_TERMS_REQUIRED
                login:
                  summary: Login
                  value:
                    success: false
                    error: Bad Request
                    message: Login failed
                    code: INSTAGRAM_LOGIN_FAILED
        '402':
          description: Plano expirado ou suspenso.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfIg_ErrorResponse'
        '403':
          description: Sem escopo ou limite de instâncias do plano.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfIg_ErrorResponse'
        '409':
          description: Conta logada ≠ locked/expected (INSTAGRAM_ACCOUNT_MISMATCH).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfIg_ErrorResponse'
              example:
                success: false
                error: Conflict
                code: INSTAGRAM_ACCOUNT_MISMATCH
                message: >-
                  This Instagram account does not match the account locked to
                  this instance. Create a new instance to use a different
                  account.
                data:
                  id: inst_abc
                  status: PENDING
        '428':
          description: 2FA ou desafio de segurança.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfIg_ErrorResponse'
              examples:
                twoFactor:
                  summary: 2FA
                  value:
                    success: false
                    error: Authentication Required
                    code: INSTAGRAM_TWO_FACTOR_REQUIRED
                    message: Two-factor authentication required
                challenge:
                  summary: Challenge
                  value:
                    success: false
                    error: Authentication Required
                    code: INSTAGRAM_CHALLENGE_REQUIRED
                    message: Security challenge required
                    data:
                      challenge:
                        step_name: verify_code
        '429':
          description: >-
            Muitas criações em paralelo, cooldown de reconexão
            (INSTAGRAM_RECONNECT_COOLDOWN) ou pause por abuso
            (INSTAGRAM_ABUSE_PAUSE). Pode incluir retryAfterSec.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/NtfIg_ErrorResponse'
                  - type: object
                    properties:
                      retryAfterSec:
                        type: integer
                        description: Segundos até poder tentar connect/challenge de novo.
              examples:
                cooldown:
                  summary: Cooldown
                  value:
                    success: false
                    error: Too Many Requests
                    code: INSTAGRAM_RECONNECT_COOLDOWN
                    message: >-
                      Reconnection is temporarily blocked after an involuntary
                      disconnect. Wait before logging in again, or create a new
                      instance.
                    retryAfterSec: 43200
                abuse:
                  summary: Abuse pause
                  value:
                    success: false
                    error: Too Many Requests
                    code: INSTAGRAM_ABUSE_PAUSE
                    message: >-
                      This Instagram account is temporarily paused after an
                      abuse or rate-limit signal.
                    retryAfterSec: 43200
        '503':
          description: Capacidade global de conexões cheia.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfIg_ErrorResponse'
components:
  schemas:
    NtfIg_CreateInstanceBody:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          minLength: 2
          example: Instagram atendimento
        acceptInstagramTerms:
          type: boolean
          enum:
            - true
          description: >-
            Obrigatório no modo UNOFFICIAL. Confirma ciência do risco de
            restrição pela plataforma.
        mode:
          type: string
          enum:
            - UNOFFICIAL
            - OFFICIAL
            - OFFICIAL_BYOK
          description: >-
            Tipo de conexão. **UNOFFICIAL** (padrão): login Instagram.
            **OFFICIAL**: linha Meta. **OFFICIAL_BYOK**: token e IDs Meta
            próprios.
          default: UNOFFICIAL
        generateShareableLink:
          type: boolean
          default: false
          description: >-
            Gera um link para outra pessoa concluir a conexão Meta. Omita quando
            você envia credenciais na hora.
        metaAccessToken:
          type: string
          description: Page Access Token (OFFICIAL_BYOK).
        facebookPageId:
          type: string
          description: Facebook Page ID vinculada à conta IG (OFFICIAL_BYOK).
        igBusinessAccountId:
          type: string
          description: Instagram Business Account ID (OFFICIAL_BYOK).
        metaAppSecret:
          type: string
          description: App Secret Meta para validar webhooks (OFFICIAL_BYOK).
        metaEmbeddedCode:
          type: string
          description: >-
            Código do Facebook Login (OFFICIAL). Alternativa:
            generateShareableLink=true.
        expectedUsername:
          type: string
          description: >-
            Opcional. Username esperado no login (conexão não oficial). Se o
            login conectar outra conta, a API responde 409
            (INSTAGRAM_ACCOUNT_MISMATCH).
          example: seu_usuario
        termsVersion:
          type: string
          example: v1
        locale:
          type: string
          example: pt-BR
        timezone:
          type: string
          example: America/Sao_Paulo
        auth:
          type: object
          required:
            - mode
            - username
            - password
          properties:
            mode:
              type: string
              enum:
                - password
            username:
              type: string
            password:
              type: string
              format: password
            verificationCode:
              type: string
              description: Código 2FA quando a API retornou INSTAGRAM_TWO_FACTOR_REQUIRED.
    NtfIg_ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
        message:
          type: string
        code:
          type: string
        details:
          type: object
          additionalProperties: true
        data:
          type: object
          additionalProperties: true
        retryAfterSec:
          type: integer
          description: >-
            Segundos até poder tentar de novo (presente em 429 de cooldown/abuse
            pause).
  securitySchemes:
    ntfIgBearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'Authorization: Bearer sk_live_...'
    ntfIgApiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````