Email Service


The Email Service enables you to send email using any of the following approaches:

When sending email with attachments, you can use as attachments any files created previously through createAttachmentFile.

To parameterize the email content or format your emails using HTML/CSS, you can optionally use email templates created previously through the Document Rendering Service.

You can obtain a list of sent messages by running the messages query. Detailed filtering options are available. The query results include, among other information, the delivery status of each message. If there were multiple recipients in the to, cc, and bcc fields, the delivery status is available for each recipient.

To investigate delivery problems across all of your sent messages, run the deliveryFailures query. It returns the history of email addresses that bounced or reported the message as spam, together with the reason and the time of each failure.

Optionally, you can enable tracking engagement for sent messages. This enables you to obtain information about the number of times the email was opened, and when. For messages sent in HTML format, you can track which links contained in the email were clicked, and when.

The Email Service also provides the ability to receive email at any address that has the following format:

 {recipient}@{tenant_subdomain}.{app_subdomain}.socrate.email

where {recipient}, {tenant_subdomain}, and {app_subdomain} are configurable. For example, you could configure your app to accept email at an address like sales@tax.ebs.socrate.email or support-123456@yyy.zzz.socrate.email. For more information, see Receiving email.

You can obtain a list of incoming messages by running the inboundMessages query. Detailed filtering options are available.

Access info

Endpoint https://email-api.socrate.io/graphql
Required access keys Tenant-level service access key
Pricing Check the available purchase options.
Notes To call the service, the access key must be provided in the x-api-key header of the HTTP request. If you are using the GraphQL console, you can view the service’s documentation and schema only after entering an access key. Make sure that the scope of the key allows access to the queries and mutations that you require. For example, to grant the key access to all queries and mutations, the key’s scope must be set to email-api:query:* email-api:mutation:*.

Usage

Sending email from a domain verified at tenant level

You can designate a specific custom domain to be used for sending email, by verifying it. For example, if your domain is example.org and it is verified, then designated email addresses on that domain (such as marketing@example.org, support@example.org, and so on) can send email from the respective domain.

To configure your domain for sending email:

  1. Verify the domain at tenant level.
  2. Restrict sending email only to specific email addresses on that domain. This is an optional, but recommended, step. If you enforce this restriction, sending email will be possible only if the domain is verified and if the email address is in the list of authorized senders. If you do not enforce this restriction, any email address from the domain can send email as long as the domain is verified.
  3. Optionally, configure the Sender Policy Framework (SPF) for your domain.

You can perform the configuration either through GraphQL as described below, or through a graphical user interface (SBS Portal). For instructions about the latter, see Authorized email senders.

Step 1: Verify the domain

  1. Run the verifyDomainIdentity mutation. In the example below, sending email from the domain will be possible only for designated email addresses, because we explicitly set the optional parameter restrictedToEmailSenders to true. The authorized email addresses will be added in a subsequent step.
mutation verifyDomainIdentity($domain:Domain!, $input: VerifyDomainIdentityInput){
    verifyDomainIdentity(domain:$domain, input:$input) {
        domain
        status
        dnsRecords {
            type name value
        }
        restrictedToEmailSenders
    }
}
{ 
    "domain": "YOUR_DOMAIN",
    "input": {
        "restrictedToEmailSenders": true
    }
}
  1. In the response, you will get a list of four DNS records.
  1. Add the DNS records given above to your domain’s DNS zone. The instructions for adding the new DNS records will vary depending on your domain provider.

To view the domain identity and its verification status, run the domainIdentities query, for example:

query domainIdentities {
  domainIdentities {
    items {
      domain
      status
      dnsRecords {
        type
        name
        value
      }
      restrictedToEmailSenders
    }
  }
}

Step 2: Add the authorized senders

In Step 1, we have specified that only designated email addresses are allowed to send email from this domain, by setting the restrictedToEmailSenders option to true. Let’s now add the email addresses authorized to send email for the designated domain, for example:

mutation AddEmailSender($address:EmailAddress!) {
  addEmailSender(address:$address)
}
{
    "address": "jane.doe@example.org"
}

To view the current email senders, run the emailSenders query, for example:

query EmailSenders {
  emailSenders
}

Step 3 (optional): Configure Sender Policy Framework (SPF)

Optionally, to improve the email delivery rate, it is recommended that you add or modify your domain’s Sender Policy Framework. This helps the servers to which you send email verify that your domain is authentic.

More specifically, there is a DNS record of type “TXT” which may already exist on your domain in the form:

Since Socrate Email Service is built on top of Amazon Web Services, the record value must be modified to include amazonses.com as designated outbound mailer, for example:

For more information about Sender Policy Framework, see:

Using the email sender addresses

Once you’ve completed the steps above, you can start using the domain for sending email. More specifically, when running the sendMessage mutation, you can use any verified email sender address in the email’s from field, for example:

mutation sendEmail ($input:SendMessageInput!) {
  sendMessage(
    input: $input
  ) {
    id
  }
}
{
  "input": {
    "to": [{ "name": "TO_NAME", "address": "TO_EMAIL" }],
  	"subject": "Test email",
    "from": {"address":"AUTHORIZED.SENDER@YOUR.VERIFIED.DOMAIN"},
    "htmlBody": "<div>This is some <strong>HTML</strong>.</div>"
  }
}

If you haven’t enabled the restrictedToEmailSenders option on the domain, then you can use any email address of that domain in the from field.

Sending email from a Google or Microsoft 365 email address

To send email from an email address managed by Google or Microsoft 365®, you must connect the user’s mail inbox to SBS, using one of the following approaches:

  1. App Password
  2. OAuth access token

App Password

To send email from an email address authorized by App Password, your app must collect from the user their third-party email address (managed by Google or Microsoft) and their corresponding app password. For instructions about obtaining an app password, see Obtaining a Google App Password and Obtaining a Microsoft 365 App Password.

Once you have the user’s email address and an app password, you can send messages by calling sendMessage as follows (this example assumes the app password was obtained for a Google email address):

mutation sendEmail ($input:SendMessageInput!) {
  sendMessage(
    input: $input
  ) {
    id
  }
}
{
  "input": {
    "to": [{ "address": "TO_EMAIL" }],
  	"subject": "Test sending email with Google app password",
    "from": {
      "address":"YOUR_GOOGLE_EMAIL_ADDRESS",
      "appPassword": {
          "password": "YOUR_GOOGLE_APP_PASSWORD",
          "provider": "GOOGLE"
      }
    },
    "htmlBody": "<div>This is some <strong>HTML</strong>.</div>"
  }
}

Optionally, you can store the email and app password as a verified identity in SBS. Doing this would enable you to call sendMessage without supplying the app password as input, for example:

{
  "input": {
    "to": [{ "address": "TO_EMAIL" }],
  	"subject": "Test sending email with Google app password",
    "from": {
      "address":"YOUR_GOOGLE_EMAIL_ADDRESS",
    },
    "htmlBody": "<div>This is some <strong>HTML</strong>.</div>"
  }
}

To store a verified Google or Microsoft identity in SBS, do one of the following:

mutation addEmailAccount($input:AddEmailAccountInput!) {
  addEmailAccount(input:$input) {
    id
    address
    provider
  }
}
{
  "input": {
    "address": "YOUR_EMAIL_ADDRESS",
    "password": "YOUR_GOOGLE_APP_PASSWORD",
    "provider": "GOOGLE"
  }
}

To list the previously added third-party email accounts, run the emailAccounts query.

To update or delete third-party email accounts, run the updateEmailAccount and deleteEmailAccount mutations, respectively.

OAuth Access Token

To send email from an email address authorized by OAuth 2.0 Access Token:

  1. Perform an authorization of the user as described in Authorization through OAuth 2.0. As part of this step, you will need to provide an approver identifier, which must be set to the internal id of the user in your application.
  2. Run the sendMessage mutation of the Email Service, for example:
