Create or Update a Contact

POST/Contacts/Insert and Update

This endpoint is used to create a new contact or update an existing contact in the Mainbrainer CRM. In case a new contact is created, a unique contact ID is also generated and assigned to the newly created contact. You can later use this contact ID to retrieve the details for a particular contact.

Usage scenario for this endpoint:

This endpoint is used to sync a single contact from another database to the Mainbrainer CRM. In case you wish to sync multiple contacts to the Mainbrainer CRM, we recommend that use the Batch API.

Method Details
HTTP Method POST
Content type Application/json
Requires authentication? YES
Rate limited? YES
Headers User-Agent
Module CRM
End Point

https://apicrm.mainbrainer.com/contacts/insertupdate

Required Parameters Usage Description
Access Token or API Key Authorization: Bearer {token} header Pass the API key in the request header for request authentication. Read more about our authentication process..
Contact JSON Body Request This is JSON that represents a contact that you're creating or updating. This should be of the format seen below in the code sample given.
ListID listId (uuid) eg: "3fa85f64-5717-4562-b3fc-2c963f66afa6 Each list is assigned a unique List ID that acts as a Unique identifier for the particular list. In case you wish to add the contact to a particular list, specify the list ID of the desired list using the parameter listId. If no list ID is specified, the contact will get added under All contacts.
Update/Insert using Contactid and Mobile/email Used in the request body The request body must include either an email address, a mobile number, or a contactID. Since contactID is a unique identifier for a contact, we recommend that you include contactID in case you are making a update request.

-- Whenever the request data set includes the contactID, the existing record with the specified contactID will be updated. In case no record exists with the specified details, a new record will be created.
--In case the data set only includes the mobile number and email address, we update the records based on the combination of the email address and mobile number data. In case a record already exists with the mobile number and email address specified in the request data, the record will get updated. Otherwise, a new contact will be created.
--In case the data set includes only a mobile number and no email data, we search if a record exists with the specified mobile number and a null email. In case such a record exists, it will be updated. In case no such record exists, a new record will be created.
-- In case the data set includes only an email address and no mobile number, we search if a record exists with the specified email and a null mobile number. In case such a record exists, it will be updated. In case no such record exists, a new record will be created.
propertyid/propertyname propertyid (uuid),propertyname (string) It is mandatory to include either a property name or the property ID in the request body. In case the property ID is mentioned, the property value will be inserted/updated on the basis of the propertyID. In case only the property name is mentioned, the property value will be inserted/updated on the basis of the property name.
mobileOptIn mobileOptIn = boolean and default = true , In case no Opt-in Status send Blank Use this parameter to specify the MobileOpt-In status of the contact.

-- Pass the parameter value as mobileOptIn= true if the contact has opted-in to receive SMS communication from you. If the contact has not opted-in to receive SMS communication from you, pass the parameter value as mobileOptIn= false.
-- In case the property is not defined in your request, we'll add/update the contact property as no consent. No communication will be sent to the contact till its mobileOptIn status is updated to true.
emailOptIn emailOptIn = boolean and default = true , In case no Opt-in Status send Blank Use this parameter to specify the Email opt-in status of the contact.

-- Pass the parameter value as emailOptIn= true if the contact has subscribed to receive emails from you. If the contact has not subscribed to your emails, pass the parameter value as emailOptIn= false.
-- In case the property is not defined in your request, we'll add/update the contact property as no consent. No communication will be sent to the contact till its emailOptIn status is updated to true.
Note

If you're working with a known contact, using the ContactID is preferred.

Note

SMSs will only be sent to contacts if their mobileOptIn status is true. Similarly emails will only be sent to contacts if their emailOptIn status is true.

List and List IDs

In the MainBrainer CRM, contacts can be grouped under various Lists. Each list is assigned a unique List ID that acts as a Unique identifier for the particular list. In case you wish to add the contact to a particular list, specify the list ID of the desired list using the parameter listId. If no list ID is specified, the contact will get added under All contacts.

Response

In case there is a problem with the data in the request body, or if there are no properties included in the request, we'll return a 400 and 422 response along with additional details listing the cause.

Copy
Copied

This example demonstrates how to update and insert contact properties
one for an existing contact as identified by the contactId or email or mobile no.

post url: https://apicrm.mainbrainer.com/contacts/insertupdate?listid=<listid> (uuid)


{
  "listId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "contactId": 234567,
  "mobileCountryCode": 47, 
  "mobileNumber": 90812501,
  "mobileOptIn": true,
  "email": "apitest@mainbrainer.com",
  "emailOptIn": true,
  "propertyfields": [
    {
      "propertyid": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "propertyname": "firstname",
      "propertyvalue": "jennifer"
    },
    {
      "propertyname": "lastname",
      "propertyvalue": "merg"
    },
    {
      "propertyname": "interest",
      "propertyvalue": "ice hockey"
    },
    {
      "propertyname": "company",
      "propertyvalue": "MainBrainer"
    },
    {
      "propertyname": "Street",
      "propertyvalue": "16 Av Street"
    },
    {
      "propertyname": "city",
      "propertyvalue": "Oslo"
    },
    {
      "propertyname": "state",
      "propertyvalue": "Oslo"
    },
    {
      "propertyid": "3fa85f64-5717-4562-b3fc-123123d23dds",
      "propertyvalue": "0236"
      }
  ]
}



Returns a 201 Accepted response with  content on success.

Response Body

Copy
Copied
{
    "status": "Success",
    "message": "Contact added/updated successfully",
    "data": {
        "ContactId": "1329318",
        "InvalidProperties": [],
        "InvalidContactIds": [],
      }
}