You are here: Communications Cloud API v1 > Common Uses > Batch and Sync Subscribers with a Directory

Batch and Sync Subscribers with a Directory

If you have existing subscribers in an internal database or have an alternative method for collecting subscribers, you can use the API in a batch process to add subscribers and move them into GovDelivery. This is helpful if, for example, you have a group of users stored in a database, such as Oracle, or directory services, like Active Directory, that you'd like to register for email updates.

There are a number of approaches you can take, based on what you want to accomplish, but one approach might be:

  1. Manually upload your current list of subscribers.
  2. Track the change or delta of your current subscribers within your internal database.
  3. Remove subscribers that you have tracked as deleted.
  4. Add those subscribers who have been updated.
1. Manually upload your current list of subscribers

This is done in the Communications Cloud administrative interface using a .CSV file.

2. Track the change or delta of your current subscribers within your internal database.

Set up a nightly process to look for any deleted subscribers in your internal database.

3. Remove subscribers that you have tracked as deleted.

Set up your system to send a call using the delete a subscriber method for any subscribers tracked as deleted in your internal database.

Operation

Send a DELETE to /api/account/ACCOUNT_CODE/subscribers/ENCODED_SUBSCRIBER_ID.xml

Subscriber Deleted Notification

This operation will cause the system to send a Subscriber Deleted confirmation message to the subscriber. To avoid sending this message, send the DELETE operation using the following endpoint:

/api/account/ACCOUNT_CODE/subscribers/ENCODED_SUBSCRIBER_ID?send_notifications=false.

Output

A successful operation will have a 200 OK response status and an empty response body.

Troubleshooting
4. Add those subscribers who have been updated.

This is done using the add a subscription method.

Operation

Send a POST to /api/account/ACCOUNT_CODE/subscriptions.xml

Example Input

For an email subscriber, the input should look like:

<subscriber>
  <email>EMAIL@ADDRESS.COM</email>
  <send-notifications type='boolean'>false</send-notifications>
  <topics type='array'>
    <topic>
      <code>####</code>
    </topic>
    <topic>
      <code>####</code>
    </topic>
  </topics>
</subscriber>

For a wireless subscriber, the input should look like:

<subscriber>
  <phone>###-###-####</phone>
  <country-code>#</country-code>
  <send-notifications type='boolean'>false</send-notifications>
  <topics type='array'>
    <topic>
      <code>####</code>
    </topic>
    <topic>
      <code>####</code>
    </topic>
  </topics>
</subscriber>
Elements
Example Output
<?xml version="1.0" encoding="UTF-8"?>
<subscriber>
  <to-param>ZW1haWxAdGVzdC5nb3ZkZWxpdmVyeS5jb20=</to-param>
  <link rel="self" href="/api/account/TOR_TEST/subscribers/ZW1haWxAdGVzdC5nb3ZkZWxpdmVyeS5jb20="/>
  <subscriber-uri>/api/account/ACCOUNT_CODE/subscribers/ZW1haWxAdGVzdC5nb3ZkZWxpdmVyeS5jb20=</subscriber-uri>
</subscriber>
Example PHP Code
Troubleshooting

 

Was this page helpful? Can't find what you need? Let us know