mutation sendEmail ($input:SendMessageInput!) {
  sendMessage(
    input: $input
  ) {
    id
  }
}

In variables, make sure to replace values as required. Note that the oauthApprover must be set to the approver ID used in step 1.

{
  "input": {
    "to": [{ "name": "Max Mustermann", "address": "email@example.org" }],
  	"subject": "YOUR_EMAIL_SUBJECT",
    "from": {"oauthApprover": "USER_ID" },
  	"textBody": "YOUR_EMAIL_BODY"    
  }
}

You can list the previously obtained OAuth 2.0 authorizations by running the authorizations query of the OAuth Service.

Sending email from a custom email address

To send email from an email address such as example@some.tenant or example@some.app, you must first verify that email address. Verification means that the bearer of the service access key will be able to use the verified email address in the “from” field when sending email through the sendMessage mutation.

There are two possible implementation scenarios:

  1. Your application needs to allow all its tenants to send email from an email address like example@some.app. In this case, you should verify the email address at application level, as described in Verify an email identity at application level.
  2. A specific tenant needs to send email only on their own behalf, from their own custom address such as example@some.tenant. In this case, you should verify the email address as described below.

To verify an email identity at tenant level:

  1. Run the verifyEmailIdentity mutation and supply the email address to be validated as input. As a result, you will receive two email messages at the specified email address.
mutation verifyEmail($input:EmailAddress!) {
  verifyEmailIdentity(address:$input) {
    address
    status
  }
}
{
  "input": "YOUR_EMAIL_ADDRESS"
}
  1. For each of the received emails, click the confirmation link. This authorizes the corresponding inbox to send emails through the Email Service API.

To view the current status of email identities (verified or pending verification), run the emailIdentities query, for example:

query emailIdentities{
  emailIdentities{
    items {
      address
      status
    }
  }
}

Once you have verified the email inbox, you can use this value in the from input parameter when running the sendMessage mutation.

mutation sendEmail ($input:SendMessageInput!) {
  sendMessage(
    input: $input
  ) {
    id
  }
}
{
  "input": {
    "to": [{ "name": "Max Mustermann", "address": "email@example.org" }],
  	"subject": "YOUR_EMAIL_SUBJECT",
    "from": {"name":"Max Mustermann", "address": "YOUR_VERIFIED_EMAIL"},
  	"textBody": "YOUR_EMAIL_BODY"    
  }
}

Sending email from the default email address

This is the most simple way of sending emails and it does not require any email inbox or domain verification. When running the sendMessage mutation, the only required parameters are at least one of the following (or any combination of): to, cc, and bcc. Secondly, you do not need to provide a value for the from parameter. The From field of the email will be automatically set to no-reply@socrate.email.

For an example, see Tutorial: Send an email.

Sending email with attachments

To send email with attachments, you have to create the attachment files first by running the createAttachmentFile mutation (this is the recommended approach). Alternatively, you can use as attachment any file from the File Management Service.

Once you have the ID(s) of the file attachment(s), you can supply them as parameters when sending the email, for example:

mutation sendMessage ($input:SendMessageInput!) {
  sendMessage(
    input: $input
  ) {
    id
    subject
    messageId
    htmlBody
    textBody
    attachmentCount
    attachments { name fileId }
  }
}
{
  "input": {
   	"to": [{ "address": "{{SOME_EMAIL_ADDRESS}}" }],
  	"subject": "Example email sent with file attachments",
    "htmlBody": "<body><p>This is a test with a PDF file attachment<p>Sent by SBS</p></body>",
    "attachments": [
        {
            "fileId": "{{YOUR_FILE_ID1}}"
        },
        {
            "fileId": "{{YOUR_FILE_ID2}}"
        }
    ]
   }   
  }

In the code listing above, replace YOUR_FILE_ID1 and YOUR_FILE_ID2 with any file ID created through createAttachmentFile or any file ID from the File Management Service.

Sending email using a template

When sending an email, you can optionally apply a template and supply parameters for rendering the respective template. This is useful to send email messages where certain text (for example, URLs or user names) should be supplied dynamically from external sources. You can create templates either from the Document Rendering UI of the SBS Portal, or by calling the Document Rendering Service programmatically.

The following GraphQL code illustrates creating an email template by calling the Document Rendering Service. Notice that the url, name, and code are parameter placeholders:

mutation createTemplate ($input:CreateTemplateInput!) {
        createTemplate(input:$input) {
          id
          name
        }
}
{
    "input": {
        "name": "demo-template",
        "type": "email",
        "subject": "Your activation code for {{url}}",
        "body": "Hello, {{name}}!\n\nHere is the activation code to complete your registration:\n\n{{code}}\n\nSincerely,\nTeam",
        "contentType": "plain"
    }
}

The following code listing illustrates sending an email by applying the demo-template template defined earlier:

mutation sendMessage ($input:SendMessageInput!) {
  sendMessage(
    input: $input
  ) {
    id
    subject
  }
}
{
  "input": {
	"to": [{ "address": "somebody@example.org" }],
  	"template": {
          "name": "demo-template",
          "params": "{\"url\": \"https://example.org\", \"name\": \"John Doe\", \"code\": \"123456\"}"
      }
   }
  }

Since the API call uses a template, the email above will reach the destination address in the form:


**Subject:** Your activation code for https://example.org

**Body:** Hello, John Doe!

Here is the activation code to complete your registration:

123456

Sincerely,
Team

Viewing the delivery status

You can view the delivery status of sent email, by running the messages query and requesting the status of each TO, CC, or BCC recipient, for example:

query sent ($filter:MessagesFilter, $nextToken:String) {
  messages(filter:$filter, nextToken:$nextToken) {
    items {
        id
        to { name address status }
        cc { name address status }
        bcc { name address status }
        subject
        sentAt
    }
    nextToken
  }
}

Note that the delivery status cannot be tracked if the email was sent from a Google or Microsoft account authorized through OAuth 2.0 or app password.

Viewing the delivery failure history

While the messages query tells you the delivery status of a specific message, the deliveryFailures query returns the recorded history of all failed deliveries for your tenant, starting with the most recent one. Use it to investigate delivery problems across messages, rather than one address or one message at a time. For each failure, you obtain the recipient address, the type of failure, the reason reported for it, the time when it occurred, and the identifier of the message that failed, for example:

query deliveryFailures ($filter:DeliveryFailuresFilter, $nextToken:String) {
  deliveryFailures(filter:$filter, nextToken:$nextToken) {
    items {
        emailAddress
        timestamp
        failureType
        reason
        messageId
    }
    nextToken
  }
}

To restrict the results to a period of time, provide a date range in the timestamp filter:

{
    "filter": {
        "timestamp": {
            "from": "2026-07-01",
            "to": "2026-07-31"
        }
    }
}

To find out whether a specific email address is currently blocked for delivery, run the addressStatus query instead. To unblock it, run the unsuppressAddress mutation.

Sending email with tracking options

When sending email, you can optionally enable tracking options. When tracking options are enabled, you can view the following statistics for a sent email message:

  • whether the message was opened by the recipient, and how many times. For each open event, you can view the origin IP address, and the time when the open event took place.
  • whether any links within the email were clicked, and how many clicks took place in total. For each click event, you can view the link that was opened, the origin IP address and the time when the event took place.

You can set tracking options only for email sent through the following means:

It is not possible to set tracking options for email sent from Google or Microsoft addresses that were verified by either OAuth 2.0 authorization or app password.

Tracking options are not enabled by default. To enable tracking options, set the trackEngagement input parameter to true and make sure that the email is in HTML format, for example:

mutation sendMessage ($input:SendMessageInput!) {
  sendMessage(
    input: $input
  ) {
    id
    subject
    messageId
    htmlBody
  }
}
{
    "input": {
        "to": [{
            "address": "SOME_EMAIL_ADDRESS"
        }],
        "subject": "Lorem ipsum",
        "htmlBody": "<body><p>This is a <a href=\"https://socrate.io\">link</a>.</p></body>",
        "trackEngagement": true
    }
}

