Insert or Update Contact

Creates a new contact or updates an existing contact based on the phone number.

Endpoint

POST /api/contacts/insertOrUpdate

Base URL

https://api.rampwin.com

Description

This API performs an upsert operation:

  • If the contact does not exist → creates a new contact
  • If the contact already exists → updates the existing contact

This helps avoid duplicate contacts and simplifies contact management.


Authentication

This API supports:

  • API Key

Headers

HeaderTypeRequiredDescription
Content-TypestringYesapplication/json
x-api-keystringYesYour Rampwin API key
CookiestringYesAWS load balancer session cookie

Query Parameters

ParameterTypeRequiredDescription
channel_idstringYesWhatsApp channel ID

Request Body

Core Fields

FieldTypeRequiredDescription
phone_numberstringYesContact phone number (with country code)
first_namestringNoFirst name
last_namestringNoLast name
emailstringNoEmail address

Custom Attributes

You can also pass additional fields dynamically (same as Create Contact), such as:

  • city
  • state
  • plan_status
  • tags
  • timezone

Example Request

curl --location 'https://api.rampwin.com/api/contacts/insertOrUpdate?channel_id=YOUR_CHANNEL_ID' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--header 'Cookie: AWSALB=XXXXX; AWSALBCORS=XXXXX' \
--data-raw '{
  "phone_number": "+11234567890",
  "first_name": "John",
  "last_name": "Doe",
  "email": "[email protected]"
}'

Response

Success (200)

{
  "success": true,
  "message": "Contact inserted or updated successfully",
  "data": {
    "_id": "contact_id",
    "phone_number": "+11234567890"
  }
}

Error (400)

{
  "success": false,
  "message": "Validation error"
}

Business Logic Notes

  • Contact uniqueness is based on phone_number + channel_id
  • Existing contact fields will be overwritten if provided
  • Fields not provided will remain unchanged
  • Prevents duplicate contact creation

Common Errors

ErrorDescription
Validation errorMissing or invalid fields
UnauthorizedInvalid API key
Invalid channelChannel ID does not exist