sendgrid-ruby 1.1.6 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE +17 -0
  3. data/.travis.yml +1 -6
  4. data/CHANGELOG.md +6 -0
  5. data/CONTRIBUTING.md +202 -0
  6. data/Gemfile +3 -5
  7. data/LICENSE.txt +1 -1
  8. data/README.md +74 -248
  9. data/Rakefile +8 -6
  10. data/USAGE.md +4645 -0
  11. data/examples/accesssettings/accesssettings.rb +89 -0
  12. data/examples/apikeys/apikeys.rb +95 -0
  13. data/examples/asm/asm.rb +169 -0
  14. data/examples/browsers/browsers.rb +29 -0
  15. data/examples/campaigns/campaigns.rb +166 -0
  16. data/examples/categories/categories.rb +49 -0
  17. data/examples/clients/clients.rb +40 -0
  18. data/examples/contactdb/contactdb.rb +398 -0
  19. data/examples/devices/devices.rb +29 -0
  20. data/examples/geo/geo.rb +29 -0
  21. data/examples/helpers/mail/example.rb +130 -0
  22. data/examples/ips/ips.rb +167 -0
  23. data/examples/mail/mail.rb +191 -0
  24. data/examples/mailboxproviders/mailboxproviders.rb +29 -0
  25. data/examples/mailsettings/mailsettings.rb +232 -0
  26. data/examples/partnersettings/partnersettings.rb +52 -0
  27. data/examples/scopes/scopes.rb +28 -0
  28. data/examples/stats/stats.rb +29 -0
  29. data/examples/subusers/subusers.rb +182 -0
  30. data/examples/suppression/suppression.rb +186 -0
  31. data/examples/templates/templates.rb +142 -0
  32. data/examples/trackingsettings/trackingsettings.rb +123 -0
  33. data/examples/user/user.rb +256 -0
  34. data/examples/whitelabel/whitelabel.rb +323 -0
  35. data/lib/helpers/mail/README.md +14 -0
  36. data/lib/helpers/mail/mail.rb +999 -0
  37. data/lib/sendgrid-ruby.rb +33 -8
  38. data/sendgrid-ruby.gemspec +5 -17
  39. data/test/helpers/mail/test_mail.rb +122 -0
  40. data/test/test_sendgrid-ruby.rb +2016 -0
  41. metadata +42 -190
  42. data/.env_sample +0 -3
  43. data/.rspec +0 -2
  44. data/.rubocop.yml +0 -30
  45. data/FETCH_HEAD +0 -0
  46. data/Guardfile +0 -10
  47. data/example.rb +0 -41
  48. data/lib/sendgrid/client.rb +0 -62
  49. data/lib/sendgrid/exceptions.rb +0 -7
  50. data/lib/sendgrid/mail.rb +0 -182
  51. data/lib/sendgrid/recipient.rb +0 -29
  52. data/lib/sendgrid/response.rb +0 -14
  53. data/lib/sendgrid/template.rb +0 -26
  54. data/lib/sendgrid/template_mailer.rb +0 -59
  55. data/lib/sendgrid/version.rb +0 -3
  56. data/spec/lib/sendgrid/client_spec.rb +0 -87
  57. data/spec/lib/sendgrid/mail_spec.rb +0 -151
  58. data/spec/lib/sendgrid/recipient_spec.rb +0 -91
  59. data/spec/lib/sendgrid/template_mailer_spec.rb +0 -86
  60. data/spec/lib/sendgrid/template_spec.rb +0 -61
  61. data/spec/lib/sendgrid_spec.rb +0 -7
  62. data/spec/spec_helper.rb +0 -1
data/Rakefile CHANGED
@@ -1,8 +1,10 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
1
+ require 'rake/testtask'
3
2
 
4
- RSpec::Core::RakeTask.new(:spec)
3
+ Rake::TestTask.new do |t|
4
+ t.libs << 'test'
5
+ t.test_files = FileList['test/test*.rb', 'test/helpers/mail/test*.rb']
6
+ t.verbose = true
7
+ end
5
8
 