When tracking is enabled, a tiny 1 pixel image is embedded within the HTML body of the sent message. In addition, all links within the email body are transformed to include Amazon Web Services tracking code.

Note that, if the recipient’s email client application is configured to block images from incoming emails, the tracking statistics will not be available until the user chooses to display the images.

To view the tracking statistics, run the messages query and request statistics about the “open” and “click” events, for example:

query sent ($filter:MessagesFilter, $nextToken:String) {
  messages(filter:$filter, nextToken:$nextToken) {
    items {
        id
        messageId
        from { address, name }
        replyTo { name, address }
        to { address, status }
        subject
        openCount
        clickCount
        opens { createdAt, ipAddress, userAgent, timestamp }
        clicks { createdAt, link, ipAddress, userAgent, timestamp }
    }
    nextToken
  }
}
{
    "filter": {
        "ids": ["YOUR_EMAIL_ID"]
    }
}

Receiving email

SBS will accept email at any address that has the following format:

 {recipient}@{tenant_subdomain}.{app_subdomain}.socrate.email

where:

  • recipient is virtually any string. For example, it could be a department name (such as “sales”, “accounting”, etc), or even include ticket numbers (“support-case-5678654”).
  • tenant_subdomain identifies the tenant in the SBS system and must be configured before you can receive email.
  • app_subdomain identifies the app in the SBS system and must be configured before you can receive email.

To configure your application for receiving email:

  1. Register an email subdomain for your application. You can do this from the SBS Console, or by running the registerAppSubdomain mutation of the Account API. For instructions, see Register an email subdomain at application level.
  2. Register a subdomain for your tenant. You can do this from the SBS Portal, or by running the registerSubdomain mutation of the Email Service. For instructions, see Register an email subdomain at tenant level.

To query all received email, run the inboundMessages query.

Queries

addressStatus

Returns information about whether the email address supplied as input is in the AWS Suppression List, and the reason why. To remove an email address from the suppression list, run the unsuppressAddress mutation.

This query reports only the current suppression state of a single address. To obtain the history of all delivery failures recorded for your tenant, run the deliveryFailures query.

Arguments

Argument Type Description
address EmailAddress Mandatory. The email address for which you would like to obtain the suppression status.

Result

AddressStatus type
Attribute Type Description
isSuppressed Boolean Returns true if the email address is in the AWS suppression list; false otherwise.
suppressionReason String The reason why the email address is suppressed, as provided by AWS.

deliveryFailures

Returns the history of email delivery failures recorded for your tenant, in reverse-chronological order (the most recent failure first). A failure is recorded when a message did not reach the recipient, or when the recipient marked it as Spam or Junk. You can restrict the results to a period of time through the filter argument.

Arguments

Argument Type Description
filter DeliveryFailuresFilter Optional argument used to filter delivery failures.
nextToken String Optional argument used to fetch the next set of results. This value can be obtained from the nextToken attribute of the DeliveryFailuresResult type.
DeliveryFailuresFilter input
Attribute Type Description
timestamp DateFilter Optional. If set, only failures that occurred within the date boundaries set by the DateFilter are returned.

Result

DeliveryFailuresResult type
Attribute Type Description
items [DeliveryFailure] An array of DeliveryFailure objects. A single page holds up to 1000 failures.
nextToken String If null, then the query has reached the end of the list of failures that match the query criteria. If not null, then use this value in the nextToken input argument to obtain the next page.
DeliveryFailure type
Attribute Type Description
emailAddress EmailAddress The recipient address that the message failed to reach.
timestamp DateTime The date and time when the failure occurred, in ISO 8601 format.
failureType DeliveryStatus The type of failure. Valid values: BOUNCED - The message did not reach the recipient; COMPLAINT - The message was marked as Spam or Junk by the recipient.
reason String The reason reported for the failure. For a bounce, this is typically the diagnostic message returned by the recipient’s mail server, for example smtp; 550 5.1.1 As requested: user unknown. For a complaint, this is the complaint subtype; if no subtype was supplied, the value is unknown.
messageId String The unique identifier assigned by the sending server to the message that failed. Use it in the messageId attribute of the MessagesFilter to retrieve the message.
accountId String The identifier of the SBS account under which the message was sent.
appId String The identifier of the SBS application under which the message was sent.
tenantId String The identifier of the SBS tenant under which the message was sent.

domainIdentities

Returns a list of email domain identities and their verification status (verified or pending verification). You should create and verify a domain identity if you intend to send email from a domain verified at tenant level.

Arguments

Argument Type Description
filter DomainIdentitiesFilter Optional argument used to filter domain identities by their status. See the DomainIdentitiesFilter type.
nextToken String Optional argument used to fetch the next set of query results. This value can be obtained from the nextToken attribute of the DomainIdentitiesResult type.
DomainIdentitiesFilter type
Attribute Type Description
status IdentityVerificationStatus An enumeration with two possible values: VERIFIED and PENDING.

Result

DomainIdentitiesResult type
Attribute Type Description
items [DomainIdentity] An array of DomainIdentity objects.
nextToken String If null, then the query has reached the end of the list of results that match the query criteria. If not null, then use this value in the nextToken input argument, with the same filter, to fetch the next set of results.
DomainIdentity type
Attribute Type Description
domain Domain The domain name. For example, example.org.
status IdentityVerificationStatus The verification status. Valid values are VERIFIED and PENDING.
dnsRecords [DnsRecord] An array of DnsRecord objects. See the DnsRecord type.
restrictedToEmailSenders Boolean If true, then sending email from this domain is restricted only to email addresses returned by the emailSenders query (assuming the domain has VERIFIED status). If false, any email address can send email from this domain as long as the domain has VERIFIED status. See also Sending email from a domain verified at tenant level.
DnsRecord type
Attribute Type Description
type DnsRecordType The type of the DNS record. For example, CNAME.
name String The name of the DNS record.
value String The value of the DNS record.

emailAccounts

Returns a list of email accounts authorized to send email managed by providers such as Google or Microsoft 365.

Arguments

Argument Type Description
filter EmailAccountsFilter Optional argument used to filter email accounts. See the EmailAccountsFilter type.
nextToken String If null, then the query has reached the end of the list of results that match the query criteria. If not null, then use this value in the nextToken input argument, with the same filter, to fetch the next set of results.
EmailAccountsFilter type
Attribute Type Description
address EmailAddress The email address associated with this email account.
provider Provider The external provider to which this email account belongs. Valid values are GOOGLE and MICROSOFT.

Result

EmailAccountsResult type
Attribute Type Description
items [EmailAccount] An array of objects of type EmailAccount.
nextToken String If null, then the query has reached the end of the list of results that match the query criteria. If not null, then use this value in the nextToken input argument, with the same filter, to fetch the next set of results.
EmailAccount type
Attribute Type Description
id ID The SBS-internal identifier of the email account.
address EmailAddress The email address associated with this email account.
provider Provider The external provider to which this email account belongs. Valid values are GOOGLE and MICROSOFT.

emailSenders

Returns a list of email addresses authorized to send email from the configured domain identities.

Arguments

None.

Result

The result is an array of EmailAddress.

emailIdentities

Returns a list of email verification requests and their outcome (verified or pending verification), also referred to as “email identities”. Only verified email identities can be used in the from field when sending email from a custom email address.

Arguments

Argument Type Description
filter EmailIdentitiesFilter Optional argument used to filter email identities by their status. See the EmailIdentitiesFilter type.
nextToken String Optional argument used to fetch the next set of query results. This value can be obtained from the nextToken attribute of the EmailIdentitiesResult type.
EmailIdentitiesFilter type
Attribute Type Description
status IdentityVerificationStatus An enumeration with two possible values: VERIFIED or PENDING.

