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

Request

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

Arguments

Body Parameter
Type
Required
type
string
Required
attributes.sku_code
string
Optional
attributes.quantity
integer
Required
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional
relationships.sku
object
Required
relationships.origin_stock_location
object
Required
relationships.destination_stock_location
object
Required
relationships.shipment
object
Optional
relationships.line_item
object
Optional

Example

Request
Response
The following request creates a new stock transfer:
1
curl -g -X POST \
2
'https://yourdomain.commercelayer.io/api/stock_transfers' \
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": "stock_transfers",
9
"attributes": {
10
"quantity": 2
11
},
12
"relationships": {
13
"sku": {
14
"data": {
15
"type": "skus",
16
"id": "QWERtyUpBa"
17
}
18
},
19
"origin_stock_location": {
20
"data": {
21
"type": "stock_locations",
22
"id": "QWERtyUpBa"
23
}
24
},
25
"destination_stock_location": {
26
"data": {
27
"type": "stock_locations",
28
"id": "QWERtyUpBa"
29
}
30
}
31
}
32
}
33
}'
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": "stock_transfers",
5
"links": {
6
"self": "https://yourdomain.commercelayer.io/api/stock_transfers/xYZkjABcde"
7
},
8
"attributes": {
9
"sku_code": "TSHIRTMM000000FFFFFFXLXX",
10
"status": "draft",
11
"quantity": 2,
12
"completed_at": "2018-01-01T12:00:00.000Z",
13
"cancelled_at": "2018-01-01T12:00:00.000Z",
14
"created_at": "2018-01-01T12:00:00.000Z",
15
"updated_at": "2018-01-01T12:00:00.000Z",
16
"reference": "ANY-EXTERNAL-REFEFERNCE",
17
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
18
"metadata": {
19
"foo": "bar"
20
}
21
},
22
"relationships": {
23
"sku": {
24
"links": {
25
"self": "https://yourdomain.commercelayer.io/api/stock_transfers/xYZkjABcde/relationships/sku",
26
"related": "https://yourdomain.commercelayer.io/api/stock_transfers/xYZkjABcde/sku"
27
}
28
},
29
"origin_stock_location": {
30
"links": {
31
"self": "https://yourdomain.commercelayer.io/api/stock_transfers/xYZkjABcde/relationships/origin_stock_location",
32
"related": "https://yourdomain.commercelayer.io/api/stock_transfers/xYZkjABcde/origin_stock_location"
33
}
34
},
35
"destination_stock_location": {
36
"links": {
37
"self": "https://yourdomain.commercelayer.io/api/stock_transfers/xYZkjABcde/relationships/destination_stock_location",
38
"related": "https://yourdomain.commercelayer.io/api/stock_transfers/xYZkjABcde/destination_stock_location"
39
}
40
},
41
"shipment": {
42
"links": {
43
"self": "https://yourdomain.commercelayer.io/api/stock_transfers/xYZkjABcde/relationships/shipment",
44
"related": "https://yourdomain.commercelayer.io/api/stock_transfers/xYZkjABcde/shipment"
45
}
46
},
47
"line_item": {
48
"links": {
49
"self": "https://yourdomain.commercelayer.io/api/stock_transfers/xYZkjABcde/relationships/line_item",
50
"related": "https://yourdomain.commercelayer.io/api/stock_transfers/xYZkjABcde/line_item"
51
}
52
}
53
},
54
"meta": {
55
"mode": "test"
56
}
57
}
58
}
Copied!
Last modified 2mo ago
Copy link