sparkpost.recipient_lists¶
-
class
sparkpost.recipient_lists.RecipientLists(base_uri, api_key, transport_class=<class 'sparkpost.base.RequestsTransport'>)¶ RecipientLists class used to create, update, delete, list and get recipient lists. For detailed request and response formats, see the Recipient Lists API documentation.
-
create(**kwargs)¶ Create a recipient list based on the supplied parameters
Parameters: - id (str) – ID used to reference the recipient list
- name (str) – Editable display name
- description (str) – Detailed description of the recipient list
- attributes (dict) – Arbitrary metadata related to the list
- recipients (list) – Array of recipient dicts
Returns: a
dictwith the ID, name, and number of accepted and rejected recipientsRaises: SparkPostAPIExceptionif API call fails
-
delete(list_id)¶ Delete a recipient list by ID
Parameters: list_id (str) – ID of the recipient list you want to delete Returns: empty dictRaises: SparkPostAPIExceptionif recipient list is not found or if recipient list is in use
-
get(list_id, show_recipients=None)¶ Get a recipient list by ID
Parameters: - list_id (str) – ID of the recipient list you want to retrieve
- show_recipients (bool) – If True, returns attributes for all recipients
Returns: the requested recipient list if found
Raises: SparkPostAPIExceptionif recipient list is not found
-
list()¶ Get a list of your recipient lists
Returns: list of recipient lists Raises: SparkPostAPIExceptionif API call fails
-
update(list_id, **kwargs)¶ Update a recipient list by ID based on the supplied parameters
Parameters: - list_id (str) – ID of the recipient list you want to update
- name (str) – Editable display name
- description (str) – Detailed description of the recipient list
- attributes (dict) – Arbitrary metadata related to the list
- recipients (list) – Array of recipient dicts
Returns: a
dictwith the ID, name, and number of accepted and rejected recipientsRaises: SparkPostAPIExceptionif API call fails
-