Upsert a contact
Creates or finds an existing contact for whatsapp, web-whatsapp, or webchat channels. For whatsapp/web-whatsapp, the contact is identified by phone number. For webchat, the contact is identified by external_user_id. Optionally assigns an agent, updates metadata, sets a stage, and upserts custom field values on the associated customer.
Overview
Create or update a customer contact with intelligent AI-powered data processing. This endpoint automatically creates the contact if it doesnβt exist, or updates it if it does, along with optional metadata, custom field values, stage assignment, and agent assignment - all in a single request. Supports WhatsApp, Web-WhatsApp, and Webchat channels. For WhatsApp-based channels the contact is identified by phone number; for webchat, the contact is identified by an external user ID you provide.Use Cases
- CRM Data Import: Bulk import customer data from external CRM systems
- Form Submissions: Create customers from web form submissions with flexible data
- E-commerce Integration: Sync customer data from your e-commerce platform
- Lead Capture: Capture leads with any structure of data
- Customer Onboarding: Create customer profiles during signup flows
- Data Migration: Migrate customer data from legacy systems
- Webchat User Tracking: Create contacts for authenticated webchat users with your own external IDs
Authentication
This endpoint requires authentication using an API key. Include your API key in the request header:Request Body
Common Fields
| Field | Type | Required | Description |
|---|---|---|---|
channel | string | Yes | Channel type: "whatsapp", "web-whatsapp", or "webchat" |
contact_name | string | No | Customerβs display name |
contact_email | string | No | Customerβs email address |
stageId | string | No | Pipeline stage UUID to assign the customer to |
agentId | string | No | Team member UUID to assign as responsible agent |
meta_data | object | No | Any additional customer data (AI will structure it) |
custom_field_values | array | No | Custom field values to set on the customer (see below) |
WhatsApp / Web-WhatsApp Fields
Required whenchannel is "whatsapp" or "web-whatsapp":
| Field | Type | Required | Description |
|---|---|---|---|
channel_phone_number | string | Yes | Your WhatsApp channel phone number (the sender) |
contact_phone_number | string | Yes | Customerβs phone number |
Webchat Fields
Required whenchannel is "webchat":
| Field | Type | Required | Description |
|---|---|---|---|
channel_id | string | Yes | UUID of your webchat channel |
external_user_id | string | Yes | Your unique identifier for the user (used to find or create the contact) |
Custom Field Values
Thecustom_field_values array lets you set values on the associated customer using custom field definition keys. Each entry has:
| Field | Type | Required | Description |
|---|---|---|---|
key | string | Yes | The custom field definition key |
value | string | Yes | The value to set |
Response Structure
Returns the created or updated AI contact object:| Field | Type | Description |
|---|---|---|
id | string (UUID) | Unique identifier for the contact |
name | string | Contactβs name |
phone | string | Contactβs phone number |
email | string | Contactβs email |
platform | string | Channel platform (whatsapp, web-whatsapp, webchat) |
client_id | string (UUID) | Your organization ID |
ai_customer_id | string (UUID) | Associated customer profile ID |
created_at | string (ISO) | Contact creation timestamp |
default_stage_id | string (UUID) | Current pipeline stage (if assigned) |
Example Requests
WhatsApp Contact
Webchat Contact
Example Response
Common Use Cases
1. Import CRM Data with Custom Fields
2. Create Webchat Contact from Authenticated User
3. Process Form Submission
4. E-commerce Customer Sync
5. Bulk Customer Import
Key Features
Upsert Behavior
The contact lookup depends on the channel:| Channel | Identified by |
|---|---|
whatsapp | contact_phone_number on the given channel |
web-whatsapp | contact_phone_number on the given channel |
webchat | external_user_id on the given channel_id |
- If contact exists: Returns the existing contact and applies any updates (name, agent, stage, metadata, custom fields)
- If contact doesnβt exist: Creates a new contact and customer
- Idempotent: Safe to call multiple times with the same data
Custom Field Values
- Values are set on the customer (not the contact), so they are shared across all contacts for that customer
- Fields are identified by their definition key (e.g.
"rut","company_name") - If a field definition is marked as an identifier, the value participates in automatic customer deduplication
- All custom field definition keys must exist beforehand; the endpoint returns a
400error listing any missing keys - Supported field types:
text,number,date,boolean,options
AI-Powered Data Processing
Themeta_data field uses AI to:
- Extract structured data from unstructured metadata
- Match fields to your custom field definitions
- Convert data types automatically
- Handle flexible formats for phone numbers, dates, etc.
Automatic Processing
All in one request:- Create/update contact
- Assign to pipeline stage
- Assign to agent
- Process and save metadata
- Upsert custom field values
Channel Types
| Channel | Description | Required Fields |
|---|---|---|
whatsapp | WhatsApp Business API | channel_phone_number, contact_phone_number |
web-whatsapp | WhatsApp Web (QR Code) | channel_phone_number, contact_phone_number |
webchat | Webchat widget | channel_id, external_user_id |
Error Responses
| Status Code | Description |
|---|---|
| 400 | Bad Request - Missing required fields for the channel, or invalid custom field keys |
| 401 | Unauthorized - Invalid or missing API key |
| 500 | Internal Server Error - Something went wrong |
Important Notes
- Channel Phone Number: Must be a WhatsApp number/channel you own and have configured
- Channel ID: Must be a webchat channel UUID you own
- External User ID: Your own unique identifier for the webchat user; used to deduplicate contacts
- Phone Format: Automatically cleaned (spaces, dashes, etc. are removed)
- Custom Field Keys: Must match existing custom field definitions; create definitions first in the Vambe dashboard
- AI Processing: Metadata is processed asynchronously with AI
- Immediate Response: Returns contact immediately, metadata processing continues in background
Best Practices
1. Use Custom Fields for Structured Data
Prefercustom_field_values over meta_data when you have well-defined fields. Custom fields are typed, searchable, and can be marked as identifiers for deduplication.
2. Include Source Information
3. Validate Data Before Sending
Related Endpoints
- POST /api/public/contact//update-metadata - Update metadata for existing contact
- POST /api/public/ticket/open/web-whatsapp/ - Create ticket for contact
- GET /api/public/contact//info - Get contact details
Migration from Deprecated Endpoint
If youβre migrating from the deprecatedPOST /api/public/whatsapp/message/note/send endpoint:
Old:
Headers
API key needed to authorize the request
Body
Channel type for the contact.
whatsapp, web-whatsapp, webchat Arbitrary metadata to set on the contact.
Phone number or ID of the channel. Required for whatsapp/web-whatsapp.
1UUID of the webchat channel. Required for webchat.
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$Stage ID to assign to the contact.
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$Agent ID to assign to the contact.
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$Phone number of the contact. Required for whatsapp/web-whatsapp.
External user identifier used to find or create the webchat contact. Required for webchat.
1Email of the contact.
Display name of the contact.
Custom field values to upsert on the customer, identified by definition key.
Response
Contact created or found successfully.
