Create a subscription model

How to create a subscription model via API

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

Request

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

Arguments

Body ParameterTypeRequired

type

string

Required

attributes.name

string

Required

attributes.strategy

string

Optional, default is by_frequency

attributes.frequencies

array

Required

attributes.auto_activate

boolean

Optional, default is 'true'

attributes.auto_cancel

boolean

Optional, default is 'false'

attributes.reference

string

Optional

attributes.reference_origin

string

Optional

attributes.metadata

object

Optional

Example

The following request creates a new subscription model:

curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/subscription_models' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "subscription_models",
    "attributes": {
      "name": "EU Subscription Model",
      "frequencies": [
        "hourly",
        "10 * * * *",
        "weekly",
        "monthly",
        "two-month"
      ]
    }
  }
}'

Last updated