Result

EmailIdentitiesResult type
Attribute Type Description
items [EmailIdentity] An array of EmailIdentity objects.
nextToken String If null, then the query has reached the end of the list of results that match the query criteria. If not null, then use this value in the nextToken input argument, with the same filter, to fetch the next set of results.
EmailIdentity type
Attribute Type Description
address EmailAddress The email address that has been verified or is pending verification.
status IdentityVerificationStatus The verification status. Valid values are VERIFIED and PENDING.

inboundMessages

Returns a list of received email messages, filtered according to the provided criteria. You can provide the criteria through the filter argument.

Arguments

Argument Type Description
filter InboundMessagesFilter Optional argument used to filter email messages.
nextToken String Optional argument used to fetch the next set of query results. This value can be obtained from the nextToken attribute of the InboundMessagesResult type.
order SortOrder Optional argument used to sort the query results. Valid values: CHRONOLOGICAL - sort results in chronological order (oldest first); ANTICHRONOLOGICAL (default) - sort results in reverse chronological order (newest first).
InboundMessagesFilter input

This object provides the criteria by which email messages should be filtered. Note that, if you specify multiple criteria, they will be joined with a logical AND (that is, the call will return only messages that satisfy all criteria).

Attribute Type Description
ids [String] Optional. Specifies an array of message IDs (InboundMessage.id) by which to filter.
messageId String Optional. If set, only email having this messageId will be returned.
toContains String Optional. If set, any email where the to field contains this string will be considered a match.
ccContains String Optional. If set, any email where the cc field contains this string will be considered a match.
replyToContains String Optional. If set, any email where the replyTo field contains this string will be considered a match.
subjectContains String Optional. If set, any email where the subject field contains this string will be considered a match.
bodyContains String Optional. If set, any email where the body field contains this string will be considered a match.
createdAt DateFilter Optional. If set, any email within the date boundaries set by the DateFilter will be considered a match.
externalReference String Optional. If set, any email where the externalReference identifier is equal to this value will be considered a match.
receivedBy EmailAddress Optional. If set, any email where the final recipient (InboundMessage.receivedBy.address) is equal to this value will be considered a match.

Result

InboundMessagesResult type
Attribute Type Description
items [InboundMessage] An array of InboundMessage objects.
nextToken String If null, then the query has reached the end of the list of results that match the query criteria. If not null, then use this value in the nextToken input argument, with the same filter, to fetch the next set of results.
InboundMessage type
Attribute Type Description
id ID! Provides the unique internal message identifier.
messageId String Provides the unique message identifier assigned by the sending server.
from Contact Provides information about the original sender. Even if the email was automatically redirected by several systems on its way from sender to recipient, this field will still reflect the original sender.
replyTo Contact Provides information about the replyTo field.
to [Recipient] Provides information about the email’s recipients. Each Recipient also holds information about the delivery status.
receivedBy Contact The inbox address of the final recipient.
cc [Recipient] Provides information about the email’s carbon copy (CC) recipients. Each Recipient also holds information about the delivery status.
subject String The email’s subject.
textBody String The email’s body, in plain text format.
htmlBody Html The email’s body, in HTML format.
createdAt DateTime The date and time when the email was created.
sentAt DateTime The date and time when the email was sent. This value matches the date within the email.
attachmentCount Int Provides the number of attachments (if the email had any).
attachments [Attachment] Provides information about the actual attachments, as an array of [Attachment] type.
original File The original message stored as a file.
inReplyTo String Provides the Message-ID of the previous message in the chain.
references [String] Provides a list of Message-IDs of previous messages in the chain.
externalReference String An identifier of the inbound email that you may want to set optionally. This field is null by default, unless you populate it with the updateInboundMessage mutation.
autoSubmitted String The content of the Auto-Submitted email header, as it was populated by the email sender. For more information about this header, refer to RFC 3834.
File type
Attribute Type Description
id ID Provides the unique identifier of the file.
downloadUrl(expiresIn:Int) Uri Generates a download URL that will expire after expiresIn seconds.
contentType String The file content (MIME) type.
contentLength Float The file size in bytes.

messages

Returns a list of sent email messages, filtered according to the provided criteria. You can provide the criteria through the filter argument.

Arguments

Argument Type Description
filter MessagesFilter Optional argument used to filter email messages.
nextToken String Optional argument used to fetch the next set of results. This value can be obtained from the nextToken attribute of the MessagesResult type.
MessagesFilter input

This object provides the criteria by which email messages should be filtered. Note that, if you specify multiple criteria, they will be joined with an AND logical clause (that is, the call will return only messages that satisfy all criteria).

Attribute Type Description
ids [String] Optional. Specifies an array of message IDs (id) by which to filter.
messageId String Optional. If set, only email having this messageId will be returned.
toContains String Optional. If set, any email where the to field contains this string will be considered a match.
ccContains String Optional. If set, any email where the cc field contains this string will be considered a match.
bccContains String Optional. If set, any email where the bcc field contains this string will be considered a match.
replyToContains String Optional. If set, any email where the replyTo field contains this string will be considered a match.
subjectContains String Optional. If set, any email where the subject field contains this string will be considered a match.
bodyContains String Optional. If set, any email where the body field contains this string will be considered a match.
createdAt DateFilter Optional. If set, any email within the date boundaries set by the DateFilter will be considered a match.
externalReference String Optional. If set, any email where the externalReference identifier is equal to this value will be considered a match.
DateFilter input
Attribute Type Description
from String ISO date format (for example, “2019-12-01”).
to String ISO date format (for example, “2020-11-30”).

Result

MessagesResult type
Attribute Type Description
items [Message] An array of Message objects.
nextToken String If null, then the query has reached the end of the list of files that match the query criteria. If not null, then use this value in the nextToken input argument to obtain the next page.
Message type
Attribute Type Description
id ID! Provides the unique internal message identifier.
messageId String Provides the unique message identifier assigned by the sending server.
from ContactUser Provides information about the sender.
replyTo Contact Provides information about the replyTo field.
to [Recipient] Provides information about the email’s recipients. Each Recipient also holds information about the delivery status.
cc [Recipient] Provides information about the email’s carbon copy (CC) recipients. Each Recipient also holds information about the delivery status.
bcc [Recipient] Provides information about the email’s blind carbon copy (BCC) recipients. Each Recipient also holds information about the delivery status.
subject String The email’s subject.
textBody String The email’s body, in plain text format.
htmlBody Html The email’s body, in HTML format.
createdAt DateTime The date and time when the email was created.
sentAt DateTime The date and time when the email was sent. This value matches the date within the email.
attachmentCount Int Provides the number of attachments (if the email had any).
attachments [Attachment] Provides information about the actual attachments, as an array of [Attachment] type.
openCount Int The number of times the email was opened by the recipient. This field is populated only if trackEngagement of the SendMessageInput type was set to true.
clickCount Int The number of times any link from the email’s HTML body was clicked by the recipient. This field is populated only if trackEngagement of the SendMessageInput type was set to true.
opens [Open] Provides a list of “email opened” events. This field is populated only if trackEngagement of the SendMessageInput type was set to true.
clicks [Click] Provides a list of “email links clicked” events. This field is populated only if trackEngagement of the SendMessageInput type was set to true.
inReplyTo String Provides the Message-ID of the previous message in the chain.
references [String] Provides a list of Message-IDs of previous messages in the chain.
externalReference String The identifier of the email within the caller system.
ContactUser type
Attribute Type Description
name String Provides the user name associated with the email address.
address EmailAddress Provides the email address.
oauthApprover ID Provides the internal user ID that was authorized to send this email. This field will be populated only if the email was sent from a from a Google or Microsoft 365 inbox. It must be set to the internal user ID in the calling application. Note that, in order for the email to be sent successfully, the user ID must first be authorized, by means of an Authorization through an app password or an Authorization through OAuth 2.0.
Contact type
Attribute Type Description
name String Provides the user name associated with the email address.
address EmailAddress Provides the email address.
Recipient type
Attribute Type Description
name String Provides the user name associated with the email address.
address EmailAddress Provides the email address.
status DeliveryStatus Provides the email delivery status. Valid values: BOUNCED - The message did not reach the recipient; COMPLAINT - The message was marked as Spam or Junk by the recipient; DELIVERED - The message was successfully delivered to recipient; UNKNOWN - No information about the delivery could be obtained.
Attachment type
Attribute Type Description
name String Provides the attachment’s file name.
uri Uri Provides the URI of the attachment, if any.
fileId String Provides the identifier of the file hosted through the File Management Service, if any.
contentType String The content (MIME) type of the attached file.
contentLength Float The size of the attached file, in bytes.
Open type
Attribute Type Description
createdAt DateTime The date and time when the “email open” event was recorded in SBS.
ipAddress String The IP address from which the email was opened.
userAgent String The browser (user agent) of the email client.
timestamp DateTime The date and time when the “email open” event actually took place.
Click type
Attribute Type Description
createdAt DateTime The date and time when the “email link click” event was recorded in SBS.
link String The link (within the email’s HTML body) that was clicked by the recipient.
ipAddress String The IP address where the event took place.
userAgent String The browser (user agent) of the email client.
timestamp DateTime The date and time when the “email link click” event actually took place.

