Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add documentation on the on-behalf-of header usage #1104

Merged
merged 2 commits into from
Apr 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/client/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ client.setApiKey(process.env.SENDGRID_API_KEY);
* [USER](#user)
* [WHITELABEL](#whitelabel)

# On behalf of subusers

Most API calls will accept an `on-behalf-of` header
in order to make API calls as a given subuser:

```javascript
// create an API key for the given subuser
const data = {
name: 'subuser API key',
scopes: ['mail.send'],
};
request.body = data;
request.method = 'POST';
request.url = '/v3/api_keys';
request.headers = { 'On-Behalf-Of': 'subuser username' };
client.request(request)
.then(([response, body]) => {
console.log(response.statusCode);
console.log(response.body);
});
```

<a name="access-settings"></a>
# ACCESS SETTINGS
Expand Down