Retrieve, delete and add entries in the Unsubscribes list.
get
Retrieve a list of Unsubscribes with addresses and optionally with dates.
|
Parameter
|
Required
|
Requirements
|
Description
|
|
date
|
No
|
Must be set to 1
|
Retrieve the timestamp of the unsubscribe records. It will return a date in a MySQL timestamp format - YYYY-MM-DD HH:MM:SS
|
|
days
|
No
|
If specified, must be an integer greater than 0
|
Number of days in the past for which to retrieve unsubscribes (includes today)
|
|
start_date
|
No
|
Date must be in YYYY-MM-DD format and be earlier than the end_date parameter.
|
The start of the date range for which to retrieve unsubscribes.
|
|
end_date
|
No
|
Date must be in YYYY-MM-DD format and be later than the start_date parameter.
|
The end of the date range for which to retrieve unsubscribes.
|
| limit |
No |
some integer |
Optional field to limit the number of results returned. |
| offset |
No |
some integer |
optional beginning point in the list to retrieve from. |
| email |
No |
email address eg testing@example.com |
optional email addresses to search for. |
Call
1
| https://sendgrid.com/api/unsubscribes.get.json?api_user=youremail@domain.com&api_key=secureSecret&date=1
|
Response
1
2
3
4
5
6
| [
{
"email": "brandon.west@sendgrid.com",
"created": "2012-09-06 14:03:18"
}
]
|
Call
Response
1
| <unsubscribes><unsubscribe><email>brandon.west@sendgrid.com</email><created>2012-09-06 14:03:18</created></unsubscribe></unsubscribes>
|
delete
Delete an address from the Unsubscribe list. Please note that if no parameters are provided the ENTIRE list will be removed.
| Parameter |
Required |
Requirements |
Description |
| start_date |
No |
Date must be in YYYY-mm-dd format and be before the end_date parameter |
Optional date to start retrieving for. |
| end_date |
No |
Date must be in YYYY-mm-dd format and be after the start_date parameter |
Optional date to end retrieving for. |
| email |
No |
Must be a valid user account email |
Unsubscribed email address to remove |
Call
1
| https://sendgrid.com/api/unsubscribes.delete.json?api_user=youremail@domain.com&api_key=secureSecret&email=emailToDelete@domain.com
|
Response: Success
1
2
3
| {
"message": "success"
}
|
Response: Error
1
2
3
4
5
6
| {
"message": "error",
"errors": [
"...error messages..."
]
}
|
Call
1
| https://sendgrid.com/api/unsubscribes.delete.xml?api_user=youremail@domain.com&api_key=secureSecret&email=emailToDelete@domain.com
|
Response: Success
1
2
3
| <result>
success
<result>
|
Response: Error
@nodes
1
2
3
4
5
6
| <?xml version="1.0" encoding="ISO-8859-1"?>
<result>
Email does not exist
@nodes
</result>
|
add
Add email addresses to the Unsubscribe list.
| Parameter |
Required |
Requirements |
Description |
| email |
Yes |
Must be a valid email address |
Email address to add to unsubscribe list |
Call
1
| https://sendgrid.com/api/unsubscribes.add.json?api_user=youremail%40domain.com&api_key=secureSecret&email=email2@domain.com
|
Response: Success
1
2
3
| {
"message": "success"
}
|
Response: Error
1
2
3
4
5
6
| {
"message": "error",
"errors": [
"...error messages..."
]
}
|
Call
1
| https://sendgrid.com/api/unsubscribes.add.xml?api_user=youremail%40domain.com&api_key=secureSecret&email=email2@domain.com
|
Response: Success
1
2
3
4
5
| <?xml version="1.0" encoding="ISO-8859-1"?>
<result>
<message>success</message>
</result>
|
Response: Error
1
2
3
4
5
| <?xml version="1.0" encoding="ISO-8859-1"?>
<result>
<message>Email does not exist</message>
</result>
|