REST API

REST Examples: Creating a Subscription

Request to Create a Subscription with a Pre-Existing Plan
{ "subscriptionInformation": { "planId":"1619214515", "name": "Daily Gym Subscription", "startDate": "2023-04-15T17:01:42Z" }, "paymentInformation": { "customer": { "id": "C09F227C54F94951E0533F36CF0A3D91" } } }
Response from a Request to Create a Subscription with a Pre-Existing Plan
{ "_links": { "self": { "href": "/rbs/v1/subscriptions/1619214690", "method": "GET" }, "update": { "href": "/rbs/v1/subscriptions/1619214690", "method": "PATCH" }, "cancel": { "href": "/rbs/v1/subscriptions/1619214690/cancel", "method": "POST" } }, "id": "1619214690", "status": "COMPLETED", "subscriptionInformation": { "code": "AWC-47", "status": "PENDING" } }
Error Response to a Request to Create a Subscription with a Pre-Existing Plan
{ "status": "INVALID_REQUEST", "reason": "INVALID_DATA", "message": "One or more fields in the request contains invalid data.", "details": [ { "field": "subscriptionInformation.startDate", "reason": "INVALID_DATA" } ] }
Request to Create a Subscription with Subscription Overrides
{ "subscriptionInformation": { "planId": "1619214515", "name": "SubName With Overrides", "startDate": "2023-04-16T17:01:42Z" }, "planInformation": { "billingCycles": { "total": "3" } }, "orderInformation": { "amountDetails": { "billingAmount": "13.14", "setupFee": "1.27" } }, "paymentInformation": { "customer": { "id": "C09F227C54F94951E0533F36CF0A3D91" } } }
Successful Response to a Request to Create a Subscription with Subscription Overrides
{ "_links": { "self": { "href": "/rbs/v1/subscriptions/1619214795", "method": "GET" }, "update": { "href": "/rbs/v1/subscriptions/1619214795", "method": "PATCH" }, "cancel": { "href": "/rbs/v1/subscriptions/1619214795/cancel", "method": "POST" } }, "id": "1619214795", "status": "COMPLETED", "subscriptionInformation": { "code": "AWC-48", "status": "PENDING" } }
Error Response to a Request to Create a Subscription with Subscription Overrides
{ "status": "INVALID_REQUEST", "reason": "DUPLICATE_REQUEST", "message": "Duplicate requests are not supported within 15 minutes.", "details": [ { "field": "subscriptionInformation.planId or paymentInformation.customer.id or subscriptionInformation.startDate or subscriptionInformation.name", "subscriptionId": "1619214795", "reason": "INVALID_DATA" } ] }
Request to Create a Fully Customized Subscription with a One-Time Payment
{ "subscriptionInformation": { "name": "SubName Testing", "startDate": "2023-04-18T17:01:42Z" }, "planInformation": { "billingCycles": { "total":"5" }, "billingPeriod": { "length": "3", "unit":"D" } }, "orderInformation": { "amountDetails": { "billingAmount": "1.21", "setupFee": "1.44", "currency":"USD" } }, "paymentInformation": { "customer": { "id": "C09F227C54F94951E0533F36CF0A3D91" } } }
Response to a Successful Request to Create a Fully Customized Subscription with a One-Time Payment
{ "_links": { "self": { "href": "/rbs/v1/subscriptions/1619214861", "method": "GET" }, "update": { "href": "/rbs/v1/subscriptions/1619214861", "method": "PATCH" }, "cancel": { "href": "/rbs/v1/subscriptions/1619214861/cancel", "method": "POST" } }, "id": "1619214861", "status": "COMPLETED", "subscriptionInformation": { "code": "AWC-49", "status": "PENDING" } }
Error Response to a Request to Create a Fully Customized Subscription with a One-Time Payment
{ "status": "INVALID_REQUEST", "reason": "INVALID_DATA", "message": "One or more fields in the request contains invalid data.", "details": [ { "field": "planInformation.billingPeriod.length", "reason": "MAX_LENGTH" } ] }