Create a subscription
POSThttps://euwest.api.elasticpath.com/v2/subscriptions/subscriptions
Create a subscription
Request
Query Parameters
filter string
- application/json
Body
data BuildSubscriptionrequired
Responses
- 201
- 400
- 500
Success. The subscription is created.
- application/json
- Schema
- Example (from schema)
Schema
data Subscription
{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "subscription",
"attributes": {
"external_ref": "abc123",
"account_id": "00000000-0000-0000-0000-000000000000",
"address_id": "00000000-0000-0000-0000-000000000000",
"offering": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "subscription_offering",
"attributes": {
"external_ref": "abc123",
"name": "Magazine",
"description": "A lovely magazine that is published every month.",
"updated_at": "2017-01-10T11:41:19.244842Z",
"created_at": "2017-01-10T11:41:19.244842Z"
},
"relationships": {
"plans": {
"links": {
"related": "/offerings/:offering-id/plans",
"self": "/offerings/:offering-id"
},
"data": {
"type": "offering-plan",
"id": "625fe958-7b4b-40a0-a2c0-dbb8f31eec0d"
}
}
},
"meta": {
"external_product_refs": [
"97dddc65-eabd-45d8-b45b-2ece5cfc8c50"
],
"owner": "store",
"timestamps": {
"updated_at": "2017-01-10T11:41:19.244842Z",
"created_at": "2017-01-10T11:41:19.244842Z"
}
}
},
"plan_id": "00000000-0000-0000-0000-000000000000",
"currency": "USD",
"payment_authority": {}
},
"relationships": {
"plans": {
"links": {
"related": "/offerings/:offering-id/plans",
"self": "/offerings/:offering-id"
},
"data": {
"type": "offering-plan",
"id": "625fe958-7b4b-40a0-a2c0-dbb8f31eec0d"
}
}
},
"meta": {
"owner": "store",
"timestamps": {
"updated_at": "2017-01-10T11:41:19.244842Z",
"created_at": "2017-01-10T11:41:19.244842Z",
"canceled_at": "2017-01-10T11:41:19.244842Z",
"paused_at": "2017-01-10T11:41:19.244842Z",
"resumed_at": "2017-01-10T11:41:19.244842Z",
"end_date": "2017-01-10T11:41:19.244842Z",
"go_live_after": "2017-01-10T11:41:19.244842Z",
"go_live": "2017-01-10T11:41:19.244842Z"
},
"status": "active",
"state": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "subscription_state",
"attributes": {
"action": "cancel"
},
"meta": {
"created_at": "2017-01-10T11:41:19.244842Z"
}
},
"manual_payments": false,
"canceled": true,
"paused": true,
"closed": true,
"suspended": false,
"pending": false,
"invoice_after": "2017-01-10T11:41:19.244842Z"
}
}
}
Bad request. The request failed validation.
- application/json
- Schema
- Example (from schema)
- missing-name
Schema
errors Error[]required
{
"errors": [
{
"status": 500,
"title": "Internal server error",
"detail": "An internal error has occurred.",
"meta": {
"missing_ids": [
"e7d50bd5-1833-43c0-9848-f9d325b08be8"
]
}
}
]
}
{
"errors": [
{
"title": "Validation Error",
"status": "400",
"detail": "data.attributes.name: \"name\" is required"
}
]
}
Internal server error. There was a system failure in the platform.
- application/json
- Schema
- Example (from schema)
- internal-server-error
Schema
errors Error[]required
{
"errors": [
{
"status": 500,
"title": "Internal server error",
"detail": "An internal error has occurred.",
"meta": {
"missing_ids": [
"e7d50bd5-1833-43c0-9848-f9d325b08be8"
]
}
}
]
}
{
"errors": [
{
"title": "Internal Server Error",
"status": "500"
}
]
}
Authorization: http
name: BearerTokentype: httpscheme: bearer
- curl
- python
- go
- nodejs
- ruby
- csharp
- php
- java
- powershell
- CURL
curl -L -X POST 'https://euwest.api.elasticpath.com/v2/subscriptions/subscriptions' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
--data-raw '{
"data": {
"external_ref": "abc123",
"account_id": "00000000-0000-0000-0000-000000000000",
"address_id": "00000000-0000-0000-0000-000000000000",
"offering_external_ref": "abc123",
"offering_id": "00000000-0000-0000-0000-000000000000",
"plan_id": "00000000-0000-0000-0000-000000000000",
"currency": "USD",
"payment_authority": {
"type": "elastic_path_payments_stripe",
"customer_id": "cus_OPfKlxWV3hp9h6",
"card_id": "card_8Diw3FQPhxK27WADPVMeXieP"
},
"manual_payments": false,
"name": "Albert Einstein",
"email": "albert@elasticpath.com",
"pending": false,
"offering": {
"external_ref": "abc123",
"name": "Magazine",
"description": "A lovely magazine that is published every month."
},
"products": [
{
"external_ref": "abc123",
"name": "Magazine",
"description": "A lovely magazine that is published every month.",
"sku": "MAGAZINE1",
"main_image": "https://magazine.com/cover.jpg",
"price": {
"USD": {
"amount": 100,
"includes_tax": false
},
"GBP": {
"amount": 90,
"includes_tax": true
}
},
"price_units": {
"unit": "day",
"amount": 7
}
}
],
"plans": [
{
"external_ref": "abc123",
"name": "Monthly",
"description": "A monthly subscription.",
"billing_interval_type": "month",
"billing_frequency": 1,
"trial_period": 7,
"plan_length": 12,
"end_behavior": "close",
"can_pause": false,
"can_resume": false,
"can_cancel": false,
"base_price_percentage": 90,
"fixed_price": {
"USD": {
"amount": 100,
"includes_tax": false
},
"GBP": {
"amount": 90,
"includes_tax": true
}
},
"meta": {
"selected": true
}
}
],
"selected_plan": "abc123"
}
}'
ResponseClear