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

# Encaminhar mensagem

> Encaminha a mensagem para outro destinatário

## Conceituação

Encaminha a mensagem para outro destinatário.

> [!NOTE]
>
> A resposta traz o `messageId` da mensagem nova, o mesmo que chega no webhook.


## OpenAPI

````yaml pt/message-actions/openapi.json POST /v1/channels/{channelId}/messages/{messageId}/forward
openapi: 3.1.0
info:
  title: Omni Z-API - Ações em mensagem
  version: 1.0.0
servers:
  - url: https://api.omni.z-api.io
security:
  - bearerAuth: []
paths:
  /v1/channels/{channelId}/messages/{messageId}/forward:
    post:
      tags:
        - Ações em mensagem
      summary: Encaminhar mensagem
      description: Encaminha a mensagem para outro destinatário.
      operationId: forwardMessage
      parameters:
        - name: channelId
          in: path
          required: true
          description: Channel id
          schema:
            type: string
            example: 58907809F0964E998D36C87F10EBA60C
        - name: messageId
          in: path
          required: true
          description: Id da mensagem no Omni (o mesmo que volta no envio e no webhook).
          schema:
            type: string
            example: 01A1EA9883087E9EB1E0D7432E185E2B
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - recipient
              properties:
                recipient:
                  type: object
                  required:
                    - identifier
                  properties:
                    identifier:
                      type: string
            example:
              recipient:
                identifier: '5544936181389'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  messageId:
                    type: string
              example:
                messageId: 01A1EEE46ACE7CABA47824FD91E490DB
        '400':
          description: recipient.identifier é obrigatório
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: invalid_request
                field: recipient.identifier
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/IpNotAllowed'
        '404':
          description: Canal ou mensagem não encontrados
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                messageNotFound:
                  summary: Mensagem inexistente ou de outro canal
                  value:
                    code: NOT_FOUND
                    subCode: MESSAGE_NOT_FOUND
                    message: 'Message not found: 01A1EA9883087E9EB1E0D7432E185E2B'
                instanceNotFound:
                  summary: Canal inexistente
                  value:
                    error: instance not found
        '422':
          description: >-
            Ação recusada. Trate pelo `subCode` (ou pelo `error`, quando não há
            `subCode`); o `message` é para leitura e pode mudar.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                notSupported:
                  summary: 'Ação sem suporte no tipo do canal (ex.: Meta)'
                  value:
                    code: BUSINESS_RULE_VIOLATION
                    subCode: FORWARD_NOT_SUPPORTED
                    message: >-
                      Forwarding messages is not supported for META_WHATSAPP
                      channels, because the provider of this channel type cannot
                      forward a message. Only WhatsApp Web (Z_API_WHATSAPP)
                      channels can; on this channel, send the content as a new
                      message instead
                channelDisconnected:
                  summary: Canal desconectado
                  value:
                    code: BUSINESS_RULE_VIOLATION
                    subCode: CHANNEL_DISCONNECTED
                    message: >-
                      Channel is disconnected: the message was not forwarded
                      because the WhatsApp Web channel is not connected right
                      now. Reconnect the channel by reading a new QR code and
                      forward again. See
                      https://developer.omni.z-api.io/en/connect/whatsapp-web
                channelInstanceNotProvisioned:
                  summary: Instância Z-API do canal não provisionada
                  value:
                    code: BUSINESS_RULE_VIOLATION
                    subCode: INSTANCE_NOT_PROVISIONED
                    message: The Z-API instance of this channel is not provisioned
                messageWithoutProviderId:
                  summary: 'Mensagem ainda sem id no WhatsApp (ex.: não entregue)'
                  value:
                    code: BUSINESS_RULE_VIOLATION
                    subCode: MESSAGE_WITHOUT_PROVIDER_ID
                    message: Message has no provider id
                chatNotSupported:
                  summary: Conversa que não é telefone, grupo nem @lid
                  value:
                    code: BUSINESS_RULE_VIOLATION
                    subCode: CHAT_NOT_SUPPORTED
                    message: >-
                      This action is not supported for the chat of this message.
                      Only messages of individual chats, groups and LID chats
                      can be deleted, forwarded, pinned or answered; this one
                      does not belong to one of these chats. Use a message from
                      an individual chat, a group or a LID chat.
                instanceNotProvisioned:
                  summary: Instância não provisionada
                  value:
                    error: instance is not provisioned
                subscriptionInactive:
                  summary: Assinatura inativa
                  value:
                    error: instance subscription is not active
                workspaceBlocked:
                  summary: Workspace bloqueado
                  value:
                    error: You are blocked, contact support.
                actionUnavailable:
                  summary: Serviço que executa a ação ainda não atende o canal
                  value:
                    error: >-
                      Forwarding messages is not available for this channel
                      right now. The service that runs this action does not
                      serve this channel yet. Check GET
                      /v1/channels/{channelId}/messages/capabilities and try
                      again later; if it persists, contact support.
        '502':
          description: Falha no serviço de mensagens
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                failed:
                  summary: Falha no serviço de mensagens
                  value:
                    error: Message forwarding failed
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
        field:
          type: string
        code:
          type: string
        subCode:
          type: string
        message:
          type: string
  responses:
    Unauthorized:
      description: Credencial recusada (API Omni)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Authorization invalid
            message: >-
              Authorization invalid: the Authorization header is missing or
              empty. Send the workspace Secret Key as "Authorization: Bearer
              <secret-key>". See
              https://developer.omni.z-api.io/en/authentication
      headers:
        WWW-Authenticate:
          description: Sempre `Bearer`.
          schema:
            type: string
          example: Bearer
    IpNotAllowed:
      description: IP fora da lista (API Omni)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: ip_not_allowed
            message: >-
              203.0.113.10 not allowed: this workspace only accepts API calls
              from the IPs on its allow list. The workspace Owner can add this
              IP under Administration > Security > IP Restriction in the panel
              (changes take up to 10 minutes to apply), or call from an allowed
              IP. See https://developer.omni.z-api.io/en/security/ip-restriction
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Secret Key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.