API Reference - Add Leads and Contacts
This guide explains how to programmatically add leads and contacts to your SandeshAI account. The API allows seamless integration with your CRM, website, or other systems for efficiently managing your contact database.
Prerequisites
Before using this API, ensure the following are set up:
1. Generate an API Key
- Log in to your dashboard here.
- Navigate to Settings > API Keys.
- Click Generate API Key, save the key securely.
- Use this key in the
apiKey
field of the request.
API Endpoint
Use this endpoint to add contacts to your SandeshAI account.
Request Payload
Required Fields
- Name
apiKey
- Type
- string
- Description
Your unique API key for authentication. Obtainable from your SandeshAI dashboard under Settings > API Key.
- Name
contactName
- Type
- string
- Description
Full name of the contact.
- Name
whatsappNumber
- Type
- string
- Description
Contact's WhatsApp number, including the country code. Example:
917805076045
.
Optional Fields
- Name
attributes
- Type
- object
- Description
Key-value pairs of custom attributes associated with the contact. Example:
{"Source": "Instagram", "City": "Mumbai", "Age": "25"}
.
Request Example
import requests
url = "https://api.sandeshai.com/whatsapp/contact/api/"
data = {
"apiKey": "your_api_key_here",
"contactName": "Rishabh Gupta",
"whatsappNumber": "917805076045",
"attributes": {"Source": "Instagram", "City": "Mumbai", "Age": "25"} # Optional
}
response = requests.post(url, json=data)
print(response.json())
Success Response: 201 Created
{
"msg": "Contact created successfully!"
}
Duplicate Response: 200 OK
{
"msg": "Contact already exists."
}
Error Response: 500 Internal Server Error
{
"msg": "An error occurred: <error_details>"
}
Notes
- If the contact already exists ( based on
whatsappNumber
), the API will return 200 OK with the message “Contact already exists.”. - Custom attributes (
attributes
) do not have to be predefined in the system. The API will create them if they don’t exist. - If the contact already exists, any new attributes provided will be added to the contact, and existing attributes with the same key will be updated with the new values.
- Ensure the whatsappNumber is valid, including the country code.
- An inactive or invalid API key will return a 401 Unauthorized error.
Feel free to reach out to SandeshAI Support if you have further questions or need assistance!