Skip to content

Commit fe835e1

Browse files
authored
docs: add documentation on the on-behalf-of header usage (#1104)
1 parent 98165eb commit fe835e1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/client/USAGE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@ client.setApiKey(process.env.SENDGRID_API_KEY);
3737
* [USER](#user)
3838
* [WHITELABEL](#whitelabel)
3939

40+
# On behalf of subusers
41+
42+
Most API calls will accept an `on-behalf-of` header
43+
in order to make API calls as a given subuser:
44+
45+
```javascript
46+
// create an API key for the given subuser
47+
const data = {
48+
name: 'subuser API key',
49+
scopes: ['mail.send'],
50+
};
51+
request.body = data;
52+
request.method = 'POST';
53+
request.url = '/v3/api_keys';
54+
request.headers = { 'On-Behalf-Of': 'subuser username' };
55+
client.request(request)
56+
.then(([response, body]) => {
57+
console.log(response.statusCode);
58+
console.log(response.body);
59+
});
60+
```
4061

4162
<a name="access-settings"></a>
4263
# ACCESS SETTINGS

0 commit comments

Comments
 (0)