Overview
Lists filtered emails.
Summary
Adds additional operators to Filter API that are
specific to Emails. A special macro, $current_user_id, is a convenience that allows for finding emails
involving the current user.
Filter By Sender
This will return all emails sent by the current user, by the contact whose ID is
fa300a0e-0ad1-b322-9601-512d0983c19a, using the email address sam@example.com, which is referenced by
the ID
b0701501-1fab-8ae7-3942-540da93f5017, or by the lead whose ID is
73b1087e-4bb6-11e7-acaa-3c15c2d582c6 using the email address wally@example.com, which is referenced by
the ID
b651d834-4bb6-11e7-bfcf-3c15c2d582c6.
{
"filter": [{
"$from": [{
"parent_type": "Users",
"parent_id": "$current_user_id"
}, {
"parent_type": "Contacts",
"parent_id": "fa300a0e-0ad1-b322-9601-512d0983c19a"
}, {
"email_address_id": "b0701501-1fab-8ae7-3942-540da93f5017"
}, {
"parent_type": "Leads",
"parent_id": "73b1087e-4bb6-11e7-acaa-3c15c2d582c6",
"email_address_id": "b651d834-4bb6-11e7-bfcf-3c15c2d582c6"
}]
}]
}
Equivalent to:
{
"filter": [{
"from_collection": {
"$in": [{
"parent_type": "Users",
"parent_id": "$current_user_id"
}, {
"parent_type": "Contacts",
"parent_id": "fa300a0e-0ad1-b322-9601-512d0983c19a"
}, {
"email_address_id": "b0701501-1fab-8ae7-3942-540da93f5017"
}, {
"parent_type": "Leads",
"parent_id": "73b1087e-4bb6-11e7-acaa-3c15c2d582c6",
"email_address_id": "b651d834-4bb6-11e7-bfcf-3c15c2d582c6"
}]
}
}]
}
Filter By Recipients
This would return all archived emails received by the current user.
{
"filter": [{
"$or": [{
"$to": [{
"parent_type": "Users",
"parent_id": "$current_user_id"
}],
"$cc": [{
"parent_type": "Users",
"parent_id": "$current_user_id"
}],
"$bcc": [{
"parent_type": "Users",
"parent_id": "$current_user_id"
}]
}]
}, {
"state": {
"$in": [
"Archived"
]
}
}]
}
Equivalent to:
{
"filter": [{
"$or": [{
"to_collection": {
"$in": [{
"parent_type": "Users",
"parent_id": "$current_user_id"
}]
},
"cc_collection": {
"$in": [{
"parent_type": "Users",
"parent_id": "$current_user_id"
}]
},
"bcc_collection": {
"$in": [{
"parent_type": "Users",
"parent_id": "$current_user_id"
}]
}
}]
}, {
"state": {
"$in": [
"Archived"
]
}
}]
}
Filter By Sender and Recipients
This would return all archived emails sent by a contact to the current user.
{
"filter": [{
"$from": [{
"parent_type": "Contacts",
"parent_id": "fa300a0e-0ad1-b322-9601-512d0983c19a"
}]
}, {
"$or": [{
"$to": [{
"parent_type": "Users",
"parent_id": "$current_user_id"
}],
"$cc": [{
"parent_type": "Users",
"parent_id": "$current_user_id"
}],
"$bcc": [{
"parent_type": "Users",
"parent_id": "$current_user_id"
}]
}]
}, {
"state": {
"$in": [
"Archived"
]
}
}]
}
Equivalent to:
{
"filter": [{
"from_collection": {
"$in": [{
"parent_type": "Contacts",
"parent_id": "fa300a0e-0ad1-b322-9601-512d0983c19a"
}]
}
}, {
"$or": [{
"to_collection": {
"$in": [{
"parent_type": "Users",
"parent_id": "$current_user_id"
}]
},
"cc_collection": {
"$in": [{
"parent_type": "Users",
"parent_id": "$current_user_id"
}]
},
"bcc_collection": {
"$in": [{
"parent_type": "Users",
"parent_id": "$current_user_id"
}]
}
}]
}, {
"state": {
"$in": [
"Archived"
]
}
}]
}
Change Log
| Version |
Change |
|
v10
|
Added the $from, $to, $cc, and $bcc operators to
/Emails/filter GET endpoint.
|