« SES Articles & Guides

Authenticating with our SES Monitor API

Authenticating with our SES Monitor API

This article will walk you through generating an API access key from within your SES Monitor account and use it to retrieve a list of SES messages via our message endpoint. Our SES API provides a powerful way to programmatically access your data and this article should explain how to properly authenticate your requests.

Generating Your API Access Key

To interact with our API, you first need an API access key. Here's how to generate one:

  • Log into your account
  • Navigate to "Settings" and then "API"
  • Click the "Create Access Key" button which will generate a random access key
  • Copy the generated access key and keep it safe - do not share this with anyone

Authenticating API Calls with CURL

With your API access key in hand you’re ready to start using the SES Monitor API. We'll use the CURL command-line tool to make API requests. CURL is a versatile tool available on most operating systems.

To retrieve a list of SES messages in your account, you'll use the "Messages Endpoint". Here's a basic curl command to do this:

curl -X POST 'https://api.sesmonitor.com/api/v1/messages/list' \
-H 'Authorization: Bearer YOUR_API_ACCESS_KEY' \
-H 'Content-Type: application/json'

Replace YOUR_API_ACCESS_KEY with the key you generated earlier from within your SES Monitor account.

Understanding the curl Command

  • -X POST: This specifies the HTTP method, in this case, POST.
  • https://api.sesmonitor.com/api/v1/messages/list: This is the URL of the Messages Endpoint.
  • -H 'Authorization: Bearer YOUR_API_ACCESS_KEY': This adds a header for authorization with your API access key.
  • -H 'Content-Type: application/json': This sets the content type of the request to JSON.
    Response

Upon successful execution, you'll receive a JSON response which includes a list of messages from your account. Here's an example output...

Array
(
    [timestamp] => 1706548818
    [timer] => 0.81938
    [success] => 1
    [result] => Array
        (
            [messages] => Array
                (
                    [total_items] => 1
                    [items] => Array
                        (
                            [0] => Array
                                (
                                    [uuid] => 768bd0ea-beca-11ee-8037-b21dbfe5a9e7
                                    [created] => 2024-01-29 17:18:47
                                    [subject] => Exploring the SES Monitor API
                                    [sender] => noreply@sesmonitor.com
                                    [date_sent] => 2024-01-29 17:18:44
                                    [mailer_timestamp] => 2024-01-29 17:18:45
                                    [mailer_message_id] => 0102018d563b0871-32c149f4-4328-4eb0-904c-469966417bd0-000000
                                    [mailer_source_arn] => arn:aws:ses:eu-west-1:1234567890:identity/sesmonitor.com
                                    [mailer_source_ip] => XXX.XXX.XXX.XXX
                                    [did_deliver] => 1
                                    [did_bounce] => 
                                    [did_complain] => 
                                    [did_open] => 
                                    [did_click] => 
                                    [headers] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [uuid] => 768c5f24-beca-11ee-ad68-b21dbfe5a9e7
                                                    [message_uuid] => 768bd0ea-beca-11ee-8037-b21dbfe5a9e7
                                                    [name] => Content-Language
                                                    [value] => en-gb
                                                )

                                            [1] => Array
                                                (
                                                    [uuid] => 768c5b28-beca-11ee-ad44-b21dbfe5a9e7
                                                    [message_uuid] => 768bd0ea-beca-11ee-8037-b21dbfe5a9e7
                                                    [name] => Thread-Index
                                                    [value] => AdpS1lhf8wHrV1reROa1jcQt2a+dFAAALfgg
                                                )

                                            [2] => Array
                                                (
                                                    [uuid] => 768c58bc-beca-11ee-af81-b21dbfe5a9e7
                                                    [message_uuid] => 768bd0ea-beca-11ee-8037-b21dbfe5a9e7
                                                    [name] => X-Mailer
                                                    [value] => Microsoft Office Outlook 12.0
                                                )
                                        )

                                )
                        )

                )

        )

)

Once you're succesfully authenticating against our SES API take a look at how to use our SES Messages API.

AWS SES Resources