subdomain

Returns information about the currently configured inbound email domain. More precisely, the result is an object that contains three attributes:

  • appLevelDomain - the email domain configured at application level. For example, if your app is configured to receive all inbound email at @ten.app.socrate.email, then appLevelDomain is “app.socrate.email”.
  • subdomain - the email subdomain configured at tenant level. For example, if your app is configured to receive all inbound email at @ten.app.socrate.email, then subdomain is “ten”.
  • domain - the full email domain at which your app is configured to receive all inbound email. It consists of subdomain, followed by a dot, followed by appLevelDomain. Both appLevelDomain and subdomain must be defined in order for domain to be considered configured. A null value means the inbound email domain is not configured.

For instructions about configuring the inbound email domain, see Receiving email.

Result

Subdomain type
Attribute Type Description
subdomain String The email subdomain configured at tenant level.
domain Domain The currently configured email domain. SBS will accept any email sent to recipient@domain, where domain is this value.
appLevelDomain Domain The email domain configured at application level.

version

Returns the API version.

Mutations

addEmailAccount

This mutation is useful if you would like to allow your app’s users to connect an email account from a third-party provider (such as Google or Microsoft 365) to the app through an app password. The app password itself must be obtained by the user from the third-party provider. For details, see Obtaining a Google App Password and Obtaining a Microsoft 365 App Password.

The addEmailAccount mutation adds to SBS the email account managed by Google or Microsoft 365 and stores the app password associated with that email account. Once added, the email address can be used in the from field when sending email through the sendMessage mutation.

Storing the app password in SBS is optional. The alternative is to supply the app password as input in the from field when sending email through the sendMessage mutation.

Arguments

Argument Type Description
input AddEmailAccountInput! Provides the input arguments to the mutation.
AddEmailAccountInput input
Attribute Type Description
address EmailAddress! Specifies the email address that is to be connected to SBS.
password String! The app password obtained from Google or Microsoft 365.
provider Provider! The third-party email provider. Valid values: GOOGLE, MICROSOFT.

Result

See the EmailAccount type.

addEmailSender

Adds an email address authorized to send email from any of the configured domain identities.

Arguments

Argument Type Description
address EmailAddress! The email address to be added.

Result

The result is an EmailAddress type.

Example

mutation AddEmailSender($address:EmailAddress!) {
  addEmailSender(address:$address)
}
{
  "address": "authorized.sender@example.org"
}

createAttachmentFile

Creates a file to be used as an email attachment.

Arguments

Argument Type Description
input CreateAttachmentFileInput! Provides input data required to create the file.
CreateAttachmentFileInput input
Attribute Type Description
name String Optional. Specifies the name of the file to be created, including the file extension, if applicable.
contentType String Optional. The MIME type of the file to be created. If left empty, the MIME will be inferred from the file extension.
externalReference String Optional. An identifier of the file set by the API caller for their own use.
expiresIn Int Optional. Specifies a value, in seconds, after which the file content expires. If you supply this value, the file gets an expiresAt attribute which indicates the date and time when the file is set to expire. NOTE: A file does not expire instantly; the file content may still be available for a maximum of one hour after the actual expiry timestamp.

Result

AttachmentFile type
Attribute Type Description
id ID The unique permanent file identifier.
name String The file name.
active Boolean True if the file is active; false if the file is deactivated. This flag permits API callers to apply a custom logic for treating files differently; in terms of SBS, there is no difference between active and inactive files.
contentType String The file content (MIME) type.
createdAt DateTime The date and time when the file was created.
expiresAt DateTime The date and time when the file is set to expire. Applicable only for files that were created with an expiry option. If null, the file does not expire.
externalReference String An identifier used to associate the file with an entity from the caller system.
uploaded Boolean Indicates that there is file content present, perhaps from some previous upload.
public Boolean Indicates that access to the file is public (true) or protected (false).
uploadUrl Uri Returns an upload URL at which you can replace the content of the file through a PUT HTTP request. The optional argument expiresIn of type Int specifies the time period, in seconds, after which the URL will expire (default is 30 seconds).

Example

Creating attachment files is a two-step operation. First, run the createAttachmentFile mutation and specify the file name to be created as input, for example:

mutation CreateAttachmentFile($input:CreateAttachmentFileInput!) {
  createAttachmentFile(input: $input) {
    id
    uploadUrl(expiresIn:3600)
  }
}
{
    "input": {
        "name": "test.pdf",
        "contentType": "application/pdf",
    }
}

The mutation above creates a file and returns the file’s upload URL. The latter is required for the next step. Note that the period after which the upload URL will expire can be parameterized according to your needs. In the mutation above, it is 3600 seconds (1 hour).

Secondly, run an HTTP PUT request and upload the actual file bytes to the upload URL. The exact program code to achieve this depends on the language you are using. With cURL, the upload operation looks as follows:

  • If you have a bash terminal, run:
    curl --location --request PUT 'YOUR_UPLOAD_URL' --header 'Content-Type: application/pdf' --data-binary '@/path/to/your/file.pdf'
    
  • If you have a Windows terminal, run:
    curl --location --request PUT "YOUR_UPLOAD_URL" --header "Content-Type: application/pdf" --data-binary "@C:\file.pdf"
    

You can query the created attachment files from the File Management Service, by ID. The ID of the file in both services is the same.

deleteDomainIdentity

Deletes a domain identity. Domain identities are created by running the verifyDomainIdentity mutation.

Arguments

Argument Type Description
domain Domain! The domain name of the domain identity to be deleted.

Result

See the DomainIdentity type.

deleteEmailAccount

This mutation deletes a previously added email account from a third-party provider (such as Google or Microsoft 365).

Arguments

Argument Type Description
id ID! The unique identifier of the email account record.

Result

See the EmailAccount type.

deleteEmailIdentity

Deletes an email identity. Email identities are created by running the verifyEmailIdentity mutation.

Arguments

Argument Type Description
address EmailAddress! The email address of the email identity to be deleted.

Result

See the EmailIdentity type.

deleteInboundMessage

Deletes an inbound email and its attachments.

Arguments

Argument Type Description
id ID! The unique identifier of the inbound email.

Result

See the InboundMessage type.

Example

mutation deleteInboundMessage($id:ID!) {
        deleteInboundMessage(id:$id) {
          id
          messageId
          from { address, name }
          to { address, status}
          subject
        }
      }
{
    "id": "YOUR_EMAIL_ID"
}

deleteMessage

Deletes a sent email.

Arguments

