# Filter messages by ID

## API Overview

Use this endpoint to retrieve detailed events for a specific message. You can obtain an `sg_message_id` from the [**Filter All Messages**](/docs/sendgrid/api-reference/email-logs/filter-all-messages) endpoint. This endpoint provides comprehensive details and the full event timeline for a single email.

## Operation overview

```json
{"path":"https://api.sendgrid.com/v3/logs/{sg_message_id}","method":"get","servers":[{"url":"https://api.sendgrid.com","description":"for global users and subusers"},{"url":"https://api.eu.sendgrid.com","description":"for EU regional subusers"}]}
```

Get all of the details about the specified message.

## Operation details

### Authentication

API Key

### Headers

```json
[{"in":"header","name":"Authorization","required":true,"default":"Bearer <<YOUR_API_KEY_HERE>>","schema":{"type":"string"}}]
```

### Path parameters

```json
[{"name":"sg_message_id","in":"path","required":true,"schema":{"type":"string"},"description":"The ID of the message you are requesting details for."}]
```

### Query string

```json
[{"name":"subuser","in":"query","description":"For requests authenticated as the parent account,\nthis argument must be passed if the desired message belongs to a subuser.\n","schema":{"type":"string","format":"^\\d+$"}}]
```

### Responses

````json
[{"responseCode":"200","schema":{"description":"Detailed information for the specified message, including all events related to the message","content":{"application/json":{"schema":{"description":"Detailed information for the specified message, including all events related to the message.","type":"object","required":["api_key_id","events","from_email","sg_message_id","client_ip","status","subject","to_email"],"refName":"EmailLogsGetMessageByIdResponse","modelName":"EmailLogsGetMessageByIdResponse","properties":{"from_email":{"type":"string","description":"The 'From' email address used to deliver the message.\nThis may not be a valid email address.\n"},"sg_message_id":{"type":"string","description":"A unique ID assigned to the message."},"subject":{"type":"string","description":"The email's subject line."},"to_email":{"type":"string","description":"The intended recipient's email address."},"status":{"type":"string","description":"**A summary of the message status based on which events have occurred.**\n\n- processed: `processed`\n- dropped: `drop`, `cancel_drop`\n- deferred: `deferred`\n- bounced: `bounce`\n- blocked: `bounce` (type=`block`)\n- delivered: `delivered`, `click`, `open`\n","enum":["processed","delivered","deferred","dropped","bounced","blocked"],"refName":"EmailLogsMessageStatus","modelName":"EmailLogsMessageStatus"},"template_id":{"type":"string","description":"The ID associated with a Twilio SendGrid email template used to format the message."},"asm_group_id":{"type":"integer","description":"The unsubscribe group associated with this email."},"teammate":{"type":"string","description":"Teammate's username.","pattern":"^$|^[A-Za-z0-9]+","maxLength":64},"api_key_id":{"type":"string","description":"The ID of the API Key used to authenticate the sending request for the message.","pattern":"^$|^[A-Za-z0-9_-]+","maxLength":50},"events":{"type":"array","description":"All events recorded for this message. Most recent events will be returned upto the maximum of 100 events.","maxItems":100,"items":{"description":"The union of all possible event types for email logs.\n","type":"object","discriminator":{"propertyName":"event","mapping":{"bounce":"#/components/schemas/BounceEvent","cancel_drop":"#/components/schemas/DroppedEvent","click":"#/components/schemas/ClickEvent","deferred":"#/components/schemas/DeferredEvent","delivered":"#/components/schemas/DeliveredEvent","dropped":"#/components/schemas/DroppedEvent","open":"#/components/schemas/OpenEvent","processed":"#/components/schemas/ProcessedEvent","received":"#/components/schemas/ReceivedEvent","spamreport":"#/components/schemas/SpamReportEvent","group_unsubscribe":"#/components/schemas/GroupUnsubscribeEvent","group_resubscribe":"#/components/schemas/GroupResubscribeEvent","unsubscribe":"#/components/schemas/UnsubscribeEvent"}},"oneOf":[{"title":"bounce","type":"object","properties":{"event":{"type":"string","enum":["bounce"],"refName":"Event","modelName":"Event"},"email":{"type":"string","description":"Recipient email address.\n"},"sg_message_id":{"description":"SendGrid Message ID, a string that uniquely identifies the message","type":"string","example":"Xj5LmNkWSOqRbdvOpR34BA.recvd-85abf8d92c-3qfgp-2-7890E356-43C.1","refName":"SgMessageId","modelName":"SgMessageId"},"sg_event_id":{"description":"SendGrid Event ID, a string that uniquely identifies the event","type":"string","example":"2M1MaNdWRNipzTpyUCWQ2g","refName":"SgEventId","modelName":"SgEventId"},"timestamp":{"description":"Unix timestamp","type":"integer","example":1755187955,"refName":"UnixEpochSeconds","modelName":"UnixEpochSeconds"},"smtp-id":{"description":"SMTP ID associated with the message","type":"string","example":"<14c5d75ce93.dfd.64b469@ismtpd-555>","refName":"SmtpId","modelName":"SmtpId"},"ip":{"description":"IPv4 or IPv6 address","type":"string","example":"192.168.1.1","refName":"IpAddress","modelName":"IpAddress"},"tls":{"description":"Indicates whether TLS was used (1). This field will only be present if TLS was used.","type":"integer","enum":[1],"refName":"TlsEnabled","modelName":"TlsEnabled"},"category":{"description":"Message categories","type":"array","refName":"EmailCategories","modelName":"EmailCategories","items":{"type":"string"}},"asm_group_id":{"type":"integer","description":"The ID of the ASM (Advanced Suppression Manager) group associated with the message","example":12345,"refName":"AsmGroupId","modelName":"AsmGroupId"},"bounce_classification":{"type":"string","enum":["Content","Frequency or Volume Too High","Invalid Address","Mailbox Unavailable","Reputation","Technical","Unclassified"],"refName":"BounceClassification","modelName":"BounceClassification"},"reason":{"type":"string","description":"SMTP response code and message indicating the reason the delivery succeeded or failed","example":"250 2.0.0 OK  1755119505 e9e14a558f8cb-3e543d3ec1csi148151125cb.10 - gsmtp\n","refName":"SmtpResponse","modelName":"SmtpResponse"},"status":{"type":"string","description":"SMTP status code associated with the bounce","pattern":"^([245]\\.[01234567]\\.[01234567]|[1-5][0-9][0-9])$","example":"5.1.1","refName":"SmtpStatus","modelName":"SmtpStatus"},"type":{"description":"The type of bounce that occurred.\n\n- `bounce` typically means that the message is permanently undeliverable (hard bounce).\n- `blocked` indicates that the message was temporarily undeliverable (soft bounce).\n","type":"string","enum":["bounce","blocked"],"refName":"BounceType","modelName":"BounceType"},"cert_err":{"type":"string","enum":["1"],"description":"Indicates that there was a certificate error during the TLS handshake.","refName":"CertificateError","modelName":"CertificateError"},"custom_args":{"description":"Custom arguments provided with the mail send request.\nWe deviate here from the Event Webhook schema by NOT merging custom args into the top level of the object,\nin order to avoid collisions with system-defined fields.\nThese are known as Custom Args in [/v3/mail/send](/docs/sendgrid/api-reference/mail-send/mail-send)\nbut [Unique Args](/docs/sendgrid/for-developers/sending-email/unique-arguments) in SMTP and HTTP v2 mail send (/api/mail.send.json).\n","type":"object","example":{"key1":"value1"},"refName":"CustomArgs","modelName":"CustomArgs","additionalProperties":{"type":"string"}}},"required":["event","email","sg_message_id","sg_event_id","timestamp","type"],"refName":"BounceEvent","modelName":"BounceEvent"},{"title":"click","type":"object","properties":{"event":{"type":"string","enum":["click"],"refName":"Event1","modelName":"Event1"},"email":{"type":"string","description":"Recipient email address.\n"},"sg_message_id":{"description":"SendGrid Message ID, a string that uniquely identifies the message","type":"string","example":"Xj5LmNkWSOqRbdvOpR34BA.recvd-85abf8d92c-3qfgp-2-7890E356-43C.1","refName":"SgMessageId","modelName":"SgMessageId"},"sg_event_id":{"description":"SendGrid Event ID, a string that uniquely identifies the event","type":"string","example":"2M1MaNdWRNipzTpyUCWQ2g","refName":"SgEventId","modelName":"SgEventId"},"timestamp":{"description":"Unix timestamp","type":"integer","example":1755187955,"refName":"UnixEpochSeconds","modelName":"UnixEpochSeconds"},"url":{"description":"Url associated with the event","type":"string","example":"http://example.com/some/path?query=param","refName":"Url","modelName":"Url"},"ip":{"description":"IPv4 or IPv6 address","type":"string","example":"192.168.1.1","refName":"IpAddress","modelName":"IpAddress"},"useragent":{"description":"User agent of the request that triggered the event","type":"string","example":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)","refName":"HttpUserAgent","modelName":"HttpUserAgent"},"category":{"description":"Message categories","type":"array","refName":"EmailCategories","modelName":"EmailCategories","items":{"type":"string"}},"asm_group_id":{"type":"integer","description":"The ID of the ASM (Advanced Suppression Manager) group associated with the message","example":12345,"refName":"AsmGroupId","modelName":"AsmGroupId"},"url_offset":{"description":"The offset index of the Url in the email content that was interacted with,\nand its content type.\n","type":"object","example":{"index":0,"type":"html"},"refName":"EngagementUrlOffset","modelName":"EngagementUrlOffset","properties":{"index":{"type":"integer"},"type":{"description":"The content type of the email part that was interacted with.\nThis is derived from the prefix of the \"urlOffset\" in engagement events:\n\n```\nh|o|uh -> html\nut|t   -> text\num     -> header\na      -> amp\n```\n","type":"string","enum":["html","text","header","amp"],"refName":"EngagementUrlContentType","modelName":"EngagementUrlContentType"}}},"custom_args":{"description":"Custom arguments provided with the mail send request.\nWe deviate here from the Event Webhook schema by NOT merging custom args into the top level of the object,\nin order to avoid collisions with system-defined fields.\nThese are known as Custom Args in [/v3/mail/send](/docs/sendgrid/api-reference/mail-send/mail-send)\nbut [Unique Args](/docs/sendgrid/for-developers/sending-email/unique-arguments) in SMTP and HTTP v2 mail send (/api/mail.send.json).\n","type":"object","example":{"key1":"value1"},"refName":"CustomArgs","modelName":"CustomArgs","additionalProperties":{"type":"string"}}},"required":["event","email","sg_message_id","sg_event_id","timestamp"],"refName":"ClickEvent","modelName":"ClickEvent"},{"title":"deferred","type":"object","properties":{"event":{"type":"string","enum":["deferred"],"refName":"Event2","modelName":"Event2"},"email":{"type":"string","description":"Recipient email address.\n"},"sg_message_id":{"description":"SendGrid Message ID, a string that uniquely identifies the message","type":"string","example":"Xj5LmNkWSOqRbdvOpR34BA.recvd-85abf8d92c-3qfgp-2-7890E356-43C.1","refName":"SgMessageId","modelName":"SgMessageId"},"sg_event_id":{"description":"SendGrid Event ID, a string that uniquely identifies the event","type":"string","example":"2M1MaNdWRNipzTpyUCWQ2g","refName":"SgEventId","modelName":"SgEventId"},"timestamp":{"description":"Unix timestamp","type":"integer","example":1755187955,"refName":"UnixEpochSeconds","modelName":"UnixEpochSeconds"},"smtp-id":{"description":"SMTP ID associated with the message","type":"string","example":"<14c5d75ce93.dfd.64b469@ismtpd-555>","refName":"SmtpId","modelName":"SmtpId"},"response":{"type":"string","description":"SMTP response code and message indicating the reason the delivery succeeded or failed","example":"250 2.0.0 OK  1755119505 e9e14a558f8cb-3e543d3ec1csi148151125cb.10 - gsmtp\n","refName":"SmtpResponse","modelName":"SmtpResponse"},"attempt":{"description":"The number of delivery attempts made for this email (zero-based counting).","type":"string","pattern":"^[0-9]+$"},"ip":{"description":"IPv4 or IPv6 address","type":"string","example":"192.168.1.1","refName":"IpAddress","modelName":"IpAddress"},"tls":{"description":"Indicates whether TLS was used (1). This field will only be present if TLS was used.","type":"integer","enum":[1],"refName":"TlsEnabled","modelName":"TlsEnabled"},"category":{"description":"Message categories","type":"array","refName":"EmailCategories","modelName":"EmailCategories","items":{"type":"string"}},"asm_group_id":{"type":"integer","description":"The ID of the ASM (Advanced Suppression Manager) group associated with the message","example":12345,"refName":"AsmGroupId","modelName":"AsmGroupId"},"cert_err":{"type":"string","enum":["1"],"description":"Indicates that there was a certificate error during the TLS handshake.","refName":"CertificateError","modelName":"CertificateError"},"domain":{"description":"The domain part of the recipient's email address.","type":"string","pattern":"^.+\\..+$","example":"example.com"},"from":{"type":"string","description":"The email address of the sender.\nThis may not always be a valid email address.\n"},"custom_args":{"description":"Custom arguments provided with the mail send request.\nWe deviate here from the Event Webhook schema by NOT merging custom args into the top level of the object,\nin order to avoid collisions with system-defined fields.\nThese are known as Custom Args in [/v3/mail/send](/docs/sendgrid/api-reference/mail-send/mail-send)\nbut [Unique Args](/docs/sendgrid/for-developers/sending-email/unique-arguments) in SMTP and HTTP v2 mail send (/api/mail.send.json).\n","type":"object","example":{"key1":"value1"},"refName":"CustomArgs","modelName":"CustomArgs","additionalProperties":{"type":"string"}}},"required":["event","email","sg_message_id","sg_event_id","smtp-id","timestamp","response","attempt"],"refName":"DeferredEvent","modelName":"DeferredEvent"},{"title":"delivered","type":"object","properties":{"event":{"type":"string","enum":["delivered"],"refName":"Event3","modelName":"Event3"},"email":{"type":"string","description":"Recipient email address.\n"},"sg_message_id":{"description":"SendGrid Message ID, a string that uniquely identifies the message","type":"string","example":"Xj5LmNkWSOqRbdvOpR34BA.recvd-85abf8d92c-3qfgp-2-7890E356-43C.1","refName":"SgMessageId","modelName":"SgMessageId"},"sg_event_id":{"description":"SendGrid Event ID, a string that uniquely identifies the event","type":"string","example":"2M1MaNdWRNipzTpyUCWQ2g","refName":"SgEventId","modelName":"SgEventId"},"timestamp":{"description":"Unix timestamp","type":"integer","example":1755187955,"refName":"UnixEpochSeconds","modelName":"UnixEpochSeconds"},"smtp-id":{"description":"SMTP ID associated with the message","type":"string","example":"<14c5d75ce93.dfd.64b469@ismtpd-555>","refName":"SmtpId","modelName":"SmtpId"},"ip":{"description":"IPv4 or IPv6 address","type":"string","example":"192.168.1.1","refName":"IpAddress","modelName":"IpAddress"},"response":{"type":"string","description":"SMTP response code and message indicating the reason the delivery succeeded or failed","example":"250 2.0.0 OK  1755119505 e9e14a558f8cb-3e543d3ec1csi148151125cb.10 - gsmtp\n","refName":"SmtpResponse","modelName":"SmtpResponse"},"tls":{"description":"Indicates whether TLS was used (1). This field will only be present if TLS was used.","type":"integer","enum":[1],"refName":"TlsEnabled","modelName":"TlsEnabled"},"category":{"description":"Message categories","type":"array","refName":"EmailCategories","modelName":"EmailCategories","items":{"type":"string"}},"asm_group_id":{"type":"integer","description":"The ID of the ASM (Advanced Suppression Manager) group associated with the message","example":12345,"refName":"AsmGroupId","modelName":"AsmGroupId"},"cert_err":{"type":"string","enum":["1"],"description":"Indicates that there was a certificate error during the TLS handshake.","refName":"CertificateError","modelName":"CertificateError"},"custom_args":{"description":"Custom arguments provided with the mail send request.\nWe deviate here from the Event Webhook schema by NOT merging custom args into the top level of the object,\nin order to avoid collisions with system-defined fields.\nThese are known as Custom Args in [/v3/mail/send](/docs/sendgrid/api-reference/mail-send/mail-send)\nbut [Unique Args](/docs/sendgrid/for-developers/sending-email/unique-arguments) in SMTP and HTTP v2 mail send (/api/mail.send.json).\n","type":"object","example":{"key1":"value1"},"refName":"CustomArgs","modelName":"CustomArgs","additionalProperties":{"type":"string"}}},"required":["email","event","ip","response","smtp-id","sg_event_id","sg_message_id","timestamp"],"refName":"DeliveredEvent","modelName":"DeliveredEvent"},{"title":"dropped","type":"object","properties":{"event":{"type":"string","enum":["dropped","cancel_drop"],"refName":"Event4","modelName":"Event4"},"email":{"type":"string","description":"Recipient email address. \nThis field may be empty in some `drop` events.\n"},"sg_message_id":{"description":"SendGrid Message ID, a string that uniquely identifies the message","type":"string","example":"Xj5LmNkWSOqRbdvOpR34BA.recvd-85abf8d92c-3qfgp-2-7890E356-43C.1","refName":"SgMessageId","modelName":"SgMessageId"},"sg_event_id":{"description":"SendGrid Event ID, a string that uniquely identifies the event","type":"string","example":"2M1MaNdWRNipzTpyUCWQ2g","refName":"SgEventId","modelName":"SgEventId"},"timestamp":{"description":"Unix timestamp","type":"integer","example":1755187955,"refName":"UnixEpochSeconds","modelName":"UnixEpochSeconds"},"smtp-id":{"description":"SMTP ID associated with the message","type":"string","example":"<14c5d75ce93.dfd.64b469@ismtpd-555>","refName":"SmtpId","modelName":"SmtpId"},"reason":{"type":"string","description":"The general reason the email was dropped","example":"Bounced Address\n","refName":"DropReason","modelName":"DropReason"},"pool":{"description":"Outbound IP Pool metadata","type":"object","refName":"OutboundIpPoolMetadata","modelName":"OutboundIpPoolMetadata","properties":{"name":{"description":"IP Pool name","type":"string"},"id":{"description":"IP Pool ID, as a numeric string","type":"string","pattern":"^[0-9]+$"}}},"category":{"description":"Message categories","type":"array","refName":"EmailCategories","modelName":"EmailCategories","items":{"type":"string"}},"asm_group_id":{"type":"integer","description":"The ID of the ASM (Advanced Suppression Manager) group associated with the message","example":12345,"refName":"AsmGroupId","modelName":"AsmGroupId"},"message":{"type":"string","description":"A detailed error message indicating why the email was dropped."},"custom_args":{"description":"Custom arguments provided with the mail send request.\nWe deviate here from the Event Webhook schema by NOT merging custom args into the top level of the object,\nin order to avoid collisions with system-defined fields.\nThese are known as Custom Args in [/v3/mail/send](/docs/sendgrid/api-reference/mail-send/mail-send)\nbut [Unique Args](/docs/sendgrid/for-developers/sending-email/unique-arguments) in SMTP and HTTP v2 mail send (/api/mail.send.json).\n","type":"object","example":{"key1":"value1"},"refName":"CustomArgs","modelName":"CustomArgs","additionalProperties":{"type":"string"}}},"required":["event","email","sg_message_id","sg_event_id","timestamp","smtp-id","reason"],"refName":"DroppedEvent","modelName":"DroppedEvent"},{"title":"open","type":"object","properties":{"event":{"type":"string","enum":["open"],"refName":"Event5","modelName":"Event5"},"email":{"type":"string","description":"Recipient email address.\n"},"sg_message_id":{"description":"SendGrid Message ID, a string that uniquely identifies the message","type":"string","example":"Xj5LmNkWSOqRbdvOpR34BA.recvd-85abf8d92c-3qfgp-2-7890E356-43C.1","refName":"SgMessageId","modelName":"SgMessageId"},"sg_event_id":{"description":"SendGrid Event ID, a string that uniquely identifies the event","type":"string","example":"2M1MaNdWRNipzTpyUCWQ2g","refName":"SgEventId","modelName":"SgEventId"},"timestamp":{"description":"Unix timestamp","type":"integer","example":1755187955,"refName":"UnixEpochSeconds","modelName":"UnixEpochSeconds"},"url":{"description":"Url associated with the event","type":"string","example":"http://example.com/some/path?query=param","refName":"Url","modelName":"Url"},"ip":{"description":"IPv4 or IPv6 address","type":"string","example":"192.168.1.1","refName":"IpAddress","modelName":"IpAddress"},"useragent":{"description":"User agent of the request that triggered the event","type":"string","example":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)","refName":"HttpUserAgent","modelName":"HttpUserAgent"},"category":{"description":"Message categories","type":"array","refName":"EmailCategories","modelName":"EmailCategories","items":{"type":"string"}},"asm_group_id":{"type":"integer","description":"The ID of the ASM (Advanced Suppression Manager) group associated with the message","example":12345,"refName":"AsmGroupId","modelName":"AsmGroupId"},"sg_content_type":{"description":"The content type of the email part that was interacted with.\nThis is derived from the prefix of the \"urlOffset\" in engagement events:\n\n```\nh|o|uh -> html\nut|t   -> text\num     -> header\na      -> amp\n```\n","type":"string","enum":["html","text","header","amp"],"refName":"EngagementUrlContentType","modelName":"EngagementUrlContentType"},"sg_machine_open":{"description":"Indicates whether the open was detected as being performed by a machine rather than a human.\nThe field is omitted if the value would be false.\n","type":"boolean","enum":[true],"refName":"SgMachineOpen","modelName":"SgMachineOpen"},"custom_args":{"description":"Custom arguments provided with the mail send request.\nWe deviate here from the Event Webhook schema by NOT merging custom args into the top level of the object,\nin order to avoid collisions with system-defined fields.\nThese are known as Custom Args in [/v3/mail/send](/docs/sendgrid/api-reference/mail-send/mail-send)\nbut [Unique Args](/docs/sendgrid/for-developers/sending-email/unique-arguments) in SMTP and HTTP v2 mail send (/api/mail.send.json).\n","type":"object","example":{"key1":"value1"},"refName":"CustomArgs","modelName":"CustomArgs","additionalProperties":{"type":"string"}}},"required":["event","email","sg_message_id","sg_event_id","timestamp"],"refName":"OpenEvent","modelName":"OpenEvent"},{"title":"processed","type":"object","properties":{"event":{"type":"string","enum":["processed"],"refName":"Event6","modelName":"Event6"},"email":{"type":"string","description":"Recipient email address.\n"},"sg_message_id":{"description":"SendGrid Message ID, a string that uniquely identifies the message","type":"string","example":"Xj5LmNkWSOqRbdvOpR34BA.recvd-85abf8d92c-3qfgp-2-7890E356-43C.1","refName":"SgMessageId","modelName":"SgMessageId"},"sg_event_id":{"description":"SendGrid Event ID, a string that uniquely identifies the event","type":"string","example":"2M1MaNdWRNipzTpyUCWQ2g","refName":"SgEventId","modelName":"SgEventId"},"timestamp":{"description":"Unix timestamp","type":"integer","example":1755187955,"refName":"UnixEpochSeconds","modelName":"UnixEpochSeconds"},"smtp-id":{"type":"string","example":"<14c5d75ce93.dfd.64b469@ismtpd-555>"},"send_at":{"description":"The Unix timestamp in seconds of when the email is scheduled to be sent.","type":"integer","format":"int64"},"pool":{"description":"Outbound IP Pool metadata","type":"object","refName":"OutboundIpPoolMetadata","modelName":"OutboundIpPoolMetadata","properties":{"name":{"description":"IP Pool name","type":"string"},"id":{"description":"IP Pool ID, as a numeric string","type":"string","pattern":"^[0-9]+$"}}},"category":{"description":"Message categories","type":"array","refName":"EmailCategories","modelName":"EmailCategories","items":{"type":"string"}},"asm_group_id":{"type":"integer","description":"The ID of the ASM (Advanced Suppression Manager) group associated with the message","example":12345,"refName":"AsmGroupId","modelName":"AsmGroupId"},"custom_args":{"description":"Custom arguments provided with the mail send request.\nWe deviate here from the Event Webhook schema by NOT merging custom args into the top level of the object,\nin order to avoid collisions with system-defined fields.\nThese are known as Custom Args in [/v3/mail/send](/docs/sendgrid/api-reference/mail-send/mail-send)\nbut [Unique Args](/docs/sendgrid/for-developers/sending-email/unique-arguments) in SMTP and HTTP v2 mail send (/api/mail.send.json).\n","type":"object","example":{"key1":"value1"},"refName":"CustomArgs","modelName":"CustomArgs","additionalProperties":{"type":"string"}}},"required":["email","event","sg_event_id","sg_message_id","smtp-id","timestamp"],"refName":"ProcessedEvent","modelName":"ProcessedEvent"},{"title":"received","type":"object","properties":{"event":{"type":"string","enum":["received"],"refName":"Event7","modelName":"Event7"},"recv_msgid":{"description":"Received Message ID, a string that uniquely identifies the mail send request","type":"string","example":"Xj5LmNkWSOqRbdvOpR34BA","refName":"ReceivedMessageId","modelName":"ReceivedMessageId"},"sg_event_id":{"description":"SendGrid Event ID, a string that uniquely identifies the event","type":"string","example":"2M1MaNdWRNipzTpyUCWQ2g","refName":"SgEventId","modelName":"SgEventId"},"timestamp":{"description":"Unix timestamp","type":"integer","example":1755187955,"refName":"UnixEpochSeconds","modelName":"UnixEpochSeconds"},"api_key_id":{"type":"string","description":"The ID of the API Key used to authenticate the sending request for the message.","pattern":"^$|^[A-Za-z0-9_-]+$","maxLength":50},"api_version":{"type":"string"},"client_ip":{"type":"string","description":"IPv4 or IPv6 address.","example":"192.168.1.1"},"protocol":{"type":"string","example":"HTTP"},"recipient_count":{"type":"integer","description":"Number of recipients."},"reseller_id":{"type":"string"},"size":{"type":"integer","description":"Size of the email in bytes."},"useragent":{"description":"User agent of the request that triggered the event","type":"string","example":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)","refName":"HttpUserAgent","modelName":"HttpUserAgent"},"v3_payload_details":{"type":"object","description":"Key-value pairs associated with the payload.","additionalProperties":{"type":"integer","format":"int64"}}},"required":["client_ip","email","event","protocol","recipient_count","recv_msgid","sg_event_id","size","timestamp"],"refName":"ReceivedEvent","modelName":"ReceivedEvent"},{"title":"spamreport","type":"object","properties":{"event":{"type":"string","enum":["spamreport"],"refName":"Event8","modelName":"Event8"},"email":{"type":"string","description":"Recipient email address.\n"},"sg_message_id":{"description":"SendGrid Message ID, a string that uniquely identifies the message","type":"string","example":"Xj5LmNkWSOqRbdvOpR34BA.recvd-85abf8d92c-3qfgp-2-7890E356-43C.1","refName":"SgMessageId","modelName":"SgMessageId"},"sg_event_id":{"description":"SendGrid Event ID, a string that uniquely identifies the event","type":"string","example":"2M1MaNdWRNipzTpyUCWQ2g","refName":"SgEventId","modelName":"SgEventId"},"timestamp":{"description":"Unix timestamp","type":"integer","example":1755187955,"refName":"UnixEpochSeconds","modelName":"UnixEpochSeconds"},"category":{"description":"Message categories","type":"array","refName":"EmailCategories","modelName":"EmailCategories","items":{"type":"string"}},"custom_args":{"description":"Custom arguments provided with the mail send request.\nWe deviate here from the Event Webhook schema by NOT merging custom args into the top level of the object,\nin order to avoid collisions with system-defined fields.\nThese are known as Custom Args in [/v3/mail/send](/docs/sendgrid/api-reference/mail-send/mail-send)\nbut [Unique Args](/docs/sendgrid/for-developers/sending-email/unique-arguments) in SMTP and HTTP v2 mail send (/api/mail.send.json).\n","type":"object","example":{"key1":"value1"},"refName":"CustomArgs","modelName":"CustomArgs","additionalProperties":{"type":"string"}}},"required":["event","email","sg_message_id","sg_event_id","timestamp"],"refName":"SpamReportEvent","modelName":"SpamReportEvent"},{"title":"group_unsubscribe","type":"object","properties":{"event":{"type":"string","enum":["group_unsubscribe"],"refName":"Event9","modelName":"Event9"},"email":{"type":"string","description":"Recipient email address.\n"},"sg_message_id":{"description":"SendGrid Message ID, a string that uniquely identifies the message","type":"string","example":"Xj5LmNkWSOqRbdvOpR34BA.recvd-85abf8d92c-3qfgp-2-7890E356-43C.1","refName":"SgMessageId","modelName":"SgMessageId"},"sg_event_id":{"description":"SendGrid Event ID, a string that uniquely identifies the event","type":"string","example":"2M1MaNdWRNipzTpyUCWQ2g","refName":"SgEventId","modelName":"SgEventId"},"timestamp":{"description":"Unix timestamp","type":"integer","example":1755187955,"refName":"UnixEpochSeconds","modelName":"UnixEpochSeconds"},"ip":{"description":"IPv4 or IPv6 address","type":"string","example":"192.168.1.1","refName":"IpAddress","modelName":"IpAddress"},"useragent":{"description":"User agent of the request that triggered the event","type":"string","example":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)","refName":"HttpUserAgent","modelName":"HttpUserAgent"},"category":{"description":"Message categories","type":"array","refName":"EmailCategories","modelName":"EmailCategories","items":{"type":"string"}},"asm_group_id":{"type":"integer","description":"The ID of the ASM (Advanced Suppression Manager) group associated with the message","example":12345,"refName":"AsmGroupId","modelName":"AsmGroupId"},"custom_args":{"description":"Custom arguments provided with the mail send request.\nWe deviate here from the Event Webhook schema by NOT merging custom args into the top level of the object,\nin order to avoid collisions with system-defined fields.\nThese are known as Custom Args in [/v3/mail/send](/docs/sendgrid/api-reference/mail-send/mail-send)\nbut [Unique Args](/docs/sendgrid/for-developers/sending-email/unique-arguments) in SMTP and HTTP v2 mail send (/api/mail.send.json).\n","type":"object","example":{"key1":"value1"},"refName":"CustomArgs","modelName":"CustomArgs","additionalProperties":{"type":"string"}}},"required":["event","email","sg_message_id","sg_event_id","timestamp"],"refName":"GroupUnsubscribeEvent","modelName":"GroupUnsubscribeEvent"},{"title":"group_resubscribe","type":"object","properties":{"event":{"type":"string","enum":["group_resubscribe"],"refName":"Event10","modelName":"Event10"},"email":{"type":"string","description":"Recipient email address.\n"},"sg_message_id":{"description":"SendGrid Message ID, a string that uniquely identifies the message","type":"string","example":"Xj5LmNkWSOqRbdvOpR34BA.recvd-85abf8d92c-3qfgp-2-7890E356-43C.1","refName":"SgMessageId","modelName":"SgMessageId"},"sg_event_id":{"description":"SendGrid Event ID, a string that uniquely identifies the event","type":"string","example":"2M1MaNdWRNipzTpyUCWQ2g","refName":"SgEventId","modelName":"SgEventId"},"timestamp":{"description":"Unix timestamp","type":"integer","example":1755187955,"refName":"UnixEpochSeconds","modelName":"UnixEpochSeconds"},"ip":{"description":"IPv4 or IPv6 address","type":"string","example":"192.168.1.1","refName":"IpAddress","modelName":"IpAddress"},"useragent":{"description":"User agent of the request that triggered the event","type":"string","example":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)","refName":"HttpUserAgent","modelName":"HttpUserAgent"},"category":{"description":"Message categories","type":"array","refName":"EmailCategories","modelName":"EmailCategories","items":{"type":"string"}},"asm_group_id":{"type":"integer","description":"The ID of the ASM (Advanced Suppression Manager) group associated with the message","example":12345,"refName":"AsmGroupId","modelName":"AsmGroupId"},"custom_args":{"description":"Custom arguments provided with the mail send request.\nWe deviate here from the Event Webhook schema by NOT merging custom args into the top level of the object,\nin order to avoid collisions with system-defined fields.\nThese are known as Custom Args in [/v3/mail/send](/docs/sendgrid/api-reference/mail-send/mail-send)\nbut [Unique Args](/docs/sendgrid/for-developers/sending-email/unique-arguments) in SMTP and HTTP v2 mail send (/api/mail.send.json).\n","type":"object","example":{"key1":"value1"},"refName":"CustomArgs","modelName":"CustomArgs","additionalProperties":{"type":"string"}}},"required":["event","email","sg_message_id","sg_event_id","timestamp"],"refName":"GroupResubscribeEvent","modelName":"GroupResubscribeEvent"},{"title":"unsubscribe","type":"object","properties":{"event":{"type":"string","enum":["unsubscribe"],"refName":"Event11","modelName":"Event11"},"email":{"type":"string","description":"Recipient email address.\n"},"sg_message_id":{"description":"SendGrid Message ID, a string that uniquely identifies the message","type":"string","example":"Xj5LmNkWSOqRbdvOpR34BA.recvd-85abf8d92c-3qfgp-2-7890E356-43C.1","refName":"SgMessageId","modelName":"SgMessageId"},"sg_event_id":{"description":"SendGrid Event ID, a string that uniquely identifies the event","type":"string","example":"2M1MaNdWRNipzTpyUCWQ2g","refName":"SgEventId","modelName":"SgEventId"},"timestamp":{"description":"Unix timestamp","type":"integer","example":1755187955,"refName":"UnixEpochSeconds","modelName":"UnixEpochSeconds"},"ip":{"description":"IPv4 or IPv6 address","type":"string","example":"192.168.1.1","refName":"IpAddress","modelName":"IpAddress"},"useragent":{"description":"User agent of the request that triggered the event","type":"string","example":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)","refName":"HttpUserAgent","modelName":"HttpUserAgent"},"reseller_id":{"type":"string"},"category":{"description":"Message categories","type":"array","refName":"EmailCategories","modelName":"EmailCategories","items":{"type":"string"}},"date":{"description":"A date in the format YYYY-MM-DD, after converting the timestamp to the customer's timezone.\n","type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2023-10-01","refName":"CustomerTimezoneDate","modelName":"CustomerTimezoneDate"},"custom_args":{"description":"Custom arguments provided with the mail send request.\nWe deviate here from the Event Webhook schema by NOT merging custom args into the top level of the object,\nin order to avoid collisions with system-defined fields.\nThese are known as Custom Args in [/v3/mail/send](/docs/sendgrid/api-reference/mail-send/mail-send)\nbut [Unique Args](/docs/sendgrid/for-developers/sending-email/unique-arguments) in SMTP and HTTP v2 mail send (/api/mail.send.json).\n","type":"object","example":{"key1":"value1"},"refName":"CustomArgs","modelName":"CustomArgs","additionalProperties":{"type":"string"}}},"required":["date","email","event","sg_event_id","sg_message_id","timestamp"],"refName":"UnsubscribeEvent","modelName":"UnsubscribeEvent"}],"refName":"EmailLogsEvent","modelName":"EmailLogsEvent"}},"client_ip":{"type":"string","description":"The IP address of the user who sent the message."},"category":{"type":"array","description":"The categories associated with the message.","examples":{"singleCategory":{"value":["category1"]},"multiCategory":{"value":["category1","category2"]}},"items":{"type":"string"}},"custom_args":{"type":"object","description":"Custom key-value pairs associated with the message.","additionalProperties":{"type":"string"}},"outbound_ip":{"type":"string","description":"The IP address used to send to the remote Mail Transfer Agent."},"outbound_ip_type":{"type":"string","description":"The type of outbound IP address used to send the message.","example":"dedicated"},"marketing_campaign_id":{"type":"integer","description":"The ID of the marketing campaign associated with the message."},"marketing_campaign_name":{"type":"string","description":"The name of the marketing campaign associated with the message."},"marketing_campaign_split_id":{"type":"integer","description":"The ID of the split associated with the marketing campaign."},"marketing_campaign_version":{"type":"string","description":"The version of the marketing campaign associated with the message."}}}}}}},{"responseCode":"400","schema":{"description":"Bad request.","content":{"application/json":{"schema":{"type":"object","description":"Standard SendGrid error response.","refName":"ErrorResponse","modelName":"ErrorResponse","properties":{"errors":{"type":"array","items":{"type":"object","required":["message"],"refName":"Error","modelName":"Error","properties":{"message":{"type":"string","description":"Error message."},"field":{"type":"string","description":"(Optional) The field that caused the error."}}}}}}}}}},{"responseCode":"403","schema":{"description":"Forbidden may be returned when trying to incorrectly access logs for another user.","content":{"application/json":{"schema":{"type":"object","description":"Standard SendGrid error response.","refName":"ErrorResponse","modelName":"ErrorResponse","properties":{"errors":{"type":"array","items":{"type":"object","required":["message"],"refName":"Error","modelName":"Error","properties":{"message":{"type":"string","description":"Error message."},"field":{"type":"string","description":"(Optional) The field that caused the error."}}}}}}}}}},{"responseCode":"404","schema":{"description":"Message not found. \nThe message may not exist, or it may be older than the data retention period.\n","content":{"application/json":{"schema":{"type":"object","description":"Standard SendGrid error response.","refName":"ErrorResponse","modelName":"ErrorResponse","properties":{"errors":{"type":"array","items":{"type":"object","required":["message"],"refName":"Error","modelName":"Error","properties":{"message":{"type":"string","description":"Error message."},"field":{"type":"string","description":"(Optional) The field that caused the error."}}}}}}}}}},{"responseCode":"429","schema":{"description":"Too many requests; capacity limit exceeded. The caller should reduce concurrent calls or back off exponentially.","content":{"application/json":{"schema":{"type":"object","description":"Standard SendGrid error response.","refName":"ErrorResponse","modelName":"ErrorResponse","properties":{"errors":{"type":"array","items":{"type":"object","required":["message"],"refName":"Error","modelName":"Error","properties":{"message":{"type":"string","description":"Error message."},"field":{"type":"string","description":"(Optional) The field that caused the error."}}}}}}}}}},{"responseCode":"default","schema":{"description":"Default error response","content":{"application/json":{"schema":{"type":"object","description":"Standard SendGrid error response.","refName":"ErrorResponse","modelName":"ErrorResponse","properties":{"errors":{"type":"array","items":{"type":"object","required":["message"],"refName":"Error","modelName":"Error","properties":{"message":{"type":"string","description":"Error message."},"field":{"type":"string","description":"(Optional) The field that caused the error."}}}}}}}}}}]
````

