1. Home
  2. Docs
  3. REST API
  4. API Guides
  5. Send an email campaign for an external contacts group

Send an email campaign for an external contacts group

The process of sending an email campaign consists of four key steps:

1. Creating an external group
2. Adding contacts to the group (external database/ external app)
3. Creating the email campaign
4. Sending the email campaign

In this guide, we will explain each method individually, and by the end, we will introduce a single method that performs all four steps simultaneously

 

1. Creating an external group

POST /contactsGroups/externalAppGeneric

In order to create an external group, you only need to enter the name of the group into the method – the name of the group you wish to create. For example: test-25-07-2022
The response will be the group_id, for example: 1045009

*For creating an external application group. Additional features of an external application group include: allowing duplicate emails, the ability to view the group through the UI application, and the contacts in the group are read-only, meaning they cannot be modified via the application.

Request URL

https://api.inwise.com/rest/v1/contactsGroups/externalAppGeneric?group_name=test-25-07-2022

Response

{  “group_id”: “1045009”}

2. Adding contacts to the group (external database/ external app)

POST /contactsGroups/pushExternalApp

In order to sync contacts from external app or DB to contact group, you need to enter the group_id from the previous method into this method.
You can add more parameters to this method: name, mobile number etc.

Example for contacts:

[{“fields”:[],”external_id”:”00Q4J000001WcHUUA0″,”email”:”tal1931@yopmail.com”,”mobile_number”:”972542291206″,”confirmation_status”:”confirmed”,”clear_existing_fields”:true},{“fields”:[],”external_id”:”00Q4J000001WcHVUA0″,”email”:”addi1928@yopmail.com”,”mobile_number”:”972542291206″,”confirmation_status”:”confirmed”,”clear_existing_fields”:true},{“fields”:[],”external_id”:”00Q4J000005szDzUAI”,”email”:”sam12@yopmail.com”,”mobile_number”:”972542291206″,”confirmation_status”:”confirmed”,”clear_existing_fields”:true},{“fields”:[],”external_id”:”00Q4J0000097sIrUAI”,”email”:”ben1803@yopmail.com”,”mobile_number”:””,”confirmation_status”:”confirmed”,”clear_existing_fields”:true},{“fields”:[],”external_id”:”00Q4J0000097sJfUAI”,”email”:”or1808@yopmail.com”,”mobile_number”:””,”confirmation_status”:”confirmed”,”clear_existing_fields”:true},{“fields”:[],”external_id”:”00Q4J0000098MRvUAM”,”email”:”shanny2423@yopmail.com”,”mobile_number”:””,”confirmation_status”:”confirmed”,”clear_existing_fields”:true},{“fields”:[],”external_id”:”00Q4J00000BtnnhUAB”,”email”:”omer11777_1832@yopmail.com”,”mobile_number”:””,”confirmation_status”:”confirmed”,”clear_existing_fields”:true},{“fields”:[],”external_id”:”00Q4J00000BtnpEUAR”,”email”:”ravit1807@yopmail.com”,”mobile_number”:””,”confirmation_status”:”confirmed”,”clear_existing_fields”:true},{“fields”:[],”external_id”:”00Q4J00000BtnpFUAR”,”email”:”john_test_2@yopmail.com”,”mobile_number”:””,”confirmation_status”:”confirmed”,”clear_existing_fields”:true},{“fields”:[],”external_id”:”00Q4J00000BtnpnUAB”,”email”:”ron12@yopmail.com”,”mobile_number”:””,”confirmation_status”:”confirmed”,”clear_existing_fields”:true}]

Response (How many contacts were successfully created, how many were updated, and how many failed. For example: 10 contacts were created)

{ “status”: “complete”, “processed”: 10, “created”: [ “00Q4J000001WcHUUA0”, “00Q4J000001WcHVUA0”, “00Q4J000005szDzUAI”, “00Q4J0000097sIrUAI”, “00Q4J0000097sJfUAI”, “00Q4J0000098MRvUAM”, “00Q4J00000BtnnhUAB”, “00Q4J00000BtnpEUAR”, “00Q4J00000BtnpFUAR”, “00Q4J00000BtnpnUAB” ] }

Personal fields