Argument Type Description
id ID! The unique identifier of the sent email.

Result

See the Message type.

Example

mutation DeleteMessage ($id:ID!) {
  deleteMessage(
    id: $id
  ) {
    id
    messageId
    from { name address oauthApprover }
    subject
  }
}
{
    "id": "YOUR_EMAIL_ID"
}

deleteSubdomain

Deletes a previously registered email subdomain, see Receiving email.

Arguments

Argument Type Description
input DeleteSubdomainInput! Provides the subdomain value to be deleted.
DeleteSubdomainInput input
Attribute Type Description
subdomain String! The subdomain value to be deleted.

Result

See the Subdomain type.

removeEmailSender

Removes an email address from the list of senders authorized to send email from any of the configured domain identities.

Arguments

Argument Type Description
address EmailAddress! The email address to be removed.

Result

The result is an EmailAddress type.

registerSubdomain

Register an email subdomain that uniquely identifies the current tenant within this app. For more information, see Receiving email.

Arguments

Argument Type Description
input RegisterSubdomainInput! Provides the subdomain value to be registered. Since this value will be part of an email address, it’s advisable to use a short string, descriptive of the tenant.
RegisterSubdomainInput input
Attribute Type Description
subdomain String! The subdomain value to be registered.

Result

See the Subdomain type.

sendMessage

Sends an email message to the specified recipients.

Arguments

Argument Type Description
input SendMessageInput! Mandatory argument used to define the properties of the new email, such as the recipient, cc, bcc, and so on.
SendMessageInput input
Attribute Type Description
to [ContactInput] Specifies an array of ContactInput objects that should be the email’s “to” recipient(s). This field is conditional; you can specify a valid recipient by setting one or more of the following fields: to, cc, bcc.
cc [ContactInput] Specifies an array of ContactInput objects that should be the email’s “cc” recipient(s). This field is conditional; you can specify a valid recipient by setting one or more of the following fields: to, cc, bcc.
bcc [ContactInput] Specifies an array of ContactInput objects that should be the email’s “bcc” recipient(s). This field is conditional; you can specify a valid recipient by setting one or more of the following fields: to, cc, bcc.
replyTo ContactInput Optional. Specifies a ContactInput object. If, upon receiving the email, the recipient clicks Reply in their email client application, then the to field will be automatically populated with this value, which may be different from the from address.
from ContactUserInput Specifies a ContactUserInput object to be used as email sender. This field is mandatory if you are sending email from a validated email address, from a validated domain, or from a Google or Microsoft 365 inbox. If you do not supply the from input, the email will be sent from the default SBS email address.
subject String Optional. Specifies the email’s subject.
textBody String Optional. Specifies the email’s body. To create an email body, either textBody or htmlBody (or both) must be set. If both are specified, then the textBody will be used as a fallback if the email client is not capable of reading HTML email.
htmlBody Html Optional. Specifies the email’s body. To create an email body, either textBody or htmlBody (or both) must be set. If both are specified, then the textBody will be used as a fallback if the email client is not capable of reading HTML email.
attachments [AttachmentInput] Optional. Specifies an array of file attachments, as [AttachmentInput] objects.
template TemplateInput Optional. If you set this parameter, the email’s body will be rendered with the help of a document rendering template created previously through the Document Rendering Service.
inReplyTo String Optional. Specifies the Message-ID of the previous message in the chain.
references [String] Optional. Specifies the Message-IDs of previous messages in the chain.
trackEngagement Boolean Optional. You can track engagement only if (i) htmlBody was set (or generated from a template), (ii) the email was not sent from a Google or Microsoft 365 inbox, and (iii) the recipient’s email client application is not blocking images embedded in the email’s body. Set this value to true if you would like to track information about (i) whether the message was opened (and when), and (ii) whether the recipient has clicked links within the email (and which ones). You can obtain these statistics by running the messages query.
externalReference String Optional. Specifies the identifier associated with the email in the caller system.
doNotStoreBody Boolean Optional. Provides indication to SBS that the email contains sensitive information and should not be stored. If true, the email’s HTML body, text body, and attachments will not be stored in SBS, and the respective attributes of the sent message will be null. The default value is false (meaning that the HTML body, text body and attachments are stored).
ContactInput input
Attribute Type Description
name String Optional. Specifies the user name associated with the email address.
address EmailAddress! Mandatory. Specifies the email address, for example somebody@example.org.
ContactUserInput input
Attribute Type Description
name String Optional. Specifies the user name associated with the email address. Setting this value is meaningful only when address is an email address verified through verifyEmailIdentity or verifyDomainIdentity.
address EmailAddress Conditional. Specifies the sending email address, for example somebody@example.org. You must set this value if you would like to send email (i) from an email address that has already been verified through verifyEmailIdentity, or (ii) from any email address where the domain has been verified through verifyDomainIdentity, or (iii) from an email address managed by a third-party provider (Google, Microsoft). Do not set this value if you set the oauthApprover value. If both address and oauthApprover are set, then oauthApprover takes precedence.
oauthApprover ID Conditional. This field must be set only if you would like to send email from from a Google or Microsoft 365 inbox for which OAuth 2.0 authorization was already obtained as described in Authorization through OAuth 2.0. Set this to the user ID (in your application) for which the OAuth 2.0 access token was obtained.
appPassword AppPasswordInput Conditional. Set this field only when address is a Google or Microsoft email address for which you would like to provide an app password as input. Providing an app password as input is an alternative to storing it in SBS through the addEmailAccount mutation.
AttachmentInput input
Attribute Type Description
name String Optional. Specifies the name of the attached file. If you don’t set this parameter, the file name will be inferred from the uri or from fileId.
uri Uri Conditional. Either uri or fileId must be set. This parameter specifies the remote URI of the file to be attached.
fileId ID Conditional. Either uri or fileId must be set. This parameter specifies the ID of a file created through the File Management Service.
TemplateInput input
Attribute Type Description
name String Specifies the name of the template created by the Document Rendering Service.
params String Specifies the parameters to be provided to the template, as a stringified JSON object.
AppPasswordInput input
Attribute Type Description
password String! Mandatory. The app password obtained from a third party provider such as Google or Microsoft.
provider Provider! Mandatory. The provider from which the app password was obtained. Valid values: GOOGLE, MICROSOFT.

unsuppressAddress

Removes an email address from the AWS suppression list.

Arguments

Argument Type Description
address EmailAddress Mandatory. The email address to be removed from the AWS suppression list.

Result

See the AddressStatus type.

updateEmailAccount

This mutation updates a previously added email account from a third-party provider (such as Google or Microsoft 365).

Arguments

Argument Type Description
id ID! The unique identifier of the email account record.
input UpdateEmailAccountInput! Provides the input arguments to the mutation.
UpdateEmailAccountInput input
Attribute Type Description
address EmailAddress! Specifies the email address that is to be connected to SBS.
password String! The app password obtained from Google or Microsoft 365.
provider Provider! The third-party email provider. Valid values: GOOGLE, MICROSOFT.

Result

See the EmailAccount type.

updateInboundMessage

Updates a received (inbound) email message. Note that the only updatable field is externalReference.

Arguments

Argument Type Description
id ID! Mandatory argument. Set this to the ID (InboundMessage.id) of the message to be updated.
input UpdateInboundMessageInput! Mandatory argument that provides the input values for the update.
UpdateInboundMessageInput input
Attribute Type Description
externalReference String The new externalReference value of the email.

Result

See the InboundMessage type.

verifyDomainIdentity

Performs a verification of a custom email domain. Email domain verification is a prerequisite to enable sending email from a domain verified at tenant level.

Arguments

