Those familiar with our API know quite well about adding and editing subscribers, and the steps involved.
Adding subscribers (that don’t exist already) is pretty straight-forward. But for existing subscribers, you first have to fetch the existing subscriber details, then perform an update by resupplying all of the subscriber information (you can also use a certain parameter to update only a portion of the subscriber details).
We’ve decided to make this whole process a little bit easier. Using our subscriber_sync API method, you can simultaneously add or edit a subscriber through a single API call.
So instead of performing these steps in your application:
- Check if subscriber exists.
- If not, add them.
- If so, edit them.
You can submit one API call containing the subscriber information, just as you would when adding a subscriber. The system will check if they exist already automatically. If they don’t exist, a normal
subscriber_add is run. If they do exist already, it performs a
subscriber_edit and only updates the information/data you have provided.
Here is an example of how simple this is using our PHP API wrapper:
$subscriber = array( "email" => "firstname.lastname@example.org", "first_name" => "First", "last_name" => "Last", "p" => 1, "status" => 1, ); $request = $ac->api("subscriber/sync", $subscriber);
If the subscriber is added (did not exist already), the response will contain:
"result_message": "Subscriber added"
If the subscriber exists already (and is being updated), the response will contain:
"result_message": "Subscriber updated"
No matter whether the subscriber exists or not, the above example request will always keep the information in sync. The unique identifier in this case is the email address (whereas
subscriber_edit requires an
id of the subscriber you are editing). So only use
subscriber_sync if you don’t need to update the email address of the subscriber.
Let us know of any questions, or other ways we can simplify using our API!