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

# Create or Update a Contact

> Finds the contact by phone, else by email, and creates it when there is none. Sending the same body again changes nothing. Attributes are merged; labels and lists are added, never removed. Fires the same workflows as the app (contact created / updated).



## OpenAPI

````yaml POST /api/pub/crm/contacts
openapi: 3.1.0
info:
  title: AdsEra REST API
  description: >-
    Welcome to the AdsEra REST API. Use our API to integrate powerful,
    multi-channel communication (Email and WhatsApp) directly into your
    applications. Automate transactional messages, trigger marketing campaigns,
    manage your audience, and track performance programmatically.
  contact:
    name: Shubham
    email: shubham@adsera.in
  version: 1.0.0
servers:
  - url: https://app.adsera.in
    description: Production Server
security:
  - AppIdAuth: []
    AppSecretAuth: []
paths:
  /api/pub/crm/contacts:
    post:
      tags:
        - 'CRM: Contacts'
      summary: Create or Update a Contact
      description: >-
        Finds the contact by phone, else by email, and creates it when there is
        none. Sending the same body again changes nothing. Attributes are
        merged; labels and lists are added, never removed. Fires the same
        workflows as the app (contact created / updated).
      operationId: crmUpsertContact
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CrmContactUpsert'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      contact:
                        $ref: '#/components/schemas/CrmContact'
                      created:
                        type: boolean
        '400':
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CrmError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CrmError'
        '409':
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CrmError'
        '429':
          description: >-
            Rate limit: 120 requests a minute per app. See the Retry-After
            header.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CrmError'
components:
  schemas:
    CrmContactUpsert:
      type: object
      description: Send `phone` or `email` (or both).
      properties:
        phone:
          type: string
          example: +91 98765 43210
          description: With country code. Everything but digits is dropped.
        email:
          type: string
          format: email
        attributes:
          type: object
          additionalProperties: true
          example:
            FIRSTNAME: Priya
          description: >-
            Attribute title → value. Titles come from List Attributes; an
            unknown title is a 400. `null` or `""` clears a value.
        labels:
          type: array
          items:
            type: string
          example:
            - VIP
          description: Label names or ids. Missing names are created.
        lists:
          type: array
          items:
            type: string
          description: List names or ids. Lists must already exist.
        subscription:
          type: object
          properties:
            whatsapp:
              type: boolean
            email:
              type: boolean
            sms:
              type: boolean
    CrmContact:
      type: object
      properties:
        _id:
          type: string
          example: 6650f1c2a1b2c3d4e5f60718
        phone:
          type: string
          example: '919876543210'
        email:
          type: string
          example: priya@example.com
        attributes:
          type: object
          additionalProperties: true
          example:
            FIRSTNAME: Priya
            CITY: Jaipur
          description: Custom fields by title.
        labels:
          type: array
          items:
            type: object
            properties:
              _id:
                type: string
                example: 6650f1c2a1b2c3d4e5f60718
              title:
                type: string
        lists:
          type: array
          items:
            type: object
            properties:
              _id:
                type: string
                example: 6650f1c2a1b2c3d4e5f60718
              name:
                type: string
        subscription:
          type: object
          properties:
            whatsapp:
              type: boolean
            email:
              type: boolean
            sms:
              type: boolean
        assignTo:
          type: object
          nullable: true
          properties:
            _id:
              type: string
              example: 6650f1c2a1b2c3d4e5f60718
            firstName:
              type: string
            lastName:
              type: string
            email:
              type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    CrmError:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          example: Contact not found
    ErrorResponse:
      type: object
      properties:
        status:
          type: integer
          example: 500
        success:
          type: boolean
          example: false
        error:
          type: string
          example: Internal Server Error!
  responses:
    Unauthorized:
      description: Unauthorized. The API keys are missing or invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: 401
            success: false
            error: 'Unauthorized: Please provide valid API credentials.'
  securitySchemes:
    AppIdAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: Your application's unique ID.
    AppSecretAuth:
      type: apiKey
      in: header
      name: x-api-secret
      description: Your application's secret key.

````

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