Filter messages by ID

```js
const client = require("@sendgrid/client");
client.setApiKey(process.env.SENDGRID_API_KEY);

const sg_message_id =
  "zYMjsUZORvevDeb4hlcVjg.recvd-6f5cbff5dc-k58s2-1-68CB0DC2-12.0";

const request = {
  url: `/v3/logs/${sg_message_id}`,
  method: "GET",
};

client
  .request(request)
  .then(([response, body]) => {
    console.log(response.statusCode);
    console.log(response.body);
  })
  .catch((error) => {
    console.error(error);
  });
```

```python
import os
from sendgrid import SendGridAPIClient


sg = SendGridAPIClient(os.environ.get("SENDGRID_API_KEY"))

sg_message_id = "zYMjsUZORvevDeb4hlcVjg.recvd-6f5cbff5dc-k58s2-1-68CB0DC2-12.0"

response = sg.client.logs._(sg_message_id).get()

print(response.status_code)
print(response.body)
print(response.headers)
```

```csharp
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using SendGrid;

public class Program {
    public static async Task Main() {
        string apiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
        var client = new SendGridClient(apiKey);

        var sgMessageId = "zYMjsUZORvevDeb4hlcVjg.recvd-6f5cbff5dc-k58s2-1-68CB0DC2-12.0";

        var response = await client.RequestAsync(
            method: SendGridClient.Method.GET, urlPath: $"logs/{sgMessageId}");

        Console.WriteLine(response.StatusCode);
        Console.WriteLine(response.Body.ReadAsStringAsync().Result);
        Console.WriteLine(response.Headers.ToString());
    }
}
```

