When using Audience Republic's API, one of the most important and common tasks is adding contacts to a mailing list with relevant tags. This guide walks you through the process and provides best practices to ensure smooth API usage.
Adding Contacts to a Mailing List with Tags
1. Ensure you have the necessary API credentials
Before making API calls, you’ll need to have your API token. This token authenticates your requests and ensures your actions are tied to the correct account.
2. Get your Mailing List ID
You’ll need to replace the `{mailing list id name}` in the example below with the actual mailing list ID of the list you want to add contacts to. You can find this by navigating to your Audience Republic account and looking at the ID or name of the list.
3. Use the Mail List API Call
The API allows you to add contacts directly into a specific list and assign them tags simultaneously. Below is an example of the API call to add a contact to a mailing list:
curl -X POST "https://api.arep.co/mailing-lists/{MAILING LIST NAME ID}/contacts" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "contacts": [ { "first-name": "John", "last-name": "Doe", "email-address": "john.doe@example.com", "phone-number": "+1234567890", "tags": ["tag1", "tag2"] } ] }'
Best Practices for Using the API
- Batch Contacts: If you are adding multiple contacts at once, it’s more efficient to batch them in a single API call. Simply add more contact objects within the `"contacts"` array.
- Tag Usage: Adding relevant tags helps organize contacts for segmentation. Ensure you use descriptive and appropriate tags to categorize your audience for better targeting.
- Error Handling: Be sure to handle any API responses or errors appropriately. Successful responses will confirm that contacts were added, while errors can give insight into potential issues (e.g., invalid email format or missing required fields).
- Test Before Sending
Always run a test with a small batch of contacts to ensure the process works as expected before scaling up. This helps ensure your API integration is smooth and working without errors. - Regularly Update Your Contacts
Using tags in conjunction with the API allows for more dynamic list management. As your marketing campaigns evolve, be sure to keep contacts and their tags up to date by making API calls to add, update, or remove tags based on their interaction with your campaigns.
Using the Audience Republic API to add contacts directly into mailing lists with tags is a powerful way to streamline your email and contact management workflows. By following these steps and best practices, you can ensure that your contacts are properly organised, tagged, and ready for your marketing campaigns.
For more information on using the Audience Republic API, check out our full API documentation here
Related articles
Still need help?
Contact us at support@audiencerepublic.com
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article