Add a Contract and Orders to an Existing Account

Here’s an example of a POST request using the Create Contract-based Orders resource to create a contract—with child orders, order products, and custom objects—to an existing account.

Example usage 

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

Example request body 

1{
2    "contract": [
3        {
4            "attributes": {
5                "type": "Contract"
6            },
7            "AccountId": "001D000000JRDAv",
8            "StartDate": "2013-08-01",
9            "Status": "Draft",
10            "ContractTerm": "1",
11            "Test_Contract1__r": {
12                "records": [
13                    {
14                        "attributes": {
15                            "type": "Test_Contract1__c"
16                        },
17                        "Name": "Contract Custom Object"
18                    }
19                ]
20            },
21            "Orders": {
22                "records": [
23                    {
24                        "attributes": {
25                            "type": "Order"
26                        },
27                        "EffectiveDate": "2013-08-11",
28                        "Status": "Draft",
29                        "billingCity": "SFO-Inside-OrderEntity-1",
30                        "Pricebook2Id": "01sD0000000G2NjIAK",
31                        "OrderItems": {
32                            "records": [
33                                {
34                                    "attributes": {
35                                        "type": "OrderItem"
36                                    },
37                                    "PricebookEntryId": "01uD0000001c5toIAA",
38                                    "quantity": "1",
39                                    "UnitPrice": "10"
40                                }
41                            ]
42                        }
43                    }
44                ]
45            }
46        }
47    ]
48}

Example JSON response body 

1{
2  "totalSize" : 1,
3  "done" : true,
4  "records" : [ {
5    "attributes" : {
6      "type" : "Contract",
7      "url" : "/services/data/v30.0/sobjects/Contract/800D0000000PIcMIAW"
8    },
9    "Id" : "800D0000000PIcMIAW",
10    "Orders" : {
11      "totalSize" : 1,
12      "done" : true,
13      "records" : [ {
14        "attributes" : {
15          "type" : "Order",
16          "url" : "/services/data/v30.0/sobjects/Order/801D0000000G0ylIAC"
17        },
18        "Id" : "801D0000000G0ylIAC",
19        "OrderItems" : {
20          "totalSize" : 1,
21          "done" : true,
22          "records" : [ {
23            "attributes" : {
24              "type" : "OrderItem",
25              "url" : "/services/data/v30.0/sobjects/OrderItem/802D0000000CKoyIAG"
26            },
27            "Id" : "802D0000000CKoyIAG"
28          } ]
29        }
30      } ]
31    },
32    "Test_Contract1__r" : {
33      "totalSize" : 1,
34      "done" : true,
35      "records" : [ {
36        "attributes" : {
37          "type" : "Test_Contract1__c",
38          "url" : "/services/data/v30.0/sobjects/Test_Contract1__c/a02D0000006YYKZIA4"
39        },
40        "Id" : "a02D0000006YYKZIA4"
41      } ]
42    }
43  } ]
44}