6
- task test: :spec
7
-
8
- task default: :test
9
+ desc "Run tests"
10
+ task :default => :test
data/USAGE.md ADDED
@@ -0,0 +1,4645 @@
1
+ This documentation is based on our [OAI specification](https://github.com/sendgrid/sendgrid-oai).
2
+
3
+ # INITIALIZATION
4
+
5
+ ```ruby
6
+ require 'sendgrid-ruby'
7
+
8
+
9
+ sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
10
+ ```
11
+
12
+ # Table of Contents
13
+
14
+ * [ACCESS SETTINGS](#access_settings)
15
+ * [API KEYS](#api_keys)
16
+ * [ASM](#asm)
17
+ * [BROWSERS](#browsers)
18
+ * [CAMPAIGNS](#campaigns)
19
+ * [CATEGORIES](#categories)
20
+ * [CLIENTS](#clients)
21
+ * [CONTACTDB](#contactdb)
22
+ * [DEVICES](#devices)
23
+ * [GEO](#geo)
24
+ * [IPS](#ips)
25
+ * [MAIL](#mail)
26
+ * [MAIL SETTINGS](#mail_settings)
27
+ * [MAILBOX PROVIDERS](#mailbox_providers)
28
+ * [PARTNER SETTINGS](#partner_settings)
29
+ * [SCOPES](#scopes)
30
+ * [STATS](#stats)
31
+ * [SUBUSERS](#subusers)
32
+ * [SUPPRESSION](#suppression)
33
+ * [TEMPLATES](#templates)
34
+ * [TRACKING SETTINGS](#tracking_settings)
35
+ * [USER](#user)
36
+ * [WHITELABEL](#whitelabel)
37
+
38
+
39
+ <a name="access_settings"></a>
40
+ # ACCESS SETTINGS
41
+
42
+ ## Retrieve all recent access attempts
43
+
44
+ **This endpoint allows you to retrieve a list of all of the IP addresses that recently attempted to access your account either through the User Interface or the API.**
45
+
46
+ IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account.
47
+
48
+ For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html).
49
+
50
+ ### GET /access_settings/activity
51
+
52
+
53
+ ```ruby
54
+ params = JSON.parse('{"limit": 1}')
55
+ response = sg.client.access_settings.activity.get(query_params: params)
56
+ puts response.status_code
57
+ puts response.body
58
+ puts response.headers
59
+ ```
60
+ ## Add one or more IPs to the whitelist
61
+
62
+ **This endpoint allows you to add one or more IP addresses to your IP whitelist.**
63
+
64
+ When adding an IP to your whitelist, include the IP address in an array. You can whitelist one IP at a time, or you can whitelist multiple IPs at once.
65
+
66
+ IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account.
67
+
68
+ For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html).
69
+
70
+ ### POST /access_settings/whitelist
71
+
72
+
73
+ ```ruby
74
+ data = JSON.parse('{
75
+ "ips": [
76
+ {
77
+ "ip": "192.168.1.1"
78
+ },
79
+ {
80
+ "ip": "192.*.*.*"
81
+ },
82
+ {
83
+ "ip": "192.168.1.3/32"
84
+ }
85
+ ]
86
+ }')
87
+ response = sg.client.access_settings.whitelist.post(request_body: data)
88
+ puts response.status_code
89
+ puts response.body
90
+ puts response.headers
91
+ ```
92
+ ## Retrieve a list of currently whitelisted IPs
93
+
94
+ **This endpoint allows you to retrieve a list of IP addresses that are currently whitelisted.**
95
+
96
+ IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account.
97
+
98
+ For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html).
99
+
100
+ ### GET /access_settings/whitelist
101
+
102
+
103
+ ```ruby
104
+ response = sg.client.access_settings.whitelist.get()
105
+ puts response.status_code
106
+ puts response.body
107
+ puts response.headers
108
+ ```
109
+ ## Remove one or more IPs from the whitelist
110
+
111
+ **This endpoint allows you to remove one or more IPs from your IP whitelist.**
112
+
113
+ You can remove one IP at a time, or you can remove multiple IP addresses.
114
+
115
+ IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account.
116
+
117
+ For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html).
118
+
119
+ ### DELETE /access_settings/whitelist
120
+
121
+
122
+ ```ruby
123
+ response = sg.client.access_settings.whitelist.delete(request_body: data)
124
+ puts response.status_code
125
+ puts response.body
126
+ puts response.headers
127
+ ```
128
+ ## Retrieve a specific whitelisted IP
129
+
130
+ **This endpoint allows you to retreive a specific IP address that has been whitelisted.**
131
+
132
+ You must include the ID for the specific IP address you want to retrieve in your call.
133
+
134
+ IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account.
135
+
136
+ For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html).
137
+
138
+ ### GET /access_settings/whitelist/{rule_id}
139
+
140
+
141
+ ```ruby
142
+ rule_id = "test_url_param"
143
+ response = sg.client.access_settings.whitelist._(rule_id).get()
144
+ puts response.status_code
145
+ puts response.body
146
+ puts response.headers
147
+ ```
148
+ ## Remove a specific IP from the whitelist
149
+
150
+ **This endpoint allows you to remove a specific IP address from your IP whitelist.**
151
+
152
+ When removing a specific IP address from your whitelist, you must include the ID in your call.
153
+
154
+ IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account.
155
+
156
+ For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html).
157
+
158
+ ### DELETE /access_settings/whitelist/{rule_id}
159
+
160
+
161
+ ```ruby
162
+ rule_id = "test_url_param"
163
+ response = sg.client.access_settings.whitelist._(rule_id).delete()
164
+ puts response.status_code
165
+ puts response.body
166
+ puts response.headers
167
+ ```
168
+ <a name="api_keys"></a>
169
+ # API KEYS
170
+
171
+ ## Create API keys
172
+
173
+ **This enpoint allows you to create a new random API Key for the user.**
174
+
175
+ A JSON request body containing a "name" property is required. If number of maximum keys is reached, HTTP 403 will be returned.
176
+
177
+ There is a limit of 100 API Keys on your account.
178
+
179
+ The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html).
180
+
181
+ See the [API Key Permissions List](https://sendgrid.com/docs/API_Reference/Web_API_v3/API_Keys/api_key_permissions_list.html) for a list of all available scopes.
182
+
183
+ ### POST /api_keys
184
+
185
+
186
+ ```ruby
187
+ data = JSON.parse('{
188
+ "name": "My API Key",
189
+ "scopes": [
190
+ "mail.send",
191
+ "alerts.create",
192
+ "alerts.read"
193
+ ]
194
+ }')
195
+ response = sg.client.api_keys.post(request_body: data)
196
+ puts response.status_code
197
+ puts response.body
198
+ puts response.headers
199
+ ```
200
+ ## Retrieve all API Keys belonging to the authenticated user
201
+
202
+ **This endpoint allows you to retrieve all API Keys that belong to the authenticated user.**
203
+
204
+ The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html).
205
+
206
+ ### GET /api_keys
207
+
208
+
209
+ ```ruby
210
+ response = sg.client.api_keys.get()
211
+ puts response.status_code
212
+ puts response.body
213
+ puts response.headers
214
+ ```
215
+ ## Update the name & scopes of an API Key
216
+
217
+ **This endpoint allows you to update the name and scopes of a given API key.**
218
+
219
+ A JSON request body with a "name" property is required.
220
+ Most provide the list of all the scopes an api key should have.
221
+
222
+ The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html).
223
+
224
+
225
+ ### PUT /api_keys/{api_key_id}
226
+
227
+
228
+ ```ruby
229
+ data = JSON.parse('{
230
+ "name": "A New Hope",
231
+ "scopes": [
232
+ "user.profile.read",
233
+ "user.profile.update"
234
+ ]
235
+ }')
236
+ api_key_id = "test_url_param"
237
+ response = sg.client.api_keys._(api_key_id).put(request_body: data)
238
+ puts response.status_code
239
+ puts response.body
240
+ puts response.headers
241
+ ```
242
+ ## Update API keys
243
+
244
+ **This endpoint allows you to update the name of an existing API Key.**
245
+
246
+ A JSON request body with a "name" property is required.
247
+
248
+ The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html).
249
+
250
+ ## URI Parameters
251
+
252
+ | URI Parameter | Type | Required? | Description |
253
+ |---|---|---|---|
254
+ |api_key_id |string | required | The ID of the API Key you are updating.|
255
+
256
+ ### PATCH /api_keys/{api_key_id}
257
+
258
+
259
+ ```ruby
260
+ data = JSON.parse('{
261
+ "name": "A New Hope"
262
+ }')
263
+ api_key_id = "test_url_param"
264
+ response = sg.client.api_keys._(api_key_id).patch(request_body: data)
265
+ puts response.status_code
266
+ puts response.body
267
+ puts response.headers
268
+ ```
269
+ ## Retrieve an existing API Key
270
+
271
+ **This endpoint allows you to retrieve a single api key.**
272
+
273
+ If the API Key ID does not exist an HTTP 404 will be returned.
274
+
275
+ ### GET /api_keys/{api_key_id}
276
+
277
+
278
+ ```ruby
279
+ api_key_id = "test_url_param"
280
+ response = sg.client.api_keys._(api_key_id).get()
281
+ puts response.status_code
282
+ puts response.body
283
+ puts response.headers
284
+ ```
285
+ ## Delete API keys
286
+
287
+ **This endpoint allows you to revoke an existing API Key**
288
+
289
+ Authentications using this API Key will fail after this request is made, with some small propogation delay.If the API Key ID does not exist an HTTP 404 will be returned.
290
+
291
+ The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html).
292
+
293
+ ## URI Parameters
294
+
295
+ | URI Parameter | Type | Required? | Description |
296
+ |---|---|---|---|
297
+ |api_key_id |string | required | The ID of the API Key you are deleting.|
298
+
299
+ ### DELETE /api_keys/{api_key_id}
300
+
301
+
302
+ ```ruby
303
+ api_key_id = "test_url_param"
304
+ response = sg.client.api_keys._(api_key_id).delete()
305
+ puts response.status_code
306
+ puts response.body
307
+ puts response.headers
308
+ ```
309
+ <a name="asm"></a>
310
+ # ASM
311
+
312
+ ## Create a new suppression group
313
+
314
+ **This endpoint allows you to create a new suppression group.**
315
+
316
+ Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts.
317
+
318
+ The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions.
319
+
320
+ Each user can create up to 25 different suppression groups.
321
+
322
+ ### POST /asm/groups
323
+
324
+
325
+ ```ruby
326
+ data = JSON.parse('{
327
+ "description": "Suggestions for products our users might like.",
328
+ "is_default": true,
329
+ "name": "Product Suggestions"
330
+ }')
331
+ response = sg.client.asm.groups.post(request_body: data)
332
+ puts response.status_code
333
+ puts response.body
334
+ puts response.headers
335
+ ```
336
+ ## Retrieve information about multiple suppression groups
337
+
338
+ **This endpoint allows you to retrieve information about multiple suppression groups.**
339
+
340
+ This endpoint will return information for each group ID that you include in your request. To add a group ID to your request, simply append `&id=` followed by the group ID.
341
+
342
+ ### GET /asm/groups
343
+
344
+
345
+ ```ruby
346
+ params = JSON.parse('{"id": 1}')
347
+ response = sg.client.asm.groups.get(query_params: params)
348
+ puts response.status_code
349
+ puts response.body
350
+ puts response.headers
351
+ ```
352
+ ## Update a suppression group.
353
+
354
+ **This endpoint allows you to update or change a suppression group.**
355
+
356
+ Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts.
357
+
358
+ The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions.
359
+
360
+ Each user can create up to 25 different suppression groups.
361
+
362
+ ### PATCH /asm/groups/{group_id}
363
+
364
+
365
+ ```ruby
366
+ data = JSON.parse('{
367
+ "description": "Suggestions for items our users might like.",
368
+ "id": 103,
369
+ "name": "Item Suggestions"
370
+ }')
371
+ group_id = "test_url_param"
372
+ response = sg.client.asm.groups._(group_id).patch(request_body: data)
373
+ puts response.status_code
374
+ puts response.body
375
+ puts response.headers
376
+ ```
377
+ ## Get information on a single suppression group.
378
+
379
+ **This endpoint allows you to retrieve a single suppression group.**
380
+
381
+ Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts.
382
+
383
+ The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions.
384
+
385
+ Each user can create up to 25 different suppression groups.
386
+
387
+ ### GET /asm/groups/{group_id}
388
+
389
+
390
+ ```ruby
391
+ group_id = "test_url_param"
392
+ response = sg.client.asm.groups._(group_id).get()
393
+ puts response.status_code
394
+ puts response.body
395
+ puts response.headers
396
+ ```
397
+ ## Delete a suppression group.
398
+
399
+ **This endpoint allows you to delete a suppression group.**
400
+
401
+ You can only delete groups that have not been attached to sent mail in the last 60 days. If a recipient uses the "one-click unsubscribe" option on an email associated with a deleted group, that recipient will be added to the global suppression list.
402
+
403
+ Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts.
404
+
405
+ The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions.
406
+
407
+ Each user can create up to 25 different suppression groups.
408
+
409
+ ### DELETE /asm/groups/{group_id}
410
+
411
+
412
+ ```ruby
413
+ group_id = "test_url_param"
414
+ response = sg.client.asm.groups._(group_id).delete()
415
+ puts response.status_code
416
+ puts response.body
417
+ puts response.headers
418
+ ```
419
+ ## Add suppressions to a suppression group
420
+
421
+ **This endpoint allows you to add email addresses to an unsubscribe group.**
422
+
423
+ If you attempt to add suppressions to a group that has been deleted or does not exist, the suppressions will be added to the global suppressions list.
424
+
425
+ Suppressions are recipient email addresses that are added to [unsubscribe groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). Once a recipient's address is on the suppressions list for an unsubscribe group, they will not receive any emails that are tagged with that unsubscribe group.
426
+
427
+ ### POST /asm/groups/{group_id}/suppressions
428
+
429
+
430
+ ```ruby
431
+ data = JSON.parse('{
432
+ "recipient_emails": [
433
+ "test1@example.com",
434
+ "test2@example.com"
435
+ ]
436
+ }')
437
+ group_id = "test_url_param"
438
+ response = sg.client.asm.groups._(group_id).suppressions.post(request_body: data)
439
+ puts response.status_code
440
+ puts response.body
441
+ puts response.headers
442
+ ```
443
+ ## Retrieve all suppressions for a suppression group
444
+
445
+ **This endpoint allows you to retrieve all suppressed email addresses belonging to the given group.**
446
+
447
+ Suppressions are recipient email addresses that are added to [unsubscribe groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). Once a recipient's address is on the suppressions list for an unsubscribe group, they will not receive any emails that are tagged with that unsubscribe group.
448
+
449
+ ### GET /asm/groups/{group_id}/suppressions
450
+
451
+
452
+ ```ruby
453
+ group_id = "test_url_param"
454
+ response = sg.client.asm.groups._(group_id).suppressions.get()
455
+ puts response.status_code
456
+ puts response.body
457
+ puts response.headers
458
+ ```
459
+ ## Delete a suppression from a suppression group
460
+
461
+ **This endpoint allows you to remove a suppressed email address from the given suppression group.**
462
+
463
+ Suppressions are recipient email addresses that are added to [unsubscribe groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). Once a recipient's address is on the suppressions list for an unsubscribe group, they will not receive any emails that are tagged with that unsubscribe group.
464
+
465
+ ### DELETE /asm/groups/{group_id}/suppressions/{email}
466
+
467
+
468
+ ```ruby
469
+ group_id = "test_url_param"
470
+ email = "test_url_param"
471
+ response = sg.client.asm.groups._(group_id).suppressions._(email).delete()
472
+ puts response.status_code
473
+ puts response.body
474
+ puts response.headers
475
+ ```
476
+ ## Retrieve all suppressions
477
+
478
+ **This endpoint allows you to retrieve a list of all suppressions.**
479
+
480
+ Suppressions are email addresses that can be added to [groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html) to prevent certain types of emails from being delivered to those addresses.
481
+
482
+ ### GET /asm/suppressions
483
+
484
+
485
+ ```ruby
486
+ response = sg.client.asm.suppressions.get()
487
+ puts response.status_code
488
+ puts response.body
489
+ puts response.headers
490
+ ```
491
+ ## Add recipient addresses to the global suppression group.
492
+
493
+ **This endpoint allows you to add one or more email addresses to the global suppressions group.**
494
+
495
+ A global suppression (or global unsubscribe) is an email address of a recipient who does not want to receive any of your messages. A globally suppressed recipient will be removed from any email you send. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/global_unsubscribes.html).
496
+
497
+ ### POST /asm/suppressions/global
498
+
499
+
500
+ ```ruby
501
+ data = JSON.parse('{
502
+ "recipient_emails": [
503
+ "test1@example.com",
504
+ "test2@example.com"
505
+ ]
506
+ }')
507
+ response = sg.client.asm.suppressions.global.post(request_body: data)
508
+ puts response.status_code
509
+ puts response.body
510
+ puts response.headers
511
+ ```
512
+ ## Retrieve a Global Suppression
513
+
514
+ **This endpoint allows you to retrieve a global suppression. You can also use this endpoint to confirm if an email address is already globally suppresed.**
515
+
516
+ If the email address you include in the URL path parameter `{email}` is alreayd globally suppressed, the response will include that email address. If the address you enter for `{email}` is not globally suppressed, an empty JSON object `{}` will be returned.
517
+
518
+ A global suppression (or global unsubscribe) is an email address of a recipient who does not want to receive any of your messages. A globally suppressed recipient will be removed from any email you send. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/global_unsubscribes.html).
519
+
520
+ ### GET /asm/suppressions/global/{email}
521
+
522
+
523
+ ```ruby
524
+ email = "test_url_param"
525
+ response = sg.client.asm.suppressions.global._(email).get()
526
+ puts response.status_code
527
+ puts response.body
528
+ puts response.headers
529
+ ```
530
+ ## Delete a Global Suppression
531
+
532
+ **This endpoint allows you to remove an email address from the global suppressions group.**
533
+
534
+ A global suppression (or global unsubscribe) is an email address of a recipient who does not want to receive any of your messages. A globally suppressed recipient will be removed from any email you send. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/global_unsubscribes.html).
535
+
536
+ ### DELETE /asm/suppressions/global/{email}
537
+
538
+
539
+ ```ruby
540
+ email = "test_url_param"
541
+ response = sg.client.asm.suppressions.global._(email).delete()
542
+ puts response.status_code
543
+ puts response.body
544
+ puts response.headers
545
+ ```
546
+ ## Retrieve all suppression groups for an email address
547
+
548
+ **This endpoint will return a list of all suppression groups, indicating if the given email address is suppressed for each group.**
549
+
550
+ Suppressions are email addresses that can be added to [groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html) to prevent certain types of emails from being delivered to those addresses.
551
+
552
+ ### GET /asm/suppressions/{email}
553
+
554
+
555
+ ```ruby
556
+ email = "test_url_param"
557
+ response = sg.client.asm.suppressions._(email).get()
558
+ puts response.status_code
559
+ puts response.body
560
+ puts response.headers
561
+ ```
562
+ <a name="browsers"></a>
563
+ # BROWSERS
564
+
565
+ ## Retrieve email statistics by browser.
566
+
567
+ **This endpoint allows you to retrieve your email statistics segmented by browser type.**
568
+
569
+ **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
570
+
571
+ Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html).
572
+
573
+ ### GET /browsers/stats
574
+
575
+
576
+ ```ruby
577
+ params = JSON.parse('{"end_date": "2016-04-01", "aggregated_by": "day", "browsers": "test_string", "limit": "test_string", "offset": "test_string", "start_date": "2016-01-01"}')
578
+ response = sg.client.browsers.stats.get(query_params: params)
579
+ puts response.status_code
580
+ puts response.body
581
+ puts response.headers
582
+ ```
583
+ <a name="campaigns"></a>
584
+ # CAMPAIGNS
585
+
586
+ ## Create a Campaign
587
+
588
+ **This endpoint allows you to create a campaign.**
589
+
590
+ Our Marketing Campaigns API lets you create, manage, send, and schedule campaigns.
591
+
592
+ Note: In order to send or schedule the campaign, you will be required to provide a subject, sender ID, content (we suggest both html and plain text), and at least one list or segment ID. This information is not required when you create a campaign.
593
+
594
+ For more information:
595
+
596
+ * [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html)
597
+
598
+ ### POST /campaigns
599
+
600
+
601
+ ```ruby
602
+ data = JSON.parse('{
603
+ "categories": [
604
+ "spring line"
605
+ ],
606
+ "custom_unsubscribe_url": "",
607
+ "html_content": "<html><head><title></title></head><body><p>Check out our spring line!</p></body></html>",
608
+ "ip_pool": "marketing",
609
+ "list_ids": [
610
+ 110,
611
+ 124
612
+ ],
613
+ "plain_content": "Check out our spring line!",
614
+ "segment_ids": [
615
+ 110
616
+ ],
617
+ "sender_id": 124451,
618
+ "subject": "New Products for Spring!",
619
+ "suppression_group_id": 42,
620
+ "title": "March Newsletter"
621
+ }')
622
+ response = sg.client.campaigns.post(request_body: data)
623
+ puts response.status_code
624
+ puts response.body
625
+ puts response.headers
626
+ ```
627
+ ## Retrieve all Campaigns
628
+
629
+ **This endpoint allows you to retrieve a list of all of your campaigns.**
630
+
631
+ Returns campaigns in reverse order they were created (newest first).
632
+
633
+ Returns an empty array if no campaigns exist.
634
+
635
+ For more information:
636
+
637
+ * [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html)
638
+
639
+ ### GET /campaigns
640
+
641
+
642
+ ```ruby
643
+ params = JSON.parse('{"limit": 0, "offset": 0}')
644
+ response = sg.client.campaigns.get(query_params: params)
645
+ puts response.status_code
646
+ puts response.body
647
+ puts response.headers
648
+ ```
649
+ ## Update a Campaign
650
+
651
+ Update a campaign. This is especially useful if you only set up the campaign using POST /campaigns, but didn't set many of the parameters.
652
+
653
+ For more information:
654
+
655
+ * [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html)
656
+
657
+ ### PATCH /campaigns/{campaign_id}
658
+
659
+
660
+ ```ruby
661
+ data = JSON.parse('{
662
+ "categories": [
663
+ "summer line"
664
+ ],
665
+ "html_content": "<html><head><title></title></head><body><p>Check out our summer line!</p></body></html>",
666
+ "plain_content": "Check out our summer line!",
667
+ "subject": "New Products for Summer!",
668
+ "title": "May Newsletter"
669
+ }')
670
+ campaign_id = "test_url_param"
671
+ response = sg.client.campaigns._(campaign_id).patch(request_body: data)
672
+ puts response.status_code
673
+ puts response.body
674
+ puts response.headers
675
+ ```
676
+ ## Retrieve a single campaign
677
+
678
+ **This endpoint allows you to retrieve a specific campaign.**
679
+
680
+ Our Marketing Campaigns API lets you create, manage, send, and schedule campaigns.
681
+
682
+ For more information:
683
+
684
+ * [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html)
685
+
686
+ ### GET /campaigns/{campaign_id}
687
+
688
+
689
+ ```ruby
690
+ campaign_id = "test_url_param"
691
+ response = sg.client.campaigns._(campaign_id).get()
692
+ puts response.status_code
693
+ puts response.body
694
+ puts response.headers
695
+ ```
696
+ ## Delete a Campaign
697
+
698
+ **This endpoint allows you to delete a specific campaign.**
699
+
700
+ Our Marketing Campaigns API lets you create, manage, send, and schedule campaigns.
701
+
702
+ For more information:
703
+
704
+ * [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html)
705
+
706
+ ### DELETE /campaigns/{campaign_id}
707
+
708
+
709
+ ```ruby
710
+ campaign_id = "test_url_param"
711
+ response = sg.client.campaigns._(campaign_id).delete()
712
+ puts response.status_code
713
+ puts response.body
714
+ puts response.headers
715
+ ```
716
+ ## Update a Scheduled Campaign
717
+
718
+ **This endpoint allows to you change the scheduled time and date for a campaign to be sent.**
719
+
720
+ For more information:
721
+
722
+ * [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html)
723
+
724
+ ### PATCH /campaigns/{campaign_id}/schedules
725
+
726
+
727
+ ```ruby
728
+ data = JSON.parse('{
729
+ "send_at": 1489451436
730
+ }')
731
+ campaign_id = "test_url_param"
732
+ response = sg.client.campaigns._(campaign_id).schedules.patch(request_body: data)
733
+ puts response.status_code
734
+ puts response.body
735
+ puts response.headers
736
+ ```
737
+ ## Schedule a Campaign
738
+
739
+ **This endpoint allows you to schedule a specific date and time for your campaign to be sent.**
740
+
741
+ For more information:
742
+
743
+ * [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html)
744
+
745
+ ### POST /campaigns/{campaign_id}/schedules
746
+
747
+
748
+ ```ruby
749
+ data = JSON.parse('{
750
+ "send_at": 1489771528
751
+ }')
752
+ campaign_id = "test_url_param"
753
+ response = sg.client.campaigns._(campaign_id).schedules.post(request_body: data)
754
+ puts response.status_code
755
+ puts response.body
756
+ puts response.headers
757
+ ```
758
+ ## View Scheduled Time of a Campaign
759
+
760
+ **This endpoint allows you to retrieve the date and time that the given campaign has been scheduled to be sent.**
761
+
762
+ For more information:
763
+
764
+ * [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html)
765
+
766
+ ### GET /campaigns/{campaign_id}/schedules
767
+
768
+
769
+ ```ruby
770
+ campaign_id = "test_url_param"
771
+ response = sg.client.campaigns._(campaign_id).schedules.get()
772
+ puts response.status_code
773
+ puts response.body
774
+ puts response.headers
775
+ ```
776
+ ## Unschedule a Scheduled Campaign
777
+
778
+ **This endpoint allows you to unschedule a campaign that has already been scheduled to be sent.**
779
+
780
+ A successful unschedule will return a 204.
781
+ If the specified campaign is in the process of being sent, the only option is to cancel (a different method).
782
+
783
+ For more information:
784
+
785
+ * [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html)
786
+
787
+ ### DELETE /campaigns/{campaign_id}/schedules
788
+
789
+
790
+ ```ruby
791
+ campaign_id = "test_url_param"
792
+ response = sg.client.campaigns._(campaign_id).schedules.delete()
793
+ puts response.status_code
794
+ puts response.body
795
+ puts response.headers
796
+ ```
797
+ ## Send a Campaign
798
+
799
+ **This endpoint allows you to immediately send a campaign at the time you make the API call.**
800
+
801
+ Normally a POST would have a request body, but since this endpoint is telling us to send a resource that is already created, a request body is not needed.
802
+
803
+ For more information:
804
+
805
+ * [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html)
806
+
807
+ ### POST /campaigns/{campaign_id}/schedules/now
808
+
809
+
810
+ ```ruby
811
+ campaign_id = "test_url_param"
812
+ response = sg.client.campaigns._(campaign_id).schedules.now.post()
813
+ puts response.status_code
814
+ puts response.body
815
+ puts response.headers
816
+ ```
817
+ ## Send a Test Campaign
818
+
819
+ **This endpoint allows you to send a test campaign.**
820
+
821
+ To send to multiple addresses, use an array for the JSON "to" value ["one@address","two@address"]
822
+
823
+ For more information:
824
+
825
+ * [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html)
826
+
827
+ ### POST /campaigns/{campaign_id}/schedules/test
828
+
829
+
830
+ ```ruby
831
+ data = JSON.parse('{
832
+ "to": "your.email@example.com"
833
+ }')
834
+ campaign_id = "test_url_param"
835
+ response = sg.client.campaigns._(campaign_id).schedules.test.post(request_body: data)
836
+ puts response.status_code
837
+ puts response.body
838
+ puts response.headers
839
+ ```
840
+ <a name="categories"></a>
841
+ # CATEGORIES
842
+
843
+ ## Retrieve all categories
844
+
845
+ **This endpoint allows you to retrieve a list of all of your categories.**
846
+
847
+ Categories can help organize your email analytics by enabling you to tag emails by type or broad topic. You can define your own custom categories. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/categories.html).
848
+
849
+ ### GET /categories
850
+
851
+
852
+ ```ruby
853
+ params = JSON.parse('{"category": "test_string", "limit": 1, "offset": 1}')
854
+ response = sg.client.categories.get(query_params: params)
855
+ puts response.status_code
856
+ puts response.body
857
+ puts response.headers
858
+ ```
859
+ ## Retrieve Email Statistics for Categories
860
+
861
+ **This endpoint allows you to retrieve all of your email statistics for each of your categories.**
862
+
863
+ If you do not define any query parameters, this endpoint will return a sum for each category in groups of 10.
864
+
865
+ Categories allow you to group your emails together according to broad topics that you define. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/categories.html).
866
+
867
+ ### GET /categories/stats
868
+
869
+
870
+ ```ruby
871
+ params = JSON.parse('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01", "categories": "test_string"}')
872
+ response = sg.client.categories.stats.get(query_params: params)
873
+ puts response.status_code
874
+ puts response.body
875
+ puts response.headers
876
+ ```
877
+ ## Retrieve sums of email stats for each category [Needs: Stats object defined, has category ID?]
878
+
879
+ **This endpoint allows you to retrieve the total sum of each email statistic for every category over the given date range.**
880
+
881
+ If you do not define any query parameters, this endpoint will return a sum for each category in groups of 10.
882
+
883
+ Categories allow you to group your emails together according to broad topics that you define. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/categories.html).
884
+
885
+ ### GET /categories/stats/sums
886
+
887
+
888
+ ```ruby
889
+ params = JSON.parse('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "start_date": "2016-01-01", "sort_by_direction": "asc"}')
890
+ response = sg.client.categories.stats.sums.get(query_params: params)
891
+ puts response.status_code
892
+ puts response.body
893
+ puts response.headers
894
+ ```
895
+ <a name="clients"></a>
896
+ # CLIENTS
897
+
898
+ ## Retrieve email statistics by client type.
899
+
900
+ **This endpoint allows you to retrieve your email statistics segmented by client type.**
901
+
902
+ **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
903
+
904
+ Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html).
905
+
906
+ ### GET /clients/stats
907
+
908
+
909
+ ```ruby
910
+ params = JSON.parse('{"aggregated_by": "day", "start_date": "2016-01-01", "end_date": "2016-04-01"}')
911
+ response = sg.client.clients.stats.get(query_params: params)
912
+ puts response.status_code
913
+ puts response.body
914
+ puts response.headers
915
+ ```
916
+ ## Retrieve stats by a specific client type.
917
+
918
+ **This endpoint allows you to retrieve your email statistics segmented by a specific client type.**
919
+
920
+ **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
921
+
922
+ ## Available Client Types
923
+ - phone
924
+ - tablet
925
+ - webmail
926
+ - desktop
927
+
928
+ Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html).
929
+
930
+ ### GET /clients/{client_type}/stats
931
+
932
+
933
+ ```ruby
934
+ params = JSON.parse('{"aggregated_by": "day", "start_date": "2016-01-01", "end_date": "2016-04-01"}')
935
+ client_type = "test_url_param"
936
+ response = sg.client.clients._(client_type).stats.get(query_params: params)
937
+ puts response.status_code
938
+ puts response.body
939
+ puts response.headers
940
+ ```
941
+ <a name="contactdb"></a>
942
+ # CONTACTDB
943
+
944
+ ## Create a Custom Field
945
+
946
+ **This endpoint allows you to create a custom field.**
947
+
948
+ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html).
949
+
950
+ ### POST /contactdb/custom_fields
951
+
952
+
953
+ ```ruby
954
+ data = JSON.parse('{
955
+ "name": "pet",
956
+ "type": "text"
957
+ }')
958
+ response = sg.client.contactdb.custom_fields.post(request_body: data)
959
+ puts response.status_code
960
+ puts response.body
961
+ puts response.headers
962
+ ```
963
+ ## Retrieve all custom fields
964
+
965
+ **This endpoint allows you to retrieve all custom fields.**
966
+
967
+ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html).
968
+
969
+ ### GET /contactdb/custom_fields
970
+
971
+
972
+ ```ruby
973
+ response = sg.client.contactdb.custom_fields.get()
974
+ puts response.status_code
975
+ puts response.body
976
+ puts response.headers
977
+ ```
978
+ ## Retrieve a Custom Field
979
+
980
+ **This endpoint allows you to retrieve a custom field by ID.**
981
+
982
+ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html).
983
+
984
+ ### GET /contactdb/custom_fields/{custom_field_id}
985
+
986
+
987
+ ```ruby
988
+ custom_field_id = "test_url_param"
989
+ response = sg.client.contactdb.custom_fields._(custom_field_id).get()
990
+ puts response.status_code
991
+ puts response.body
992
+ puts response.headers
993
+ ```
994
+ ## Delete a Custom Field
995
+
996
+ **This endpoint allows you to delete a custom field by ID.**
997
+
998
+ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html).
999
+
1000
+ ### DELETE /contactdb/custom_fields/{custom_field_id}
1001
+
1002
+
1003
+ ```ruby
1004
+ custom_field_id = "test_url_param"
1005
+ response = sg.client.contactdb.custom_fields._(custom_field_id).delete()
1006
+ puts response.status_code
1007
+ puts response.body
1008
+ puts response.headers
1009
+ ```
1010
+ ## Create a List
1011
+
1012
+ **This endpoint allows you to create a list for your recipients.**
1013
+
1014
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1015
+
1016
+ ### POST /contactdb/lists
1017
+
1018
+
1019
+ ```ruby
1020
+ data = JSON.parse('{
1021
+ "name": "your list name"
1022
+ }')
1023
+ response = sg.client.contactdb.lists.post(request_body: data)
1024
+ puts response.status_code
1025
+ puts response.body
1026
+ puts response.headers
1027
+ ```
1028
+ ## Retrieve all lists
1029
+
1030
+ **This endpoint allows you to retrieve all of your recipient lists. If you don't have any lists, an empty array will be returned.**
1031
+
1032
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1033
+
1034
+ ### GET /contactdb/lists
1035
+
1036
+
1037
+ ```ruby
1038
+ response = sg.client.contactdb.lists.get()
1039
+ puts response.status_code
1040
+ puts response.body
1041
+ puts response.headers
1042
+ ```
1043
+ ## Delete Multiple lists
1044
+
1045
+ **This endpoint allows you to delete multiple recipient lists.**
1046
+
1047
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1048
+
1049
+ ### DELETE /contactdb/lists
1050
+
1051
+
1052
+ ```ruby
1053
+ response = sg.client.contactdb.lists.delete(request_body: data)
1054
+ puts response.status_code
1055
+ puts response.body
1056
+ puts response.headers
1057
+ ```
1058
+ ## Update a List
1059
+
1060
+ **This endpoint allows you to update the name of one of your recipient lists.**
1061
+
1062
+
1063
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1064
+
1065
+ ### PATCH /contactdb/lists/{list_id}
1066
+
1067
+
1068
+ ```ruby
1069
+ data = JSON.parse('{
1070
+ "name": "newlistname"
1071
+ }')
1072
+ params = JSON.parse('{"list_id": 0}')
1073
+ list_id = "test_url_param"
1074
+ response = sg.client.contactdb.lists._(list_id).patch(request_body: data, query_params: params)
1075
+ puts response.status_code
1076
+ puts response.body
1077
+ puts response.headers
1078
+ ```
1079
+ ## Retrieve a single list
1080
+
1081
+ This endpoint allows you to retrieve a single recipient list.
1082
+
1083
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1084
+
1085
+ ### GET /contactdb/lists/{list_id}
1086
+
1087
+
1088
+ ```ruby
1089
+ params = JSON.parse('{"list_id": 0}')
1090
+ list_id = "test_url_param"
1091
+ response = sg.client.contactdb.lists._(list_id).get(query_params: params)
1092
+ puts response.status_code
1093
+ puts response.body
1094
+ puts response.headers
1095
+ ```
1096
+ ## Delete a List
1097
+
1098
+ **This endpoint allows you to delete a specific recipient list with the given ID.**
1099
+
1100
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1101
+
1102
+ ### DELETE /contactdb/lists/{list_id}
1103
+
1104
+
1105
+ ```ruby
1106
+ params = JSON.parse('{"delete_contacts": "true"}')
1107
+ list_id = "test_url_param"
1108
+ response = sg.client.contactdb.lists._(list_id).delete(query_params: params)
1109
+ puts response.status_code
1110
+ puts response.body
1111
+ puts response.headers
1112
+ ```
1113
+ ## Add Multiple Recipients to a List
1114
+
1115
+ **This endpoint allows you to add multiple recipients to a list.**
1116
+
1117
+ Adds existing recipients to a list, passing in the recipient IDs to add. Recipient IDs should be passed exactly as they are returned from recipient endpoints.
1118
+
1119
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1120
+
1121
+ ### POST /contactdb/lists/{list_id}/recipients
1122
+
1123
+
1124
+ ```ruby
1125
+ data = JSON.parse('[
1126
+ "recipient_id1",
1127
+ "recipient_id2"
1128
+ ]')
1129
+ list_id = "test_url_param"
1130
+ response = sg.client.contactdb.lists._(list_id).recipients.post(request_body: data)
1131
+ puts response.status_code
1132
+ puts response.body
1133
+ puts response.headers
1134
+ ```
1135
+ ## Retrieve all recipients on a List
1136
+
1137
+ **This endpoint allows you to retrieve all recipients on the list with the given ID.**
1138
+
1139
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1140
+
1141
+ ### GET /contactdb/lists/{list_id}/recipients
1142
+
1143
+
1144
+ ```ruby
1145
+ params = JSON.parse('{"page": 1, "page_size": 1, "list_id": 0}')
1146
+ list_id = "test_url_param"
1147
+ response = sg.client.contactdb.lists._(list_id).recipients.get(query_params: params)
1148
+ puts response.status_code
1149
+ puts response.body
1150
+ puts response.headers
1151
+ ```
1152
+ ## Add a Single Recipient to a List
1153
+
1154
+ **This endpoint allows you to add a single recipient to a list.**
1155
+
1156
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1157
+
1158
+ ### POST /contactdb/lists/{list_id}/recipients/{recipient_id}
1159
+
1160
+
1161
+ ```ruby
1162
+ list_id = "test_url_param"
1163
+ recipient_id = "test_url_param"
1164
+ response = sg.client.contactdb.lists._(list_id).recipients._(recipient_id).post()
1165
+ puts response.status_code
1166
+ puts response.body
1167
+ puts response.headers
1168
+ ```
1169
+ ## Delete a Single Recipient from a Single List
1170
+
1171
+ **This endpoint allows you to delete a single recipient from a list.**
1172
+
1173
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1174
+
1175
+ ### DELETE /contactdb/lists/{list_id}/recipients/{recipient_id}
1176
+
1177
+
1178
+ ```ruby
1179
+ params = JSON.parse('{"recipient_id": 0, "list_id": 0}')
1180
+ list_id = "test_url_param"
1181
+ recipient_id = "test_url_param"
1182
+ response = sg.client.contactdb.lists._(list_id).recipients._(recipient_id).delete(query_params: params)
1183
+ puts response.status_code
1184
+ puts response.body
1185
+ puts response.headers
1186
+ ```
1187
+ ## Update Recipient
1188
+
1189
+ **This endpoint allows you to update one or more recipients.**
1190
+
1191
+ The body of an API call to this endpoint must include an array of one or more recipient objects.
1192
+
1193
+ It is of note that you can add custom field data as parameters on recipient objects. We have provided an example using some of the default custom fields SendGrid provides.
1194
+
1195
+ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html).
1196
+
1197
+ ### PATCH /contactdb/recipients
1198
+
1199
+
1200
+ ```ruby
1201
+ data = JSON.parse('[
1202
+ {
1203
+ "email": "jones@example.com",
1204
+ "first_name": "Guy",
1205
+ "last_name": "Jones"
1206
+ }
1207
+ ]')
1208
+ response = sg.client.contactdb.recipients.patch(request_body: data)
1209
+ puts response.status_code
1210
+ puts response.body
1211
+ puts response.headers
1212
+ ```
1213
+ ## Add recipients
1214
+
1215
+ **This endpoint allows you to add a Marketing Campaigns recipient.**
1216
+
1217
+ It is of note that you can add custom field data as a parameter on this endpoint. We have provided an example using some of the default custom fields SendGrid provides.
1218
+
1219
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1220
+
1221
+ ### POST /contactdb/recipients
1222
+
1223
+
1224
+ ```ruby
1225
+ data = JSON.parse('[
1226
+ {
1227
+ "age": 25,
1228
+ "email": "example@example.com",
1229
+ "first_name": "",
1230
+ "last_name": "User"
1231
+ },
1232
+ {
1233
+ "age": 25,
1234
+ "email": "example2@example.com",
1235
+ "first_name": "Example",
1236
+ "last_name": "User"
1237
+ }
1238
+ ]')
1239
+ response = sg.client.contactdb.recipients.post(request_body: data)
1240
+ puts response.status_code
1241
+ puts response.body
1242
+ puts response.headers
1243
+ ```
1244
+ ## Retrieve recipients
1245
+
1246
+ **This endpoint allows you to retrieve all of your Marketing Campaigns recipients.**
1247
+
1248
+ Batch deletion of a page makes it possible to receive an empty page of recipients before reaching the end of
1249
+ the list of recipients. To avoid this issue; iterate over pages until a 404 is retrieved.
1250
+
1251
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1252
+
1253
+ ### GET /contactdb/recipients
1254
+
1255
+
1256
+ ```ruby
1257
+ params = JSON.parse('{"page": 1, "page_size": 1}')
1258
+ response = sg.client.contactdb.recipients.get(query_params: params)
1259
+ puts response.status_code
1260
+ puts response.body
1261
+ puts response.headers
1262
+ ```
1263
+ ## Delete Recipient
1264
+
1265
+ **This endpoint allows you to deletes one or more recipients.**
1266
+
1267
+ The body of an API call to this endpoint must include an array of recipient IDs of the recipients you want to delete.
1268
+
1269
+ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html).
1270
+
1271
+ ### DELETE /contactdb/recipients
1272
+
1273
+
1274
+ ```ruby
1275
+ response = sg.client.contactdb.recipients.delete(request_body: data)
1276
+ puts response.status_code
1277
+ puts response.body
1278
+ puts response.headers
1279
+ ```
1280
+ ## Retrieve the count of billable recipients
1281
+
1282
+ **This endpoint allows you to retrieve the number of Marketing Campaigns recipients that you will be billed for.**
1283
+
1284
+ You are billed for marketing campaigns based on the highest number of recipients you have had in your account at one time. This endpoint will allow you to know the current billable count value.
1285
+
1286
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1287
+
1288
+ ### GET /contactdb/recipients/billable_count
1289
+
1290
+
1291
+ ```ruby
1292
+ response = sg.client.contactdb.recipients.billable_count.get()
1293
+ puts response.status_code
1294
+ puts response.body
1295
+ puts response.headers
1296
+ ```
1297
+ ## Retrieve a Count of Recipients
1298
+
1299
+ **This endpoint allows you to retrieve the total number of Marketing Campaigns recipients.**
1300
+
1301
+ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html).
1302
+
1303
+ ### GET /contactdb/recipients/count
1304
+
1305
+
1306
+ ```ruby
1307
+ response = sg.client.contactdb.recipients.count.get()
1308
+ puts response.status_code
1309
+ puts response.body
1310
+ puts response.headers
1311
+ ```
1312
+ ## Retrieve recipients matching search criteria
1313
+
1314
+ **This endpoint allows you to perform a search on all of your Marketing Campaigns recipients.**
1315
+
1316
+ field_name:
1317
+
1318
+ * is a variable that is substituted for your actual custom field name from your recipient.
1319
+ * Text fields must be url-encoded. Date fields are searchable only by unix timestamp (e.g. 2/2/2015 becomes 1422835200)
1320
+ * If field_name is a 'reserved' date field, such as created_at or updated_at, the system will internally convert
1321
+ your epoch time to a date range encompassing the entire day. For example, an epoch time of 1422835600 converts to
1322
+ Mon, 02 Feb 2015 00:06:40 GMT, but internally the system will search from Mon, 02 Feb 2015 00:00:00 GMT through
1323
+ Mon, 02 Feb 2015 23:59:59 GMT.
1324
+
1325
+ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html).
1326
+
1327
+ ### GET /contactdb/recipients/search
1328
+
1329
+
1330
+ ```ruby
1331
+ params = JSON.parse('{"{field_name}": "test_string"}')
1332
+ response = sg.client.contactdb.recipients.search.get(query_params: params)
1333
+ puts response.status_code
1334
+ puts response.body
1335
+ puts response.headers
1336
+ ```
1337
+ ## Retrieve a single recipient
1338
+
1339
+ **This endpoint allows you to retrieve a single recipient by ID from your contact database.**
1340
+
1341
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1342
+
1343
+ ### GET /contactdb/recipients/{recipient_id}
1344
+
1345
+
1346
+ ```ruby
1347
+ recipient_id = "test_url_param"
1348
+ response = sg.client.contactdb.recipients._(recipient_id).get()
1349
+ puts response.status_code
1350
+ puts response.body
1351
+ puts response.headers
1352
+ ```
1353
+ ## Delete a Recipient
1354
+
1355
+ **This endpoint allows you to delete a single recipient with the given ID from your contact database.**
1356
+
1357
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1358
+
1359
+ ### DELETE /contactdb/recipients/{recipient_id}
1360
+
1361
+
1362
+ ```ruby
1363
+ recipient_id = "test_url_param"
1364
+ response = sg.client.contactdb.recipients._(recipient_id).delete()
1365
+ puts response.status_code
1366
+ puts response.body
1367
+ puts response.headers
1368
+ ```
1369
+ ## Retrieve the lists that a recipient is on
1370
+
1371
+ **This endpoint allows you to retrieve the lists that a given recipient belongs to.**
1372
+
1373
+ Each recipient can be on many lists. This endpoint gives you all of the lists that any one recipient has been added to.
1374
+
1375
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1376
+
1377
+ ### GET /contactdb/recipients/{recipient_id}/lists
1378
+
1379
+
1380
+ ```ruby
1381
+ recipient_id = "test_url_param"
1382
+ response = sg.client.contactdb.recipients._(recipient_id).lists.get()
1383
+ puts response.status_code
1384
+ puts response.body
1385
+ puts response.headers
1386
+ ```
1387
+ ## Retrieve reserved fields
1388
+
1389
+ **This endpoint allows you to list all fields that are reserved and can't be used for custom field names.**
1390
+
1391
+ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html).
1392
+
1393
+ ### GET /contactdb/reserved_fields
1394
+
1395
+
1396
+ ```ruby
1397
+ response = sg.client.contactdb.reserved_fields.get()
1398
+ puts response.status_code
1399
+ puts response.body
1400
+ puts response.headers
1401
+ ```
1402
+ ## Create a Segment
1403
+
1404
+ **This endpoint allows you to create a segment.**
1405
+
1406
+ All recipients in your contactdb will be added or removed automatically depending on whether they match the criteria for this segment.
1407
+
1408
+ List Id:
1409
+
1410
+ * Send this to segment from an existing list
1411
+ * Don't send this in order to segment from your entire contactdb.
1412
+
1413
+ Valid operators for create and update depend on the type of the field you are segmenting:
1414
+
1415
+ * **Dates:** "eq", "ne", "lt" (before), "gt" (after)
1416
+ * **Text:** "contains", "eq" (is - matches the full field), "ne" (is not - matches any field where the entire field is not the condition value)
1417
+ * **Numbers:** "eq", "lt", "gt"
1418
+ * **Email Clicks and Opens:** "eq" (opened), "ne" (not opened)
1419
+
1420
+ Segment conditions using "eq" or "ne" for email clicks and opens should provide a "field" of either *clicks.campaign_identifier* or *opens.campaign_identifier*. The condition value should be a string containing the id of a completed campaign.
1421
+
1422
+ Segments may contain multiple condtions, joined by an "and" or "or" in the "and_or" field. The first condition in the conditions list must have an empty "and_or", and subsequent conditions must all specify an "and_or".
1423
+
1424
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1425
+
1426
+ For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment).
1427
+
1428
+ ### POST /contactdb/segments
1429
+
1430
+
1431
+ ```ruby
1432
+ data = JSON.parse('{
1433
+ "conditions": [
1434
+ {
1435
+ "and_or": "",
1436
+ "field": "last_name",
1437
+ "operator": "eq",
1438
+ "value": "Miller"
1439
+ },
1440
+ {
1441
+ "and_or": "and",
1442
+ "field": "last_clicked",
1443
+ "operator": "gt",
1444
+ "value": "01/02/2015"
1445
+ },
1446
+ {
1447
+ "and_or": "or",
1448
+ "field": "clicks.campaign_identifier",
1449
+ "operator": "eq",
1450
+ "value": "513"
1451
+ }
1452
+ ],
1453
+ "list_id": 4,
1454
+ "name": "Last Name Miller"
1455
+ }')
1456
+ response = sg.client.contactdb.segments.post(request_body: data)
1457
+ puts response.status_code
1458
+ puts response.body
1459
+ puts response.headers
1460
+ ```
1461
+ ## Retrieve all segments
1462
+
1463
+ **This endpoint allows you to retrieve all of your segments.**
1464
+
1465
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1466
+
1467
+ For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment).
1468
+
1469
+ ### GET /contactdb/segments
1470
+
1471
+
1472
+ ```ruby
1473
+ response = sg.client.contactdb.segments.get()
1474
+ puts response.status_code
1475
+ puts response.body
1476
+ puts response.headers
1477
+ ```
1478
+ ## Update a segment
1479
+
1480
+ **This endpoint allows you to update a segment.**
1481
+
1482
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1483
+
1484
+ For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment).
1485
+
1486
+ ### PATCH /contactdb/segments/{segment_id}
1487
+
1488
+
1489
+ ```ruby
1490
+ data = JSON.parse('{
1491
+ "conditions": [
1492
+ {
1493
+ "and_or": "",
1494
+ "field": "last_name",
1495
+ "operator": "eq",
1496
+ "value": "Miller"
1497
+ }
1498
+ ],
1499
+ "list_id": 5,
1500
+ "name": "The Millers"
1501
+ }')
1502
+ params = JSON.parse('{"segment_id": "test_string"}')
1503
+ segment_id = "test_url_param"
1504
+ response = sg.client.contactdb.segments._(segment_id).patch(request_body: data, query_params: params)
1505
+ puts response.status_code
1506
+ puts response.body
1507
+ puts response.headers
1508
+ ```
1509
+ ## Retrieve a segment
1510
+
1511
+ **This endpoint allows you to retrieve a single segment with the given ID.**
1512
+
1513
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1514
+
1515
+ For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment).
1516
+
1517
+ ### GET /contactdb/segments/{segment_id}
1518
+
1519
+
1520
+ ```ruby
1521
+ params = JSON.parse('{"segment_id": 0}')
1522
+ segment_id = "test_url_param"
1523
+ response = sg.client.contactdb.segments._(segment_id).get(query_params: params)
1524
+ puts response.status_code
1525
+ puts response.body
1526
+ puts response.headers
1527
+ ```
1528
+ ## Delete a segment
1529
+
1530
+ **This endpoint allows you to delete a segment from your recipients database.**
1531
+
1532
+ You also have the option to delete all the contacts from your Marketing Campaigns recipient database who were in this segment.
1533
+
1534
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1535
+
1536
+ For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment).
1537
+
1538
+ ### DELETE /contactdb/segments/{segment_id}
1539
+
1540
+
1541
+ ```ruby
1542
+ params = JSON.parse('{"delete_contacts": "true"}')
1543
+ segment_id = "test_url_param"
1544
+ response = sg.client.contactdb.segments._(segment_id).delete(query_params: params)
1545
+ puts response.status_code
1546
+ puts response.body
1547
+ puts response.headers
1548
+ ```
1549
+ ## Retrieve recipients on a segment
1550
+
1551
+ **This endpoint allows you to retrieve all of the recipients in a segment with the given ID.**
1552
+
1553
+ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
1554
+
1555
+ For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment).
1556
+
1557
+ ### GET /contactdb/segments/{segment_id}/recipients
1558
+
1559
+
1560
+ ```ruby
1561
+ params = JSON.parse('{"page": 1, "page_size": 1}')
1562
+ segment_id = "test_url_param"
1563
+ response = sg.client.contactdb.segments._(segment_id).recipients.get(query_params: params)
1564
+ puts response.status_code
1565
+ puts response.body
1566
+ puts response.headers
1567
+ ```
1568
+ <a name="devices"></a>
1569
+ # DEVICES
1570
+
1571
+ ## Retrieve email statistics by device type.
1572
+
1573
+ **This endpoint allows you to retrieve your email statistics segmented by the device type.**
1574
+
1575
+ **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
1576
+
1577
+ ## Available Device Types
1578
+ | **Device** | **Description** | **Example** |
1579
+ |---|---|---|
1580
+ | Desktop | Email software on desktop computer. | I.E., Outlook, Sparrow, or Apple Mail. |
1581
+ | Webmail | A web-based email client. | I.E., Yahoo, Google, AOL, or Outlook.com. |
1582
+ | Phone | A smart phone. | iPhone, Android, Blackberry, etc.
1583
+ | Tablet | A tablet computer. | iPad, android based tablet, etc. |
1584
+ | Other | An unrecognized device. |
1585
+
1586
+ Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html).
1587
+
1588
+ ### GET /devices/stats
1589
+
1590
+
1591
+ ```ruby
1592
+ params = JSON.parse('{"aggregated_by": "day", "limit": 1, "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": 1}')
1593
+ response = sg.client.devices.stats.get(query_params: params)
1594
+ puts response.status_code
1595
+ puts response.body
1596
+ puts response.headers
1597
+ ```
1598
+ <a name="geo"></a>
1599
+ # GEO
1600
+
1601
+ ## Retrieve email statistics by country and state/province.
1602
+
1603
+ **This endpoint allows you to retrieve your email statistics segmented by country and state/province.**
1604
+
1605
+ **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
1606
+
1607
+ Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html).
1608
+
1609
+ ### GET /geo/stats
1610
+
1611
+
1612
+ ```ruby
1613
+ params = JSON.parse('{"end_date": "2016-04-01", "country": "US", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01"}')
1614
+ response = sg.client.geo.stats.get(query_params: params)
1615
+ puts response.status_code
1616
+ puts response.body
1617
+ puts response.headers
1618
+ ```
1619
+ <a name="ips"></a>
1620
+ # IPS
1621
+
1622
+ ## Retrieve all IP addresses
1623
+
1624
+ **This endpoint allows you to retrieve a list of all assigned and unassigned IPs.**
1625
+
1626
+ Response includes warm up status, pools, assigned subusers, and whitelabel info. The start_date field corresponds to when warmup started for that IP.
1627
+
1628
+ A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it.
1629
+
1630
+ ### GET /ips
1631
+
1632
+
1633
+ ```ruby
1634
+ params = JSON.parse('{"subuser": "test_string", "ip": "test_string", "limit": 1, "exclude_whitelabels": "true", "offset": 1}')
1635
+ response = sg.client.ips.get(query_params: params)
1636
+ puts response.status_code
1637
+ puts response.body
1638
+ puts response.headers
1639
+ ```
1640
+ ## Retrieve all assigned IPs
1641
+
1642
+ **This endpoint allows you to retrieve only assigned IP addresses.**
1643
+
1644
+ A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it.
1645
+
1646
+ ### GET /ips/assigned
1647
+
1648
+
1649
+ ```ruby
1650
+ response = sg.client.ips.assigned.get()
1651
+ puts response.status_code
1652
+ puts response.body
1653
+ puts response.headers
1654
+ ```
1655
+ ## Create an IP pool.
1656
+
1657
+ **This endpoint allows you to create an IP pool.**
1658
+
1659
+ **Each user can create up to 10 different IP pools.**
1660
+
1661
+ IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic.
1662
+
1663
+ IP pools can only be used with whitelabeled IP addresses.
1664
+
1665
+ If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools.
1666
+
1667
+ ### POST /ips/pools
1668
+
1669
+
1670
+ ```ruby
1671
+ data = JSON.parse('{
1672
+ "name": "marketing"
1673
+ }')
1674
+ response = sg.client.ips.pools.post(request_body: data)
1675
+ puts response.status_code
1676
+ puts response.body
1677
+ puts response.headers
1678
+ ```
1679
+ ## Retrieve all IP pools.
1680
+
1681
+ **This endpoint allows you to retreive all of your IP pools.**
1682
+
1683
+ IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic.
1684
+
1685
+ IP pools can only be used with whitelabeled IP addresses.
1686
+
1687
+ If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools.
1688
+
1689
+ ### GET /ips/pools
1690
+
1691
+
1692
+ ```ruby
1693
+ response = sg.client.ips.pools.get()
1694
+ puts response.status_code
1695
+ puts response.body
1696
+ puts response.headers
1697
+ ```
1698
+ ## Update an IP pools name.
1699
+
1700
+ **This endpoint allows you to update the name of an IP pool.**
1701
+
1702
+ IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic.
1703
+
1704
+ IP pools can only be used with whitelabeled IP addresses.
1705
+
1706
+ If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools.
1707
+
1708
+ ### PUT /ips/pools/{pool_name}
1709
+
1710
+
1711
+ ```ruby
1712
+ data = JSON.parse('{
1713
+ "name": "new_pool_name"
1714
+ }')
1715
+ pool_name = "test_url_param"
1716
+ response = sg.client.ips.pools._(pool_name).put(request_body: data)
1717
+ puts response.status_code
1718
+ puts response.body
1719
+ puts response.headers
1720
+ ```
1721
+ ## Retrieve all IPs in a specified pool.
1722
+
1723
+ **This endpoint allows you to list all of the IP addresses that are in a specific IP pool.**
1724
+
1725
+ IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic.
1726
+
1727
+ IP pools can only be used with whitelabeled IP addresses.
1728
+
1729
+ If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools.
1730
+
1731
+ ### GET /ips/pools/{pool_name}
1732
+
1733
+
1734
+ ```ruby
1735
+ pool_name = "test_url_param"
1736
+ response = sg.client.ips.pools._(pool_name).get()
1737
+ puts response.status_code
1738
+ puts response.body
1739
+ puts response.headers
1740
+ ```
1741
+ ## Delete an IP pool.
1742
+
1743
+ **This endpoint allows you to delete an IP pool.**
1744
+
1745
+ IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic.
1746
+
1747
+ IP pools can only be used with whitelabeled IP addresses.
1748
+
1749
+ If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools.
1750
+
1751
+ ### DELETE /ips/pools/{pool_name}
1752
+
1753
+
1754
+ ```ruby
1755
+ pool_name = "test_url_param"
1756
+ response = sg.client.ips.pools._(pool_name).delete()
1757
+ puts response.status_code
1758
+ puts response.body
1759
+ puts response.headers
1760
+ ```
1761
+ ## Add an IP address to a pool
1762
+
1763
+ **This endpoint allows you to add an IP address to an IP pool.**
1764
+
1765
+ You can add the same IP address to multiple pools. It may take up to 60 seconds for your IP address to be added to a pool after your request is made.
1766
+
1767
+ A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it.
1768
+
1769
+ ### POST /ips/pools/{pool_name}/ips
1770
+
1771
+
1772
+ ```ruby
1773
+ data = JSON.parse('{
1774
+ "ip": "0.0.0.0"
1775
+ }')
1776
+ pool_name = "test_url_param"
1777
+ response = sg.client.ips.pools._(pool_name).ips.post(request_body: data)
1778
+ puts response.status_code
1779
+ puts response.body
1780
+ puts response.headers
1781
+ ```
1782
+ ## Remove an IP address from a pool.
1783
+
1784
+ **This endpoint allows you to remove an IP address from an IP pool.**
1785
+
1786
+ The same IP address can be added to multiple IP pools.
1787
+
1788
+ A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it.
1789
+
1790
+ ### DELETE /ips/pools/{pool_name}/ips/{ip}
1791
+
1792
+
1793
+ ```ruby
1794
+ pool_name = "test_url_param"
1795
+ ip = "test_url_param"
1796
+ response = sg.client.ips.pools._(pool_name).ips._(ip).delete()
1797
+ puts response.status_code
1798
+ puts response.body
1799
+ puts response.headers
1800
+ ```
1801
+ ## Add an IP to warmup
1802
+
1803
+ **This endpoint allows you to enter an IP address into warmup mode.**
1804
+
1805
+ SendGrid can automatically warm up dedicated IP addresses by limiting the amount of mail that can be sent through them per hour, with the limit determined by how long the IP address has been in warmup. See the [warmup schedule](https://sendgrid.com/docs/API_Reference/Web_API_v3/IP_Management/ip_warmup_schedule.html) for more details on how SendGrid limits your email traffic for IPs in warmup.
1806
+
1807
+ For more general information about warming up IPs, please see our [Classroom](https://sendgrid.com/docs/Classroom/Deliver/Delivery_Introduction/warming_up_ips.html).
1808
+
1809
+ ### POST /ips/warmup
1810
+
1811
+
1812
+ ```ruby
1813
+ data = JSON.parse('{
1814
+ "ip": "0.0.0.0"
1815
+ }')
1816
+ response = sg.client.ips.warmup.post(request_body: data)
1817
+ puts response.status_code
1818
+ puts response.body
1819
+ puts response.headers
1820
+ ```
1821
+ ## Retrieve all IPs currently in warmup
1822
+
1823
+ **This endpoint allows you to retrieve all of your IP addresses that are currently warming up.**
1824
+
1825
+ SendGrid can automatically warm up dedicated IP addresses by limiting the amount of mail that can be sent through them per hour, with the limit determined by how long the IP address has been in warmup. See the [warmup schedule](https://sendgrid.com/docs/API_Reference/Web_API_v3/IP_Management/ip_warmup_schedule.html) for more details on how SendGrid limits your email traffic for IPs in warmup.
1826
+
1827
+ For more general information about warming up IPs, please see our [Classroom](https://sendgrid.com/docs/Classroom/Deliver/Delivery_Introduction/warming_up_ips.html).
1828
+
1829
+ ### GET /ips/warmup
1830
+
1831
+
1832
+ ```ruby
1833
+ response = sg.client.ips.warmup.get()
1834
+ puts response.status_code
1835
+ puts response.body
1836
+ puts response.headers
1837
+ ```
1838
+ ## Retrieve warmup status for a specific IP address
1839
+
1840
+ **This endpoint allows you to retrieve the warmup status for a specific IP address.**
1841
+
1842
+ SendGrid can automatically warm up dedicated IP addresses by limiting the amount of mail that can be sent through them per hour, with the limit determined by how long the IP address has been in warmup. See the [warmup schedule](https://sendgrid.com/docs/API_Reference/Web_API_v3/IP_Management/ip_warmup_schedule.html) for more details on how SendGrid limits your email traffic for IPs in warmup.
1843
+
1844
+ For more general information about warming up IPs, please see our [Classroom](https://sendgrid.com/docs/Classroom/Deliver/Delivery_Introduction/warming_up_ips.html).
1845
+
1846
+ ### GET /ips/warmup/{ip_address}
1847
+
1848
+
1849
+ ```ruby
1850
+ ip_address = "test_url_param"
1851
+ response = sg.client.ips.warmup._(ip_address).get()
1852
+ puts response.status_code
1853
+ puts response.body
1854
+ puts response.headers
1855
+ ```
1856
+ ## Remove an IP from warmup
1857
+
1858
+ **This endpoint allows you to remove an IP address from warmup mode.**
1859
+
1860
+ SendGrid can automatically warm up dedicated IP addresses by limiting the amount of mail that can be sent through them per hour, with the limit determined by how long the IP address has been in warmup. See the [warmup schedule](https://sendgrid.com/docs/API_Reference/Web_API_v3/IP_Management/ip_warmup_schedule.html) for more details on how SendGrid limits your email traffic for IPs in warmup.
1861
+
1862
+ For more general information about warming up IPs, please see our [Classroom](https://sendgrid.com/docs/Classroom/Deliver/Delivery_Introduction/warming_up_ips.html).
1863
+
1864
+ ### DELETE /ips/warmup/{ip_address}
1865
+
1866
+
1867
+ ```ruby
1868
+ ip_address = "test_url_param"
1869
+ response = sg.client.ips.warmup._(ip_address).delete()
1870
+ puts response.status_code
1871
+ puts response.body
1872
+ puts response.headers
1873
+ ```
1874
+ ## Retrieve all IP pools an IP address belongs to
1875
+
1876
+ **This endpoint allows you to see which IP pools a particular IP address has been added to.**
1877
+
1878
+ The same IP address can be added to multiple IP pools.
1879
+
1880
+ A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it.
1881
+
1882
+ ### GET /ips/{ip_address}
1883
+
1884
+
1885
+ ```ruby
1886
+ ip_address = "test_url_param"
1887
+ response = sg.client.ips._(ip_address).get()
1888
+ puts response.status_code
1889
+ puts response.body
1890
+ puts response.headers
1891
+ ```
1892
+ <a name="mail"></a>
1893
+ # MAIL
1894
+
1895
+ ## Create a batch ID
1896
+
1897
+ **This endpoint allows you to generate a new batch ID. This batch ID can be associated with scheduled sends via the mail/send endpoint.**
1898
+
1899
+ If you set the SMTPAPI header `batch_id`, it allows you to then associate multiple scheduled mail/send requests together with the same ID. Then at anytime up to 10 minutes before the schedule date, you can cancel all of the mail/send requests that have this batch ID by calling the Cancel Scheduled Send endpoint.
1900
+
1901
+ More Information:
1902
+
1903
+ * [Scheduling Parameters > Batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html)
1904
+
1905
+ ### POST /mail/batch
1906
+
1907
+
1908
+ ```ruby
1909
+ response = sg.client.mail.batch.post()
1910
+ puts response.status_code
1911
+ puts response.body
1912
+ puts response.headers
1913
+ ```
1914
+ ## Validate batch ID
1915
+
1916
+ **This endpoint allows you to validate a batch ID.**
1917
+
1918
+ If you set the SMTPAPI header `batch_id`, it allows you to then associate multiple scheduled mail/send requests together with the same ID. Then at anytime up to 10 minutes before the schedule date, you can cancel all of the mail/send requests that have this batch ID by calling the Cancel Scheduled Send endpoint.
1919
+
1920
+ More Information:
1921
+
1922
+ * [Scheduling Parameters > Batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html)
1923
+
1924
+ ### GET /mail/batch/{batch_id}
1925
+
1926
+
1927
+ ```ruby
1928
+ batch_id = "test_url_param"
1929
+ response = sg.client.mail.batch._(batch_id).get()
1930
+ puts response.status_code
1931
+ puts response.body
1932
+ puts response.headers
1933
+ ```
1934
+ ## v3 Mail Send
1935
+
1936
+ This endpoint allows you to send email over SendGrids v3 Web API, the most recent version of our API. If you are looking for documentation about the v2 Mail Send endpoint, please see our [v2 API Reference](https://sendgrid.com/docs/API_Reference/Web_API/mail.html).
1937
+
1938
+ * Top level parameters are referred to as "global".
1939
+ * Individual fields within the personalizations array will override any other global, or message level, parameters that are defined outside of personalizations.
1940
+
1941
+ For an overview of the v3 Mail Send endpoint, please visit our [v3 API Reference](https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html)
1942
+
1943
+ For more detailed information about how to use the v3 Mail Send endpoint, please visit our [Classroom](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/index.html).
1944
+
1945
+ ### POST /mail/send
1946
+
1947
+ This endpoint has a helper, check it out [here](https://github.com/sendgrid/sendgrid-ruby/blob/master/lib/helpers/mail/README.md).
1948
+
1949
+ ```ruby
1950
+ data = JSON.parse('{
1951
+ "asm": {
1952
+ "group_id": 1,
1953
+ "groups_to_display": [
1954
+ 1,
1955
+ 2,
1956
+ 3
1957
+ ]
1958
+ },
1959
+ "attachments": [
1960
+ {
1961
+ "content": "[BASE64 encoded content block here]",
1962
+ "content_id": "ii_139db99fdb5c3704",
1963
+ "disposition": "inline",
1964
+ "filename": "file1.jpg",
1965
+ "name": "file1",
1966
+ "type": "jpg"
1967
+ }
1968
+ ],
1969
+ "batch_id": "[YOUR BATCH ID GOES HERE]",
1970
+ "categories": [
1971
+ "category1",
1972
+ "category2"
1973
+ ],
1974
+ "content": [
1975
+ {
1976
+ "type": "text/html",
1977
+ "value": "<html><p>Hello, world!</p><img src=[CID GOES HERE]></img></html>"
1978
+ }
1979
+ ],
1980
+ "custom_args": {
1981
+ "New Argument 1": "New Value 1",
1982
+ "activationAttempt": "1",
1983
+ "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
1984
+ },
1985
+ "from": {
1986
+ "email": "sam.smith@example.com",
1987
+ "name": "Sam Smith"
1988
+ },
1989
+ "headers": {},
1990
+ "ip_pool_name": "[YOUR POOL NAME GOES HERE]",
1991
+ "mail_settings": {
1992
+ "bcc": {
1993
+ "email": "ben.doe@example.com",
1994
+ "enable": true
1995
+ },
1996
+ "bypass_list_management": {
1997
+ "enable": true
1998
+ },
1999
+ "footer": {
2000
+ "enable": true,
2001
+ "html": "<p>Thanks</br>The SendGrid Team</p>",
2002
+ "text": "Thanks,/n The SendGrid Team"
2003
+ },
2004
+ "sandbox_mode": {
2005
+ "enable": false
2006
+ },
2007
+ "spam_check": {
2008
+ "enable": true,
2009
+ "post_to_url": "http://example.com/compliance",
2010
+ "threshold": 3
2011
+ }
2012
+ },
2013
+ "personalizations": [
2014
+ {
2015
+ "bcc": [
2016
+ {
2017
+ "email": "sam.doe@example.com",
2018
+ "name": "Sam Doe"
2019
+ }
2020
+ ],
2021
+ "cc": [
2022
+ {
2023
+ "email": "jane.doe@example.com",
2024
+ "name": "Jane Doe"
2025
+ }
2026
+ ],
2027
+ "custom_args": {
2028
+ "New Argument 1": "New Value 1",
2029
+ "activationAttempt": "1",
2030
+ "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
2031
+ },
2032
+ "headers": {
2033
+ "X-Accept-Language": "en",
2034
+ "X-Mailer": "MyApp"
2035
+ },
2036
+ "send_at": 1409348513,
2037
+ "subject": "Hello, World!",
2038
+ "substitutions": {
2039
+ "sub": {
2040
+ "%name%": [
2041
+ "John",
2042
+ "Jane",
2043
+ "Sam"
2044
+ ]
2045
+ }
2046
+ },
2047
+ "to": [
2048
+ {
2049
+ "email": "john.doe@example.com",
2050
+ "name": "John Doe"
2051
+ }
2052
+ ]
2053
+ }
2054
+ ],
2055
+ "reply_to": {
2056
+ "email": "sam.smith@example.com",
2057
+ "name": "Sam Smith"
2058
+ },
2059
+ "sections": {
2060
+ "section": {
2061
+ ":sectionName1": "section 1 text",
2062
+ ":sectionName2": "section 2 text"
2063
+ }
2064
+ },
2065
+ "send_at": 1409348513,
2066
+ "subject": "Hello, World!",
2067
+ "template_id": "[YOUR TEMPLATE ID GOES HERE]",
2068
+ "tracking_settings": {
2069
+ "click_tracking": {
2070
+ "enable": true,
2071
+ "enable_text": true
2072
+ },
2073
+ "ganalytics": {
2074
+ "enable": true,
2075
+ "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]",
2076
+ "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]",
2077
+ "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]",
2078
+ "utm_name": "[NAME OF YOUR CAMPAIGN]",
2079
+ "utm_term": "[IDENTIFY PAID KEYWORDS HERE]"
2080
+ },
2081
+ "open_tracking": {
2082
+ "enable": true,
2083
+ "substitution_tag": "%opentrack"
2084
+ },
2085
+ "subscription_tracking": {
2086
+ "enable": true,
2087
+ "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.",
2088
+ "substitution_tag": "<%click here%>",
2089
+ "text": "If you would like to unsubscribe and stop receiveing these emails <% click here %>."
2090
+ }
2091
+ }
2092
+ }')
2093
+ response = sg.client.mail._("send").post(request_body: data)
2094
+ puts response.status_code
2095
+ puts response.body
2096
+ puts response.headers
2097
+ ```
2098
+ <a name="mail_settings"></a>
2099
+ # MAIL SETTINGS
2100
+
2101
+ ## Retrieve all mail settings
2102
+
2103
+ **This endpoint allows you to retrieve a list of all mail settings.**
2104
+
2105
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2106
+
2107
+ ### GET /mail_settings
2108
+
2109
+
2110
+ ```ruby
2111
+ params = JSON.parse('{"limit": 1, "offset": 1}')
2112
+ response = sg.client.mail_settings.get(query_params: params)
2113
+ puts response.status_code
2114
+ puts response.body
2115
+ puts response.headers
2116
+ ```
2117
+ ## Update address whitelist mail settings
2118
+
2119
+ **This endpoint allows you to update your current email address whitelist settings.**
2120
+
2121
+ The address whitelist setting whitelists a specified email address or domain for which mail should never be suppressed. For example, you own the domain example.com, and one or more of your recipients use email@example.com addresses, by placing example.com in the address whitelist setting, all bounces, blocks, and unsubscribes logged for that domain will be ignored and sent as if under normal sending conditions.
2122
+
2123
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2124
+
2125
+ ### PATCH /mail_settings/address_whitelist
2126
+
2127
+
2128
+ ```ruby
2129
+ data = JSON.parse('{
2130
+ "enabled": true,
2131
+ "list": [
2132
+ "email1@example.com",
2133
+ "example.com"
2134
+ ]
2135
+ }')
2136
+ response = sg.client.mail_settings.address_whitelist.patch(request_body: data)
2137
+ puts response.status_code
2138
+ puts response.body
2139
+ puts response.headers
2140
+ ```
2141
+ ## Retrieve address whitelist mail settings
2142
+
2143
+ **This endpoint allows you to retrieve your current email address whitelist settings.**
2144
+
2145
+ The address whitelist setting whitelists a specified email address or domain for which mail should never be suppressed. For example, you own the domain example.com, and one or more of your recipients use email@example.com addresses, by placing example.com in the address whitelist setting, all bounces, blocks, and unsubscribes logged for that domain will be ignored and sent as if under normal sending conditions.
2146
+
2147
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2148
+
2149
+ ### GET /mail_settings/address_whitelist
2150
+
2151
+
2152
+ ```ruby
2153
+ response = sg.client.mail_settings.address_whitelist.get()
2154
+ puts response.status_code
2155
+ puts response.body
2156
+ puts response.headers
2157
+ ```
2158
+ ## Update BCC mail settings
2159
+
2160
+ **This endpoint allows you to update your current BCC mail settings.**
2161
+
2162
+ When the BCC mail setting is enabled, SendGrid will automatically send a blind carbon copy (BCC) to an address for every email sent without adding that address to the header. Please note that only one email address may be entered in this field, if you wish to distribute BCCs to multiple addresses you will need to create a distribution group or use forwarding rules.
2163
+
2164
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2165
+
2166
+ ### PATCH /mail_settings/bcc
2167
+
2168
+
2169
+ ```ruby
2170
+ data = JSON.parse('{
2171
+ "email": "email@example.com",
2172
+ "enabled": false
2173
+ }')
2174
+ response = sg.client.mail_settings.bcc.patch(request_body: data)
2175
+ puts response.status_code
2176
+ puts response.body
2177
+ puts response.headers
2178
+ ```
2179
+ ## Retrieve all BCC mail settings
2180
+
2181
+ **This endpoint allows you to retrieve your current BCC mail settings.**
2182
+
2183
+ When the BCC mail setting is enabled, SendGrid will automatically send a blind carbon copy (BCC) to an address for every email sent without adding that address to the header. Please note that only one email address may be entered in this field, if you wish to distribute BCCs to multiple addresses you will need to create a distribution group or use forwarding rules.
2184
+
2185
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2186
+
2187
+ ### GET /mail_settings/bcc
2188
+
2189
+
2190
+ ```ruby
2191
+ response = sg.client.mail_settings.bcc.get()
2192
+ puts response.status_code
2193
+ puts response.body
2194
+ puts response.headers
2195
+ ```
2196
+ ## Update bounce purge mail settings
2197
+
2198
+ **This endpoint allows you to update your current bounce purge settings.**
2199
+
2200
+ This setting allows you to set a schedule for SendGrid to automatically delete contacts from your soft and hard bounce suppression lists.
2201
+
2202
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2203
+
2204
+ ### PATCH /mail_settings/bounce_purge
2205
+
2206
+
2207
+ ```ruby
2208
+ data = JSON.parse('{
2209
+ "enabled": true,
2210
+ "hard_bounces": 5,
2211
+ "soft_bounces": 5
2212
+ }')
2213
+ response = sg.client.mail_settings.bounce_purge.patch(request_body: data)
2214
+ puts response.status_code
2215
+ puts response.body
2216
+ puts response.headers
2217
+ ```
2218
+ ## Retrieve bounce purge mail settings
2219
+
2220
+ **This endpoint allows you to retrieve your current bounce purge settings.**
2221
+
2222
+ This setting allows you to set a schedule for SendGrid to automatically delete contacts from your soft and hard bounce suppression lists.
2223
+
2224
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2225
+
2226
+ ### GET /mail_settings/bounce_purge
2227
+
2228
+
2229
+ ```ruby
2230
+ response = sg.client.mail_settings.bounce_purge.get()
2231
+ puts response.status_code
2232
+ puts response.body
2233
+ puts response.headers
2234
+ ```
2235
+ ## Update footer mail settings
2236
+
2237
+ **This endpoint allows you to update your current Footer mail settings.**
2238
+
2239
+ The footer setting will insert a custom footer at the bottom of the text and HTML bodies. Use the embedded HTML editor and plain text entry fields to create the content of the footers to be inserted into your emails.
2240
+
2241
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2242
+
2243
+ ### PATCH /mail_settings/footer
2244
+
2245
+
2246
+ ```ruby
2247
+ data = JSON.parse('{
2248
+ "enabled": true,
2249
+ "html_content": "...",
2250
+ "plain_content": "..."
2251
+ }')
2252
+ response = sg.client.mail_settings.footer.patch(request_body: data)
2253
+ puts response.status_code
2254
+ puts response.body
2255
+ puts response.headers
2256
+ ```
2257
+ ## Retrieve footer mail settings
2258
+
2259
+ **This endpoint allows you to retrieve your current Footer mail settings.**
2260
+
2261
+ The footer setting will insert a custom footer at the bottom of the text and HTML bodies. Use the embedded HTML editor and plain text entry fields to create the content of the footers to be inserted into your emails.
2262
+
2263
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2264
+
2265
+ ### GET /mail_settings/footer
2266
+
2267
+
2268
+ ```ruby
2269
+ response = sg.client.mail_settings.footer.get()
2270
+ puts response.status_code
2271
+ puts response.body
2272
+ puts response.headers
2273
+ ```
2274
+ ## Update forward bounce mail settings
2275
+
2276
+ **This endpoint allows you to update your current bounce forwarding mail settings.**
2277
+
2278
+ Activating this setting allows you to specify an email address to which bounce reports are forwarded.
2279
+
2280
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2281
+
2282
+ ### PATCH /mail_settings/forward_bounce
2283
+
2284
+
2285
+ ```ruby
2286
+ data = JSON.parse('{
2287
+ "email": "example@example.com",
2288
+ "enabled": true
2289
+ }')
2290
+ response = sg.client.mail_settings.forward_bounce.patch(request_body: data)
2291
+ puts response.status_code
2292
+ puts response.body
2293
+ puts response.headers
2294
+ ```
2295
+ ## Retrieve forward bounce mail settings
2296
+
2297
+ **This endpoint allows you to retrieve your current bounce forwarding mail settings.**
2298
+
2299
+ Activating this setting allows you to specify an email address to which bounce reports are forwarded.
2300
+
2301
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2302
+
2303
+ ### GET /mail_settings/forward_bounce
2304
+
2305
+
2306
+ ```ruby
2307
+ response = sg.client.mail_settings.forward_bounce.get()
2308
+ puts response.status_code
2309
+ puts response.body
2310
+ puts response.headers
2311
+ ```
2312
+ ## Update forward spam mail settings
2313
+
2314
+ **This endpoint allows you to update your current Forward Spam mail settings.**
2315
+
2316
+ Enabling the forward spam setting allows you to specify an email address to which spam reports will be forwarded.
2317
+
2318
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2319
+
2320
+ ### PATCH /mail_settings/forward_spam
2321
+
2322
+
2323
+ ```ruby
2324
+ data = JSON.parse('{
2325
+ "email": "",
2326
+ "enabled": false
2327
+ }')
2328
+ response = sg.client.mail_settings.forward_spam.patch(request_body: data)
2329
+ puts response.status_code
2330
+ puts response.body
2331
+ puts response.headers
2332
+ ```
2333
+ ## Retrieve forward spam mail settings
2334
+
2335
+ **This endpoint allows you to retrieve your current Forward Spam mail settings.**
2336
+
2337
+ Enabling the forward spam setting allows you to specify an email address to which spam reports will be forwarded.
2338
+
2339
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2340
+
2341
+ ### GET /mail_settings/forward_spam
2342
+
2343
+
2344
+ ```ruby
2345
+ response = sg.client.mail_settings.forward_spam.get()
2346
+ puts response.status_code
2347
+ puts response.body
2348
+ puts response.headers
2349
+ ```
2350
+ ## Update plain content mail settings
2351
+
2352
+ **This endpoint allows you to update your current Plain Content mail settings.**
2353
+
2354
+ The plain content setting will automatically convert any plain text emails that you send to HTML before sending.
2355
+
2356
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2357
+
2358
+ ### PATCH /mail_settings/plain_content
2359
+
2360
+
2361
+ ```ruby
2362
+ data = JSON.parse('{
2363
+ "enabled": false
2364
+ }')
2365
+ response = sg.client.mail_settings.plain_content.patch(request_body: data)
2366
+ puts response.status_code
2367
+ puts response.body
2368
+ puts response.headers
2369
+ ```
2370
+ ## Retrieve plain content mail settings
2371
+
2372
+ **This endpoint allows you to retrieve your current Plain Content mail settings.**
2373
+
2374
+ The plain content setting will automatically convert any plain text emails that you send to HTML before sending.
2375
+
2376
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2377
+
2378
+ ### GET /mail_settings/plain_content
2379
+
2380
+
2381
+ ```ruby
2382
+ response = sg.client.mail_settings.plain_content.get()
2383
+ puts response.status_code
2384
+ puts response.body
2385
+ puts response.headers
2386
+ ```
2387
+ ## Update spam check mail settings
2388
+
2389
+ **This endpoint allows you to update your current spam checker mail settings.**
2390
+
2391
+ The spam checker filter notifies you when emails are detected that exceed a predefined spam threshold.
2392
+
2393
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2394
+
2395
+ ### PATCH /mail_settings/spam_check
2396
+
2397
+
2398
+ ```ruby
2399
+ data = JSON.parse('{
2400
+ "enabled": true,
2401
+ "max_score": 5,
2402
+ "url": "url"
2403
+ }')
2404
+ response = sg.client.mail_settings.spam_check.patch(request_body: data)
2405
+ puts response.status_code
2406
+ puts response.body
2407
+ puts response.headers
2408
+ ```
2409
+ ## Retrieve spam check mail settings
2410
+
2411
+ **This endpoint allows you to retrieve your current Spam Checker mail settings.**
2412
+
2413
+ The spam checker filter notifies you when emails are detected that exceed a predefined spam threshold.
2414
+
2415
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2416
+
2417
+ ### GET /mail_settings/spam_check
2418
+
2419
+
2420
+ ```ruby
2421
+ response = sg.client.mail_settings.spam_check.get()
2422
+ puts response.status_code
2423
+ puts response.body
2424
+ puts response.headers
2425
+ ```
2426
+ ## Update template mail settings
2427
+
2428
+ **This endpoint allows you to update your current legacy email template settings.**
2429
+
2430
+ This setting refers to our original email templates. We currently support more fully featured [transactional templates](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
2431
+
2432
+ The legacy email template setting wraps an HTML template around your email content. This can be useful for sending out marketing email and/or other HTML formatted messages.
2433
+
2434
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2435
+
2436
+ ### PATCH /mail_settings/template
2437
+
2438
+
2439
+ ```ruby
2440
+ data = JSON.parse('{
2441
+ "enabled": true,
2442
+ "html_content": "<% body %>"
2443
+ }')
2444
+ response = sg.client.mail_settings.template.patch(request_body: data)
2445
+ puts response.status_code
2446
+ puts response.body
2447
+ puts response.headers
2448
+ ```
2449
+ ## Retrieve legacy template mail settings
2450
+
2451
+ **This endpoint allows you to retrieve your current legacy email template settings.**
2452
+
2453
+ This setting refers to our original email templates. We currently support more fully featured [transactional templates](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
2454
+
2455
+ The legacy email template setting wraps an HTML template around your email content. This can be useful for sending out marketing email and/or other HTML formatted messages.
2456
+
2457
+ Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
2458
+
2459
+ ### GET /mail_settings/template
2460
+
2461
+
2462
+ ```ruby
2463
+ response = sg.client.mail_settings.template.get()
2464
+ puts response.status_code
2465
+ puts response.body
2466
+ puts response.headers
2467
+ ```
2468
+ <a name="mailbox_providers"></a>
2469
+ # MAILBOX PROVIDERS
2470
+
2471
+ ## Retrieve email statistics by mailbox provider.
2472
+
2473
+ **This endpoint allows you to retrieve your email statistics segmented by recipient mailbox provider.**
2474
+
2475
+ **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
2476
+
2477
+ Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html).
2478
+
2479
+ ### GET /mailbox_providers/stats
2480
+
2481
+
2482
+ ```ruby
2483
+ params = JSON.parse('{"end_date": "2016-04-01", "mailbox_providers": "test_string", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01"}')
2484
+ response = sg.client.mailbox_providers.stats.get(query_params: params)
2485
+ puts response.status_code
2486
+ puts response.body
2487
+ puts response.headers
2488
+ ```
2489
+ <a name="partner_settings"></a>
2490
+ # PARTNER SETTINGS
2491
+
2492
+ ## Returns a list of all partner settings.
2493
+
2494
+ **This endpoint allows you to retrieve a list of all partner settings that you can enable.**
2495
+
2496
+ Our partner settings allow you to integrate your SendGrid account with our partners to increase your SendGrid experience and functionality. For more information about our partners, and how you can begin integrating with them, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/partners.html).
2497
+
2498
+ ### GET /partner_settings
2499
+
2500
+
2501
+ ```ruby
2502
+ params = JSON.parse('{"limit": 1, "offset": 1}')
2503
+ response = sg.client.partner_settings.get(query_params: params)
2504
+ puts response.status_code
2505
+ puts response.body
2506
+ puts response.headers
2507
+ ```
2508
+ ## Updates New Relic partner settings.
2509
+
2510
+ **This endpoint allows you to update or change your New Relic partner settings.**
2511
+
2512
+ Our partner settings allow you to integrate your SendGrid account with our partners to increase your SendGrid experience and functionality. For more information about our partners, and how you can begin integrating with them, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/partners.html).
2513
+
2514
+ By integrating with New Relic, you can send your SendGrid email statistics to your New Relic Dashboard. If you enable this setting, your stats will be sent to New Relic every 5 minutes. You will need your New Relic License Key to enable this setting. For more information, please see our [Classroom](https://sendgrid.com/docs/Classroom/Track/Collecting_Data/new_relic.html).
2515
+
2516
+ ### PATCH /partner_settings/new_relic
2517
+
2518
+
2519
+ ```ruby
2520
+ data = JSON.parse('{
2521
+ "enable_subuser_statistics": true,
2522
+ "enabled": true,
2523
+ "license_key": ""
2524
+ }')
2525
+ response = sg.client.partner_settings.new_relic.patch(request_body: data)
2526
+ puts response.status_code
2527
+ puts response.body
2528
+ puts response.headers
2529
+ ```
2530
+ ## Returns all New Relic partner settings.
2531
+
2532
+ **This endpoint allows you to retrieve your current New Relic partner settings.**
2533
+
2534
+ Our partner settings allow you to integrate your SendGrid account with our partners to increase your SendGrid experience and functionality. For more information about our partners, and how you can begin integrating with them, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/partners.html).
2535
+
2536
+ By integrating with New Relic, you can send your SendGrid email statistics to your New Relic Dashboard. If you enable this setting, your stats will be sent to New Relic every 5 minutes. You will need your New Relic License Key to enable this setting. For more information, please see our [Classroom](https://sendgrid.com/docs/Classroom/Track/Collecting_Data/new_relic.html).
2537
+
2538
+ ### GET /partner_settings/new_relic
2539
+
2540
+
2541
+ ```ruby
2542
+ response = sg.client.partner_settings.new_relic.get()
2543
+ puts response.status_code
2544
+ puts response.body
2545
+ puts response.headers
2546
+ ```
2547
+ <a name="scopes"></a>
2548
+ # SCOPES
2549
+
2550
+ ## Retrieve a list of scopes for which this user has access.
2551
+
2552
+ **This endpoint returns a list of all scopes that this user has access to.**
2553
+
2554
+ API Keys can be used to authenticate the use of [SendGrids v3 Web API](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html), or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). API Keys may be assigned certain permissions, or scopes, that limit which API endpoints they are able to access. For a more detailed explanation of how you can use API Key permissios, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/api_keys.html#-API-Key-Permissions) or [Classroom](https://sendgrid.com/docs/Classroom/Basics/API/api_key_permissions.html).
2555
+
2556
+ ### GET /scopes
2557
+
2558
+
2559
+ ```ruby
2560
+ response = sg.client.scopes.get()
2561
+ puts response.status_code
2562
+ puts response.body
2563
+ puts response.headers
2564
+ ```
2565
+ <a name="stats"></a>
2566
+ # STATS
2567
+
2568
+ ## Retrieve global email statistics
2569
+
2570
+ **This endpoint allows you to retrieve all of your global email statistics between a given date range.**
2571
+
2572
+ Parent accounts will see aggregated stats for their account and all subuser accounts. Subuser accounts will only see their own stats.
2573
+
2574
+ ### GET /stats
2575
+
2576
+
2577
+ ```ruby
2578
+ params = JSON.parse('{"aggregated_by": "day", "limit": 1, "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": 1}')
2579
+ response = sg.client.stats.get(query_params: params)
2580
+ puts response.status_code
2581
+ puts response.body
2582
+ puts response.headers
2583
+ ```
2584
+ <a name="subusers"></a>
2585
+ # SUBUSERS
2586
+
2587
+ ## Create Subuser
2588
+
2589
+ This endpoint allows you to retrieve a list of all of your subusers. You can choose to retrieve specific subusers as well as limit the results that come back from the API.
2590
+
2591
+ For more information about Subusers:
2592
+
2593
+ * [User Guide > Subusers](https://sendgrid.com/docs/User_Guide/Settings/Subusers/index.html)
2594
+ * [Classroom > How do I add more subusers to my account?](https://sendgrid.com/docs/Classroom/Basics/Account/how_do_i_add_more_subusers_to_my_account.html)
2595
+
2596
+ ### POST /subusers
2597
+
2598
+
2599
+ ```ruby
2600
+ data = JSON.parse('{
2601
+ "email": "John@example.com",
2602
+ "ips": [
2603
+ "1.1.1.1",
2604
+ "2.2.2.2"
2605
+ ],
2606
+ "password": "johns_password",
2607
+ "username": "John@example.com"
2608
+ }')
2609
+ response = sg.client.subusers.post(request_body: data)
2610
+ puts response.status_code
2611
+ puts response.body
2612
+ puts response.headers
2613
+ ```
2614
+ ## List all Subusers
2615
+
2616
+ This endpoint allows you to retrieve a list of all of your subusers. You can choose to retrieve specific subusers as well as limit the results that come back from the API.
2617
+
2618
+ For more information about Subusers:
2619
+
2620
+ * [User Guide > Subusers](https://sendgrid.com/docs/User_Guide/Settings/Subusers/index.html)
2621
+ * [Classroom > How do I add more subusers to my account?](https://sendgrid.com/docs/Classroom/Basics/Account/how_do_i_add_more_subusers_to_my_account.html)
2622
+
2623
+ ### GET /subusers
2624
+
2625
+
2626
+ ```ruby
2627
+ params = JSON.parse('{"username": "test_string", "limit": 0, "offset": 0}')
2628
+ response = sg.client.subusers.get(query_params: params)
2629
+ puts response.status_code
2630
+ puts response.body
2631
+ puts response.headers
2632
+ ```
2633
+ ## Retrieve Subuser Reputations
2634
+
2635
+ Subuser sender reputations give a good idea how well a sender is doing with regards to how recipients and recipient servers react to the mail that is being received. When a bounce, spam report, or other negative action happens on a sent email, it will effect your sender rating.
2636
+
2637
+ This endpoint allows you to request the reputations for your subusers.
2638
+
2639
+ ### GET /subusers/reputations
2640
+
2641
+
2642
+ ```ruby
2643
+ params = JSON.parse('{"usernames": "test_string"}')
2644
+ response = sg.client.subusers.reputations.get(query_params: params)
2645
+ puts response.status_code
2646
+ puts response.body
2647
+ puts response.headers
2648
+ ```
2649
+ ## Retrieve email statistics for your subusers.
2650
+
2651
+ **This endpoint allows you to retrieve the email statistics for the given subusers.**
2652
+
2653
+ You may retrieve statistics for up to 10 different subusers by including an additional _subusers_ parameter for each additional subuser.
2654
+
2655
+ While you can always view the statistics for all email activity on your account, subuser statistics enable you to view specific segments of your stats. Emails sent, bounces, and spam reports are always tracked for subusers. Unsubscribes, clicks, and opens are tracked if you have enabled the required settings.
2656
+
2657
+ For more information, see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/subuser.html).
2658
+
2659
+ ### GET /subusers/stats
2660
+
2661
+
2662
+ ```ruby
2663
+ params = JSON.parse('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01", "subusers": "test_string"}')
2664
+ response = sg.client.subusers.stats.get(query_params: params)
2665
+ puts response.status_code
2666
+ puts response.body
2667
+ puts response.headers
2668
+ ```
2669
+ ## Retrieve monthly stats for all subusers
2670
+
2671
+ **This endpoint allows you to retrieve the monthly email statistics for all subusers over the given date range.**
2672
+
2673
+ While you can always view the statistics for all email activity on your account, subuser statistics enable you to view specific segments of your stats for your subusers. Emails sent, bounces, and spam reports are always tracked for subusers. Unsubscribes, clicks, and opens are tracked if you have enabled the required settings.
2674
+
2675
+ When using the `sort_by_metric` to sort your stats by a specific metric, you can not sort by the following metrics:
2676
+ `bounce_drops`, `deferred`, `invalid_emails`, `processed`, `spam_report_drops`, `spam_reports`, or `unsubscribe_drops`.
2677
+
2678
+ For more information, see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/subuser.html).
2679
+
2680
+ ### GET /subusers/stats/monthly
2681
+
2682
+
2683
+ ```ruby
2684
+ params = JSON.parse('{"subuser": "test_string", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "date": "test_string", "sort_by_direction": "asc"}')
2685
+ response = sg.client.subusers.stats.monthly.get(query_params: params)
2686
+ puts response.status_code
2687
+ puts response.body
2688
+ puts response.headers
2689
+ ```
2690
+ ## Retrieve the totals for each email statistic metric for all subusers.
2691
+
2692
+ **This endpoint allows you to retrieve the total sums of each email statistic metric for all subusers over the given date range.**
2693
+
2694
+
2695
+ While you can always view the statistics for all email activity on your account, subuser statistics enable you to view specific segments of your stats. Emails sent, bounces, and spam reports are always tracked for subusers. Unsubscribes, clicks, and opens are tracked if you have enabled the required settings.
2696
+
2697
+ For more information, see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/subuser.html).
2698
+
2699
+ ### GET /subusers/stats/sums
2700
+
2701
+
2702
+ ```ruby
2703
+ params = JSON.parse('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "start_date": "2016-01-01", "sort_by_direction": "asc"}')
2704
+ response = sg.client.subusers.stats.sums.get(query_params: params)
2705
+ puts response.status_code
2706
+ puts response.body
2707
+ puts response.headers
2708
+ ```
2709
+ ## Enable/disable a subuser
2710
+
2711
+ This endpoint allows you to enable or disable a subuser.
2712
+
2713
+ For more information about Subusers:
2714
+
2715
+ * [User Guide > Subusers](https://sendgrid.com/docs/User_Guide/Settings/Subusers/index.html)
2716
+ * [Classroom > How do I add more subusers to my account?](https://sendgrid.com/docs/Classroom/Basics/Account/how_do_i_add_more_subusers_to_my_account.html)
2717
+
2718
+ ### PATCH /subusers/{subuser_name}
2719
+
2720
+
2721
+ ```ruby
2722
+ data = JSON.parse('{
2723
+ "disabled": false
2724
+ }')
2725
+ subuser_name = "test_url_param"
2726
+ response = sg.client.subusers._(subuser_name).patch(request_body: data)
2727
+ puts response.status_code
2728
+ puts response.body
2729
+ puts response.headers
2730
+ ```
2731
+ ## Delete a subuser
2732
+
2733
+ This endpoint allows you to delete a subuser. This is a permanent action, once deleted a subuser cannot be retrieved.
2734
+
2735
+ For more information about Subusers:
2736
+
2737
+ * [User Guide > Subusers](https://sendgrid.com/docs/User_Guide/Settings/Subusers/index.html)
2738
+ * [Classroom > How do I add more subusers to my account?](https://sendgrid.com/docs/Classroom/Basics/Account/how_do_i_add_more_subusers_to_my_account.html)
2739
+
2740
+ ### DELETE /subusers/{subuser_name}
2741
+
2742
+
2743
+ ```ruby
2744
+ subuser_name = "test_url_param"
2745
+ response = sg.client.subusers._(subuser_name).delete()
2746
+ puts response.status_code
2747
+ puts response.body
2748
+ puts response.headers
2749
+ ```
2750
+ ## Update IPs assigned to a subuser
2751
+
2752
+ Each subuser should be assigned to an IP address, from which all of this subuser's mail will be sent. Often, this is the same IP as the parent account, but each subuser can have their own, or multiple, IP addresses as well.
2753
+
2754
+ More information:
2755
+
2756
+ * [How to request more IPs](https://sendgrid.com/docs/Classroom/Basics/Account/adding_an_additional_dedicated_ip_to_your_account.html)
2757
+ * [IPs can be whitelabeled](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/ips.html)
2758
+
2759
+ ### PUT /subusers/{subuser_name}/ips
2760
+
2761
+
2762
+ ```ruby
2763
+ data = JSON.parse('[
2764
+ "127.0.0.1"
2765
+ ]')
2766
+ subuser_name = "test_url_param"
2767
+ response = sg.client.subusers._(subuser_name).ips.put(request_body: data)
2768
+ puts response.status_code
2769
+ puts response.body
2770
+ puts response.headers
2771
+ ```
2772
+ ## Update Monitor Settings for a subuser
2773
+
2774
+ Subuser monitor settings allow you to receive a sample of an outgoing message by a specific customer at a specific frequency of emails.
2775
+
2776
+ ### PUT /subusers/{subuser_name}/monitor
2777
+
2778
+
2779
+ ```ruby
2780
+ data = JSON.parse('{
2781
+ "email": "example@example.com",
2782
+ "frequency": 500
2783
+ }')
2784
+ subuser_name = "test_url_param"
2785
+ response = sg.client.subusers._(subuser_name).monitor.put(request_body: data)
2786
+ puts response.status_code
2787
+ puts response.body
2788
+ puts response.headers
2789
+ ```
2790
+ ## Create monitor settings
2791
+
2792
+ Subuser monitor settings allow you to receive a sample of an outgoing message by a specific customer at a specific frequency of emails.
2793
+
2794
+ ### POST /subusers/{subuser_name}/monitor
2795
+
2796
+
2797
+ ```ruby
2798
+ data = JSON.parse('{
2799
+ "email": "example@example.com",
2800
+ "frequency": 50000
2801
+ }')
2802
+ subuser_name = "test_url_param"
2803
+ response = sg.client.subusers._(subuser_name).monitor.post(request_body: data)
2804
+ puts response.status_code
2805
+ puts response.body
2806
+ puts response.headers
2807
+ ```
2808
+ ## Retrieve monitor settings for a subuser
2809
+
2810
+ Subuser monitor settings allow you to receive a sample of an outgoing message by a specific customer at a specific frequency of emails.
2811
+
2812
+ ### GET /subusers/{subuser_name}/monitor
2813
+
2814
+
2815
+ ```ruby
2816
+ subuser_name = "test_url_param"
2817
+ response = sg.client.subusers._(subuser_name).monitor.get()
2818
+ puts response.status_code
2819
+ puts response.body
2820
+ puts response.headers
2821
+ ```
2822
+ ## Delete monitor settings
2823
+
2824
+ Subuser monitor settings allow you to receive a sample of an outgoing message by a specific customer at a specific frequency of emails.
2825
+
2826
+ ### DELETE /subusers/{subuser_name}/monitor
2827
+
2828
+
2829
+ ```ruby
2830
+ subuser_name = "test_url_param"
2831
+ response = sg.client.subusers._(subuser_name).monitor.delete()
2832
+ puts response.status_code
2833
+ puts response.body
2834
+ puts response.headers
2835
+ ```
2836
+ ## Retrieve the monthly email statistics for a single subuser
2837
+
2838
+ **This endpoint allows you to retrive the monthly email statistics for a specific subuser.**
2839
+
2840
+ While you can always view the statistics for all email activity on your account, subuser statistics enable you to view specific segments of your stats for your subusers. Emails sent, bounces, and spam reports are always tracked for subusers. Unsubscribes, clicks, and opens are tracked if you have enabled the required settings.
2841
+
2842
+ When using the `sort_by_metric` to sort your stats by a specific metric, you can not sort by the following metrics:
2843
+ `bounce_drops`, `deferred`, `invalid_emails`, `processed`, `spam_report_drops`, `spam_reports`, or `unsubscribe_drops`.
2844
+
2845
+ For more information, see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/subuser.html).
2846
+
2847
+ ### GET /subusers/{subuser_name}/stats/monthly
2848
+
2849
+
2850
+ ```ruby
2851
+ params = JSON.parse('{"date": "test_string", "sort_by_direction": "asc", "limit": 0, "sort_by_metric": "test_string", "offset": 1}')
2852
+ subuser_name = "test_url_param"
2853
+ response = sg.client.subusers._(subuser_name).stats.monthly.get(query_params: params)
2854
+ puts response.status_code
2855
+ puts response.body
2856
+ puts response.headers
2857
+ ```
2858
+ <a name="suppression"></a>
2859
+ # SUPPRESSION
2860
+
2861
+ ## Retrieve all blocks
2862
+
2863
+ **This endpoint allows you to retrieve a list of all email addresses that are currently on your blocks list.**
2864
+
2865
+ [Blocks](https://sendgrid.com/docs/Glossary/blocks.html) happen when your message was rejected for a reason related to the message, not the recipient address. This can happen when your mail server IP address has been added to a blacklist or blocked by an ISP, or if the message content is flagged by a filter on the receiving server.
2866
+
2867
+ For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/blocks.html).
2868
+
2869
+ ### GET /suppression/blocks
2870
+
2871
+
2872
+ ```ruby
2873
+ params = JSON.parse('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}')
2874
+ response = sg.client.suppression.blocks.get(query_params: params)
2875
+ puts response.status_code
2876
+ puts response.body
2877
+ puts response.headers
2878
+ ```
2879
+ ## Delete blocks
2880
+
2881
+ **This endpoint allows you to delete all email addresses on your blocks list.**
2882
+
2883
+ There are two options for deleting blocked emails:
2884
+
2885
+ 1. You can delete all blocked emails by setting `delete_all` to true in the request body.
2886
+ 2. You can delete some blocked emails by specifying the email addresses in an array in the request body.
2887
+
2888
+ [Blocks](https://sendgrid.com/docs/Glossary/blocks.html) happen when your message was rejected for a reason related to the message, not the recipient address. This can happen when your mail server IP address has been added to a blacklist or blocked by an ISP, or if the message content is flagged by a filter on the receiving server.
2889
+
2890
+ For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/blocks.html).
2891
+
2892
+ ### DELETE /suppression/blocks
2893
+
2894
+
2895
+ ```ruby
2896
+ response = sg.client.suppression.blocks.delete(request_body: data)
2897
+ puts response.status_code
2898
+ puts response.body
2899
+ puts response.headers
2900
+ ```
2901
+ ## Retrieve a specific block
2902
+
2903
+ **This endpoint allows you to retrieve a specific email address from your blocks list.**
2904
+
2905
+ [Blocks](https://sendgrid.com/docs/Glossary/blocks.html) happen when your message was rejected for a reason related to the message, not the recipient address. This can happen when your mail server IP address has been added to a blacklist or blocked by an ISP, or if the message content is flagged by a filter on the receiving server.
2906
+
2907
+ For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/blocks.html).
2908
+
2909
+ ### GET /suppression/blocks/{email}
2910
+
2911
+
2912
+ ```ruby
2913
+ email = "test_url_param"
2914
+ response = sg.client.suppression.blocks._(email).get()
2915
+ puts response.status_code
2916
+ puts response.body
2917
+ puts response.headers
2918
+ ```
2919
+ ## Delete a specific block
2920
+
2921
+ **This endpoint allows you to delete a specific email address from your blocks list.**
2922
+
2923
+ [Blocks](https://sendgrid.com/docs/Glossary/blocks.html) happen when your message was rejected for a reason related to the message, not the recipient address. This can happen when your mail server IP address has been added to a blacklist or blocked by an ISP, or if the message content is flagged by a filter on the receiving server.
2924
+
2925
+ For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/blocks.html).
2926
+
2927
+ ### DELETE /suppression/blocks/{email}
2928
+
2929
+
2930
+ ```ruby
2931
+ email = "test_url_param"
2932
+ response = sg.client.suppression.blocks._(email).delete()
2933
+ puts response.status_code
2934
+ puts response.body
2935
+ puts response.headers
2936
+ ```
2937
+ ## Retrieve all bounces
2938
+
2939
+ **This endpoint allows you to retrieve all of your bounces.**
2940
+
2941
+ Bounces are messages that are returned to the server that sent it.
2942
+
2943
+ For more information see:
2944
+
2945
+ * [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information
2946
+ * [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html)
2947
+
2948
+ ### GET /suppression/bounces
2949
+
2950
+
2951
+ ```ruby
2952
+ params = JSON.parse('{"start_time": 0, "end_time": 0}')
2953
+ response = sg.client.suppression.bounces.get(query_params: params)
2954
+ puts response.status_code
2955
+ puts response.body
2956
+ puts response.headers
2957
+ ```
2958
+ ## Delete bounces
2959
+
2960
+ **This endpoint allows you to delete all of your bounces. You can also use this endpoint to remove a specific email address from your bounce list.**
2961
+
2962
+ Bounces are messages that are returned to the server that sent it.
2963
+
2964
+ For more information see:
2965
+
2966
+ * [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information
2967
+ * [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html)
2968
+ * [Classroom > List Scrubbing Guide](https://sendgrid.com/docs/Classroom/Deliver/list_scrubbing.html)
2969
+
2970
+ Note: the `delete_all` and `emails` parameters should be used independently of each other as they have different purposes.
2971
+
2972
+ ### DELETE /suppression/bounces
2973
+
2974
+
2975
+ ```ruby
2976
+ response = sg.client.suppression.bounces.delete(request_body: data)
2977
+ puts response.status_code
2978
+ puts response.body
2979
+ puts response.headers
2980
+ ```
2981
+ ## Retrieve a Bounce
2982
+
2983
+ **This endpoint allows you to retrieve a specific bounce for a given email address.**
2984
+
2985
+ Bounces are messages that are returned to the server that sent it.
2986
+
2987
+ For more information see:
2988
+
2989
+ * [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information
2990
+ * [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html)
2991
+ * [Classroom > List Scrubbing Guide](https://sendgrid.com/docs/Classroom/Deliver/list_scrubbing.html)
2992
+
2993
+ ### GET /suppression/bounces/{email}
2994
+
2995
+
2996
+ ```ruby
2997
+ email = "test_url_param"
2998
+ response = sg.client.suppression.bounces._(email).get()
2999
+ puts response.status_code
3000
+ puts response.body
3001
+ puts response.headers
3002
+ ```
3003
+ ## Delete a bounce
3004
+
3005
+ **This endpoint allows you to remove an email address from your bounce list.**
3006
+
3007
+ Bounces are messages that are returned to the server that sent it. This endpoint allows you to delete a single email addresses from your bounce list.
3008
+
3009
+ For more information see:
3010
+
3011
+ * [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information
3012
+ * [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html)
3013
+ * [Classroom > List Scrubbing Guide](https://sendgrid.com/docs/Classroom/Deliver/list_scrubbing.html)
3014
+
3015
+ ### DELETE /suppression/bounces/{email}
3016
+
3017
+
3018
+ ```ruby
3019
+ params = JSON.parse('{"email_address": "example@example.com"}')
3020
+ email = "test_url_param"
3021
+ response = sg.client.suppression.bounces._(email).delete(query_params: params)
3022
+ puts response.status_code
3023
+ puts response.body
3024
+ puts response.headers
3025
+ ```
3026
+ ## Retrieve all invalid emails
3027
+
3028
+ **This endpoint allows you to retrieve a list of all invalid email addresses.**
3029
+
3030
+ An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipients mail server.
3031
+
3032
+ Examples include addresses without the @ sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server.
3033
+
3034
+ For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/invalid_emails.html).
3035
+
3036
+ ### GET /suppression/invalid_emails
3037
+
3038
+
3039
+ ```ruby
3040
+ params = JSON.parse('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}')
3041
+ response = sg.client.suppression.invalid_emails.get(query_params: params)
3042
+ puts response.status_code
3043
+ puts response.body
3044
+ puts response.headers
3045
+ ```
3046
+ ## Delete invalid emails
3047
+
3048
+ **This endpoint allows you to remove email addresses from your invalid email address list.**
3049
+
3050
+ There are two options for deleting invalid email addresses:
3051
+
3052
+ 1) You can delete all invalid email addresses by setting `delete_all` to true in the request body.
3053
+ 2) You can delete some invalid email addresses by specifying certain addresses in an array in the request body.
3054
+
3055
+ An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipients mail server.
3056
+
3057
+ Examples include addresses without the @ sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server.
3058
+
3059
+ For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/invalid_emails.html).
3060
+
3061
+ ### DELETE /suppression/invalid_emails
3062
+
3063
+
3064
+ ```ruby
3065
+ response = sg.client.suppression.invalid_emails.delete(request_body: data)
3066
+ puts response.status_code
3067
+ puts response.body
3068
+ puts response.headers
3069
+ ```
3070
+ ## Retrieve a specific invalid email
3071
+
3072
+ **This endpoint allows you to retrieve a specific invalid email addresses.**
3073
+
3074
+ An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipients mail server.
3075
+
3076
+ Examples include addresses without the @ sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server.
3077
+
3078
+ For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/invalid_emails.html).
3079
+
3080
+ ### GET /suppression/invalid_emails/{email}
3081
+
3082
+
3083
+ ```ruby
3084
+ email = "test_url_param"
3085
+ response = sg.client.suppression.invalid_emails._(email).get()
3086
+ puts response.status_code
3087
+ puts response.body
3088
+ puts response.headers
3089
+ ```
3090
+ ## Delete a specific invalid email
3091
+
3092
+ **This endpoint allows you to remove a specific email address from the invalid email address list.**
3093
+
3094
+ An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipients mail server.
3095
+
3096
+ Examples include addresses without the @ sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server.
3097
+
3098
+ For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/invalid_emails.html).
3099
+
3100
+ ### DELETE /suppression/invalid_emails/{email}
3101
+
3102
+
3103
+ ```ruby
3104
+ email = "test_url_param"
3105
+ response = sg.client.suppression.invalid_emails._(email).delete()
3106
+ puts response.status_code
3107
+ puts response.body
3108
+ puts response.headers
3109
+ ```
3110
+ ## Retrieve a specific spam report
3111
+
3112
+ **This endpoint allows you to retrieve a specific spam report.**
3113
+
3114
+ [Spam reports](https://sendgrid.com/docs/Glossary/spam_reports.html) happen when a recipient indicates that they think your email is [spam](https://sendgrid.com/docs/Glossary/spam.html) and then their email provider reports this to SendGrid.
3115
+
3116
+ For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/spam_reports.html).
3117
+
3118
+ ### GET /suppression/spam_report/{email}
3119
+
3120
+
3121
+ ```ruby
3122
+ email = "test_url_param"
3123
+ response = sg.client.suppression.spam_report._(email).get()
3124
+ puts response.status_code
3125
+ puts response.body
3126
+ puts response.headers
3127
+ ```
3128
+ ## Delete a specific spam report
3129
+
3130
+ **This endpoint allows you to delete a specific spam report.**
3131
+
3132
+ [Spam reports](https://sendgrid.com/docs/Glossary/spam_reports.html) happen when a recipient indicates that they think your email is [spam](https://sendgrid.com/docs/Glossary/spam.html) and then their email provider reports this to SendGrid.
3133
+
3134
+ For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/spam_reports.html).
3135
+
3136
+ ### DELETE /suppression/spam_report/{email}
3137
+
3138
+
3139
+ ```ruby
3140
+ email = "test_url_param"
3141
+ response = sg.client.suppression.spam_report._(email).delete()
3142
+ puts response.status_code
3143
+ puts response.body
3144
+ puts response.headers
3145
+ ```
3146
+ ## Retrieve all spam reports
3147
+
3148
+ **This endpoint allows you to retrieve all spam reports.**
3149
+
3150
+ [Spam reports](https://sendgrid.com/docs/Glossary/spam_reports.html) happen when a recipient indicates that they think your email is [spam](https://sendgrid.com/docs/Glossary/spam.html) and then their email provider reports this to SendGrid.
3151
+
3152
+ For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/spam_reports.html).
3153
+
3154
+ ### GET /suppression/spam_reports
3155
+
3156
+
3157
+ ```ruby
3158
+ params = JSON.parse('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}')
3159
+ response = sg.client.suppression.spam_reports.get(query_params: params)
3160
+ puts response.status_code
3161
+ puts response.body
3162
+ puts response.headers
3163
+ ```
3164
+ ## Delete spam reports
3165
+
3166
+ **This endpoint allows you to delete your spam reports.**
3167
+
3168
+ There are two options for deleting spam reports:
3169
+
3170
+ 1) You can delete all spam reports by setting "delete_all" to true in the request body.
3171
+ 2) You can delete some spam reports by specifying the email addresses in an array in the request body.
3172
+
3173
+ [Spam reports](https://sendgrid.com/docs/Glossary/spam_reports.html) happen when a recipient indicates that they think your email is [spam](https://sendgrid.com/docs/Glossary/spam.html) and then their email provider reports this to SendGrid.
3174
+
3175
+ For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/spam_reports.html).
3176
+
3177
+ ### DELETE /suppression/spam_reports
3178
+
3179
+
3180
+ ```ruby
3181
+ response = sg.client.suppression.spam_reports.delete(request_body: data)
3182
+ puts response.status_code
3183
+ puts response.body
3184
+ puts response.headers
3185
+ ```
3186
+ ## Retrieve all global suppressions
3187
+
3188
+ **This endpoint allows you to retrieve a list of all email address that are globally suppressed.**
3189
+
3190
+ A global suppression (or global unsubscribe) is an email address of a recipient who does not want to receive any of your messages. A globally suppressed recipient will be removed from any email you send. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/global_unsubscribes.html).
3191
+
3192
+ ### GET /suppression/unsubscribes
3193
+
3194
+
3195
+ ```ruby
3196
+ params = JSON.parse('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}')
3197
+ response = sg.client.suppression.unsubscribes.get(query_params: params)
3198
+ puts response.status_code
3199
+ puts response.body
3200
+ puts response.headers
3201
+ ```
3202
+ <a name="templates"></a>
3203
+ # TEMPLATES
3204
+
3205
+ ## Create a transactional template.
3206
+
3207
+ **This endpoint allows you to create a transactional template.**
3208
+
3209
+ Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts.
3210
+
3211
+ Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
3212
+
3213
+ ### POST /templates
3214
+
3215
+
3216
+ ```ruby
3217
+ data = JSON.parse('{
3218
+ "name": "example_name"
3219
+ }')
3220
+ response = sg.client.templates.post(request_body: data)
3221
+ puts response.status_code
3222
+ puts response.body
3223
+ puts response.headers
3224
+ ```
3225
+ ## Retrieve all transactional templates.
3226
+
3227
+ **This endpoint allows you to retrieve all transactional templates.**
3228
+
3229
+ Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts.
3230
+
3231
+ Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
3232
+
3233
+ ### GET /templates
3234
+
3235
+
3236
+ ```ruby
3237
+ response = sg.client.templates.get()
3238
+ puts response.status_code
3239
+ puts response.body
3240
+ puts response.headers
3241
+ ```
3242
+ ## Edit a transactional template.
3243
+
3244
+ **This endpoint allows you to edit a transactional template.**
3245
+
3246
+ Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts.
3247
+
3248
+ Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
3249
+
3250
+
3251
+ ### PATCH /templates/{template_id}
3252
+
3253
+
3254
+ ```ruby
3255
+ data = JSON.parse('{
3256
+ "name": "new_example_name"
3257
+ }')
3258
+ template_id = "test_url_param"
3259
+ response = sg.client.templates._(template_id).patch(request_body: data)
3260
+ puts response.status_code
3261
+ puts response.body
3262
+ puts response.headers
3263
+ ```
3264
+ ## Retrieve a single transactional template.
3265
+
3266
+ **This endpoint allows you to retrieve a single transactional template.**
3267
+
3268
+ Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts.
3269
+
3270
+ Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
3271
+
3272
+
3273
+ ### GET /templates/{template_id}
3274
+
3275
+
3276
+ ```ruby
3277
+ template_id = "test_url_param"
3278
+ response = sg.client.templates._(template_id).get()
3279
+ puts response.status_code
3280
+ puts response.body
3281
+ puts response.headers
3282
+ ```
3283
+ ## Delete a template.
3284
+
3285
+ **This endpoint allows you to delete a transactional template.**
3286
+
3287
+ Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts.
3288
+
3289
+ Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
3290
+
3291
+
3292
+ ### DELETE /templates/{template_id}
3293
+
3294
+
3295
+ ```ruby
3296
+ template_id = "test_url_param"
3297
+ response = sg.client.templates._(template_id).delete()
3298
+ puts response.status_code
3299
+ puts response.body
3300
+ puts response.headers
3301
+ ```
3302
+ ## Create a new transactional template version.
3303
+
3304
+ **This endpoint allows you to create a new version of a template.**
3305
+
3306
+ Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates.
3307
+
3308
+ For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
3309
+
3310
+
3311
+ ### POST /templates/{template_id}/versions
3312
+
3313
+
3314
+ ```ruby
3315
+ data = JSON.parse('{
3316
+ "active": 1,
3317
+ "html_content": "<%body%>",
3318
+ "name": "example_version_name",
3319
+ "plain_content": "<%body%>",
3320
+ "subject": "<%subject%>",
3321
+ "template_id": "ddb96bbc-9b92-425e-8979-99464621b543"
3322
+ }')
3323
+ template_id = "test_url_param"
3324
+ response = sg.client.templates._(template_id).versions.post(request_body: data)
3325
+ puts response.status_code
3326
+ puts response.body
3327
+ puts response.headers
3328
+ ```
3329
+ ## Edit a transactional template version.
3330
+
3331
+ **This endpoint allows you to edit a version of one of your transactional templates.**
3332
+
3333
+ Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates.
3334
+
3335
+ For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
3336
+
3337
+ ## URI Parameters
3338
+ | URI Parameter | Type | Description |
3339
+ |---|---|---|
3340
+ | template_id | string | The ID of the original template |
3341
+ | version_id | string | The ID of the template version |
3342
+
3343
+ ### PATCH /templates/{template_id}/versions/{version_id}
3344
+
3345
+
3346
+ ```ruby
3347
+ data = JSON.parse('{
3348
+ "active": 1,
3349
+ "html_content": "<%body%>",
3350
+ "name": "updated_example_name",
3351
+ "plain_content": "<%body%>",
3352
+ "subject": "<%subject%>"
3353
+ }')
3354
+ template_id = "test_url_param"
3355
+ version_id = "test_url_param"
3356
+ response = sg.client.templates._(template_id).versions._(version_id).patch(request_body: data)
3357
+ puts response.status_code
3358
+ puts response.body
3359
+ puts response.headers
3360
+ ```
3361
+ ## Retrieve a specific transactional template version.
3362
+
3363
+ **This endpoint allows you to retrieve a specific version of a template.**
3364
+
3365
+ Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates.
3366
+
3367
+ For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
3368
+
3369
+ ## URI Parameters
3370
+ | URI Parameter | Type | Description |
3371
+ |---|---|---|
3372
+ | template_id | string | The ID of the original template |
3373
+ | version_id | string | The ID of the template version |
3374
+
3375
+ ### GET /templates/{template_id}/versions/{version_id}
3376
+
3377
+
3378
+ ```ruby
3379
+ template_id = "test_url_param"
3380
+ version_id = "test_url_param"
3381
+ response = sg.client.templates._(template_id).versions._(version_id).get()
3382
+ puts response.status_code
3383
+ puts response.body
3384
+ puts response.headers
3385
+ ```
3386
+ ## Delete a transactional template version.
3387
+
3388
+ **This endpoint allows you to delete one of your transactional template versions.**
3389
+
3390
+ Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates.
3391
+
3392
+ For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
3393
+
3394
+ ## URI Parameters
3395
+ | URI Parameter | Type | Description |
3396
+ |---|---|---|
3397
+ | template_id | string | The ID of the original template |
3398
+ | version_id | string | The ID of the template version |
3399
+
3400
+ ### DELETE /templates/{template_id}/versions/{version_id}
3401
+
3402
+
3403
+ ```ruby
3404
+ template_id = "test_url_param"
3405
+ version_id = "test_url_param"
3406
+ response = sg.client.templates._(template_id).versions._(version_id).delete()
3407
+ puts response.status_code
3408
+ puts response.body
3409
+ puts response.headers
3410
+ ```
3411
+ ## Activate a transactional template version.
3412
+
3413
+ **This endpoint allows you to activate a version of one of your templates.**
3414
+
3415
+ Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates.
3416
+
3417
+
3418
+ For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
3419
+
3420
+ ## URI Parameters
3421
+ | URI Parameter | Type | Description |
3422
+ |---|---|---|
3423
+ | template_id | string | The ID of the original template |
3424
+ | version_id | string | The ID of the template version |
3425
+
3426
+ ### POST /templates/{template_id}/versions/{version_id}/activate
3427
+
3428
+
3429
+ ```ruby
3430
+ template_id = "test_url_param"
3431
+ version_id = "test_url_param"
3432
+ response = sg.client.templates._(template_id).versions._(version_id).activate.post()
3433
+ puts response.status_code
3434
+ puts response.body
3435
+ puts response.headers
3436
+ ```
3437
+ <a name="tracking_settings"></a>
3438
+ # TRACKING SETTINGS
3439
+
3440
+ ## Retrieve Tracking Settings
3441
+
3442
+ **This endpoint allows you to retrieve a list of all tracking settings that you can enable on your account.**
3443
+
3444
+ You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails.
3445
+
3446
+ For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html).
3447
+
3448
+ ### GET /tracking_settings
3449
+
3450
+
3451
+ ```ruby
3452
+ params = JSON.parse('{"limit": 1, "offset": 1}')
3453
+ response = sg.client.tracking_settings.get(query_params: params)
3454
+ puts response.status_code
3455
+ puts response.body
3456
+ puts response.headers
3457
+ ```
3458
+ ## Update Click Tracking Settings
3459
+
3460
+ **This endpoint allows you to change your current click tracking setting. You can enable, or disable, click tracking using this endpoint.**
3461
+
3462
+ You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails.
3463
+
3464
+ For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html).
3465
+
3466
+ ### PATCH /tracking_settings/click
3467
+
3468
+
3469
+ ```ruby
3470
+ data = JSON.parse('{
3471
+ "enabled": true
3472
+ }')
3473
+ response = sg.client.tracking_settings.click.patch(request_body: data)
3474
+ puts response.status_code
3475
+ puts response.body
3476
+ puts response.headers
3477
+ ```
3478
+ ## Retrieve Click Track Settings
3479
+
3480
+ **This endpoint allows you to retrieve your current click tracking setting.**
3481
+
3482
+ You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails.
3483
+
3484
+ For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html).
3485
+
3486
+ ### GET /tracking_settings/click
3487
+
3488
+
3489
+ ```ruby
3490
+ response = sg.client.tracking_settings.click.get()
3491
+ puts response.status_code
3492
+ puts response.body
3493
+ puts response.headers
3494
+ ```
3495
+ ## Update Google Analytics Settings
3496
+
3497
+ **This endpoint allows you to update your current setting for Google Analytics.**
3498
+
3499
+ For more information about using Google Analytics, please refer to [Googles URL Builder](https://support.google.com/analytics/answer/1033867?hl=en) and their article on ["Best Practices for Campaign Building"](https://support.google.com/analytics/answer/1037445).
3500
+
3501
+ We default the settings to Googles recommendations. For more information, see [Google Analytics Demystified](https://sendgrid.com/docs/Classroom/Track/Collecting_Data/google_analytics_demystified_ga_statistics_vs_sg_statistics.html).
3502
+
3503
+ You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails.
3504
+
3505
+ For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html).
3506
+
3507
+ ### PATCH /tracking_settings/google_analytics
3508
+
3509
+
3510
+ ```ruby
3511
+ data = JSON.parse('{
3512
+ "enabled": true,
3513
+ "utm_campaign": "website",
3514
+ "utm_content": "",
3515
+ "utm_medium": "email",
3516
+ "utm_source": "sendgrid.com",
3517
+ "utm_term": ""
3518
+ }')
3519
+ response = sg.client.tracking_settings.google_analytics.patch(request_body: data)
3520
+ puts response.status_code
3521
+ puts response.body
3522
+ puts response.headers
3523
+ ```
3524
+ ## Retrieve Google Analytics Settings
3525
+
3526
+ **This endpoint allows you to retrieve your current setting for Google Analytics.**
3527
+
3528
+ For more information about using Google Analytics, please refer to [Googles URL Builder](https://support.google.com/analytics/answer/1033867?hl=en) and their article on ["Best Practices for Campaign Building"](https://support.google.com/analytics/answer/1037445).
3529
+
3530
+ We default the settings to Googles recommendations. For more information, see [Google Analytics Demystified](https://sendgrid.com/docs/Classroom/Track/Collecting_Data/google_analytics_demystified_ga_statistics_vs_sg_statistics.html).
3531
+
3532
+ You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails.
3533
+
3534
+ For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html).
3535
+
3536
+ ### GET /tracking_settings/google_analytics
3537
+
3538
+
3539
+ ```ruby
3540
+ response = sg.client.tracking_settings.google_analytics.get()
3541
+ puts response.status_code
3542
+ puts response.body
3543
+ puts response.headers
3544
+ ```
3545
+ ## Update Open Tracking Settings
3546
+
3547
+ **This endpoint allows you to update your current settings for open tracking.**
3548
+
3549
+ Open Tracking adds an invisible image at the end of the email which can track email opens. If the email recipient has images enabled on their email client, a request to SendGrids server for the invisible image is executed and an open event is logged. These events are logged in the Statistics portal, Email Activity interface, and are reported by the Event Webhook.
3550
+
3551
+ You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails.
3552
+
3553
+ For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html).
3554
+
3555
+ ### PATCH /tracking_settings/open
3556
+
3557
+
3558
+ ```ruby
3559
+ data = JSON.parse('{
3560
+ "enabled": true
3561
+ }')
3562
+ response = sg.client.tracking_settings.open.patch(request_body: data)
3563
+ puts response.status_code
3564
+ puts response.body
3565
+ puts response.headers
3566
+ ```
3567
+ ## Get Open Tracking Settings
3568
+
3569
+ **This endpoint allows you to retrieve your current settings for open tracking.**
3570
+
3571
+ Open Tracking adds an invisible image at the end of the email which can track email opens. If the email recipient has images enabled on their email client, a request to SendGrids server for the invisible image is executed and an open event is logged. These events are logged in the Statistics portal, Email Activity interface, and are reported by the Event Webhook.
3572
+
3573
+ You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails.
3574
+
3575
+ For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html).
3576
+
3577
+ ### GET /tracking_settings/open
3578
+
3579
+
3580
+ ```ruby
3581
+ response = sg.client.tracking_settings.open.get()
3582
+ puts response.status_code
3583
+ puts response.body
3584
+ puts response.headers
3585
+ ```
3586
+ ## Update Subscription Tracking Settings
3587
+
3588
+ **This endpoint allows you to update your current settings for subscription tracking.**
3589
+
3590
+ Subscription tracking adds links to the bottom of your emails that allows your recipients to subscribe to, or unsubscribe from, your emails.
3591
+
3592
+ You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails.
3593
+
3594
+ For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html).
3595
+
3596
+ ### PATCH /tracking_settings/subscription
3597
+
3598
+
3599
+ ```ruby
3600
+ data = JSON.parse('{
3601
+ "enabled": true,
3602
+ "html_content": "html content",
3603
+ "landing": "landing page html",
3604
+ "plain_content": "text content",
3605
+ "replace": "replacement tag",
3606
+ "url": "url"
3607
+ }')
3608
+ response = sg.client.tracking_settings.subscription.patch(request_body: data)
3609
+ puts response.status_code
3610
+ puts response.body
3611
+ puts response.headers
3612
+ ```
3613
+ ## Retrieve Subscription Tracking Settings
3614
+
3615
+ **This endpoint allows you to retrieve your current settings for subscription tracking.**
3616
+
3617
+ Subscription tracking adds links to the bottom of your emails that allows your recipients to subscribe to, or unsubscribe from, your emails.
3618
+
3619
+ You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails.
3620
+
3621
+ For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html).
3622
+
3623
+ ### GET /tracking_settings/subscription
3624
+
3625
+
3626
+ ```ruby
3627
+ response = sg.client.tracking_settings.subscription.get()
3628
+ puts response.status_code
3629
+ puts response.body
3630
+ puts response.headers
3631
+ ```
3632
+ <a name="user"></a>
3633
+ # USER
3634
+
3635
+ ## Get a user's account information.
3636
+
3637
+ **This endpoint allows you to retrieve your user account details.**
3638
+
3639
+ Your user's account information includes the user's account type and reputation.
3640
+
3641
+ Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to.
3642
+
3643
+ For more information about your user profile:
3644
+
3645
+ * [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html)
3646
+
3647
+ ### GET /user/account
3648
+
3649
+
3650
+ ```ruby
3651
+ response = sg.client.user.account.get()
3652
+ puts response.status_code
3653
+ puts response.body
3654
+ puts response.headers
3655
+ ```
3656
+ ## Retrieve your credit balance
3657
+
3658
+ **This endpoint allows you to retrieve the current credit balance for your account.**
3659
+
3660
+ Your monthly credit allotment limits the number of emails you may send before incurring overage charges. For more information about credits and billing, please visit our [Clssroom](https://sendgrid.com/docs/Classroom/Basics/Billing/billing_info_and_faqs.html).
3661
+
3662
+ ### GET /user/credits
3663
+
3664
+
3665
+ ```ruby
3666
+ response = sg.client.user.credits.get()
3667
+ puts response.status_code
3668
+ puts response.body
3669
+ puts response.headers
3670
+ ```
3671
+ ## Update your account email address
3672
+
3673
+ **This endpoint allows you to update the email address currently on file for your account.**
3674
+
3675
+ Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to.
3676
+
3677
+ For more information about your user profile:
3678
+
3679
+ * [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html)
3680
+
3681
+ ### PUT /user/email
3682
+
3683
+
3684
+ ```ruby
3685
+ data = JSON.parse('{
3686
+ "email": "example@example.com"
3687
+ }')
3688
+ response = sg.client.user.email.put(request_body: data)
3689
+ puts response.status_code
3690
+ puts response.body
3691
+ puts response.headers
3692
+ ```
3693
+ ## Retrieve your account email address
3694
+
3695
+ **This endpoint allows you to retrieve the email address currently on file for your account.**
3696
+
3697
+ Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to.
3698
+
3699
+ For more information about your user profile:
3700
+
3701
+ * [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html)
3702
+
3703
+ ### GET /user/email
3704
+
3705
+
3706
+ ```ruby
3707
+ response = sg.client.user.email.get()
3708
+ puts response.status_code
3709
+ puts response.body
3710
+ puts response.headers
3711
+ ```
3712
+ ## Update your password
3713
+
3714
+ **This endpoint allows you to update your password.**
3715
+
3716
+ Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to.
3717
+
3718
+ For more information about your user profile:
3719
+
3720
+ * [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html)
3721
+
3722
+ ### PUT /user/password
3723
+
3724
+
3725
+ ```ruby
3726
+ data = JSON.parse('{
3727
+ "new_password": "new_password",
3728
+ "old_password": "old_password"
3729
+ }')
3730
+ response = sg.client.user.password.put(request_body: data)
3731
+ puts response.status_code
3732
+ puts response.body
3733
+ puts response.headers
3734
+ ```
3735
+ ## Update a user's profile
3736
+
3737
+ **This endpoint allows you to update your current profile details.**
3738
+
3739
+ Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to.
3740
+
3741
+ For more information about your user profile:
3742
+
3743
+ * [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html)
3744
+
3745
+ It should be noted that any one or more of the parameters can be updated via the PATCH /user/profile endpoint. The only requirement is that you include at least one when you PATCH.
3746
+
3747
+ ### PATCH /user/profile
3748
+
3749
+
3750
+ ```ruby
3751
+ data = JSON.parse('{
3752
+ "city": "Orange",
3753
+ "first_name": "Example",
3754
+ "last_name": "User"
3755
+ }')
3756
+ response = sg.client.user.profile.patch(request_body: data)
3757
+ puts response.status_code
3758
+ puts response.body
3759
+ puts response.headers
3760
+ ```
3761
+ ## Get a user's profile
3762
+
3763
+ Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to.
3764
+
3765
+ For more information about your user profile:
3766
+
3767
+ * [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html)
3768
+
3769
+ ### GET /user/profile
3770
+
3771
+
3772
+ ```ruby
3773
+ response = sg.client.user.profile.get()
3774
+ puts response.status_code
3775
+ puts response.body
3776
+ puts response.headers
3777
+ ```
3778
+ ## Cancel or pause a scheduled send
3779
+
3780
+ **This endpoint allows you to cancel or pause an email that has been scheduled to be sent.**
3781
+
3782
+ If the maximum number of cancellations/pauses are added, HTTP 400 will
3783
+ be returned.
3784
+
3785
+ The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled.
3786
+
3787
+ ### POST /user/scheduled_sends
3788
+
3789
+
3790
+ ```ruby
3791
+ data = JSON.parse('{
3792
+ "batch_id": "YOUR_BATCH_ID",
3793
+ "status": "pause"
3794
+ }')
3795
+ response = sg.client.user.scheduled_sends.post(request_body: data)
3796
+ puts response.status_code
3797
+ puts response.body
3798
+ puts response.headers
3799
+ ```
3800
+ ## Retrieve all scheduled sends
3801
+
3802
+ **This endpoint allows you to retrieve all cancel/paused scheduled send information.**
3803
+
3804
+ The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled.
3805
+
3806
+ ### GET /user/scheduled_sends
3807
+
3808
+
3809
+ ```ruby
3810
+ response = sg.client.user.scheduled_sends.get()
3811
+ puts response.status_code
3812
+ puts response.body
3813
+ puts response.headers
3814
+ ```
3815
+ ## Update user scheduled send information
3816
+
3817
+ **This endpoint allows you to update the status of a scheduled send for the given `batch_id`.**
3818
+
3819
+ The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled.
3820
+
3821
+ ### PATCH /user/scheduled_sends/{batch_id}
3822
+
3823
+
3824
+ ```ruby
3825
+ data = JSON.parse('{
3826
+ "status": "pause"
3827
+ }')
3828
+ batch_id = "test_url_param"
3829
+ response = sg.client.user.scheduled_sends._(batch_id).patch(request_body: data)
3830
+ puts response.status_code
3831
+ puts response.body
3832
+ puts response.headers
3833
+ ```
3834
+ ## Retrieve scheduled send
3835
+
3836
+ **This endpoint allows you to retrieve the cancel/paused scheduled send information for a specific `batch_id`.**
3837
+
3838
+ The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled.
3839
+
3840
+ ### GET /user/scheduled_sends/{batch_id}
3841
+
3842
+
3843
+ ```ruby
3844
+ batch_id = "test_url_param"
3845
+ response = sg.client.user.scheduled_sends._(batch_id).get()
3846
+ puts response.status_code
3847
+ puts response.body
3848
+ puts response.headers
3849
+ ```
3850
+ ## Delete a cancellation or pause of a scheduled send
3851
+
3852
+ **This endpoint allows you to delete the cancellation/pause of a scheduled send.**
3853
+
3854
+ The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled.
3855
+
3856
+ ### DELETE /user/scheduled_sends/{batch_id}
3857
+
3858
+
3859
+ ```ruby
3860
+ batch_id = "test_url_param"
3861
+ response = sg.client.user.scheduled_sends._(batch_id).delete()
3862
+ puts response.status_code
3863
+ puts response.body
3864
+ puts response.headers
3865
+ ```
3866
+ ## Update Enforced TLS settings
3867
+
3868
+ **This endpoint allows you to update your current Enforced TLS settings.**
3869
+
3870
+ The Enforced TLS settings specify whether or not the recipient is required to support TLS or have a valid certificate. See the [SMTP Ports User Guide](https://sendgrid.com/docs/Classroom/Basics/Email_Infrastructure/smtp_ports.html) for more information on opportunistic TLS.
3871
+
3872
+ **Note:** If either setting is enabled and the recipient does not support TLS or have a valid certificate, we drop the message and send a block event with TLS required but not supported as the description.
3873
+
3874
+ ### PATCH /user/settings/enforced_tls
3875
+
3876
+
3877
+ ```ruby
3878
+ data = JSON.parse('{
3879
+ "require_tls": true,
3880
+ "require_valid_cert": false
3881
+ }')
3882
+ response = sg.client.user.settings.enforced_tls.patch(request_body: data)
3883
+ puts response.status_code
3884
+ puts response.body
3885
+ puts response.headers
3886
+ ```
3887
+ ## Retrieve current Enforced TLS settings.
3888
+
3889
+ **This endpoint allows you to retrieve your current Enforced TLS settings.**
3890
+
3891
+ The Enforced TLS settings specify whether or not the recipient is required to support TLS or have a valid certificate. See the [SMTP Ports User Guide](https://sendgrid.com/docs/Classroom/Basics/Email_Infrastructure/smtp_ports.html) for more information on opportunistic TLS.
3892
+
3893
+ **Note:** If either setting is enabled and the recipient does not support TLS or have a valid certificate, we drop the message and send a block event with TLS required but not supported as the description.
3894
+
3895
+ ### GET /user/settings/enforced_tls
3896
+
3897
+
3898
+ ```ruby
3899
+ response = sg.client.user.settings.enforced_tls.get()
3900
+ puts response.status_code
3901
+ puts response.body
3902
+ puts response.headers
3903
+ ```
3904
+ ## Update your username
3905
+
3906
+ **This endpoint allows you to update the username for your account.**
3907
+
3908
+ Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to.
3909
+
3910
+ For more information about your user profile:
3911
+
3912
+ * [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html)
3913
+
3914
+ ### PUT /user/username
3915
+
3916
+
3917
+ ```ruby
3918
+ data = JSON.parse('{
3919
+ "username": "test_username"
3920
+ }')
3921
+ response = sg.client.user.username.put(request_body: data)
3922
+ puts response.status_code
3923
+ puts response.body
3924
+ puts response.headers
3925
+ ```
3926
+ ## Retrieve your username
3927
+
3928
+ **This endpoint allows you to retrieve your current account username.**
3929
+
3930
+ Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to.
3931
+
3932
+ For more information about your user profile:
3933
+
3934
+ * [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html)
3935
+
3936
+ ### GET /user/username
3937
+
3938
+
3939
+ ```ruby
3940
+ response = sg.client.user.username.get()
3941
+ puts response.status_code
3942
+ puts response.body
3943
+ puts response.headers
3944
+ ```
3945
+ ## Update Event Notification Settings
3946
+
3947
+ **This endpoint allows you to update your current event webhook settings.**
3948
+
3949
+ If an event type is marked as `true`, then the event webhook will include information about that event.
3950
+
3951
+ SendGrids Event Webhook will notify a URL of your choice via HTTP POST with information about events that occur as SendGrid processes your email.
3952
+
3953
+ Common uses of this data are to remove unsubscribes, react to spam reports, determine unengaged recipients, identify bounced email addresses, or create advanced analytics of your email program.
3954
+
3955
+ ### PATCH /user/webhooks/event/settings
3956
+
3957
+
3958
+ ```ruby
3959
+ data = JSON.parse('{
3960
+ "bounce": true,
3961
+ "click": true,
3962
+ "deferred": true,
3963
+ "delivered": true,
3964
+ "dropped": true,
3965
+ "enabled": true,
3966
+ "group_resubscribe": true,
3967
+ "group_unsubscribe": true,
3968
+ "open": true,
3969
+ "processed": true,
3970
+ "spam_report": true,
3971
+ "unsubscribe": true,
3972
+ "url": "url"
3973
+ }')
3974
+ response = sg.client.user.webhooks.event.settings.patch(request_body: data)
3975
+ puts response.status_code
3976
+ puts response.body
3977
+ puts response.headers
3978
+ ```
3979
+ ## Retrieve Event Webhook settings
3980
+
3981
+ **This endpoint allows you to retrieve your current event webhook settings.**
3982
+
3983
+ If an event type is marked as `true`, then the event webhook will include information about that event.
3984
+
3985
+ SendGrids Event Webhook will notify a URL of your choice via HTTP POST with information about events that occur as SendGrid processes your email.
3986
+
3987
+ Common uses of this data are to remove unsubscribes, react to spam reports, determine unengaged recipients, identify bounced email addresses, or create advanced analytics of your email program.
3988
+
3989
+ ### GET /user/webhooks/event/settings
3990
+
3991
+
3992
+ ```ruby
3993
+ response = sg.client.user.webhooks.event.settings.get()
3994
+ puts response.status_code
3995
+ puts response.body
3996
+ puts response.headers
3997
+ ```
3998
+ ## Test Event Notification Settings
3999
+
4000
+ **This endpoint allows you to test your event webhook by sending a fake event notification post to the provided URL.**
4001
+
4002
+ SendGrids Event Webhook will notify a URL of your choice via HTTP POST with information about events that occur as SendGrid processes your email.
4003
+
4004
+ Common uses of this data are to remove unsubscribes, react to spam reports, determine unengaged recipients, identify bounced email addresses, or create advanced analytics of your email program.
4005
+
4006
+ ### POST /user/webhooks/event/test
4007
+
4008
+
4009
+ ```ruby
4010
+ data = JSON.parse('{
4011
+ "url": "url"
4012
+ }')
4013
+ response = sg.client.user.webhooks.event.test.post(request_body: data)
4014
+ puts response.status_code
4015
+ puts response.body
4016
+ puts response.headers
4017
+ ```
4018
+ ## Retrieve Parse Webhook settings
4019
+
4020
+ **This endpoint allows you to retrieve your current inbound parse webhook settings.**
4021
+
4022
+ SendGrid can parse the attachments and contents of incoming emails. The Parse API will POST the parsed email to a URL that you specify. For more information, see our Inbound [Parse Webhook documentation](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html).
4023
+
4024
+ ### GET /user/webhooks/parse/settings
4025
+
4026
+
4027
+ ```ruby
4028
+ response = sg.client.user.webhooks.parse.settings.get()
4029
+ puts response.status_code
4030
+ puts response.body
4031
+ puts response.headers
4032
+ ```
4033
+ ## Retrieves Inbound Parse Webhook statistics.
4034
+
4035
+ **This endpoint allows you to retrieve the statistics for your Parse Webhook useage.**
4036
+
4037
+ SendGrid's Inbound Parse Webhook allows you to parse the contents and attachments of incomming emails. The Parse API can then POST the parsed emails to a URL that you specify. The Inbound Parse Webhook cannot parse messages greater than 20MB in size, including all attachments.
4038
+
4039
+ There are a number of pre-made integrations for the SendGrid Parse Webhook which make processing events easy. You can find these integrations in the [Library Index](https://sendgrid.com/docs/Integrate/libraries.html#-Webhook-Libraries).
4040
+
4041
+ ### GET /user/webhooks/parse/stats
4042
+
4043
+
4044
+ ```ruby
4045
+ params = JSON.parse('{"aggregated_by": "day", "limit": "test_string", "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": "test_string"}')
4046
+ response = sg.client.user.webhooks.parse.stats.get(query_params: params)
4047
+ puts response.status_code
4048
+ puts response.body
4049
+ puts response.headers
4050
+ ```
4051
+ <a name="whitelabel"></a>
4052
+ # WHITELABEL
4053
+
4054
+ ## Create a domain whitelabel.
4055
+
4056
+ **This endpoint allows you to create a whitelabel for one of your domains.**
4057
+
4058
+ If you are creating a domain whitelabel that you would like a subuser to use, you have two options:
4059
+ 1. Use the "username" parameter. This allows you to create a whitelabel on behalf of your subuser. This means the subuser is able to see and modify the created whitelabel.
4060
+ 2. Use the Association workflow (see Associate Domain section). This allows you to assign a whitelabel created by the parent to a subuser. This means the subuser will default to the assigned whitelabel, but will not be able to see or modify that whitelabel. However, if the subuser creates their own whitelabel it will overwrite the assigned whitelabel.
4061
+
4062
+ A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
4063
+
4064
+ For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
4065
+
4066
+ ### POST /whitelabel/domains
4067
+
4068
+
4069
+ ```ruby
4070
+ data = JSON.parse('{
4071
+ "automatic_security": false,
4072
+ "custom_spf": true,
4073
+ "default": true,
4074
+ "domain": "example.com",
4075
+ "ips": [
4076
+ "192.168.1.1",
4077
+ "192.168.1.2"
4078
+ ],
4079
+ "subdomain": "news",
4080
+ "username": "john@example.com"
4081
+ }')
4082
+ response = sg.client.whitelabel.domains.post(request_body: data)
4083
+ puts response.status_code
4084
+ puts response.body
4085
+ puts response.headers
4086
+ ```
4087
+ ## List all domain whitelabels.
4088
+
4089
+ **This endpoint allows you to retrieve a list of all domain whitelabels you have created.**
4090
+
4091
+ A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
4092
+
4093
+ For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
4094
+
4095
+
4096
+ ### GET /whitelabel/domains
4097
+
4098
+
4099
+ ```ruby
4100
+ params = JSON.parse('{"username": "test_string", "domain": "test_string", "exclude_subusers": "true", "limit": 1, "offset": 1}')
4101
+ response = sg.client.whitelabel.domains.get(query_params: params)
4102
+ puts response.status_code
4103
+ puts response.body
4104
+ puts response.headers
4105
+ ```
4106
+ ## Get the default domain whitelabel.
4107
+
4108
+ **This endpoint allows you to retrieve the default whitelabel for a domain.**
4109
+
4110
+ A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
4111
+
4112
+ For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
4113
+
4114
+ ## URI Parameters
4115
+ | URI Parameter | Type | Description |
4116
+ |---|---|---|
4117
+ | domain | string |The domain to find a default domain whitelabel for. |
4118
+
4119
+ ### GET /whitelabel/domains/default
4120
+
4121
+
4122
+ ```ruby
4123
+ response = sg.client.whitelabel.domains.default.get()
4124
+ puts response.status_code
4125
+ puts response.body
4126
+ puts response.headers
4127
+ ```
4128
+ ## List the domain whitelabel associated with the given user.
4129
+
4130
+ **This endpoint allows you to retrieve all of the whitelabels that have been assigned to a specific subuser.**
4131
+
4132
+ A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
4133
+
4134
+ Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools.
4135
+
4136
+ For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
4137
+
4138
+ ## URI Parameters
4139
+ | URI Parameter | Type | Description |
4140
+ |---|---|---|
4141
+ | username | string | Username of the subuser to find associated whitelabels for. |
4142
+
4143
+ ### GET /whitelabel/domains/subuser
4144
+
4145
+
4146
+ ```ruby
4147
+ response = sg.client.whitelabel.domains.subuser.get()
4148
+ puts response.status_code
4149
+ puts response.body
4150
+ puts response.headers
4151
+ ```
4152
+ ## Disassociate a domain whitelabel from a given user.
4153
+
4154
+ **This endpoint allows you to disassociate a specific whitelabel from a subuser.**
4155
+
4156
+ A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
4157
+
4158
+ Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools.
4159
+
4160
+ For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
4161
+
4162
+ ## URI Parameters
4163
+ | URI Parameter | Type | Required? | Description |
4164
+ |---|---|---|---|
4165
+ | username | string | required | Username for the subuser to find associated whitelabels for. |
4166
+
4167
+ ### DELETE /whitelabel/domains/subuser
4168
+
4169
+
4170
+ ```ruby
4171
+ response = sg.client.whitelabel.domains.subuser.delete()
4172
+ puts response.status_code
4173
+ puts response.body
4174
+ puts response.headers
4175
+ ```
4176
+ ## Update a domain whitelabel.
4177
+
4178
+ **This endpoint allows you to update the settings for a domain whitelabel.**
4179
+
4180
+ A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
4181
+
4182
+ For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
4183
+
4184
+ ### PATCH /whitelabel/domains/{domain_id}
4185
+
4186
+
4187
+ ```ruby
4188
+ data = JSON.parse('{
4189
+ "custom_spf": true,
4190
+ "default": false
4191
+ }')
4192
+ domain_id = "test_url_param"
4193
+ response = sg.client.whitelabel.domains._(domain_id).patch(request_body: data)
4194
+ puts response.status_code
4195
+ puts response.body
4196
+ puts response.headers
4197
+ ```
4198
+ ## Retrieve a domain whitelabel.
4199
+
4200
+ **This endpoint allows you to retrieve a specific domain whitelabel.**
4201
+
4202
+ A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
4203
+
4204
+ For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
4205
+
4206
+
4207
+ ### GET /whitelabel/domains/{domain_id}
4208
+
4209
+
4210
+ ```ruby
4211
+ domain_id = "test_url_param"
4212
+ response = sg.client.whitelabel.domains._(domain_id).get()
4213
+ puts response.status_code
4214
+ puts response.body
4215
+ puts response.headers
4216
+ ```
4217
+ ## Delete a domain whitelabel.
4218
+
4219
+ **This endpoint allows you to delete a domain whitelabel.**
4220
+
4221
+ A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
4222
+
4223
+ For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
4224
+
4225
+ ### DELETE /whitelabel/domains/{domain_id}
4226
+
4227
+
4228
+ ```ruby
4229
+ domain_id = "test_url_param"
4230
+ response = sg.client.whitelabel.domains._(domain_id).delete()
4231
+ puts response.status_code
4232
+ puts response.body
4233
+ puts response.headers
4234
+ ```
4235
+ ## Associate a domain whitelabel with a given user.
4236
+
4237
+ **This endpoint allows you to associate a specific domain whitelabel with a subuser.**
4238
+
4239
+ A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
4240
+
4241
+ Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools.
4242
+
4243
+ For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
4244
+
4245
+ ## URI Parameters
4246
+ | URI Parameter | Type | Description |
4247
+ |---|---|---|
4248
+ | domain_id | integer | ID of the domain whitelabel to associate with the subuser. |
4249
+
4250
+ ### POST /whitelabel/domains/{domain_id}/subuser
4251
+
4252
+
4253
+ ```ruby
4254
+ data = JSON.parse('{
4255
+ "username": "jane@example.com"
4256
+ }')
4257
+ domain_id = "test_url_param"
4258
+ response = sg.client.whitelabel.domains._(domain_id).subuser.post(request_body: data)
4259
+ puts response.status_code
4260
+ puts response.body
4261
+ puts response.headers
4262
+ ```
4263
+ ## Add an IP to a domain whitelabel.
4264
+
4265
+ **This endpoint allows you to add an IP address to a domain whitelabel.**
4266
+
4267
+ A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
4268
+
4269
+ For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
4270
+
4271
+ ## URI Parameters
4272
+ | URI Parameter | Type | Description |
4273
+ |---|---|---|
4274
+ | id | integer | ID of the domain to which you are adding an IP |
4275
+
4276
+ ### POST /whitelabel/domains/{id}/ips
4277
+
4278
+
4279
+ ```ruby
4280
+ data = JSON.parse('{
4281
+ "ip": "192.168.0.1"
4282
+ }')
4283
+ id = "test_url_param"
4284
+ response = sg.client.whitelabel.domains._(id).ips.post(request_body: data)
4285
+ puts response.status_code
4286
+ puts response.body
4287
+ puts response.headers
4288
+ ```
4289
+ ## Remove an IP from a domain whitelabel.
4290
+
4291
+ **This endpoint allows you to remove a domain's IP address from that domain's whitelabel.**
4292
+
4293
+ A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
4294
+
4295
+ For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
4296
+
4297
+ ## URI Parameters
4298
+ | URI Parameter | Type | Description |
4299
+ |---|---|---|
4300
+ | id | integer | ID of the domain whitelabel to delete the IP from. |
4301
+ | ip | string | IP to remove from the domain whitelabel. |
4302
+
4303
+ ### DELETE /whitelabel/domains/{id}/ips/{ip}
4304
+
4305
+
4306
+ ```ruby
4307
+ id = "test_url_param"
4308
+ ip = "test_url_param"
4309
+ response = sg.client.whitelabel.domains._(id).ips._(ip).delete()
4310
+ puts response.status_code
4311
+ puts response.body
4312
+ puts response.headers
4313
+ ```
4314
+ ## Validate a domain whitelabel.
4315
+
4316
+ **This endpoint allows you to validate a domain whitelabel. If it fails, it will return an error message describing why the whitelabel could not be validated.**
4317
+
4318
+ A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
4319
+
4320
+ For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
4321
+
4322
+ ## URI Parameters
4323
+ | URI Parameter | Type | Description |
4324
+ |---|---|---|
4325
+ | id | integer |ID of the domain whitelabel to validate. |
4326
+
4327
+ ### POST /whitelabel/domains/{id}/validate
4328
+
4329
+
4330
+ ```ruby
4331
+ id = "test_url_param"
4332
+ response = sg.client.whitelabel.domains._(id).validate.post()
4333
+ puts response.status_code
4334
+ puts response.body
4335
+ puts response.headers
4336
+ ```
4337
+ ## Create an IP whitelabel
4338
+
4339
+ **This endpoint allows you to create an IP whitelabel.**
4340
+
4341
+ When creating an IP whitelable, you should use the same subdomain that you used when you created a domain whitelabel.
4342
+
4343
+ A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated.
4344
+
4345
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html).
4346
+
4347
+ ### POST /whitelabel/ips
4348
+
4349
+
4350
+ ```ruby
4351
+ data = JSON.parse('{
4352
+ "domain": "example.com",
4353
+ "ip": "192.168.1.1",
4354
+ "subdomain": "email"
4355
+ }')
4356
+ response = sg.client.whitelabel.ips.post(request_body: data)
4357
+ puts response.status_code
4358
+ puts response.body
4359
+ puts response.headers
4360
+ ```
4361
+ ## Retrieve all IP whitelabels
4362
+
4363
+ **This endpoint allows you to retrieve all of the IP whitelabels that have been createdy by this account.**
4364
+
4365
+ You may include a search key by using the "ip" parameter. This enables you to perform a prefix search for a given IP segment (e.g. "192.").
4366
+
4367
+ A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated.
4368
+
4369
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html).
4370
+
4371
+ ### GET /whitelabel/ips
4372
+
4373
+
4374
+ ```ruby
4375
+ params = JSON.parse('{"ip": "test_string", "limit": 1, "offset": 1}')
4376
+ response = sg.client.whitelabel.ips.get(query_params: params)
4377
+ puts response.status_code
4378
+ puts response.body
4379
+ puts response.headers
4380
+ ```
4381
+ ## Retrieve an IP whitelabel
4382
+
4383
+ **This endpoint allows you to retrieve an IP whitelabel.**
4384
+
4385
+ A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated.
4386
+
4387
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html).
4388
+
4389
+ ### GET /whitelabel/ips/{id}
4390
+
4391
+
4392
+ ```ruby
4393
+ id = "test_url_param"
4394
+ response = sg.client.whitelabel.ips._(id).get()
4395
+ puts response.status_code
4396
+ puts response.body
4397
+ puts response.headers
4398
+ ```
4399
+ ## Delete an IP whitelabel
4400
+
4401
+ **This endpoint allows you to delete an IP whitelabel.**
4402
+
4403
+ A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated.
4404
+
4405
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html).
4406
+
4407
+ ### DELETE /whitelabel/ips/{id}
4408
+
4409
+
4410
+ ```ruby
4411
+ id = "test_url_param"
4412
+ response = sg.client.whitelabel.ips._(id).delete()
4413
+ puts response.status_code
4414
+ puts response.body
4415
+ puts response.headers
4416
+ ```
4417
+ ## Validate an IP whitelabel
4418
+
4419
+ **This endpoint allows you to validate an IP whitelabel.**
4420
+
4421
+ A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated.
4422
+
4423
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html).
4424
+
4425
+ ### POST /whitelabel/ips/{id}/validate
4426
+
4427
+
4428
+ ```ruby
4429
+ id = "test_url_param"
4430
+ response = sg.client.whitelabel.ips._(id).validate.post()
4431
+ puts response.status_code
4432
+ puts response.body
4433
+ puts response.headers
4434
+ ```
4435
+ ## Create a Link Whitelabel
4436
+
4437
+ **This endpoint allows you to create a new link whitelabel.**
4438
+
4439
+ Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
4440
+
4441
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html).
4442
+
4443
+ ### POST /whitelabel/links
4444
+
4445
+
4446
+ ```ruby
4447
+ data = JSON.parse('{
4448
+ "default": true,
4449
+ "domain": "example.com",
4450
+ "subdomain": "mail"
4451
+ }')
4452
+ params = JSON.parse('{"limit": 1, "offset": 1}')
4453
+ response = sg.client.whitelabel.links.post(request_body: data, query_params: params)
4454
+ puts response.status_code
4455
+ puts response.body
4456
+ puts response.headers
4457
+ ```
4458
+ ## Retrieve all link whitelabels
4459
+
4460
+ **This endpoint allows you to retrieve all link whitelabels.**
4461
+
4462
+ Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
4463
+
4464
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html).
4465
+
4466
+ ### GET /whitelabel/links
4467
+
4468
+
4469
+ ```ruby
4470
+ params = JSON.parse('{"limit": 1}')
4471
+ response = sg.client.whitelabel.links.get(query_params: params)
4472
+ puts response.status_code
4473
+ puts response.body
4474
+ puts response.headers
4475
+ ```
4476
+ ## Retrieve a Default Link Whitelabel
4477
+
4478
+ **This endpoint allows you to retrieve the default link whitelabel.**
4479
+
4480
+ Default link whitelabel is the actual link whitelabel to be used when sending messages. If there are multiple link whitelabels, the default is determined by the following order:
4481
+ <ul>
4482
+ <li>Validated link whitelabels marked as "default"</li>
4483
+ <li>Legacy link whitelabels (migrated from the whitelabel wizard)</li>
4484
+ <li>Default SendGrid link whitelabel (i.e. 100.ct.sendgrid.net)</li>
4485
+ </ul>
4486
+
4487
+ Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
4488
+
4489
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html).
4490
+
4491
+ ### GET /whitelabel/links/default
4492
+
4493
+
4494
+ ```ruby
4495
+ params = JSON.parse('{"domain": "test_string"}')
4496
+ response = sg.client.whitelabel.links.default.get(query_params: params)
4497
+ puts response.status_code
4498
+ puts response.body
4499
+ puts response.headers
4500
+ ```
4501
+ ## Retrieve Associated Link Whitelabel
4502
+
4503
+ **This endpoint allows you to retrieve the associated link whitelabel for a subuser.**
4504
+
4505
+ Link whitelables can be associated with subusers from the parent account. This functionality allows
4506
+ subusers to send mail using their parent's linke whitelabels. To associate a link whitelabel, the parent account
4507
+ must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface.
4508
+
4509
+ Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
4510
+
4511
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html).
4512
+
4513
+ ### GET /whitelabel/links/subuser
4514
+
4515
+
4516
+ ```ruby
4517
+ params = JSON.parse('{"username": "test_string"}')
4518
+ response = sg.client.whitelabel.links.subuser.get(query_params: params)
4519
+ puts response.status_code
4520
+ puts response.body
4521
+ puts response.headers
4522
+ ```
4523
+ ## Disassociate a Link Whitelabel
4524
+
4525
+ **This endpoint allows you to disassociate a link whitelabel from a subuser.**
4526
+
4527
+ Link whitelables can be associated with subusers from the parent account. This functionality allows
4528
+ subusers to send mail using their parent's linke whitelabels. To associate a link whitelabel, the parent account
4529
+ must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface.
4530
+
4531
+ Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
4532
+
4533
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html).
4534
+
4535
+ ### DELETE /whitelabel/links/subuser
4536
+
4537
+
4538
+ ```ruby
4539
+ params = JSON.parse('{"username": "test_string"}')
4540
+ response = sg.client.whitelabel.links.subuser.delete(query_params: params)
4541
+ puts response.status_code
4542
+ puts response.body
4543
+ puts response.headers
4544
+ ```
4545
+ ## Update a Link Whitelabel
4546
+
4547
+ **This endpoint allows you to update a specific link whitelabel. You can use this endpoint to change a link whitelabel's default status.**
4548
+
4549
+ Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
4550
+
4551
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html).
4552
+
4553
+ ### PATCH /whitelabel/links/{id}
4554
+
4555
+
4556
+ ```ruby
4557
+ data = JSON.parse('{
4558
+ "default": true
4559
+ }')
4560
+ id = "test_url_param"
4561
+ response = sg.client.whitelabel.links._(id).patch(request_body: data)
4562
+ puts response.status_code
4563
+ puts response.body
4564
+ puts response.headers
4565
+ ```
4566
+ ## Retrieve a Link Whitelabel
4567
+
4568
+ **This endpoint allows you to retrieve a specific link whitelabel.**
4569
+
4570
+ Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
4571
+
4572
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html).
4573
+
4574
+ ### GET /whitelabel/links/{id}
4575
+
4576
+
4577
+ ```ruby
4578
+ id = "test_url_param"
4579
+ response = sg.client.whitelabel.links._(id).get()
4580
+ puts response.status_code
4581
+ puts response.body
4582
+ puts response.headers
4583
+ ```
4584
+ ## Delete a Link Whitelabel
4585
+
4586
+ **This endpoint allows you to delete a link whitelabel.**
4587
+
4588
+ Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
4589
+
4590
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html).
4591
+
4592
+ ### DELETE /whitelabel/links/{id}
4593
+
4594
+
4595
+ ```ruby
4596
+ id = "test_url_param"
4597
+ response = sg.client.whitelabel.links._(id).delete()
4598
+ puts response.status_code
4599
+ puts response.body
4600
+ puts response.headers
4601
+ ```
4602
+ ## Validate a Link Whitelabel
4603
+
4604
+ **This endpoint allows you to validate a link whitelabel.**
4605
+
4606
+ Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
4607
+
4608
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html).
4609
+
4610
+ ### POST /whitelabel/links/{id}/validate
4611
+
4612
+
4613
+ ```ruby
4614
+ id = "test_url_param"
4615
+ response = sg.client.whitelabel.links._(id).validate.post()
4616
+ puts response.status_code
4617
+ puts response.body
4618
+ puts response.headers
4619
+ ```
4620
+ ## Associate a Link Whitelabel
4621
+
4622
+ **This endpoint allows you to associate a link whitelabel with a subuser account.**
4623
+
4624
+ Link whitelables can be associated with subusers from the parent account. This functionality allows
4625
+ subusers to send mail using their parent's linke whitelabels. To associate a link whitelabel, the parent account
4626
+ must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface.
4627
+
4628
+ Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
4629
+
4630
+ For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html).
4631
+
4632
+ ### POST /whitelabel/links/{link_id}/subuser
4633
+
4634
+
4635
+ ```ruby
4636
+ data = JSON.parse('{
4637
+ "username": "jane@example.com"
4638
+ }')
4639
+ link_id = "test_url_param"
4640
+ response = sg.client.whitelabel.links._(link_id).subuser.post(request_body: data)
4641
+ puts response.status_code
4642
+ puts response.body
4643
+ puts response.headers
4644
+ ```
4645
+