```java
import com.sendgrid.*;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        try {
            SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
            Request request = new Request();
            request.setMethod(Method.GET);
            request.setEndpoint("/logs/zYMjsUZORvevDeb4hlcVjg.recvd-6f5cbff5dc-k58s2-1-68CB0DC2-12.0");
            Response response = sg.api(request);
            System.out.println(response.getStatusCode());
            System.out.println(response.getBody());
            System.out.println(response.getHeaders());
        } catch (IOException ex) {
            throw ex;
        }
    }
}
```

```go
package main

import (
	"fmt"
	"github.com/sendgrid/sendgrid-go"
	"os"
)

func main() {
	apiKey := os.Getenv("SENDGRID_API_KEY")
	host := "https://api.sendgrid.com"
	request := sendgrid.GetRequest(apiKey, "/v3/logs/zYMjsUZORvevDeb4hlcVjg.recvd-6f5cbff5dc-k58s2-1-68CB0DC2-12.0", host)
	request.Method = "GET"
	response, err := sendgrid.API(request)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		fmt.Println(response.StatusCode)
		fmt.Println(response.Body)
		fmt.Println(response.Headers)
	}
}
```

```php
<?php
// Uncomment the next line if you're using a dependency loader (such as Composer) (recommended)
// require 'vendor/autoload.php';

// Uncomment next line if you're not using a dependency loader (such as Composer)
// require_once '<PATH TO>/sendgrid-php.php';

$apiKey = getenv("SENDGRID_API_KEY");
$sg = new \SendGrid($apiKey);
$sg_message_id =
    "zYMjsUZORvevDeb4hlcVjg.recvd-6f5cbff5dc-k58s2-1-68CB0DC2-12.0";

try {
    $response = $sg->client
        ->logs()
        ->_($sg_message_id)
        ->get();
    print $response->statusCode() . "\n";
    print_r($response->headers());
    print $response->body() . "\n";
} catch (Exception $ex) {
    echo "Caught exception: " . $ex->getMessage();
}
```

```ruby
require 'sendgrid-ruby'
include SendGrid

sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
sg_message_id = "zYMjsUZORvevDeb4hlcVjg.recvd-6f5cbff5dc-k58s2-1-68CB0DC2-12.0"

response = sg.client.logs._(sg_message_id).get()
puts response.status_code
puts response.headers
puts response.body
```

```bash
curl -X GET "https://api.sendgrid.com/v3/logs/zYMjsUZORvevDeb4hlcVjg.recvd-6f5cbff5dc-k58s2-1-68CB0DC2-12.0" \
--header "Authorization: Bearer $SENDGRID_API_KEY"
```
