API Reference
Resources
Create a fixed price promotion
How to create a fixed price promotion via API
To create a new fixed price promotion, send a POST request to the /api/fixed_price_promotions endpoint, passing the resource arguments in the request body.

Request

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

Arguments

Body Parameter
Type
Required
type
string
Required
attributes.name
string
Required
attributes.starts_at
datetime
Required
attributes.expires_at
datetime
Required
attributes.total_usage_limit
integer
Required
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional
attributes.fixed_amount_cents
integer
Required
relationships.market
object
Required, unless in scope
relationships.promotion_rules
array
Optional
relationships.order_amount_promotion_rule
object
Optional
relationships.sku_list_promotion_rule
object
Optional
relationships.coupon_codes_promotion_rule
object
Optional
relationships.sku_list
object
Required

Example

Request
Response
The following request creates a new fixed price promotion:
1
curl -g -X POST \
2
'https://yourdomain.commercelayer.io/api/fixed_price_promotions' \
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": "fixed_price_promotions",
9
"attributes": {
10
"name": "Personal promotion",
11
"starts_at": "2018-01-01T12:00:00.000Z",
12
"expires_at": "2018-01-02T12:00:00.000Z",
13
"total_usage_limit": 5,
14
"fixed_amount_cents": 1000
15
},
16
"relationships": {
17
"market": {
18
"data": {
19
"type": "markets",
20
"id": "QWERtyUpBa"
21
}
22
},
23
"sku_list": {
24
"data": {
25
"type": "sku_lists",
26
"id": "QWERtyUpBa"
27
}
28
}
29
}
30
}
31
}'
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": "fixed_price_promotions",
5
"links": {
6
"self": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde"
7
},
8
"attributes": {
9
"name": "Personal promotion",
10
"starts_at": "2018-01-01T12:00:00.000Z",
11
"expires_at": "2018-01-02T12:00:00.000Z",
12
"total_usage_limit": 5,
13
"total_usage_count": 2,
14
"active": true,
15
"created_at": "2018-01-01T12:00:00.000Z",
16
"updated_at": "2018-01-01T12:00:00.000Z",
17
"reference": "ANY-EXTERNAL-REFEFERNCE",
18
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
19
"metadata": {
20
"foo": "bar"
21
},
22
"fixed_amount_cents": 1000,
23
"fixed_amount_float": 10.0,
24
"formatted_fixed_amount": "€10,00"
25
},
26
"relationships": {
27
"market": {
28
"links": {
29
"self": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/relationships/market",
30
"related": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/market"
31
}
32
},
33
"promotion_rules": {
34
"links": {
35
"self": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/relationships/promotion_rules",
36
"related": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/promotion_rules"
37
}
38
},
39
"order_amount_promotion_rule": {
40
"links": {
41
"self": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/relationships/order_amount_promotion_rule",
42
"related": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/order_amount_promotion_rule"
43
}
44
},
45
"sku_list_promotion_rule": {
46
"links": {
47
"self": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/relationships/sku_list_promotion_rule",
48
"related": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/sku_list_promotion_rule"
49
}
50
},
51
"coupon_codes_promotion_rule": {
52
"links": {
53
"self": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/relationships/coupon_codes_promotion_rule",
54
"related": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/coupon_codes_promotion_rule"
55
}
56
},
57
"attachments": {
58
"links": {
59
"self": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/relationships/attachments",
60
"related": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/attachments"
61
}
62
},
63
"sku_list": {
64
"links": {
65
"self": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/relationships/sku_list",
66
"related": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/sku_list"
67
}
68
},
69
"skus": {
70
"links": {
71
"self": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/relationships/skus",
72
"related": "https://yourdomain.commercelayer.io/api/fixed_price_promotions/xYZkjABcde/skus"
73
}
74
}
75
},
76
"meta": {
77
"mode": "test"
78
}
79
}
80
}
Copied!
Last modified 2mo ago
Copy link