Query email history for tracking sent communications.
EmailHistory
EmailHistoryReturns a single email history entry based on the provided id.
Example Query:
query {
EmailHistory(id: 100012) {
id
to
cc
bcc
object
body
emailable_type
created_at
attachments {
id
filename
url
}
}
}Example Result:
{
"data": {
"EmailHistory": {
"id": 100012,
"to": ["[email protected]", "[email protected]"],
"cc": ["[email protected]"],
"bcc": ["[email protected]"],
"object": "Invoice #INV-2025-001",
"body": "<html>Your invoice is attached.</html>",
"emailable_type": "Invoice",
"created_at": "2025-10-01T12:00:00Z",
"attachments": [
{
"id": 5001,
"filename": "invoice_001.pdf",
"url": "https://example.com/attachments/invoice_001.pdf"
}
]
}
}
}EmailHistories
EmailHistoriesReturns a paginated list of email histories. You can apply filters and sorting to refine results.
Example Query:
query {
EmailHistories(
where: { AND: [{ column: "TO", operator: "EQ", value: "[email protected]" }] }
orderBy: { column: "CREATED_AT", order: "DESC" }
first: 2
page: 1
) {
paginatorInfo {
total
currentPage
lastPage
}
data {
id
to
cc
object
emailable_type
created_at
}
}
}Example Result:
{
"data": {
"EmailHistories": {
"paginatorInfo": {
"total": 42,
"currentPage": 1,
"lastPage": 3
},
"data": [
{
"id": 100012,
"to": ["[email protected]"],
"cc": ["[email protected]"],
"object": "Invoice #INV-2025-001",
"emailable_type": "Invoice",
"created_at": "2025-10-01T12:00:00Z"
},
{
"id": 100011,
"to": ["[email protected]"],
"cc": [],
"object": "Order Confirmation #ORD-2025-042",
"emailable_type": "Order",
"created_at": "2025-09-30T15:30:00Z"
}
]
}
}
}Available Fields
| Field | Type | Description |
|---|---|---|
id | Int | Unique identifier of the email history. |
user_profile_id | Int | User profile ID associated with the email. |
to | [String] | Recipients of the email. |
cc | [String] | Carbon copy (CC) recipients of the email. |
bcc | [String] | Blind carbon copy (BCC) recipients of the email. |
object | String | Subject of the email. |
body | String | Body content of the email. |
emailable_id | Int | ID of the document associated with the email. |
emailable_type | DocumentType | Type of the document the email is related to. |
attachments | [File] | List of files attached to the email. |
created_at | Date | Date when the email history was created. |
Filters
You can filter results using the following fields. Each filter is defined by:
column: The field to filter on.operator: Comparison operator (EQ,LIKE,IN, etc.).value: The value to compare against.
| Field | Example |
|---|---|
id | { "column": "ID", "operator": "EQ", "value": 12345 } |
to | { "column": "TO", "operator": "LIKE", "value": "%@fakecompany.com%" } |
cc | { "column": "CC", "operator": "IN", "value": ["[email protected]", "[email protected]"] } |
bcc | { "column": "BCC", "operator": "EQ", "value": "[email protected]" } |
emailable_id | { "column": "EMAILABLE_ID", "operator": "EQ", "value": 987654321 } |
emailable_type | { "column": "EMAILABLE_TYPE", "operator": "EQ", "value": "Invoice" } |
user_profile_id | { "column": "USER_PROFILE_ID", "operator": "EQ", "value": 123456789 } |
Sorting
You can sort results using the following fields:
emailable_idemailable_typecreated_at
Example Sorting:
query {
EmailHistories(
orderBy: [
{ column: "CREATED_AT", order: "DESC" }
{ column: "EMAILABLE_TYPE", order: "ASC" }
]
first: 50
page: 1
) {
data {
id
to
emailable_type
created_at
}
}
}Example Result:
{
"data": {
"EmailHistories": {
"data": [
{
"id": 100012,
"to": ["[email protected]"],
"emailable_type": "Invoice",
"created_at": "2025-10-01T12:00:00Z"
},
{
"id": 100011,
"to": ["[email protected]"],
"emailable_type": "Order",
"created_at": "2025-09-30T15:30:00Z"
}
]
}
}
}Additional Notes
- Fields like
to,cc, andbccare arrays of strings (e.g.,["[email protected]", "[email protected]"]). - The
attachmentsfield returns an array ofFileobjects, each withid,filename, andurl. - For paginated queries, use
firstto set the number of results per page andpageto navigate.
DocumentType
| Value | Description |
|---|---|
Estimate | Document is an estimate. |
CreditTransaction | Document is a credit transaction. |
Order | Document is a sales order. |
Invoice | Document is an invoice. |
ShippingOrder | Document is a shipping order. |
ProductReturn | Document is a product return. |
Purchase | Document is a purchase. |
PurchaseReceipt | Document is a purchase receipt. |
StockAdjustment | Document is a stock adjustment. |
ManufacturingOrder | Document is a manufacturing order. |
