Description
Issue Summary
Right now we are migrating from Mailgun to Sendgrid, due to their generally bad IP reputation on Outlook 365 and other mail service providers. We nearly finished the migration, but right now we are experiencing a showstopper for us:
We have a subdomain for each ouf our customers (customer1.mycompany.com., customernext123.mycompany.com,... and so on) and we also want everything seperated: reverse dns, link tracking domains, sender domains, subusers for each customer - so we want to add all these things to our subusers.
The only problem stops us now is, that you can't add webhooks for subusers?
There is nothing mentioned in the documentation unfortunately, but at least your support told me that I can submit such a request by setting a on-behalf-of header:
In order to make API calls for the subuser through the parent account, you can use the On-Behalf-Of header.
In the header you are passing you will need to add:
On-Behalf-Of: subuser_username
This will make the API call as if it was the subuser account making the call. Just make sure you are using the correct subuser username.
Also, when authenticating using this header, you will need to use the parent account's username and password or an API key that has Subuser Management permissions. When authenticating using basic auth it will require a base64 encoded username/password.
Examples: Using in cURL call: curl --request POST \ --url api.sendgrid.com/v3/api_keys \ --header 'authorization: Bearer SENDGRID_API_KEY’ \ --header 'content-type: application/json' \ --header 'On-Behalf-Of: subuser_username’\ --data '{"name":"My API Key","scopes":["mail.send","alerts.create","alerts.read"]}' Using in Sendgrid Ruby SDK: sg = SendGrid::API.new( api_key: ENV['SENDGRID_API_KEY'], host: 'api.sendgrid.com', request_headers["On-Behalf-Of"] => subuser_usrname_var)
But somehow this looks like a hack and it would be much better to implement this natively in the ruby gem, by just adding the username paramter to the PATCH /user/webhooks/event/settings
call (https://github.com/sendgrid/sendgrid-ruby/blob/master/USAGE.md#update-event-notification-settings)
What do you think? Is there any chance of getting this implemented in the near future? Thank you!
Technical details:
- sendgrid-ruby Version: master (latest commit: [commit number])
- Ruby Version: 2.2