-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathapiary.apib
1275 lines (976 loc) · 50.1 KB
/
apiary.apib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
FORMAT: 1A
HOST: http://emailmarketingapi.apiblueprint.org/
# Email Marketing API
Email Marketing API is a Hypermedia API for allowing consumers to manage an email marketing application.
## Group Conventions and references
#### Links
Each response and collection item will contain a `_links` property as array of `link` objects.
Each `link` has `href` field (an URI), and optional `description` field and a `rel` field to describe the link role, expected payload, return format. `rel` field could contains one or more _relation types_ separated by white spaces.
A valid _relation type_ could be any [IANA standard link relation type](http://www.iana.org/assignments/link-relations/link-relations.xhtml), like `item`, `self`, `parent` o `prev`. Or it also could be an URI to the specification, for example: `/rels/subscriber` or `/rels/lists-collection`.
#### JSON Schemas
_Relation type_ specifications will include [JSON schema](http://json-schema.org/) documents for expected and result payloads.
Also, `application/json` responses will include a Schema reference in _content type_ header, for example: `Content-Type: application/json; profile=/schemas/subscriber` (in the same way that it is done [JSON Hyper-Schema: Hypertext definitions for JSON Schema - Section 5.2.2](http://json-schema.org/latest/json-schema-hypermedia.html)).
#### Special folders
* `/models`: Will contain human readable information about models types, like `/models/subscriber` or `/models/lists-collection`.
* `/errors`: Will contain human readable description about expected problem types, like `/errors/400.38-duplicated-name`.
* `/rels`: Will contain human readable specification about custom _relation types_, including expected _HTTP method_ and _content-type_ or _JSON Shema_ of expected and result payloads. It could also contain information about possible errors. For example: `/rels/subscriber` or `/rels/lists-collection`.
* `/schemas`: Will contain _JSON schema_ documents for all possible input and output `application/json` payloads. For example: `/schemas/subscriber`.
#### Authentication
By the moment, we will still use current `apikey` generated in [Doppler API control panel section in Doppler](http://app2.fromdoppler.com/ControlPanel/AdvancedPreferences/GetDopplerApiInformation).
To authenticate your requests you can follow [Bearer Token Usage (RCF6750)](http://tools.ietf.org/html/rfc6750) or also include it in basic authentication password field [like GitHub does](https://developer.github.com/v3/oauth/#use-the-access-token-to-access-the-api).
Basically, the options are the follow:
* Include `apikey` in `access_token` parameter in _query string_ (not recommended for production usage).
```
GET https://testapi.com/?access_token=317F632427BCDA059B19EF241705BD2F
```
* Include `apikey` in `Authorization` header with some of these literals: `Bearer `, `OAuth2 `, `Token `.
```
GET https://testapi.com/
Authorization: token 317F632427BCDA059B19EF241705BD2F`
```
* Include `apikey` as basic authentication password.
```
GET https://testapi.com/
Authorization: basic dXNlcjozMTdGNjMyNDI3QkNEQTA1OUIxOUVGMjQxNzA1QkQyRg==
```
_`dXNlcjozMTdGNjMyNDI3QkNEQTA1OUIxOUVGMjQxNzA1QkQyRg==` corresponds to `BASE64("user:317F632427BCDA059B19EF241705BD2F")`_.
## Group Indexes
See [Message Model](/models/message).
# Hypermedia Email Marketing API Root [/]
This resource does not have any attributes. Instead it offers the initial
API affordances in the form of the links in the JSON body.
It is recommend to follow the "url" link values,
[Link](https://tools.ietf.org/html/rfc5988) or Location headers where
applicable to retrieve resources. Instead of constructing your own URLs,
to keep your client decoupled from implementation details.
## Retrieve the General Entry Point [GET]
+ Response 200 (application/json; profile=/schemas/message)
+ Headers
```
Cache-Control: private, max-age=86400
```
+ Body
```
{
"message": "Welcome to Email Marketing Hypermedia API",
"_links": [
{ "href": "/", "rel": "self index", "description": "General Index" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
# Account Index [/accounts/{accountName}]
This resource does not have any attributes. Instead it offers the initial
API affordances in the form of the links in the JSON body.
It is recommend to follow the “url” link values,
[Link](https://tools.ietf.org/html/rfc5988) or Location headers where
applicable to retrieve resources. Instead of constructing your own URLs,
to keep your client decoupled from implementation details.
## Retrieve Account Entry Point [GET]
**`To be implemented in first release`**
+ Response 200 (application/json; profile=/schemas/message)
+ Headers
```
Cache-Control: private, max-age=86400
```
+ Body
```
{
"message": "Welcome to Email Marketing Hypermedia API",
"_links": [
{ "href": "/", "rel": "parent index", "description": "General Index" },
{ "href": "/accounts/[email protected]", "rel": "self /rels/account-home", "description": "Account Index" },
{ "href": "/accounts/[email protected]/lists", "rel": "/rels/lists-collection", "description": "Lists" },
{ "href": "/accounts/[email protected]/lists", "rel": "/rels/create-list", "description": "Create a list" },
{ "href": "/accounts/[email protected]/lists/{listId}", "rel": "edit", "description": "Edit a list" },
{ "href": "/accounts/[email protected]/lists/{listId}", "rel": "delete", "description": "Delete a list" },
{ "href": "/accounts/[email protected]/lists/{listId}/subscribers". "rel": "/rels/subscribers-collection", "description": "Subscribers in a list" },
{ "href": "/accounts/[email protected]/lists/{listId}/subscribers", "rel": "/rels/subscribe-to-list", "description": "Subscribe" },
{ "href": "/accounts/[email protected]/lists/{listId}/subscribers/import", "rel": "/rels/import-to-list", "description": "Import subscribers to a list" },
{ "href": "/accounts/[email protected]/lists/{listId}/subscribers/{emailMd5}", "rel": "/rels/remove-from-list", "description": "Remove a subscriber from a list" },
{ "href": "/accounts/[email protected]/subscribers", "rel": "/rels/subscribers-collection", "description": "Subscribers in account" },
{ "href": "/accounts/[email protected]/subscribers/{emailMd5}", "rel": "/rels/subscriber", "description": "Subscriber details" },
{ "href": "/accounts/[email protected]/subscribers/{emailMd5}", "rel": "/rels/edit-subscriber", "description": "Edit subscriber" },
{ "href": "/accounts/[email protected]/subscribers/{emailMd5}/unsubscribe", "rel": "/rels/unsubscribe", "description": "Unsubscribe" },
{ "href": "/accounts/[email protected]/tasks", "rel": "/rels/tasks-collection", "description": "Tasks" },
{ "href": "/accounts/[email protected]/tasks/{taskId}", "rel": "/rels/task", "description": "Task details" },
{ "href": "/accounts/[email protected]/tasks/{taskId}/stop", "rel": "/rels/stop-task", "description": "Stop task" },
{ "href": "/accounts/[email protected]/tasks/{taskId}/pause", "rel": "/rels/pause-task", "description": "Pause task" },
{ "href": "/accounts/[email protected]/tasks/{taskId}/start", "rel": "/rels/start-task", "description": "Start task" },
{ "href": "/accounts/[email protected]/fields", "rel": "/rels/fields-collection", "description": "Fields" },
{ "href": "/accounts/[email protected]/fields", "rel": "/rels/create-field", "description": "Create field" },
{ "href": "/accounts/[email protected]/fields/{fieldId}", "rel": "/rels/edit-field", "description": "Edit field" },
{ "href": "/accounts/[email protected]/fields/{fieldId}", "rel": "/rels/delete-field", "description": "Delete field" }
]
}
```
## Group Lists
Resources related to _Subscribers Lists_. See [List Model](/models/list).
### Lists Collection [/accounts/{accountName}/lists]
Collection of all _Subscribers Lists_ for a specified _Account_.
+ Parameters
+ accountName: `[email protected]` (required, string) - Selected _Account_.
#### Get Lists [GET /accounts/{accountName}/lists{?page}{?per_page}]
**`To be implemented in first release`**
Returns a _paginated_ collection of _Lists_ into selected _Account_.
+ Parameters
+ accountName: `[email protected]` (required, string) - Selected _Account_.
+ page: `2` (optional, number) - The number of page to return.
+ Default: `1`
+ per_page: `15` (optional, number) - Number of items in each page (max value: 50, min value: 5).
+ Default: `20`
+ Response 200 (application/json; profile=/schemas/lists-collection)
+ Body
```
{
"items": [
{
"listId": 345,
"name": "North Section",
"subcribersQuantity": 34,
"_links": [
{ "href": "/accounts/[email protected]/lists/345", "rel": "/rels/list", "description": "List details" },
{ "href": "/accounts/[email protected]/lists/345", "rel": "edit /rels/edit-list", "description": "Edit list" },
{ "href": "/accounts/[email protected]/lists/345", "rel": "delete", "description": "Delete list" },
]
}
//, ...
],
"pageSize": 20,
"currentPage": 2,
"itemsCount": 483,
"pagesCount": 25,
"_links": [
{ "href": "/accounts/[email protected]/lists?page=2", "rel": "self /rels/lists-collection", "description": "Current page" },
{ "href": "/accounts/[email protected]/lists", "rel": "first prev /rels/lists-collection", "description": "First page" },
{ "href": "/accounts/[email protected]/lists?page=3", "rel": "next /rels/lists-collection", "description": "Next page" },
{ "href": "/accounts/[email protected]/lists?page=25", "rel": "last /rels/lists-collection", "description": "Last page" },
{ "href": "/accounts/[email protected]/lists?page={page}", "rel": "/rels/specific-page /rels/lists-collection", "description": "Go to page" },
{ "href": "/accounts/[email protected]/lists", "rel": "/rels/create-list", "description": "Create a new list" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
#### Create a list [POST]
**`To be implemented in first release`**
+ Attributes
+ name: `TestList` (string) - Name of the new list.
+ active: `true` (string, optional) - Status of the list.
+ Default: `true`
+ Request (application/json)
+ Body
```
{
"name": "TestList",
"active": true
}
```
+ Response 201 (application/json; profile=/schemas/message)
+ Headers
```
Location: /accounts/[email protected]/lists/345
```
+ Body
```
{
"message": "List successfully created",
"_links": [
{ "href": "/accounts/[email protected]/lists/345", "rel": "related /rels/list", "description": "Created list" },
{ "href": "/accounts/[email protected]/lists/345", "rel": "delete", "Delete list" },
{ "href": "/accounts/[email protected]/lists/345", "rel": "edit rels/edit-list", "description": "Edit list" },
{ "href": "/accounts/[email protected]/lists", "rel": "parent /rels/lists-collection", "description": "Lists" },
{ "href": "/accounts/[email protected]/lists", "rel": "/rels/create-list", "description": "Create a new list" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
+ Response 400 (application/problem+json)
+ Body
```
{
"type": "/errors/400.38-duplicated-name",
"title": "The name already exists for another resource.",
"detail": "Already exists an active list with the name 'TestList'.",
"status": 400,
"errorCode": 38
}
```
### List [/accounts/{accountName}/lists/{listId}]
Details of a specific _Subscribers List_.
+ Parameters
+ accountName: `[email protected]` (required, string) - Selected _Account_ identifier.
+ listId: `345` (required, string) - Selected _List_ identifier.
#### Get a List [GET]
Gets details about an specific _Subscribers List_ and some summarized information about its _Subscribers_.
+ Response 200 (application/json; profile=/schemas/list)
+ Body
```
{
"listId": "345",
"name": "TestList",
"subcribersQuantity": 34,
"active": true,
"creation-date": "2015-02-04T10:45:12+03:00",
"_links": [
{ "href": "/accounts/[email protected]/lists/345", "rel": "self /rels/list" },
{ "href": "/accounts/[email protected]/lists/345", "rel": "delete", "description": "Delete list" },
{ "href": "/accounts/[email protected]/lists/345", "rel": "edit /rels/edit-list", "description": "Edit list" },
{ "href": "/accounts/[email protected]/lists", "rel": "parent /rels/lists-collection", "description": "Lists" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
#### Edit a List [PUT]
Updates _Subscribers List_ values (not _Subscribers_ nor summarized data).
+ Attributes
+ name: `TestList` (string) - Name of the new list.
+ active: `true` (string) - Status of the list.
+ Request (application/json)
+ Body
```
{
"name": "TestList-Old",
"active": false
}
```
+ Response 200 (application/json; profile=/schemas/message)
+ Body
```
{
"message": "List updated successfully",
"_links": [
{ "href": "/accounts/[email protected]/lists/345", "rel": "related /rels/list", "description": "Updated list" },
{ "href": "/accounts/[email protected]/lists/345", "rel": "delete", "description": "Delete list" },
{ "href": "/accounts/[email protected]/lists/345", "rel": "edit /rels/edit-list", "description": "Edit list" },
{ "href": "/accounts/[email protected]/lists", "rel": "parent /rels/lists-collection", "description": "Lists" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
#### Delete a List [DELETE]
Deletes a _Subscribers List_ removing the _Subscribers_ but not deleting them.
+ Response 200 (application/json; profile=/schemas/message)
+ Body
```
{
"message": "List deleted successfully",
"_links": [
{ "href": "/accounts/[email protected]/lists", "rel": "parent /rels/lists-collection", "description": "Lists" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
## Group Subscribers
See [Subscriber Model](/docs/subscriber).
### Subscribers of a List [/accounts/{accountName}/lists/{listId}/subscribers]
Represents the active _Subscribers_ associated to a _Subscribers List_.
+ Parameters
+ accountName: `[email protected]` (required, string) - Selected _Account_ identifier.
+ listId: `345` (required, string) - Selected _List_ identifier.
#### Get List Subscribers [GET /accounts/{accountName}/lists/{listId}/subscribers{?page}{?per_page}]
Returns a _paginated_ collection of _Subscribers_ related to selected _List_.
+ Parameters
+ accountName: `[email protected]` (required, string) - Selected _Account_ identifier.
+ listId: `345` (required, string) - Selected _List_ identifier.
+ page: `2` (optional, number) - The number of page to return.
+ Default: `1`
+ per_page: `15` (optional, number) - Number of items in each page (max value: 50, min value: 5).
+ Default: `20`
+ Response 200 (application/json; profile=/schemas/subscribers-collection)
+ Body
```
{
"items": [
{
"emailAddress": "[email protected]",
"emailMd5": "d41d8cd98f00b204e9800998ecf8427e",
"belongsToLists": [ "345", "346" ],
"_links": [
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "item /rels/subscriber", "description": "Subscriber details" },
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "edit /rels/edit-subscriber", "description": "Edit subscriber" },
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e/unsubscribe", "rel": "/rels/unsubscribe", "description": "Unsubscribe" },
{ "href": "/accounts/[email protected]/lists/345/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "/rels/remove-from-list", "description": "Remove from current list" }
]
}
//, ...
],
"pageSize": 20,
"currentPage": 2,
"itemsCount": 483,
"pagesCount": 25,
"_links": [
{ "href": "/accounts/[email protected]/lists/345/subscribers?page=2", "rel": "self /rels/subscribers-collection", "description": "Current page" },
{ "href": "/accounts/[email protected]/lists/345/subscribers", "rel": "first prev /rels/subscribers-collection", "description": "First page" },
{ "href": "/accounts/[email protected]/lists/345/subscribers?page=3", "rel": "next /rels/subscribers-collection", "description": "Next page" },
{ "href": "/accounts/[email protected]/lists/345/subscribers?page=25", "rel": "last /rels/subscribers-collection", "description": "Last page" },
{ "href": "/accounts/[email protected]/lists/345/subscribers?page={page}", "rel": "/rels/specific-page /rels/subscribers-collection", "description": "Go to page" },
{ "href": "/accounts/[email protected]/lists/345", "rel": "parent /rels/list", "description": "Parent List" },
{ "href": "/accounts/[email protected]/lists/345/subscribers", "rel": "/rels/subscribe-to-list", "description": "Subscribe" },
{ "href": "/accounts/[email protected]/lists/345/import", "rel": "/rels/import-to-list", "description": "Import subscribers" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
#### Subscribe to List [POST]
**`To be implemented in first release`**
Associate a _Subscriber_ to the _List_. If _Subscriber's email address_ already exists in current _Account_, the existent _Subscriber_ is updated. Only data included in the payload is applied.
+ Attributes
+ emailAddress: [email protected] (string, required) - Subscriber email.
+ fields: [ { fieldName: "firstName", value: "Andres" } ] (array, optional) - List of fields to set or unset (with empty value).
+ Request (application/json)
+ Body
```
{
"name": "[email protected]"
}
```
+ Response 201 (application/json; profile=/schemas/message)
+ Headers
```
Location: /accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e
```
+ Body
```
{
"message": "Subscriber successfully created",
"_links": [
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "related /rels/subscriber", "description": "Created subscriber" },
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "/rels/unsubscribe", "description": "Unsubscribe" },
{ "href": "/accounts/[email protected]/lists/345/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "/rels/remove-from-list", "description": "Remove from list 345" },
{ "href": "/accounts/[email protected]/lists/345/subscribers", "rel": "parent /rels/subscribers-collection", "description": "Other subscribers" },
{ "href": "/accounts/[email protected]/lists/345/subscribers", "rel": "/rels/subscribe-to-list", "description": "Subscribe another" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
+ Response 200 (application/json; profile=/schemas/message)
+ Headers
```
Location: /accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e
```
+ Body
```
{
"message": "Subscriber successfully updated",
"_links": [
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "related /rels/subscriber", "description": "Subscribers" },
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "/rels/unsubscribe", "description": "Unsubscribe" },
{ "href": "/accounts/[email protected]/lists/345/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "/rels/remove-from-list", "description": "Remove from list 345" },
{ "href": "/accounts/[email protected]/lists/345/subscribers", "rel": "parent /rels/subscribers-collection", "description": "List subscribers" },
{ "href": "/accounts/[email protected]/lists/345/subscribers", "rel": "/rels/subscribe-to-list", "description": "Subscribe" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
+ Response 400 (application/problem+json)
+ Body
```
{
"type": "/errors/400.24-missing-data",
"title": "Required data is missing.",
"detail": "To add a subscriber to a list email address is required.",
"status": 400,
"errorCode": 24
}
```
#### Import Subscribers to List [POST /accounts/{accountName}/lists/{listId}/subscribers/import]
**`To be implemented in first release`** (Only JSON input)
Creates a _Task_ to import a collection of _Subscribers_ to a specified _List_. Items with new email address will be added as new subscribers, and items with already existent email address will be updated. Only will be updated the data included in the payload.
+ Parameters
+ accountName: `[email protected]` (required, string) - Selected _Account_ identifier.
+ listId: `345` (required, string) - Selected _List_ identifier.
+ Request JSON (application/json)
+ Body
```
{
"items": [
{
"emailAddress": "[email protected]",
fields: [
{ "fieldName": "firstName", "value": "John" },
{ "fieldName": "lastName", "value": "Smith" }
]
}
//, ...
],
"callback": "http://myownserver.com/importtask"
}
```
+ Request CSV (application/csv)
+ Request Legacy Excel (application/vnd.ms-excel)
+ Request Excel (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
+ Request HTML Form (x-www-form-urlencoded)
+ Attributes
+ file - Attached file.
+ content-type: `true` (string, optional) - ContentType of attached file.
+ Response 202 (application/json; profile=/schemas/message)
+ Headers
```
Location: /accounts/[email protected]/tasks/567
```
+ Body
```
{
"message": "Import task successfully created",
"_links": [
{ "href": "/accounts/[email protected]/tasks/567", "rel": "related /rels/task", "description": "Created task" },
{ "href": "/accounts/[email protected]/tasks/567/cancel", "rel": "related /rels/cancel-task", "description": "Cancel task" },
{ "href": "/accounts/[email protected]/lists/345", "rel": "parent /rels/list", "description": "Related list" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
### Subscribers Collection [/accounts/{accountName}/subscribers]
Collection of all _Subscribers_ into an specific _Account_.
#### Get subscribers [GET /accounts/{accountName}/subscribers{?page}{?per_page}{?status}]
Returns a _paginated_ collection of _Subscribers_ related to selected _Account_. It includes active and inactive _Subscribers_ and could be filtered by status.
+ Parameters
+ accountName: `[email protected]` (required, string) - Selected _Account_ identifier.
+ page: `2` (optional, number) - The number of page to return.
+ Default: `1`
+ per_page: `15` (optional, number) - Number of items in each page (max value: 50, min value: 5).
+ Default: `20`
+ status: `active` (optional, enum[string]) - Returns only _Subscribers_ with specified status.
+ `active`
+ `soft-bounce`
+ `hard-bounce`
+ `unsubscribed-by-user`
+ `unsubscribed-by-admin`
+ `never-open`
+ Response 200 (application/json; profile=/schemas/subscribers-collection)
+ Body
```
{
"items": [
{
"emailAddress": "[email protected]",
"emailMd5": "d41d8cd98f00b204e9800998ecf8427e",
"belongsToLists": [ "345", "346" ],
"_links": [
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "item /rels/subscriber", "description": "Subscriber details" },
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "edit /rels/edit-subscriber", "description": "Edit subscriber" },
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e/unsubscribe", "rel": "/rels/unsubscribe", "description": "Unsubscribe" },
{ "href": "/accounts/[email protected]/lists/345/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "/rels/remove-from-list", "description": "Remove from list 345" },
{ "href": "/accounts/[email protected]/lists/346/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "/rels/remove-from-list", "description": "Remove from list 346" }
]
}
//, ...
],
"pageSize": 20,
"currentPage": 2,
"itemsCount": 483,
"pagesCount": 25,
"_links": [
{ "href": "/accounts/[email protected]/subscribers?page=2", "rel": "self /rels/subscribers-collection", "description": "Current page" },
{ "href": "/accounts/[email protected]/subscribers", "rel": "first prev /rels/subscribers-collection", "description": "First page" },
{ "href": "/accounts/[email protected]/subscribers?page=3", "rel": "next /rels/subscribers-collection", "description": "Next page" },
{ "href": "/accounts/[email protected]/subscribers?page=25", "rel": "last /rels/subscribers-collection", "description": "Last page" },
{ "href": "/accounts/[email protected]/subscribers?page={page}", "rel": "/rels/specific-page /rels/subscribers-collection", "description": "Go to page" },
{ "href": "/accounts/[email protected]", "rel": "parent /rels/account-home", "description": "Account Index" }
]
}
```
### Subscriber [/accounts/{accountName}/subscribers/{emailMd5}]
Specific _Subscriber_ identified by the application of MD5 hash function on its email address.
+ Parameters
+ accountName: `[email protected]` (required, string) - Selected _Account_ identifier.
+ emailMd5: `d41d8cd98f00b204e9800998ecf8427e` (required, string) - Selected _Subscriber_ identifier (`hashMD5(emailAddress)`).
### Get a Subscriber [GET]
Gets details about an specific _Subscriber_.
+ Response 200 (application/json; profile=/schemas/subscriber)
+ Body
```
{
"emailAddress": "[email protected]",
"emailMd5": "d41d8cd98f00b204e9800998ecf8427e",
"belongsToLists": [ "345", "346" ],
"status": "active",
"fields": [
{ "fieldName": "firstName", "value": "John", "type": "string" },
{ "fieldName": "lastName", "value": "Smith", "type": "string" },
{ "fieldName": "income", "value": "450000", "type": "number" }
],
"_links": [
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "self /rels/subscriber" },
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "edit /rels/edit-subscriber", "description": "Edit" },
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e/unsubscribe", "rel": "/rels/unsubscribe", "description": "Unsubscribe" },
{ "href": "/accounts/[email protected]/lists/345/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "/rels/remove-from-list", "description": "Remove from list 345" },
{ "href": "/accounts/[email protected]/lists/346/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "/rels/remove-from-list", "description": "Remove from list 346" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
### Edit a Subscriber [PUT]
Edits a _Subscriber_. It expects full representation of the _Subscriber_.
+ Request (application/json)
+ Body
```
{
"emailAddress": "[email protected]",
"belongsToLists": [ "345", "346", "247" ],
"status": "active",
"fields": [
{ "fieldName": "firstName", "value": "John" },
{ "fieldName": "lastName", "value": "Smith" },
{ "fieldName": "annualIncome", "value": "450000" }
]
}
```
+ Response 200 (application/json; profile=/schemas/message)
+ Body
```
{
"message": "Subscriber updated successfully",
"_links": [
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "related /rels/subscriber", "description": "Updated subscriber" },
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "edit /rels/edit-subscriber", "description": "Edit subscriber" },
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e/unsubscribe", "rel": "/rels/unsubscribe", "description": "Unsubscriber" },
{ "href": "/accounts/[email protected]/lists/345/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "/rels/remove-from-list", "description": "Remove from list 345" },
{ "href": "/accounts/[email protected]/lists/346/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "/rels/remove-from-list", "description": "Remove from list 346" },
{ "href": "/accounts/[email protected]/lists/247/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "/rels/remove-from-list", "description": "Remove from list 247" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
### Unsubscribe [POST /accounts/{accountName}/subscribers/{emailMd5}/unsubscribe]
Mark a _Subscriber_ as _unsubscribed_, it expects an special payload with reason and other unsubscription information.
+ Parameters
+ accountName: `[email protected]` (required, string) - Selected _Account_ identifier.
+ emailMd5: `d41d8cd98f00b204e9800998ecf8427e` (required, string) - Selected _Subscriber_ identifier (`hashMD5(emailAddress)`).
+ Request (application/json)
+ Body
```
{
"reason": "You are too annoying!"
}
```
+ Response 200 (application/json; profile=/schemas/message)
+ Body
```
{
"message": "Subscriber unsubscribed successfully",
"_links": [
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "related /rels/subscriber", "description": "Unsubscribed subscriber" },
{ "href": "/accounts/[email protected]/subscribers/d41d8cd98f00b204e9800998ecf8427e", "rel": "edit /rels/edit-subscriber", "description": "Edit subscriber" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
## Group Fields
Represents the possible fields that a _Subscriber_ could have, including predefined and custom fields. See [Field Model](/models/field).
### Fields Definition Collection [/accounts/{accountName}/fields]
+ Parameters
+ accountName: `[email protected]` (required, string) - Selected _Account_ identifier.
#### Get Fields [GET]
**`To be implemented in first release`**
Gets all field definitions.
+ Response 200 (application/json; profile=/schemas/fields-collection)
+ Body
```
{
"items": [
{
"fieldName": "firstName",
"label": "First Name",
"type": "string",
"predefined": true,
"private": false,
"_links": [
{ "href": "/accounts/[email protected]/fields/firstName", "rel": "item /rels/field" },
{ "href": "/accounts/[email protected]/fields/firstName", "rel": "/rels/edit-field", "description": "Edit field" }
]
},
{
"fieldName": "lastName",
"label": "Last Name",
"type": "string",
"predefined": true,
"private": false,
"_links": [
{ "href": "/accounts/[email protected]/fields/lastName", "rel": "item /rels/field" },
{ "href": "/accounts/[email protected]/fields/lastName", "rel": "/rels/edit-field", "description": "Edit field" }
]
},
{
"fieldName": "income",
"label": "Annual Income",
"type": "number",
"predefined": false,
"private": false,
"_links": [
{ "href": "/accounts/[email protected]/fields/income", "rel": "item /rels/field" },
{ "href": "/accounts/[email protected]/fields/income", "rel": "/rels/edit-field", "description": "Edit field" },
{ "href": "/accounts/[email protected]/fields/income", "rel": "/rels/delete-field", "description": "Delete field" }
]
}
],
"_links": [
{ "href": "/accounts/[email protected]/", "rel": "parent /rels/account-home", "description": "Account index" },
{ "href": "/accounts/[email protected]/fields", "rel": "self /rels/fields-collection", "description": "Fields" },
{ "href": "/accounts/[email protected]/fields", "rel": "self /rels/add-field", "description": "Create a new field" }
]
}
```
#### Create a Field [POST]
Creates a new custom field.
+ Request (application/json)
+ Body
```
{
"fieldName": "city",
"label": "City",
"type": "string",
"private": false
}
```
+ Response 200 (application/json; profile=/schemas/message)
+ Body
```
{
"message": "Field created successfully",
"_links": [
{ "href": "/accounts/[email protected]/fields", "rel": "parent /rels/fields-collection", "description": "Fields" },
{ "href": "/accounts/[email protected]/fields/city", "rel": "related /rels/field", "description": "Created field" },
{ "href": "/accounts/[email protected]/fields/city", "rel": "/rels/edit-field", "description": "Edit field" },
{ "href": "/accounts/[email protected]/fields/city", "rel": "/rels/delete-field", "description": "Delete field" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
### Field [/accounts/{accountName}/fields/{fieldName}]
+ Parameters
+ accountName: `[email protected]` (required, string) - Selected _Account_ identifier.
+ fieldName: `income` (required, string) - Selected Field
#### Get a Field [GET]
Gets a specified field definition.
+ Response 200 (application/json; profile=/schemas/field)
+ Body
```
{
"fieldName": "income",
"label": "Annual Income",
"type": "number",
"predefined": false,
"private": false,
"_links": [
{ "href": "/accounts/[email protected]/fields/income", "rel": "self /rels/field" },
{ "href": "/accounts/[email protected]/fields/income", "rel": "/rels/edit-field", "description": "Edit field" },
{ "href": "/accounts/[email protected]/fields/income", "rel": "/rels/delete-field", "description": "Delete field" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
#### Edit a Field [PUT]
Edit a field definition. Only editable fields are required.
+ Request (application/json)
+ Body
```
{
"label": "Income",
"private": false
}
```
+ Response 200 (application/json; profile=/schemas/message)
+ Body
```
{
"message": "Field updated successfully",
"_links": [
{ "href": "/accounts/[email protected]/fields", "rel": "parent /rels/fields-collection", "description": "Fields" },
{ "href": "/accounts/[email protected]/fields/city", "rel": "related /rels/field", "description": "Updated field" },
{ "href": "/accounts/[email protected]/fields/city", "rel": "/rels/edit-field", "description": "Edit field" },
{ "href": "/accounts/[email protected]/fields/city", "rel": "/rels/delete-field", "description": "Delete field" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
#### Delete a Field [DELETE]
Deletes a field definition. Only custom fields are deletable. When a field definition is deleted, all data related to that field in _Subscribers_ is removed.
+ Response 200 (application/json; profile=/schemas/message)
+ Body
```
{
"message": "Field deleted successfully",
"_links": [
{ "href": "/accounts/[email protected]/fields", "rel": "parent /rels/fields-collection", "description": "Fields" },
{ "href": "/accounts/[email protected]", "rel": "/rels/account-home", "description": "Account Index" }
]
}
```
## Group Tasks
See [Task Model](/models/task).
### Tasks Collection [/accounts/{accountName}/tasks]
+ Parameters
+ accountName: `[email protected]` (required, string) - Selected _Account_ identifier.
#### Get Tasks [GET /accounts/{accountName}/tasks{?page}{?per_page}{?status}]
Returns a _paginated_ collection of _Tasks_ related to selected _Account_. It includes active and inactive _Tasks_ and could be filtered by status.
+ Parameters
+ accountName: `[email protected]` (required, string) - Selected _Account_ identifier.
+ page: `2` (optional, number) - The number of page to return.
+ Default: `1`
+ per_page: `15` (optional, number) - Number of items in each page (max value: 50, min value: 5).
+ Default: `20`
+ status: `queued` (optional, enum[string]) - Returns only _Tasks_ with specified status.
+ `queued`
+ `in-progress`
+ `canceled`
+ `paused`
+ `done`
+ `error`
+ Response 200 (application/json; profile=/schemas/tasks-collection)
+ Body
```
{
"items": [
{
"taskId": "567",
"status": "in-progress",
"_links": [
{ "href": "/accounts/[email protected]/tasks/567", "rel": "item /rels/task", "description": "Task details" },
{ "href": "/accounts/[email protected]/tasks/567/cancel", "rel": "item /rels/cancel-task", "description": "Cancel task" }
]
}
//, ...
],
"pageSize": 20,
"currentPage": 2,
"itemsCount": 483,
"pagesCount": 25,
"_links": [
{ "href": "/accounts/[email protected]/tasks/?page=2", "rel": "self /rels/tasks-collection", "description": "Current page" },
{ "href": "/accounts/[email protected]/tasks", "rel": "first prev /rels/tasks-collection", "description": "First page" },
{ "href": "/accounts/[email protected]/tasks?page=3", "rel": "next /rels/tasks-collection", "description": "Next page" },
{ "href": "/accounts/[email protected]/tasks?page=25", "rel": "last /rels/tasks-collection", "description": "Last page" },
{ "href": "/accounts/[email protected]/tasks?page={page}", "rel": "/rels/specific-page /rels/tasks-collection", "description": "Go to page" },
{ "href": "/accounts/[email protected]", "rel": "parent /rels/account-home", "description": "Account Index" }
]
}
```
### Task [/accounts/{accountName}/tasks/{taskId}]
+ Parameters
+ accountName: `[email protected]` (required, string) - Selected _Account_ identifier.
+ taskId: `567` (required, string) - Selected _Account_ identifier.
#### Get a Task [GET]
**`To be implemented in first release`**
Gets details of a specified _Task_ including links to related actions and resources.
+ Response 200 (application/json; profile=/schemas/task)
+ Body
```
{
"taskId": "567",
"status": "in-progress",