Skip to content

Commit

Permalink
Add an example readme
Browse files Browse the repository at this point in the history
  • Loading branch information
shrutiburman committed Nov 20, 2023
1 parent 50a8691 commit 2f7c9ea
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/use-cases/data-residency-set-hostname.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Choosing a hostname to send messages to

Use the `setDataResidency` setter to specify which host to send to:

Send to EU (hostname: `https://api.eu.sendgrid.com/`)
```js
const sgMail = require('@sendgrid/mail');
sgMail.setDataResidency('eu');
const msg = {
to: '[email protected]',
from: '[email protected]',
subject: 'Hello world',
text: 'Hello plain world!',
html: '<p>Hello HTML world!</p>',
};
sgMail.send(msg);
```
Send to Global region, this is also the default host, if the setter is not used
(hostname: `https://api.sendgrid.com/`)
```js
const sgMail = require('@sendgrid/mail');
sgMail.setDataResidency('global');
const msg = {
to: '[email protected]',
from: '[email protected]',
subject: 'Hello world',
text: 'Hello plain world!',
html: '<p>Hello HTML world!</p>',
};
sgMail.send(msg);
```

## Limitations

1. Emails can only be sent to two hosts for now; 'eu' (https://api.eu.sendgrid.com/) and 'global' (https://api.eu.sendgrid.com/)
2. The default hostname is https://api.sendgrid.com/
3. The valid values for `region` in `client.setDataResidency(region)` are only `eu` and `global`. Case-sensitive.

0 comments on commit 2f7c9ea

Please sign in to comment.