Argument Type Description
domain Domain! Mandatory. The email domain to be verified. For example, example.org.
input VerifyDomainIdentityInput Optional. Provides additional input to the mutation.
VerifyDomainIdentityInput input
Attribute Type Description
restrictedToEmailSenders Boolean If true, then sending email from this domain is restricted only to email addresses returned by the emailSenders query (assuming the domain has VERIFIED status). If false, any email address can send email from this domain as long as the domain has VERIFIED status. See also Sending email from a domain verified at tenant level.

Result

See the DomainIdentity type.

Example

The example below illustrates how to verify a domain. Make sure to replace YOUR_DOMAIN with the actual domain name, for example, example.org. In this example, sending email from the domain will be possible only for designated email addresses, because the restrictedToEmailSenders parameter is set to true. You can add the authorized email addresses by running the addEmailSender mutation.

mutation verifyDomainIdentity($domain:Domain!, $input: VerifyDomainIdentityInput){
    verifyDomainIdentity(domain:$domain, input:$input) {
        domain
        status
        dnsRecords {
            type name value
        }
        restrictedToEmailSenders
    }
}
{ 
    "domain": "YOUR_DOMAIN",
    "input": {
        "restrictedToEmailSenders": true
    }
}

updateDomainIdentity

Updates a domain identity.

Arguments

Argument Type Description
domain Domain! Mandatory. The domain to be updated. For example, example.org.
input UpdateDomainIdentityInput! Mandatory. Provides input data to the mutation.
UpdateDomainIdentityInput input
Attribute Type Description
restrictedToEmailSenders Boolean If true, then sending email from this domain is restricted only to email addresses returned by the emailSenders query (assuming the domain has VERIFIED status). If false, any email address can send email from this domain as long as the domain has VERIFIED status. See also Sending email from a domain verified at tenant level.

Result

See the DomainIdentity type.

verifyEmailIdentity

Performs a verification of a custom email address. Email address verification is a prerequisite to enable sending email from a custom email address.

Arguments

Argument Type Description
address EmailAddress! The email address to be verified. For example, some.email@example.org.

Result

See the EmailIdentity type.

Error codes

See Conventions for the error format and the codes shared across all services. This service can also return the codes listed below, grouped by the object they concern. The Returned by column names the operations that report each code.

Messages

Code Meaning Returned by
RECIPIENT_REQUIRED The message names no recipient in to, cc, or bcc. sendMessage
RECIPIENT_COUNT_EXCEEDED The message names more than 50 recipients across to, cc, and bcc. sendMessage
TRACK_ENGAGEMENT_REQUIRES_HTML_BODY trackEngagement is true, but the message has no HTML body, either set in htmlBody or rendered from a template. sendMessage
DOCUMENT_RENDERING_FAILED The Document Rendering Service refused the template in template. sendMessage
SERVICE_ACCESS_TOKEN_UNAVAILABLE The service could not authorize a call it makes to another SBS service on your behalf. sendMessage
MAIL_SEND_FAILED The mail provider refused to send the message. sendMessage and verifyEmailIdentity
MESSAGE_NOT_FOUND No sent message exists for the id supplied. deleteMessage
INBOUND_MESSAGE_NOT_FOUND No inbound message exists for the id supplied. updateInboundMessage and deleteInboundMessage
FILE_DELETE_FAILED The files of the inbound message could not be deleted from the File Management Service. deleteInboundMessage

Attachments

Code Meaning Returned by
ATTACHMENT_FILE_NOT_FOUND An attachment’s fileId names a file that the File Management Service does not hold. sendMessage
ATTACHMENT_URL_MISSING An attachment sets neither fileId nor uri. sendMessage
EXPIRES_IN_NOT_POSITIVE expiresIn is not a positive number of seconds. createAttachmentFile
FILE_EXTERNAL_REFERENCE_EMPTY externalReference is an empty string. createAttachmentFile
ATTACHMENT_FILE_CREATE_FAILED The attachment file could not be created in the File Management Service. createAttachmentFile

Senders and identities

Code Meaning Returned by
SENDER_NOT_ENTITLED The from address is neither a verified email identity nor an authorized sender of a verified domain. sendMessage and verifyEmailIdentity
SENDER_ENTITLEMENT_CHECK_FAILED The service could not check whether the from address may send email. sendMessage and verifyEmailIdentity
EMAIL_IDENTITY_PLUS_SIGN_NOT_ALLOWED address contains a + sign. verifyEmailIdentity
EMAIL_IDENTITY_NOT_FOUND No email identity exists for the address supplied. verifyEmailIdentity and deleteEmailIdentity
SES_IDENTITY_LOOKUP_FAILED The verification status of the identity could not be read from Amazon Simple Email Service (SES). verifyEmailIdentity and verifyDomainIdentity
SES_IDENTITY_VERIFY_FAILED Amazon SES refused to start verifying the email address. verifyEmailIdentity
SES_DOMAIN_DKIM_VERIFY_FAILED Amazon SES refused to start DomainKeys Identified Mail (DKIM) verification of the domain. verifyDomainIdentity
DOMAIN_IDENTITY_NOT_FOUND No domain identity exists for the domain supplied. verifyDomainIdentity, updateDomainIdentity, and deleteDomainIdentity
EMAIL_SENDER_ALREADY_EXISTS address is already an authorized sender. addEmailSender
EMAIL_SENDER_PLUS_SIGN_NOT_ALLOWED address contains a + sign. addEmailSender
EMAIL_SENDER_CREATE_FAILED The sender could not be registered. addEmailSender
EMAIL_SENDER_NOT_FOUND address is not an authorized sender. removeEmailSender

Google and Microsoft 365 accounts

Code Meaning Returned by
EMAIL_ACCOUNT_ALREADY_EXISTS An email account for address is already stored. addEmailAccount
EMAIL_ACCOUNT_NOT_FOUND No email account exists for the id supplied. updateEmailAccount
EMAIL_ACCOUNT_CREDENTIALS_MISSING The email account has no address and app password to send with. sendMessage
EMAIL_ACCOUNT_PROVIDER_UNSUPPORTED The email account names no provider, or a provider that cannot send email. sendMessage
OAUTH_AUTHORIZATION_NOT_FOUND oauthApprover holds no OAuth 2.0 authorization to send email. sendMessage
OAUTH_AUTHORIZATION_LOOKUP_FAILED The OAuth 2.0 authorizations of oauthApprover could not be read. sendMessage
OAUTH_PROVIDER_UNSUPPORTED The OAuth 2.0 authorization names a provider that cannot send email. sendMessage
GOOGLE_OAUTH_REQUEST_FAILED Google refused to send the message. sendMessage
MICROSOFT_GRAPH_REQUEST_FAILED Microsoft Graph refused to send the message. sendMessage
AZURE_API_CREDENTIALS_MISSING The OAuth 2.0 authorization holds no Microsoft Azure API credentials. sendMessage
AZURE_CLIENT_SECRET_MISSING Your application has no Microsoft Azure configuration. sendMessage

Subdomains and applications

Code Meaning Returned by
SUBDOMAIN_INVALID_CHARACTERS The subdomain contains characters that a host name cannot contain. registerSubdomain
SUBDOMAIN_ALREADY_DEFINED A subdomain is already registered for your tenant and application. registerSubdomain
SUBDOMAIN_ALREADY_IN_USE The subdomain is already in use. registerSubdomain
SUBDOMAIN_REGISTRATION_FAILED The DNS records of the subdomain could not be written. registerSubdomain
SUBDOMAIN_NOT_FOUND No subdomain is registered for your tenant and application. deleteSubdomain
APP_NOT_FOUND The application of your access key could not be read. subdomain, sendMessage, registerSubdomain, and deleteSubdomain
APP_LEVEL_DOMAIN_NOT_DEFINED Your application has no email subdomain. See Register an email subdomain at application level. registerSubdomain and deleteSubdomain

Suppression list