You can also retrieve personal fields of the contacts, such as birthdate, place of residence, and more. This is done by using the field’s location.
In your account, you can define the fields.
For example, in the HTML body of the campaign, you would use the string: #field1# . This will serve as a placeholder for the recipient’s name.

“fields”: [ { “name”: “field1”, “content”: “ben” } ]

POST /contactsGroups/externalGroup

Another option for creating a group with external contacts is using an external database. A table with the contacts is prepared, and we synchronize with it

3. Creating the email campaign

https://api.inwise.com/rest/v1/campaigns/email

Please note, the campaign name must be unique.

4. Sending the email campaign

https://api.inwise.com/rest/v1/campaigns/email/send

Please note, the campaign will be distributed asynchronously. A 200 response in this method means the campaign has been queued.

You should also consider what will happen if your process runs twice. For example: assigning a unique name to the group or campaign, or running a method to delete the group or campaign:

Delete contact group
https://api.inwise.com/rest/v1/ContactGroups/X

Delete email campaign
https://api.inwise.com/rest/v1/campaigns/email/X?delete_even_if_sending_started=true

 

After sending the campaign, it’s important to track the analytics.

___________________________________________________________________________________________

There is an option to use a single method that consolidates all four steps mentioned above and executes them simultaneously:

Load your contacts, create a new group, create a new campaign and send it in a single step. there is a size limit of 20000 contacts using regular json, or 50000 using zipped json. This method may be called up to 20 times per minute.

https://api.inwise.com/rest/v1/campaigns/email/loadContactsAndSend

Example for JSON:

{ “group_name”: “test0804241232” , “contacts”: [ { “external_id”: “ABC123”, “email”: “ravitb@inwise.com“, “mobile_number”: “0548889999”, “trim_mobile_number_leading_zero”: true, “add_default_country_to_mobile_number_only_if_not_exists”: true, “mobile_number_default_country_code”: “972”, “fields”: [ { “name”: “field1”, “content”: “name1” } ], } , { “external_id”: “ABC1234”, “email”: “ravitb@inwise.com“, “mobile_number”: “548889999”, “trim_mobile_number_leading_zero”: true, “add_default_country_to_mobile_number_only_if_not_exists”: true, “mobile_number_default_country_code”: “972”, “fields”: [ { “name”: “field1”, “content”: “name1” } ], } , ], , “new_campaign_details”: { “name”: “”, “html”: “string”, “subject”: “test08042924 subject”, “from_email”: “”, “reply_to”: “”, “from_name”: “string”, “charset”: “utf-8”, “content_type”: “html”, “google_analytics_campaign”: “”, “attachments_mapping”: [ 0 ],   “allow_sending_for_contact_with_no_value”: true, “delete_files_after_sending”: true, “http_attachments_mapping”: [ 0 ], “http_allow_sending_for_contact_with_no_value”: true, “google_analytics”: “”, “use_personalized_attachment”: true, “to_name”: “”, “is_onSite_tracking”: true, “onSite_tracking_timeout”: 0, “attachment_file_data”: “”, “attachment_file_name”: “” }, }

 

Example for ZIPPED CONTACTS instead of CONTACTS:

,”zipped_contacts”:”UEsDBBQAAAAIAHVpiFhPap3q5QAAADMDAAAMAAAAY29udGFjdHMudHh07ZHBasMwEETvgfyD0bmUWElaklObfkYIi2yty4K0AnmdJin991pOjF33UEqv1UWL5s2waPbzWdae9+uVZQpPgpGNA7Jqm6nn3Uuul+pu0L0hl5RojiTFE/Eb1XhfBj+CfCjIIXDjC4wJXqxXWm9yvXgYURLJwxcUHBpL/AoXjKH1SWyw55WxFixWpnECZWhY4hkkTAICuzNQBRwE8ES11JOYyXLfEstgMW28edSjVStCZ1PUvn8a/VlHsPGdryPzwdqJZWBBlqQnLleD+tGPh5ulfbhOP3Sy+nMp/538rpM0H+azT1BLAQIUABQAAAAIAHVpiFhPap3q5QAAADMDAAAMAAAAAAAAAAEAIAAAAAAAAABjb250YWN0cy50eHRQSwUGAAAAAAEAAQA6AAAADwEAAAAA”

How can we help?