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

# Merge contacts

> Merge a source contact into this contact. All channels from the source contact will be moved to the target contact, and the source contact will be marked as merged.



## OpenAPI

````yaml /openapi.json post /v1/contacts/{contactId}/merge
openapi: 3.0.3
info:
  title: Zavu Unified Messaging Layer API
  version: 0.2.0
  description: >
    Unified multi-channel messaging API for Zavu.


    Supported channels:

    - **SMS**: Simple text messages

    - **WhatsApp**: Rich messaging with media, buttons, lists, CTA URL buttons,
    and templates

    - **Telegram**: Bot messaging with text, media, and interactive elements

    - **Email**: Transactional emails via Amazon SES


    Design goals:

    - Simple `send()` entrypoint for developers

    - Project-level authentication via Bearer token

    - Support for all WhatsApp message types (text, image, video, audio,
    document, sticker, location, contact, buttons, list, cta_url, reaction,
    template)

    - If a non-text message type is sent, WhatsApp channel is used automatically

    - 24-hour WhatsApp conversation window enforcement

    - Universal `to` field accepts phone numbers (E.164), email addresses, or
    numeric chat IDs (Telegram/Instagram)
servers:
  - url: https://api.zavu.dev
security:
  - bearerAuth: []
paths:
  /v1/contacts/{contactId}/merge:
    post:
      summary: Merge contacts
      description: >-
        Merge a source contact into this contact. All channels from the source
        contact will be moved to the target contact, and the source contact will
        be marked as merged.
      operationId: mergeContacts
      parameters:
        - $ref: '#/components/parameters/ContactIdParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MergeContactsRequest'
            example:
              sourceContactId: jx7xyz789
      responses:
        '200':
          description: Contacts merged. Returns the updated target contact.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Contact'
        '400':
          description: Invalid request (e.g., cannot merge contact with itself).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Target or source contact not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  parameters:
    ContactIdParam:
      name: contactId
      in: path
      required: true
      schema:
        type: string
  schemas:
    MergeContactsRequest:
      type: object
      description: Request body to merge contacts.
      required:
        - sourceContactId
      properties:
        sourceContactId:
          type: string
          description: >-
            ID of the contact to merge into the target contact. The source
            contact will be marked as merged.
    Contact:
      type: object
      required:
        - id
        - availableChannels
        - verified
        - metadata
        - createdAt
      properties:
        id:
          type: string
        displayName:
          type: string
          description: Display name for the contact.
          example: John Doe
        phoneNumber:
          type: string
          description: >-
            DEPRECATED: Use primaryPhone instead. Primary phone number in E.164
            format.
          example: '+56912345678'
        primaryPhone:
          type: string
          description: Primary phone number in E.164 format.
          example: '+56912345678'
        primaryEmail:
          type: string
          format: email
          description: Primary email address.
          example: john@example.com
        countryCode:
          type: string
          example: CL
        profileName:
          type: string
          nullable: true
          description: >-
            Contact's WhatsApp profile name. Only available for WhatsApp
            contacts.
          example: John Doe
        availableChannels:
          type: array
          items:
            type: string
          description: List of available messaging channels for this contact.
        defaultChannel:
          type: string
          enum:
            - sms
            - whatsapp
            - telegram
            - email
            - instagram
            - voice
          description: Preferred channel for this contact.
        verified:
          type: boolean
          description: Whether this contact has been verified.
        channels:
          type: array
          items:
            $ref: '#/components/schemas/ContactChannel'
          description: All communication channels for this contact.
        suggestedMergeWith:
          type: string
          description: ID of a contact suggested for merging.
        metadata:
          type: object
          additionalProperties:
            type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          example: invalid_request
        message:
          type: string
          example: Phone number is invalid
        details:
          type: object
          additionalProperties: true
    ContactChannel:
      type: object
      description: A communication channel for a contact.
      required:
        - id
        - channel
        - identifier
        - isPrimary
        - verified
        - createdAt
      properties:
        id:
          type: string
        channel:
          type: string
          enum:
            - sms
            - whatsapp
            - email
            - telegram
            - voice
          description: Channel type.
        identifier:
          type: string
          description: Channel identifier (phone number or email address).
          example: '+14155551234'
        countryCode:
          type: string
          description: ISO country code for phone numbers.
          example: US
        label:
          type: string
          description: Optional label for the channel.
          example: work
        isPrimary:
          type: boolean
          description: Whether this is the primary channel for its type.
        verified:
          type: boolean
          description: Whether this channel has been verified.
        metrics:
          type: object
          description: Delivery metrics for this channel.
          properties:
            successCount:
              type: integer
            failureCount:
              type: integer
            totalAttempts:
              type: integer
            avgDeliveryTimeMs:
              type: number
            lastSuccessAt:
              type: string
              format: date-time
        lastInboundAt:
          type: string
          format: date-time
          description: Last time a message was received on this channel.
        metadata:
          type: object
          additionalProperties:
            type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````