GET/ users/ :id/ emails/
Get user emails
You can return all email messages sent to a specific user.
Attributes
Optional unless marked required
- id
- A unique identifier for the user which is given by User automatically.
Request
- cURL
- JavaScript
- PHP
- Python
curl -X GET "https://<your_app_subdomain>.user.com/api/public/users/:id/emails/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2"
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/users/:id/emails/",
{
method: "GET",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
},
},
);
const data = await response.json();
console.log(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/users/:id/emails/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.get(
"https://<your_app_subdomain>.user.com/api/public/users/:id/emails/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
)
print(response.json())
Response examples
- 200 OK
- 404 Not Found
{"count": 19,"next": null,"previous": null,"results": [{"id": 513449,"status": "sent","created_at": "2016-11-22T07:54:40.932410Z","sent_at": "2016-11-22T07:54:42.419161Z","opened_at": "2016-11-22T07:54:45.713255Z","clicked_at": "2016-11-22T07:56:57.292886Z","subject": "This is sample message - do not reply"},{"id": 513448,"status": "sent","created_at": "2016-11-22T07:48:37.224001Z","sent_at": "2016-11-22T07:48:39.349955Z","opened_at": "2016-11-22T07:48:43.162584Z","clicked_at": null,"subject": "Hello World"}]}{
"detail": "No ClientUser matches the given query."
}
Response fields
Fields returned in the 200 OK response body.
- count
- Number of results across all pages. It can lag behind recent changes; see Response pagination.
- next
- URL of the next page of results. null on the last page.
- previous
- URL of the previous page of results. null on the first page.
- results
- Results on this page.
- results[].
id - ID of the email.
- results[].
status - Status of the email, for example
sent. - results[].
created_at - When the email was created, ISO 8601.
- results[].
sent_at - When the email was sent, ISO 8601.
- results[].
opened_at - When the contact opened the email, ISO 8601.
nullif it wasn't opened. - results[].
clicked_at - When the contact clicked a link in the email, ISO 8601.
nullif there was no click. - results[].
subject - Subject of the email.
- results[].
note
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.