Code Meaning Returned by
ADDRESS_STATUS_LOOKUP_FAILED The suppression list could not be read. addressStatus and unsuppressAddress
ADDRESS_NOT_FOUND The suppression list answered without naming the address. unsuppressAddress
ADDRESS_UNSUPPRESS_REJECTED The suppression list refused to remove the address. unsuppressAddress
ADDRESS_UNSUPPRESS_FAILED The address could not be removed from the suppression list. unsuppressAddress

Email address values

Code Meaning Returned by
EMAIL_ADDRESS_INVALID_FORMAT An EmailAddress value is not an email address. Any operation that takes an EmailAddress value
EMAIL_ADDRESS_INVALID_IN_BACKEND A stored email address could not be returned as an EmailAddress value. Any operation that returns an EmailAddress value

AI agent access (MCP)

The service serves its queries as tools to AI agent clients over the Model Context Protocol (MCP), a JSON-RPC 2.0 protocol through which a client reads a catalog of tools and calls them by name. Agent clients such as Claude Code connect to https://email-api.socrate.io/mcp.

Access

The MCP endpoint is on the same host as the GraphQL endpoint and accepts the same credentials:

The endpoint speaks protocol revision 2026-07-28 and accepts protocol requests as POST only. It is stateless: every request carries its own credentials, and there is no handshake or session to open first. Your agent client must support revision 2026-07-28.

For connection instructions, open https://email-api.socrate.io/mcp in a browser. The page needs no credential.

Tools

The catalog holds one tool per query of this service:

Tool include values
version —
messages See Sent message include values
inboundMessages See Inbound message include values
subdomain —
emailAccounts —
emailIdentities —
domainIdentities items.dnsRecords
addressStatus —
emailSenders —
deliveryFailures —

No tool has a required argument. The optional arguments of each query (filter, nextToken, order, address) are optional arguments of its tool. The tools cover the service’s queries only. To send messages or to create or change data, use the service’s mutations.

The catalog a caller receives lists only the tools whose query the scope of its key or token allows. If a service access denial blocks a query, your agent does not see a tool for it. A tool call runs the query under the caller’s own credentials and returns the data that the equivalent GraphQL query returns for that caller. Every tool is marked read-only (readOnlyHint is true), and answers from SBS alone, without calling any system outside SBS (openWorldHint is false).

Optional result fields

By default, a tool returns compact records. You request the remaining fields by naming their paths in the tool’s optional include argument:

  • Sent messages. Without include, messages returns each message’s own fields, such as id, from, subject, sentAt, attachmentCount, openCount, and clickCount. The text and HTML bodies, the recipients, the attachments, the opens, the clicks, and the references are returned only when named.
  • Inbound messages. Without include, inboundMessages returns each message’s own fields and its original file without a download URL. The text and HTML bodies, the recipients, the attachments, the references, and the download URL of the original file are returned only when named.
  • Domain identities. Without include, domainIdentities returns each identity’s domain, status, and restrictedToEmailSenders. The DNS records are returned only when named.

Each of these tools always returns its page of items and its nextToken.

A path is a sequence of field names separated by dots. Naming a path returns that field with its default content. Naming a path inside a field that is returned by default adds only that inner field: include: ["items.original.downloadUrl"] adds the downloadUrl of each message’s original beside its id, contentType, and contentLength. To receive several optional fields, name each path: include: ["items.to", "items.textBody"].

Sent message include values

The messages tool accepts these values:

Value Returns
items.to The recipients of each message, each with its delivery status
items.cc The carbon copy (CC) recipients of each message
items.bcc The blind carbon copy (BCC) recipients of each message
items.textBody The plain text body of each message
items.htmlBody The HTML body of each message
items.attachments The attachments of each message
items.opens The “email opened” events of each message
items.clicks The “email links clicked” events of each message
items.references The Message-IDs of the previous messages in the chain of each message

Inbound message include values

The inboundMessages tool accepts these values:

Value Returns
items.to The recipients of each message
items.cc The carbon copy (CC) recipients of each message
items.textBody The plain text body of each message
items.htmlBody The HTML body of each message
items.attachments The attachments of each message
items.original.downloadUrl The download URL of the original file of each message
items.references The Message-IDs of the previous messages in the chain of each message

Documentation resources

Besides its tools, the endpoint publishes, as addresses, this page and the API conventions page.

Connecting an agent client

To add the endpoint to Claude Code, run:

claude mcp add --transport http email https://email-api.socrate.io/mcp --header "x-api-key: YOUR_ACCESS_KEY"

Other agent clients take the same URL and header in their own configuration.

Example

An agent client builds the protocol requests for you. To call a tool directly over HTTP, send a POST request that names the protocol revision both in the MCP-Protocol-Version header and in the request’s _meta, the method in the Mcp-Method header, and, for a tool call, the tool in the Mcp-Name header:

POST /mcp HTTP/1.1
Host: email-api.socrate.io
Content-Type: application/json
Accept: application/json
x-api-key: YOUR_ACCESS_KEY
MCP-Protocol-Version: 2026-07-28
Mcp-Method: tools/call
Mcp-Name: messages
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "_meta": {
      "io.modelcontextprotocol/protocolVersion": "2026-07-28",
      "io.modelcontextprotocol/clientCapabilities": {}
    },
    "name": "messages",
    "arguments": {
      "filter": {
        "createdAt": { "from": "2026-10-01", "to": "2026-10-31" }
      },
      "include": ["items.to"]
    }
  }
}

The page of messages is returned in structuredContent, and as the same JSON text in content. The response below is shortened to one message:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "resultType": "complete",
    "content": [
      { "type": "text", "text": "{\"items\":[{\"id\":\"YOUR_MESSAGE_ID\", ...}" }
    ],
    "structuredContent": {
      "items": [
        {
          "id": "YOUR_MESSAGE_ID",
          "from": {
            "name": "Contoso Sales",
            "address": "sales@example.com"
          },
          "subject": "Your order has shipped",
          "to": [
            {
              "name": "Jane Doe",
              "address": "jane.doe@example.com",
              "status": "DELIVERED"
            }
          ],
          "createdAt": "2026-10-07T06:08:56.352Z",
          "sentAt": "2026-10-07T06:08:57.104Z",
          "attachmentCount": 0,
          "openCount": 1,
          "clickCount": 0
        }
      ],
      "nextToken": "YOUR_NEXT_TOKEN"
    }
  }
}

Webhooks

The Email Service supports webhooks. This means you can optionally configure SBS to send an HTTP POST request to an external server or application whenever any of the following events occur:

  • EMAIL_RECEIVED - fires whenever an email was received.
  • EMAIL_DELIVERED - fires whenever an email was delivered.
  • EMAIL_DELIVERY_FAILURE - fires whenever an email has failed delivery.

The POST request of the EMAIL_RECEIVED event has the following payload:

{
  "service": "email-api",
  "event": "EMAIL_RECEIVED",
  "tenantId": "<some-tenant-id>",
  "payload": {
      "id": "<some-email-id>",
      "address": "<some-email-address>"
  },
  "customKey1": "Custom value 1",
  "customKey2": "Custom value 2 "
}

The POST request of the EMAIL_DELIVERED event has the following payload:

{
  "service": "email-api",
  "event": "EMAIL_DELIVERED",
  "tenantId": "<some-tenant-id>",
  "payload": {
      "id": "<some-email-id>",
      "address": "<some-email-address>"
  },
  "customKey1": "Custom value 1",
  "customKey2": "Custom value 2 "
}

The POST request of the EMAIL_DELIVERY_FAILURE event has the following payload:

{
  "service": "email-api",
  "event": "EMAIL_DELIVERY_FAILURE",
  "tenantId": "<some-tenant-id>",
  "payload": {
      "id": "<some-email-id>",
      "address": "<some-email-address>"
  },
  "customKey1": "Custom value 1",
  "customKey2": "Custom value 2",
}

Note that the customKey1 and customValue1 will be present in the request body only if you configured them when creating the webhook. You may configure as many key-value pairs as required.

For information about configuring webhooks, see Webhooks.