API reference
Create a customer subscription
How to create a customer subscription via API
To create a new customer subscription, send a POST request to the /api/customer_subscriptions endpoint, passing the resource arguments in the request body.

Request

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

Arguments

Body Parameter
Type
Required
type
string
Required
attributes.customer_email
string
Required
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional

Example

Request
Response
The following request creates a new customer subscription:
1
curl -g -X POST \
2
'https://yourdomain.commercelayer.io/api/customer_subscriptions' \
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": "customer_subscriptions",
9
"attributes": {
10
"customer_email": "[email protected]"
11
}
12
}
13
}'
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": "customer_subscriptions",
5
"links": {
6
"self": "https://yourdomain.commercelayer.io/api/customer_subscriptions/xYZkjABcde"
7
},
8
"attributes": {
9
"customer_email": "[email protected]",
10
"created_at": "2018-01-01T12:00:00.000Z",
11
"updated_at": "2018-01-01T12:00:00.000Z",
12
"reference": "ANY-EXTERNAL-REFEFERNCE",
13
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
14
"metadata": {
15
"foo": "bar"
16
}
17
},
18
"relationships": {
19
"customer": {
20
"links": {
21
"self": "https://yourdomain.commercelayer.io/api/customer_subscriptions/xYZkjABcde/relationships/customer",
22
"related": "https://yourdomain.commercelayer.io/api/customer_subscriptions/xYZkjABcde/customer"
23
}
24
}
25
},
26
"meta": {
27
"mode": "test"
28
}
29
}
30
}
Copied!
Copy link