|
| 1 | +Recipient Lists |
| 2 | +=============== |
| 3 | + |
| 4 | +Let's use the underlying `recipient_lists API`_ to create a recipient list: |
| 5 | + |
| 6 | +.. code-block:: python |
| 7 | +
|
| 8 | + from sparkpost import SparkPost |
| 9 | +
|
| 10 | + sp = SparkPost() |
| 11 | +
|
| 12 | + response = sp.recipient_lists.create( |
| 13 | + id='UNIQUE_TEST_ID', |
| 14 | + name='Test Recipient list', |
| 15 | + recipients=[ |
| 16 | + { |
| 17 | + 'address': { |
| 18 | + 'email': 'test1@test.com' |
| 19 | + } |
| 20 | + }, |
| 21 | + { |
| 22 | + 'address': { |
| 23 | + 'email': 'test2@test.com' |
| 24 | + } |
| 25 | + }, |
| 26 | + { |
| 27 | + 'address': { |
| 28 | + 'email': 'test3@test.com' |
| 29 | + } |
| 30 | + } |
| 31 | + ] |
| 32 | + ) |
| 33 | +
|
| 34 | + print response |
| 35 | + # outputs {u'total_accepted_recipients': 3, u'id': u'UNIQUE_TEST_ID', u'total_rejected_recipients': 0, u'name':'Test Recipient list'} |
| 36 | +
|
| 37 | +.. _recipient_lists API: https://www.sparkpost.com/api#/reference/recipient-lists |
| 38 | + |
| 39 | + |
| 40 | +Retrieve a recipient list |
| 41 | +------------------------- |
| 42 | + |
| 43 | +.. code-block:: python |
| 44 | +
|
| 45 | + from sparkpost import SparkPost |
| 46 | +
|
| 47 | + sp = SparkPost() |
| 48 | +
|
| 49 | + sp.recipient_lists.get('my-list-id') |
| 50 | +
|
| 51 | +
|
| 52 | +List all recipient lists |
| 53 | +------------------------ |
| 54 | + |
| 55 | +.. code-block:: python |
| 56 | +
|
| 57 | + from sparkpost import SparkPost |
| 58 | +
|
| 59 | + sp = SparkPost() |
| 60 | +
|
| 61 | + sp.recipient_lists.list() |
| 62 | +
|
| 63 | +
|
| 64 | +API reference |
| 65 | +------------- |
| 66 | + |
| 67 | +:doc:`/api/recipient_lists` |
| 68 | + |
| 69 | + |
| 70 | +Further examples |
| 71 | +---------------- |
| 72 | + |
| 73 | +See the `python-sparkpost recipient_lists examples`_. |
| 74 | + |
| 75 | +.. _python-sparkpost recipient_lists examples: https://github.com/SparkPost/python-sparkpost/tree/master/examples/recipient_lists |
| 76 | + |
| 77 | + |
| 78 | +Additional documentation |
| 79 | +------------------------ |
| 80 | + |
| 81 | +See the `SparkPost Recipient Lists API Reference`_. |
| 82 | + |
| 83 | +.. _SparkPost Recipient Lists API Reference: https://www.sparkpost.com/api#/reference/recipient_lists |
0 commit comments