Welcome to SendGrid’s Web API v3! This API is RESTful, fully featured, easy to integrate with, and offers support in 7 different languages.
The On Behalf Of header allows you to make API calls from a parent account on behalf of the parent's Subusers or customer accounts. Use this header to automate bulk updates or to administer a Subuser or account without changing the authentication in your code.
on-behalf-of header does not work with the Mail Send API.
On Behalf Of generates the API call as if the Subuser or customer account is making the call. When authenticating and using the
on-behalf-of header, you must use the parent account's API key credentials.
On Behalf Of accepts either a Subuser username or customer account ID, depending on which type of sub-account structure you are administering. Subusers function like separate SendGrid sub-accounts, and they're available to all customers on Pro and Premier plans. Customer accounts also act as separate sub-accounts that are managed by a parent account; however, customer accounts are available only to companies that have a formal reseller partnership with Twilio SendGrid.
When making a call on behalf of a customer account, the property value should be "account-id" followed by the customer account's ID.
on-behalf-of: account-id <account-id>
When making a call on behalf of a Subuser, the property value should be the Subuser's username.
curl --request GET \ --url 'https://api.sendgrid.com/v3/stats?start_date=2018-02-01&aggregated_by=day' \ --header 'authorization: Bearer <SENDGRID_API_KEY>' \ --header 'on-behalf-of: <subuser-username>'
curl --request GET \ --url 'https://api.sendgrid.com/v3/stats?start_date=2018-02-01&aggregated_by=day' \ --header 'authorization: Bearer <SENDGRID_API_KEY>' \ --header 'on-behalf-of: account-id <account-id>'