Add Orders to an Existing Contract

Here’s an example of a PATCH request using the Contract-based Orders resource to add new orders and order products to an existing contract.

Example usage 

1/services/data/v30.0/commerce/sale/800D0000000PFL8IAO

Example request body 

1{
2   "contract": [
3      {
4      "attributes": {
5         "type": "Contract"
6            },
7      "Id" : "800D0000000PFL8IAO", 
8      "Orders": {
9         "records": [
10            {
11            "attributes": {
12               "type": "Order"
13                  },
14            "EffectiveDate": "2013-08-11",
15            "Status": "Draft",
16            "billingCity": "SFO-Inside-OrderEntity-1",
17            "contractId": "800D0000000PFL8IAO",
18            "pricebook2Id": "01sD0000000G2JbIAK",
19            "OrderItems": {
20               "records": [
21                  {
22                  "attributes": {
23                     "type": "OrderItem"
24                        },
25                  "PricebookEntryId": "01uD0000001c5tjIAA",
26                  "quantity": "12",
27                  "UnitPrice": "10"
28                     },
29                  {
30                  "attributes": {
31                     "type": "OrderItem"
32                        },
33                  "PricebookEntryId": "01uD0000001cAkMIAU",
34                  "quantity": "2",
35                  "UnitPrice": "20"
36                     }
37                  ]
38               }
39            },
40            {
41            "attributes": {
42               "type": "Order"
43                   },
44            "EffectiveDate": "2013-10-11",
45            "Status": "Draft",
46            "billingCity": "SFO-Inside-OrderEntity-1",
47            "contractId": "800D0000000PFL8IAO",
48            "pricebook2Id": "01sD0000000G2JbIAK",
49            "OrderItems": {
50               "records": [
51                  {
52                     "attributes": {
53                        "type": "OrderItem"
54                           },
55                     "PricebookEntryId": "01uD0000001cAkRIAU",
56                     "quantity": "11",
57                     "UnitPrice": "10"
58                        },
59                     {
60                     "attributes": {
61                        "type": "OrderItem"
62                        },
63                     "PricebookEntryId": "01uD0000001cAkWIAU",
64                     "quantity": "2",
65                     "UnitPrice": "20"
66                        },
67                     {
68                     "attributes": {
69                        "type": "OrderItem"
70                           },
71                     "PricebookEntryId": "01uD0000001cAkgIAE",
72                     "quantity": "14",
73                     "UnitPrice": "10"
74                        }
75                    ]
76                }
77            }
78            ]
79        }
80      }
81    ]
82}

Example JSON response body 

1{
2  "totalSize" : 1,
3  "done" : true,
4  "records" : [ {
5    "attributes" : {
6      "type" : "Contract"
7    },
8    "Orders" : {
9      "totalSize" : 2,
10      "done" : true,
11      "records" : [ {
12        "attributes" : {
13          "type" : "Order",
14          "url" : "/services/data/v29.0/sobjects/Order/801D0000000G0xsIAC"
15        },
16        "Id" : "801D0000000G0xsIAC",
17        "OrderItems" : {
18          "totalSize" : 2,
19          "done" : true,
20          "records" : [ {
21            "attributes" : {
22              "type" : "OrderItem",
23              "url" : "/services/data/v29.0/sobjects/OrderItem/802D0000000CKoPIAW"
24            },
25            "Id" : "802D0000000CKoPIAW"
26          }, {
27            "attributes" : {
28              "type" : "OrderItem",
29              "url" : "/services/data/v29.0/sobjects/OrderItem/802D0000000CKoQIAW"
30            },
31            "Id" : "802D0000000CKoQIAW"
32          } ]
33        }
34      }, {
35        "attributes" : {
36          "type" : "Order",
37          "url" : "/services/data/v29.0/sobjects/Order/801D0000000G0xtIAC"
38        },
39        "Id" : "801D0000000G0xtIAC",
40        "OrderItems" : {
41          "totalSize" : 3,
42          "done" : true,
43          "records" : [ {
44            "attributes" : {
45              "type" : "OrderItem",
46              "url" : "/services/data/v29.0/sobjects/OrderItem/802D0000000CKoRIAW"
47            },
48            "Id" : "802D0000000CKoRIAW"
49          }, {
50            "attributes" : {
51              "type" : "OrderItem",
52              "url" : "/services/data/v29.0/sobjects/OrderItem/802D0000000CKoSIAW"
53            },
54            "Id" : "802D0000000CKoSIAW"
55          }, {
56            "attributes" : {
57              "type" : "OrderItem",
58              "url" : "/services/data/v29.0/sobjects/OrderItem/802D0000000CKoTIAW"
59            },
60            "Id" : "802D0000000CKoTIAW"
61          } ]
62        }
63      } ]
64    }
65  } ]
66}