Search…
API Reference
Resources
Create a return
How to create a return via API
To create a new return, send a POST request to the /api/returns endpoint, passing the resource arguments in the request body.

Request

POST https://yourdomain.commercelayer.io/api/returns

Arguments

Body Parameter
Type
Required
type
string
Required
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional
relationships.order
object
Required
relationships.stock_location
object
Optional

Example

Request
Response
The following request creates a new return:
1
curl -g -X POST \
2
'https://yourdomain.commercelayer.io/api/returns' \
3
-H 'Accept: application/vnd.api+json' \
4
-H 'Authorization: Bearer your-access-token' \
5
-H 'Content-Type: application/vnd.api+json' \
6
-d '{
7
"data": {
8
"type": "returns",
9
"relationships": {
10
"order": {
11
"data": {
12
"type": "orders",
13
"id": "QWERtyUpBa"
14
}
15
}
16
}
17
}
18
}'
Copied!
On success, the API responds with a 201 Created status code, returning the created resource object:
1
{
2
"data": {
3
"id": "xYZkjABcde",
4
"type": "returns",
5
"links": {
6
"self": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde"
7
},
8
"attributes": {
9
"number": "#1234/R/001",
10
"status": "draft",
11
"customer_email": "[email protected]",
12
"skus_count": 2,
13
"approved_at": "2018-01-01T12:00:00.000Z",
14
"cancelled_at": "2018-01-01T12:00:00.000Z",
15
"shipped_at": "2018-01-01T12:00:00.000Z",
16
"rejected_at": "2018-01-01T12:00:00.000Z",
17
"received_at": "2018-01-01T12:00:00.000Z",
18
"archived_at": "2018-01-01T12:00:00.000Z",
19
"created_at": "2018-01-01T12:00:00.000Z",
20
"updated_at": "2018-01-01T12:00:00.000Z",
21
"reference": "ANY-EXTERNAL-REFEFERNCE",
22
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
23
"metadata": {
24
"foo": "bar"
25
}
26
},
27
"relationships": {
28
"order": {
29
"links": {
30
"self": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde/relationships/order",
31
"related": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde/order"
32
}
33
},
34
"customer": {
35
"links": {
36
"self": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde/relationships/customer",
37
"related": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde/customer"
38
}
39
},
40
"stock_location": {
41
"links": {
42
"self": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde/relationships/stock_location",
43
"related": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde/stock_location"
44
}
45
},
46
"origin_address": {
47
"links": {
48
"self": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde/relationships/origin_address",
49
"related": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde/origin_address"
50
}
51
},
52
"destination_address": {
53
"links": {
54
"self": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde/relationships/destination_address",
55
"related": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde/destination_address"
56
}
57
},
58
"return_line_items": {
59
"links": {
60
"self": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde/relationships/return_line_items",
61
"related": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde/return_line_items"
62
}
63
},
64
"attachments": {
65
"links": {
66
"self": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde/relationships/attachments",
67
"related": "https://yourdomain.commercelayer.io/api/returns/xYZkjABcde/attachments"
68
}
69
}
70
},
71
"meta": {
72
"mode": "test"
73
}
74
}
75
}
Copied!
Last modified 20d ago
Copy link