Create a stock reservation
How to create a stock reservation via API
To create a new stock reservation, send a POST
request to the /api/stock_reservations
endpoint, passing the resource arguments in the request body.
Request
POST https://yourdomain.commercelayer.io/api/stock_reservations
Arguments
Body Parameter | Type | Required |
---|
| | |
| | |
| | |
attributes.reference_origin | | |
| | |
| | |
Example
The following request creates a new stock reservation:
curl -g -X POST \
'https://yourdomain.commercelayer.io/api/stock_reservations' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer your-access-token' \
-H 'Content-Type: application/vnd.api+json' \
-d '{
"data": {
"type": "stock_reservations",
"attributes": {
"quantity": 4
},
"relationships": {
"stock_item": {
"data": {
"type": "stock_items",
"id": "ABCRtyUpBa"
}
}
}
}
}'
On success, the API responds with a 201 Created
status code, returning the created resource object:
{
"data": {
"id": "xYZkjABcde",
"type": "stock_reservations",
"links": {
"self": "https://yourdomain.commercelayer.io/api/stock_reservations/xYZkjABcde"
},
"attributes": {
"status": "draft",
"quantity": 4,
"expires_at": "2018-01-02T12:00:00.000Z",
"created_at": "2018-01-01T12:00:00.000Z",
"updated_at": "2018-01-01T12:00:00.000Z",
"reference": "ANY-EXTERNAL-REFEFERNCE",
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
"metadata": {
"foo": "bar"
}
},
"relationships": {
"line_item": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/stock_reservations/xYZkjABcde/relationships/line_item",
"related": "https://yourdomain.commercelayer.io/api/stock_reservations/xYZkjABcde/line_item"
}
},
"order": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/stock_reservations/xYZkjABcde/relationships/order",
"related": "https://yourdomain.commercelayer.io/api/stock_reservations/xYZkjABcde/order"
}
},
"stock_item": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/stock_reservations/xYZkjABcde/relationships/stock_item",
"related": "https://yourdomain.commercelayer.io/api/stock_reservations/xYZkjABcde/stock_item"
}
},
"reserved_stock": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/stock_reservations/xYZkjABcde/relationships/reserved_stock",
"related": "https://yourdomain.commercelayer.io/api/stock_reservations/xYZkjABcde/reserved_stock"
}
},
"sku": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/stock_reservations/xYZkjABcde/relationships/sku",
"related": "https://yourdomain.commercelayer.io/api/stock_reservations/xYZkjABcde/sku"
}
}
},
"meta": {
"mode": "test"
}
}
}
Last updated