Create an order subscription

How to create an order subscription via API

To create a new order subscription, send a POST request to the /api/order_subscriptions endpoint, passing the resource arguments in the request body.

Request

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

Arguments

Body ParameterTypeRequired

type

string

Required

attributes.frequency

string

Required

attributes.activate_by_source_order

boolean

Optional, default is 'true'

attributes.place_target_order

boolean

Optional, default is 'true'

attributes.renewal_alert_period

integer

Optional, default is "1"

attributes.starts_at

datetime

Required, unless activate_by_source_order

attributes.expires_at

datetime

Optional

attributes.reference

string

Optional

attributes.reference_origin

string

Optional

attributes.metadata

object

Optional

relationships.market

object

Optional

relationships.source_order

object

Required

relationships.tags

array

Optional

Example

The following request creates a new order subscription:

curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/order_subscriptions' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "order_subscriptions",
    "attributes": {
      "frequency": "monthly",
      "starts_at": "2018-01-01T12:00:00.000Z"
    },
    "relationships": {
      "source_order": {
        "data": {
          "type": "orders",
          "id": "ABCRtyUpBa"
        }
      }
    }
  }
}'

Last updated