-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathshopper-baskets-oas-v1-public.yaml
More file actions
6636 lines (6588 loc) · 260 KB
/
shopper-baskets-oas-v1-public.yaml
File metadata and controls
6636 lines (6588 loc) · 260 KB
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
openapi: 3.0.3
info:
x-api-type: Shopper
x-api-family: Checkout
title: Shopper Baskets
version: 1.11.0
description: |-
[Download API specification](https://developer.salesforce.com/static/commercecloud/commerce-api/shopper-baskets/shopper-baskets-oas-v1-public.yaml)
# API Overview
Use the Shopper Baskets API to create a basket in the B2C Commerce system and populate it with all the data required to ready the basket for checkout.
To create a basket, start with the [Create basket](https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-baskets?meta=createBasket) endpoint. The endpoint creates the basket in the B2C Commerce system and returns a JSON representation of the basket with a `basketId` property.
If you provide the JSON for a prepopulated basket to the [Create basket](https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-baskets?meta=createBasket) endpoint, you can create a basket using a single API request.
You can also create a basket and gradually populate it with data using subsequent API requests that reference the same `basketId`. The gradual approach allows you to validate the input data as you go.
The Shopper Baskets API includes endpoints to populate each part of a basket separately, including:
- Billing address
- Customer information
- Line items
- Products
- Coupons
- Gift certificates
- Payment methods
- Price books
- Shipments
- Taxation (for items and the basket itself)
In addition to creating a basket, the main `/baskets` resource offers endpoints to get, transfer, merge, and delete baskets, depending on the HTTP method that you use and the parameters that you supply. These endpoints can you help you handle a variety of complex scenarios, such as when a user starts shopping as a guest and then logs in before checkout.
You can also use the main `/baskets` resource to add custom properties to your basket, prefixed with `c_` (example: `c_faxNumber`).
When your basket is fully populated, you can use its `basketId` property to create an order with the [Shopper Orders API](https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=Summary).
For more detail on building baskets, see [Build Baskets and Place Orders](https://developer.salesforce.com/docs/commerce/commerce-api/guide/work-with-baskets-orders.html).
## Authentication & Authorization
The client requesting the basket information must have access to the `/baskets` resource. The Shopper Baskets API requires a shopper access token from the Shopper Login and API Access Service (SLAS).
For details on how to request a shopper access token from SLAS, see the guest user flows for [public clients](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas-public-client.html#guest-user) and [private clients](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas-private-client.html#guest-user) in the SLAS guides.
You must include `sfcc.shopper-baskets-orders` or `sfcc.shopper-baskets-orders.rw` in the client ID used to generate the SLAS token. For a full list of permissions, see the [Authorization Scopes Catalog.](https://developer.salesforce.com/docs/commerce/commerce-api/guide/auth-z-scope-catalog.html)
The following resources require an Account Manager OAuth token with a client ID:
- `/baskets/{basketId}/taxes`
- `/baskets/{basketId}/items/{itemId}/taxes`
- `/baskets/{basketId}/price-books`
## Use Cases
### Use Hooks
For details on working with hooks, see [Extensibility with Hooks.](https://developer.salesforce.com/docs/commerce/commerce-api/guide/extensibility_via_hooks.html)
## Basket Calculation
Unless you’re using [hooks](https://developer.salesforce.com/docs/commerce/commerce-api/guide/extensibility_via_hooks.html), each modification to a basket triggers the following calculations:
1. Calculate product prices:
- Iterate through the product line items and determine the base price of each using its price model. If multiple price books apply to a product, the lowest price is used.
- Calculate product option line item prices using the product option model.
- For bonus products, check dependent adjustments in the basket to determine the price.
2. Iterate through the gift certificate line items and calculate the price of each by multiplying the base price by the quantity.
3. Recalculate for all promotions, adding and removing them as appropriate.
4. Apply product-specific shipping costs.
5. Calculate the total shipping cost.
6. Recalculate for all promotions, adding and removing them as appropriate.
7. Calculate prices for products added by the promotion engine.
8. Calculate taxes using line item tax class codes.
- For internal tax mode, use the tax tables.
- For external tax mode, use the tax rates returned by the tax API endpoints.
9. Calculate the order’s net, tax, and gross totals by adding up the line totals.
## External Taxation
The B2C Commerce API calculates taxes internally using tax tables. If you want to integrate with a third-party tax provider, or calculate tax on your own, you can use the external taxation feature to add a taxation rate and optional taxation value. When setting a taxation rate, the taxation is calculated for this specific rate. If you pass a value, this value is used as taxation value, as well, without recalculation. To use this feature, set the `taxMode` parameter to `external` when creating the basket.
When using external taxation, you must set a tax rate either in one request to the `/baskets/{basketId}/taxes` or with separate requests for each line item, using `/baskets/{basketId}/items/{lineItemId}/taxes`.
If the tax mode of a basket is set to `external`, a tax item is required for all line items even for zero-tax items to avoid oversights.
### External Taxation with Hooks Enabled
To use external tax calculation with [hooks](https://developer.salesforce.com/docs/commerce/commerce-api/guide/extensibility_via_hooks.html), use the following API methods in the [Calculate Hook](https://developer.salesforce.com/docs/commerce/commerce-api/guide/extensibility_via_hooks.html#calculate-hook):
- `dw.order.LineItemCtnr#isExternallyTaxed`: Returns true if the basket was created with `taxMode = external`
- `dw.order.TaxMgr#applyExternalTax`: Applies externally set tax rates to the given basket. Only use when `dw.order.LineItemCtnr#isExternallyTaxed` returns true.
The following example shows an implementation of external tax calculation with hooks enabled in the [Calculate Hook](https://developer.salesforce.com/docs/commerce/commerce-api/guide/extensibility_via_hooks.html#calculate-hook):
exports.calculate = function (basket) {
if ( basket.isExternallyTaxed() )
{
TaxMgr.applyExternalTaxation( basket ); // apply the external tax calculation based on the tax rates set by the SCAPI external taxation APIs
}
else
{
// calculation with tax tables or customization
}
}
servers:
- url: https://{shortCode}.api.commercecloud.salesforce.com/checkout/shopper-baskets/v1
variables:
shortCode:
default: shortCode
paths:
/organizations/{organizationId}/baskets:
parameters:
- $ref: '#/components/parameters/siteId'
- $ref: '#/components/parameters/organizationId'
post:
description: |-
Creates a new basket.
The created basket is initialized with default values. Optional JSON data provided in the request body is populated into the created basket. It can be updated with other endpoints offered by the Shopper Baskets API.
Each shopper is limited to one open basket at a time. Attempting to create a second basket for the same customer will result in a 400 Bad Request error with the message: "Customer Baskets Quota Exceeded".
A basket is considered "open" upon creation and remains in this state until it is either converted into an order or explicitly deleted. For implementation best practices, see [Hybrid Storefront Best Practices for Working with Baskets](https://developer.salesforce.com/docs/commerce/commerce-api/guide/hybrid-storefront-baskets.html#hybrid-storefront-best-practices-for-working-with-baskets).
operationId: createBasket
summary: Create a new basket.
security:
- ShopperToken:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-standard
responses:
'200':
description: The initialized basket.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
BasketsPostSuccess:
$ref: '#/components/examples/examples-BasketPost'
'400':
description: |-
Possible reasons:
- the provided payment method is invalid or not applicable.
- the customerId URL parameter does not match the verified customer
represented by the JSON Web Token (JWT).
- a new basket cannot be created because the maximum number
of baskets per customer would be exceeded.
- the same shipment ID appeared twice in the body.
- the coupon number is not provided.
- a fixed price adjustment was added at order level which is disallowed.
- a promotion ID was
used twice, while attempting to add a price adjustment.
- a system promotion
ID was used as a manual promotion ID, while attempting to add a price adjustment.
- more than one hundred price adjustments would have been
created.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
BadRequest:
$ref: '#/components/examples/BadRequest'
CustomerBasketQuotaExceededException:
$ref: '#/components/examples/CustomerBasketQuotaExceededException'
'404':
description: Thrown if the shipment with the given shipment ID is unknown.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
ShipmentNotFound:
$ref: '#/components/examples/ShipmentNotFound'
requestBody:
content:
application/json:
examples:
PostBasketBody:
$ref: '#/components/examples/BasketPost'
schema:
$ref: '#/components/schemas/Basket'
required: true
parameters:
- $ref: '#/components/parameters/taxMode'
- $ref: '#/components/parameters/locale'
/organizations/{organizationId}/baskets/actions/transfer:
parameters:
- $ref: '#/components/parameters/siteId'
- $ref: '#/components/parameters/organizationId'
post:
description: |-
Transfer the previous shopper's basket to the current shopper by updating the basket's owner. No other values change. You must obtain the shopper authorization token via SLAS and you must provide the ‘guest usid‘ in both the ‘/oauth2/login‘ and ‘/oauth2/token‘ calls while fetching the registered user JWT token.
This endpoint provides different methods for handling the scenario in which both a previous guest shopper and the current registered shopper have an active basket attached, and utilizes the `merge` parameter as follows:
- `true` (recommended): Triggers a merge hook for graceful handling and prevents 409 status returns. For more information, refer to the `merge` parameter documentation.
- `false`: Either overrides the basket of the current registered shopper or returns a 409 response, and allows you to choose between the options explained below.
If you call the endpoint with `merge=false` and the current shopper has an active basket, you have two options using the `overrideExisting` parameter. Setting it to `true` deletes the registered user's basket, while setting it to `false` returns a `BasketTransferException` (HTTP status 409), after which you can choose how to proceed:
- Keep the current shopper's active basket.
- Merge the previous and current shoppers' baskets by calling the `baskets/actions/merge` endpoint.
- Force the transfer by calling the `baskets/actions/transfer` endpoint again, with the parameter `overrideExisting=true`. Forcing the transfer deletes the current shopper's active basket.
A successful response provides the transferred (and merged) current basket. However, if neither the previous nor current shopper had an active basket, a 204 (No Content) response is returned.
operationId: transferBasket
summary: Transfer an existing basket.
security:
- ShopperToken:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-standard
parameters:
- $ref: '#/components/parameters/overrideExisting'
- $ref: '#/components/parameters/merge'
- $ref: '#/components/parameters/locale'
responses:
'200':
description: The current basket.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
BasketPost:
$ref: '#/components/examples/examples-BasketPost'
'204':
description: The operation was successful. No current basket was returned because neither the previous nor current shopper had an active basket attached that could be transferred.
'403':
description: The call returns this error if no SLAS token for a registered shopper is available.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
ForbiddenMissingPrevCustomerInfo:
$ref: '#/components/examples/ForbiddenMissingPrevCustomerInfo'
'409':
description: |-
The call returns this response when the `merge` request parameter is set to `false` and one of the following cases applies:
- The previous shopper has no active basket.
- The current shopper has an active basket and the `overrideExisting` query parameter is set to `false` (default value).
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
SourceBasketException:
$ref: '#/components/examples/SourceBasketException'
BasketTransferException:
$ref: '#/components/examples/BasketTransferException'
/organizations/{organizationId}/baskets/actions/merge:
parameters:
- $ref: '#/components/parameters/siteId'
- $ref: '#/components/parameters/organizationId'
post:
operationId: mergeBasket
summary: Merge baskets.
description: |-
( DEPRECATED ) Instead of using this endpoint, we recommend using the `/baskets/actions/transfer` endpoint with the `merge=true` parameter, because the transfer endpoint offers greater customization by invoking a hook, allowing for adjustments if the default implementation does not process the merge as expected.
Merge data from the previous shopper's basket into the current shopper's active basket and delete the previous shopper's basket. This endpoint doesn't merge Personally Identifiable Information (PII). You must obtain the shopper authorization token via SLAS and you must provide the ‘guest usid‘ in both the ‘/oauth2/login‘ and ‘/oauth2/token‘ calls while fetching the registered user JWT token. After the merge, all basket amounts are recalculated and totaled, including lookups for prices, taxes, shipping, and promotions, unless hooks are enabled.
The following information is merged:
- custom attributes on the basket and on all copied records
- product items
- gift certificate items
- coupon items
- shipments
- ad-hoc price adjustments
To control the merging of products that exist in both baskets, use the `productItemMergeMode` parameter. By default, the higher of the two basket quantities is used for each product. Products in both baskets are considered to be the same when all of the following values match (if one product doesn't have a value, the other product is a match only if it also doesn't have that value):
- shipment
- productId
- option values
- wishlist reference
- inventory list id
- gift flag & message
- ad-hoc price adjustments
If any of the listed values don't match, then the item in the previous shopper's basket is copied to a new line item in the current shopper's basket. If the listed values all match, but the matching products have different values for any custom attribute, the merged line item keeps the custom attribute value from the current shopper's basket.
A success response contains the current shopper's active basket. The previous guest shopper's active basket is deleted.
If the current shopper doesn't have an active basket, and the createDestinationBasket request parameter is false, then the merge request returns a BasketMergeException (HTTP status 409). You can proceed with one of these options:
- Transfer the previous shopper's active basket to the current logged-in shopper by calling the `baskets/transfer` endpoint.
- Force the merge by calling the `baskets/merge` endpoint again, with the parameter `createDestinationBasket=true`. Forcing the merge creates a new basket for the current shopper and copies information from the previous shopper's basket into it. Because the merge doesn't copy all basket data, a forced merge is not the same as a transfer. For example, the new basket doesn't contain any Personally Identifiable Information (PII) from the previous basket.
### before merge
| Previous Shopper's Basket, SKU: Quantity, Custom Attributes | Current Shopper's Basket, SKU: Quantity, Custom Attributes |
|-------------------------------------------------------------|-------------------------------------------------------------|
| SKU_A: 5<br> SKU_B: 3<br> SKU_C: 4<br> c_customAttr_1: 'ABC' <br> c_customAttr_2: 'DEF' | SKU_A: 2<br> SKU_D: 6<br> SKU_E: 7<br> c_customAttr_1: 'UVW' <br> c_customAttr_3: 'XYZ' |
### after merge - (previous shopper's basket is deleted)
| productItemMergeMode | Current Shopper's Basket - SKU: Quantity, Custom Attributes |
|----------------------|--------------------------------------------------------------|
| sum_quantities | SKU_A: 7<br> SKU_B: 3<br> SKU_C: 4<br> SKU_D: 6<br> SKU_E: 7<br> c_customAttr_1: 'UVW' <br> c_customAttr_2: 'DEF' <br> c_customAttr_3: 'XYZ' |
| higher_quantity | SKU_A: 5<br> SKU_B: 3<br> SKU_C: 4<br> SKU_D: 6<br> SKU_E: 7<br> c_customAttr_1: 'UVW' <br> c_customAttr_2: 'DEF' <br> c_customAttr_3: 'XYZ' |
| saved_quantity | SKU_A: 2<br> SKU_B: 3<br> SKU_C: 4<br> SKU_D: 6<br> SKU_E: 7<br> c_customAttr_1: 'UVW' <br> c_customAttr_2: 'DEF' <br> c_customAttr_3: 'XYZ' |
| separate_item | SKU_A: 5<br> SKU_B: 3<br> SKU_C: 4<br> SKU_A: 2<br> SKU_D: 6<br> SKU_E: 7<br> c_customAttr_1: 'UVW' <br> c_customAttr_2: 'DEF' <br> c_customAttr_3: 'XYZ' |
security:
- ShopperToken:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-standard
parameters:
- $ref: '#/components/parameters/createDestinationBasket'
- $ref: '#/components/parameters/productItemMergeMode'
- $ref: '#/components/parameters/locale'
responses:
'200':
description: The current shopper's active basket, including items merged from the previous shopper's basket.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
BasketPost:
$ref: '#/components/examples/examples-BasketPost'
'403':
description: The call returns this error if no SLAS token for a registered shopper is available.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
ForbiddenMissingPrevCustomerInfo:
$ref: '#/components/examples/ForbiddenMissingPrevCustomerInfo'
'409':
description: |-
The call returns this response in either of these cases:
- The previous shopper has no active basket.
- The current shopper has no active basket and the `createDestinationBasket` query parameter was `false` (default value).
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
SourceBasketException:
$ref: '#/components/examples/SourceBasketException'
BasketMergeException:
$ref: '#/components/examples/BasketMergeException'
/organizations/{organizationId}/baskets/{basketId}:
parameters:
- $ref: '#/components/parameters/siteId'
- $ref: '#/components/parameters/organizationId'
- $ref: '#/components/parameters/basketId'
delete:
description: Removes a basket.
summary: Delete a basket.
operationId: deleteBasket
security:
- ShopperToken:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-standard
responses:
'204':
description: Success, without a body.
'400':
description: |-
The customer assigned to the basket does not
match the verified customer represented by the JSON Web Token (JWT).
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
CustomerInfoJwtMismatch:
$ref: '#/components/examples/CustomerInfoJwtMismatch'
'404':
description: The basket with the given basket ID is unknown.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
BasketNotFound:
$ref: '#/components/examples/BasketNotFound'
get:
description: Gets a basket.
operationId: getBasket
summary: Retrieve an existing basket.
security:
- ShopperToken:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-baskets-orders
- sfcc.shopper-standard
parameters:
- $ref: '#/components/parameters/locale'
responses:
'200':
description: Success, the response body contains the retrieved basket.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
GetBasket:
$ref: '#/components/examples/BasketGet'
'400':
description: |-
The customer assigned to the basket does not
match the verified customer represented by the JSON Web Token (JWT).
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
CustomerInfoJwtMismatch:
$ref: '#/components/examples/CustomerInfoJwtMismatch'
'404':
description: The basket with the given basket ID is unknown.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
BasketNotFound:
$ref: '#/components/examples/BasketNotFound'
patch:
description: |-
Updates a basket. Only the currency of the basket, source code, the custom
properties of the basket, and the shipping items will be considered.
operationId: updateBasket
summary: Update a basket.
security:
- ShopperToken:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-standard
parameters:
- $ref: '#/components/parameters/removeExternalTax'
- $ref: '#/components/parameters/locale'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
BasketPatch:
$ref: '#/components/examples/BasketPatch'
responses:
'200':
description: Success, the response body contains the updated basket.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
BasketPatch:
$ref: '#/components/examples/examples-BasketPatch'
'400':
description: |-
Possible reasons:
- the customer assigned to the basket does not
match the verified customer represented by the JSON Web Token (JWT).
- the basket cannot be updated because the
requested currency is not supported by the site.
- the given shipping item ID is null or empty.
- a few shipping items with the same item ID are
provided.
- the provided code is not currently active.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
CustomerInfoJwtMismatch:
$ref: '#/components/examples/CustomerInfoJwtMismatch'
BadRequest:
$ref: '#/components/examples/BadRequest'
'404':
description: |-
Possible reasons:
- the basket with the given basket ID is unknown.
- the shipping item with the given item ID is
unknown for the basket.
- the provided code was not found.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
BasketNotFound:
$ref: '#/components/examples/BasketNotFound'
/organizations/{organizationId}/baskets/{basketId}/agent:
parameters:
- $ref: '#/components/parameters/siteId'
- $ref: '#/components/parameters/organizationId'
- $ref: '#/components/parameters/basketId'
put:
description: Marks a basket as an agent basket.
operationId: updateAsAgentBasket
summary: Designate a basket as an agent basket.
security:
- ShopperTokenTaob:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-standard
parameters:
- $ref: '#/components/parameters/locale'
responses:
'200':
description: Success, the response body contains basket that is set as an agent basket.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
BasketPutAgent:
$ref: '#/components/examples/BasketPutAgent'
'400':
description: Marking this basket as an agent basket would exceed the open agent basket limit for the basket customer.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
CustomerInfoJwtMismatch:
$ref: '#/components/examples/CustomerBasketQuotaExceededException'
'404':
description: The basket with the given basket ID is unknown.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
BasketNotFound:
$ref: '#/components/examples/BasketNotFound'
/organizations/{organizationId}/baskets/{basketId}/billing-address:
parameters:
- $ref: '#/components/parameters/siteId'
- $ref: '#/components/parameters/organizationId'
- $ref: '#/components/parameters/basketId'
put:
description: Sets the billing address of a basket.
operationId: updateBillingAddressForBasket
summary: Add a billing address to a basket.
security:
- ShopperToken:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-standard
parameters:
- $ref: '#/components/parameters/locale'
- $ref: '#/components/parameters/useAsShipping'
- $ref: '#/components/parameters/removeExternalTax'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/OrderAddress'
examples:
BillingAddressPut:
$ref: '#/components/examples/BillingAddressPut'
responses:
'200':
description: Success, the response body contains basket with the added billing address.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
BillingAddress:
$ref: '#/components/examples/examples-BillingAddressPut'
'400':
description: |-
The customer assigned to the basket does not
match the verified customer represented by the JSON Web Token (JWT).
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
CustomerInfoJwtMismatch:
$ref: '#/components/examples/CustomerInfoJwtMismatch'
'404':
description: The basket with the given basket ID is unknown.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
BasketNotFound:
$ref: '#/components/examples/BasketNotFound'
/organizations/{organizationId}/baskets/{basketId}/coupons:
parameters:
- $ref: '#/components/parameters/siteId'
- $ref: '#/components/parameters/organizationId'
- $ref: '#/components/parameters/basketId'
post:
description: Adds a coupon to an existing basket.
operationId: addCouponToBasket
summary: Add a coupon to a basket.
security:
- ShopperToken:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-standard
parameters:
- $ref: '#/components/parameters/locale'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CouponItem'
examples:
CouponCodePost:
$ref: '#/components/examples/CouponCodePost'
responses:
'200':
description: Success, the response body contains the basket with the added coupon.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
CouponCodePost:
$ref: '#/components/examples/examples-CouponCodePost'
'400':
description: |-
Possible Reasons:
- the customer assigned to the basket does not
match the verified customer represented by the JSON Web Token (JWT).
- the coupon number is not provided.
- the coupon code specified is invalid.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
CustomerInfoJwtMismatch:
$ref: '#/components/examples/CustomerInfoJwtMismatch'
BadRequest:
$ref: '#/components/examples/BadRequest'
'404':
description: The basket with the given basket ID is unknown.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
BasketNotFound:
$ref: '#/components/examples/BasketNotFound'
/organizations/{organizationId}/baskets/{basketId}/coupons/{couponItemId}:
parameters:
- $ref: '#/components/parameters/siteId'
- $ref: '#/components/parameters/organizationId'
- $ref: '#/components/parameters/basketId'
- $ref: '#/components/parameters/couponItemId'
delete:
description: Removes a coupon from the basket.
operationId: removeCouponFromBasket
summary: Remove a coupon from a basket.
security:
- ShopperToken:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-standard
parameters:
- $ref: '#/components/parameters/locale'
responses:
'200':
description: Success, the response body contains the basket without the deleted coupon.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
Basket:
$ref: '#/components/examples/examples-BasketPost'
'400':
description: |-
The customer assigned to the basket does not
match the verified customer represented by the JSON Web Token (JWT).
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
CustomerInfoJwtMismatch:
$ref: '#/components/examples/CustomerInfoJwtMismatch'
'404':
description: |-
Possible reasons:
- the basket with the given basket ID is unknown.
- the couponItemId URL parameter does not match any
coupon item ID in the basket.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
BasketNotFound:
$ref: '#/components/examples/BasketNotFound'
/organizations/{organizationId}/baskets/{basketId}/customer:
parameters:
- $ref: '#/components/parameters/siteId'
- $ref: '#/components/parameters/organizationId'
- $ref: '#/components/parameters/basketId'
put:
description: Sets customer information for an existing basket.
operationId: updateCustomerForBasket
summary: Add shopper information to a basket.
security:
- ShopperToken:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-standard
parameters:
- $ref: '#/components/parameters/locale'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CustomerInfo'
examples:
BillingAddressPut:
$ref: '#/components/examples/CustomerPut'
responses:
'200':
description: Success, the response body contains the basket with the added customer information.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
BillingAddress:
$ref: '#/components/examples/examples-CustomerPut'
'400':
description: |-
Possible reasons:
- the customer assigned to the basket does not match the verified
customer represented by the JSON Web Token (JWT).
- the customer cannot be set to the basket because the
max number of baskets per customer would be exceeded.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
CustomerInfoJwtMismatch:
$ref: '#/components/examples/CustomerInfoJwtMismatch'
BadRequest:
$ref: '#/components/examples/BadRequest'
'404':
description: |-
Possible reasons:
- the customer with the given customer number is unknown.
- the basket with the given basket ID is unknown.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
BasketNotFound:
$ref: '#/components/examples/BasketNotFound'
/organizations/{organizationId}/baskets/{basketId}/gift-certificate-items:
parameters:
- $ref: '#/components/parameters/siteId'
- $ref: '#/components/parameters/organizationId'
- $ref: '#/components/parameters/basketId'
post:
description: Adds a gift certificate item to an existing basket.
operationId: addGiftCertificateItemToBasket
summary: Add a gift certificate to a basket.
security:
- ShopperToken:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-standard
parameters:
- $ref: '#/components/parameters/locale'
responses:
'200':
description: Success, the response body contains the basket with the added gift certificate.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
GiftCertPost:
$ref: '#/components/examples/examples-GiftCertPost'
'400':
description: The gift certificate item amount is negative.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
BadRequest:
$ref: '#/components/examples/BadRequest'
'404':
description: |-
Possible reasons:
- the basket with the given basket ID is unknown.
- the shipment with the given shipment ID is unknown.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
BasketNotFound:
$ref: '#/components/examples/BasketNotFound'
requestBody:
content:
application/json:
examples:
GiftCertificateItemPost:
$ref: '#/components/examples/GiftCertPost'
schema:
$ref: '#/components/schemas/GiftCertificateItem'
/organizations/{organizationId}/baskets/{basketId}/gift-certificate-items/{giftCertificateItemId}:
parameters:
- $ref: '#/components/parameters/siteId'
- $ref: '#/components/parameters/organizationId'
- $ref: '#/components/parameters/basketId'
- $ref: '#/components/parameters/giftCertificateItemId'
delete:
description: Deletes a gift certificate item from an existing basket.
operationId: removeGiftCertificateItemFromBasket
summary: Remove a gift certificate from a basket.
parameters:
- $ref: '#/components/parameters/locale'
security:
- ShopperToken:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-standard
responses:
'200':
description: Success, the response body contains the basket without the deleted gift certificate.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
'404':
description: |-
Possible reasons:
- the basket with the given basket ID is unknown.
- the gift certificate item with the given gift certificate item ID is unknown.
patch:
description: Updates a gift certificate item of an existing basket.
operationId: updateGiftCertificateItemInBasket
summary: Update gift certificate information for a basket.
security:
- ShopperToken:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-standard
parameters:
- $ref: '#/components/parameters/locale'
responses:
'200':
description: Success, the response body contains the basket with the updated gift certificate.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
GiftCertPatch:
$ref: '#/components/examples/examples-GiftCertPatch'
'400':
description: The gift certificate item amount is negative.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
BadRequest:
$ref: '#/components/examples/BadRequest'
'404':
description: |-
Possible reasons:
- the basket with the given basket ID is unknown.
- the gift certificate item with the given gift certificate item ID is unknown.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
BasketNotFound:
$ref: '#/components/examples/BasketNotFound'
requestBody:
content:
application/json:
examples:
GiftCertificateItemPost:
$ref: '#/components/examples/GiftCertPatch'
schema:
$ref: '#/components/schemas/GiftCertificateItem'
/organizations/{organizationId}/baskets/{basketId}/items:
post:
responses:
'200':
description: Success, the response body contains the basket with the added items.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
BasketsPostSuccess:
$ref: '#/components/examples/examples-BasketPost'
'400':
description: |-
Possible reasons:
- the given product ID is null or invalid.
- the product with the given product ID is unknown, offline or
not assigned to site catalog or the given product item quantity is null or invalid.
- a null quantity value.
- the requested product quantity is not available.
- the product cannot be added to the basket because of its type.
- an option with the specified option ID is unknown.
- an option with the specified option value ID is
unknown.
- the maximum allowed number of products added to the basket,
has been exceeded.
- the customer assigned to the basket does not match the verified
customer represented by the JSON Web Token (JWT).
- the provided bonus discount line item ID is not
present in the current basket.
- the quantity of the product to be added will result in the
number of selected bonus choice products to exceed the amount that the user is permitted to select.
- the selected bonus product is not an applicable product for
the bonus discount line item provided.
body:
application/problem+json:
type: ErrorResponse
examples:
dataTypes.ErrorResponse: !include exchange_modules/893f605e-10e2-423a-bdb4-f952f56eb6d8/checkout-data-types/2.0.6/examples/error/bad-request-example.raml
'404':
description: |-
Possible reasons:
- the basket with the given basket ID is unknown.
- the basket does not contain a shipment with the given shipment ID.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
BasketNotFound:
$ref: '#/components/examples/BasketNotFound'
description: |-
Adds new items to a basket. The added items are associated with the
specified shipment. If no shipment id is specified, the added items are associated with the default shipment.
Considered values from the request body, for each item are:
- productId: a valid product ID. This is the ID of the product to be added to the basket. If the
product is already in the basket, the API either increments the quantity of the existing product line item or
creates a new product line item, based on the site preference 'Add Product Behavior'. For option products and
product bundles containing variation masters, the API creates a new product line item regardless of the site
preference.
- shipmentId: a valid shipment ID (optional). This is the ID of the shipment in which the product item
is created.
- quantity: a number between 0.01 and 999. This is the quantity of the product to order.
- inventoryId: a valid inventory ID (optional). This is the ID of the inventory from which the item is
allocated.
- bonusDiscountLineItemId: a valid bonus discount line item ID (optional). This is the ID of the
bonus discount line item for which the added product is a selected bonus product.
- optionItems/optionValueId: a valid option value ID. This is an option value for an option item of
an option product. This is only possible if the product item is an option
product. To set option values, you must specify a collection of option items in the optionItems
property. These option items must contain optionId and optionValueId. Also,
the values you specify must be valid for the option product that this product item represents. Otherwise, the
server throws an InvalidProductOptionItemException or an
InvalidProductOptionValueItemException.
- custom properties in the form c_<CUSTOM_NAME>: the custom property must correspond to a custom
attribute (<CUSTOM_NAME>) defined for ProductLineItem. The value of this property must be valid for the
type of custom attribute defined for ProductLineItem.
operationId: addItemToBasket
summary: Add an item to a basket.
security:
- ShopperToken:
- sfcc.shopper-baskets-orders.rw
- sfcc.shopper-standard
requestBody:
content:
application/json:
examples:
ItemPost:
$ref: '#/components/examples/ItemPost'
schema:
type: array
items:
$ref: '#/components/schemas/ProductItem'
required: true
parameters:
- $ref: '#/components/parameters/locale'
patch:
responses:
'200':
description: Success, the response body contains the basket with the updated item.
content:
application/json:
schema:
$ref: '#/components/schemas/Basket'
examples:
BasketsPostSuccess:
$ref: '#/components/examples/examples-BasketPost'
'400':
description: |-
Possible reasons:
- no product item with a given item ID was found for the basket.
- the product with the given product ID in the
request body is invalid.
- a null quantity value.
- an option with a specified option ID is unknown.
- an option with a specified option value ID is unknown.