Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

How to Create a EU Regional Subuser with the Twilio SendGrid API



API Overview

api-overview page anchor

For more information about Subusers, visit the longform Subusers documentation. You can also manage Subusers in the SendGrid console(link takes you to an external page).

This guide provides a step-by-step process on how to create a regional subuser using the Twilio SendGrid API, specifically for the European Union (EU) region. By following this guide, you will be able to set up a subuser, configure necessary settings, and send emails from the EU region.


Before you begin, ensure you have the following:

  • A Twilio SendGrid API account on the Pro plan or above with a dedicated IP. Sign up here(link takes you to an external page)
  • An API key for your parent account
  • Rename $YOUR_API_KEY in the examples below with the name of your environment variable

Steps to Create a EU Regional Subuser

steps-to-create-a-eu-regional-subuser page anchor

Step 1: Create a Subuser

step-1-create-a-subuser page anchor

Create a subuser that is bound to the EU region. When creating the subuser, specify the region as eu.


_10
curl -X POST "https://api.sendgrid.com/v3/subusers" \
_10
--header "Authorization: Bearer $YOUR_API_KEY" \
_10
--header "Content-Type: application/json" \
_10
--data '{"username":"John@example.com","email":"John@example.com","password":"johns_password","region":"eu","include_region":true}'

Step 2: Add a Regional IP and Assign to Parent Account and Subusers

step-2-add-a-regional-ip-and-assign-to-parent-account-and-subusers page anchor

You can add one IP address per month via self-service. The following command adds an EU-based IP address and assigns it to the subuser and parent accounts.


_10
curl -H "Authorization: Bearer $YOUR_API_KEY" -X POST \
_10
'https://api.sendgrid.com/v3/send_ips/ips' -d '{"is_auto_warmup":false, "is_parent_assigned":true, "subusers":["12345678"], "region":"eu", "include_region":true}'

Step 3: Complete Sender Authentication

step-3-complete-sender-authentication page anchor

Configure Domain Authentication by adding a record to your DNS host. Follow these steps to complete Domain Authentication:

  1. Authenticate your domain

_10
curl -X POST "https://api.sendgrid.com/v3/whitelabel/domains" \
_10
--header "Authorization: Bearer $YOUR_API_KEY" \
_10
--header "Content-Type: application/json" \
_10
--data '{"domain": "example.com", "region": "eu"}'

  1. Validate the domain authentication

_10
curl -X POST "https://api.sendgrid.com/v3/whitelabel/domains/{DOMAIN_ID}/validate" \
_10
--header "Authorization: Bearer $YOUR_API_KEY"

  1. Associate the authenticated domain with your EU-based subuser

_10
curl -X POST "https://api.sendgrid.com/v3/whitelabel/domains/{DOMAIN_ID}/subuser" \
_10
--header "Authorization: Bearer $YOUR_API_KEY" \
_10
--header "Content-Type: application/json" \
_10
--data '{"username":"jdoe"}'

Step 4: Create a Twilio SendGrid API Key to Send Emails

step-4-create-a-twilio-sendgrid-api-key-to-send-emails page anchor

Create an API key for your EU-based subuser via the Twilio SendGrid Console(link takes you to an external page) or the API. This key should have the mail.send permission.


_10
curl -X POST "https://api.sendgrid.com/v3/api_keys" \
_10
--header "Authorization: Bearer $YOUR_API_KEY" \
_10
--header "Content-Type: application/json" \
_10
--data '{"name":"MyEU API Key", "scopes":["mail.send","alerts.create","alerts.read"]}'

Step 5: Send Your Email

step-5-send-your-email page anchor

Now that you have an API Key for your EU subuser, you can use that subuser to send email. Make sure to send email using the base URL api.eu.sendgrid.com.


_10
curl --request POST --url https://api.eu.sendgrid.com/v3/mail/send --header 'Authorization: Bearer $YOUR_API_KEY' --header 'Content-Type: application/json' --data '{"personalizations":[{"to":[{"email":"recipient@example.com"}]}],"from":{"email":"sender@example.com"},"subject":"Hello, World!","content":[{"type":"text/plain","value":"Heya!"}]}'


By following these steps, you have successfully created a regional subuser in the EU, configured necessary settings, and sent an email. This setup helps in complying with data residency requirements by ensuring that the data does not leave the EU region.

For more detailed information, refer to the original blog post: Regional Email Public Beta: Set Up a Subuser and IP Address in the EU(link takes you to an external page).



Rate this page: