Skip to main content
POST
/
api
/
v2
/
platform
/
promotion_rules
Create a Promotion Rule
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({promotion_rule: {promotion_id: '22', type: 'Spree::Promotion::Rules::Country'}})
};

fetch('http://{defaultHost}/api/v2/platform/promotion_rules', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "data": {
    "id": "5",
    "type": "promotion_rule",
    "attributes": {
      "type": null,
      "created_at": "2022-11-08T19:35:01.131Z",
      "updated_at": "2022-11-08T19:35:01.131Z",
      "code": null,
      "preferences": {}
    },
    "relationships": {
      "promotion": {
        "data": {
          "id": "16",
          "type": "promotion"
        }
      }
    }
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

include
string

Select which associated resources you would like to fetch, see: https://jsonapi.org/format/#fetching-includes

Body

application/json
promotion_rule
object
required

Response

201 - application/vnd.api+json

Record created

data
object
required