Create Subscription Plan
POST/plans
Creates a new subscription plan based on the provided details.
The request must provide the following header: x-api-key: {merchantKey}
In the request example below we are creating a new Prepaid Subscription Plan with a trial duration of 1 day ("trialDurationPeriod": 1
, "trialDurationUnit": "day"
). The consumer will be billed in total 4 times ("billingCycles": 4
) every 1 month ("billingUnit": "month"
, "billingOccurrence": 1
).
Request
Header Parameters
Must be application/json
Must be be en-US
The origin of the request
The client making the request
x-api-key: {merchantKey}
- application/json
Body
required
Name of the Subscription Plan
Description of the Subscription Plan
Possible values: <= 60 characters
Amount to be billed recurrently
Currency code (e.g., EUR). Format: ISO 4217
Possible values: non-empty
and <= 28 characters
Period of the trial. (e.g., 14 days - trialDurationUnit
to be set to days
).
When a Trial duration Unit is provided a trialDurationPeriod
is required.
Possible values: [day
, month
, year
]
Unit of the trial period. When a Trial Duration Period is provided a trialDurationUnit
is required.
Recurrence of the billing occurrences. (e.g., billingOccurrence=1
& billingUnit=month
→ charge the consumer every 1 month)
Possible values: [day
, month
, year
]
Unit of the billing recurrence.
Possible values : [-1 , 120]
Number of the billing occurrences. The count of how many times the customer would be charged. -1 could be sent for unlimited subscription.
Possible values: [true
, false
]
Sending true
would create a pre-paid plan, the value false
would create a post-paid plan. If no value is sent it would be always set to true
by default.
Possible values: <= 255 characters
In this field you could pass information that you deem important to be saved on a subscription plan level which is not covered by the fields above.
Responses
- 201
- 400
- 401
- 403
- 404
- 500
Subscription plan created successfully
- application/json
- Schema
- Example (from schema)
- Example
Schema
Unique Identifier of the Subscription Plan. Format: SubscriptionPlan + - + <UUID>
Timestamp of when the Subscription Plan was created.
Timestamp of when the Subscription Plan was last updated.
Timestamp of when the Subscription Plan was deleted (if applicable).
Possible values: <= 255 characters
Name of the Subscription Plan.
Possible values: <= 255 characters
Description of the Subscription Plan.
Possible values: <= 60 characters
Amount to be billed recurrently.
Possible values: >= 3 characters
and <= 3 characters
Currency code. Format ISO 4217.
Possible values: >= 1
and <= 28
Period of the trial. MinValue 1, MaxValue 28.
Possible values: [day
, month
, year
]
Unit of the trial period.
Recurrence of the billing occurrences.
Possible values: [day
, month
, year
]
Unit of the billing recurrence.
Possible values: >= -1
and <= 120
Number of the billing occurrences. -1 for unlimited subscription.
Default value: true
The value would be true
for pre-paid and false
for post-paid.
Possible values: <= 255 characters
Field that allows the merchant to store specific metadata linked with the subscription plan.
{
"id": "SubscriptionPlan-12033695-99d8-4dc6-bf51-db64ef27620b",
"createdAt": "2021-03-17T17:18:53.01Z",
"updatedAt": "2021-03-17T17:18:53.01Z",
"deletedAt": null,
"name": "Premium",
"description": "Premium sub for only 90.99 EUR!",
"recurrentAmount": 90.99,
"currencyIsoCode": "EUR",
"trialDurationPeriod": 1,
"trialDurationUnit": "day",
"billingUnit": "month",
"billingOccurrence": 1,
"billingCycles": 4,
"prepaid": true,
"merchantMetadata": "{\"orderId\": \"1asd265jh4\", \"usageTracking\": false, \"referenceId\": \"s125jkwh2321\"}"
}
{
"id": "SubscriptionPlan-12033695-99d8-4dc6-bf51-db64ef27620b",
"createdAt": "2021-03-17T17:18:53.01Z",
"updatedAt": "2021-03-17T17:18:53.01Z",
"deletedAt": null,
"name": "Premium",
"description": "Premium sub for only 90.99 EUR!",
"recurrentAmount": 90.99,
"currencyIsoCode": "EUR",
"trialDurationPeriod": 1,
"trialDurationUnit": "day",
"billingUnit": "month",
"billingOccurrence": 1,
"billingCycles": 4,
"prepaid": true,
"merchantMetadata": "{\"orderId\": 1asd265jh4, \"usageTracking\": false, \"referenceId\": s125jkwh2321 }"
}
Bad Request
For error handling, please refer to this section.
- application/json
- Schema
- Example (from schema)
- Example
Schema
Array [
]
Internally generated trace_id
for this error message so it can be found easily in the logs.
errors
object[]
A predefined string which describes the error. The purpose of the message is to allow for future usage of translation.
A pre-defined code from the list of error codes.
The property from the request object which the error is linked to.
context
object
A json object containing a list of predefined properties which are filled based on the error.
{
"traceId": "string",
"errors": [
{
"message": "string",
"code": "string",
"property": "string",
"context": {
"type": "string",
"minimum": 0,
"maximum": 0,
"maxLength": 0,
"allowedValues": [
"string"
]
}
}
]
}
{
"traceId": "00-1234567890abcdef0123456789abcdef-0123456789abcdef-00",
"errors": [
{
"message": "Value out of bounds. Value must be between 1 and 100",
"code": "value_out_of_bounds",
"property": "someField",
"context": {
"minimum": 1,
"maximum": 100
}
}
]
}
Unauthenticated
For error handling, please refer to this section.
- application/json
- Schema
- Example (from schema)
- Example
Schema
Array [
]
Internally generated trace_id
for this error message so it can be found easily in the logs.
errors
object[]
A predefined string which describes the error. The purpose of the message is to allow for future usage of translation.
A pre-defined code from the list of error codes.
The property from the request object which the error is linked to.
context
object
A json object containing a list of predefined properties which are filled based on the error.
{
"traceId": "string",
"errors": [
{
"message": "string",
"code": "string",
"property": "string",
"context": {
"type": "string",
"minimum": 0,
"maximum": 0,
"maxLength": 0,
"allowedValues": [
"string"
]
}
}
]
}
{
"traceId": "00-1234567890abcdef0123456789abcdef-0123456789abcdef-00",
"errors": [
{
"message": "You are not authenticated to perform this request.",
"code": "unauthorized"
}
]
}
Forbidden
For error handling, please refer to this section.
- application/json
- Schema
- Example (from schema)
- Example
Schema
Array [
]
Internally generated trace_id
for this error message so it can be found easily in the logs.
errors
object[]
A predefined string which describes the error. The purpose of the message is to allow for future usage of translation.
A pre-defined code from the list of error codes.
The property from the request object which the error is linked to.
context
object
A json object containing a list of predefined properties which are filled based on the error.
{
"traceId": "string",
"errors": [
{
"message": "string",
"code": "string",
"property": "string",
"context": {
"type": "string",
"minimum": 0,
"maximum": 0,
"maxLength": 0,
"allowedValues": [
"string"
]
}
}
]
}
{
"traceId": "00-1234567890abcdef0123456789abcdef-0123456789abcdef-00",
"errors": [
{
"message": "You do not have permissions to perform this request.",
"code": "forbidden"
}
]
}
Not Found
For error handling, please refer to this section.
- application/json
- Schema
- Example (from schema)
- Example
Schema
Array [
]
Internally generated trace_id
for this error message so it can be found easily in the logs.
errors
object[]
A predefined string which describes the error. The purpose of the message is to allow for future usage of translation.
A pre-defined code from the list of error codes.
The property from the request object which the error is linked to.
context
object
A json object containing a list of predefined properties which are filled based on the error.
{
"traceId": "string",
"errors": [
{
"message": "string",
"code": "string",
"property": "string",
"context": {
"type": "string",
"minimum": 0,
"maximum": 0,
"maxLength": 0,
"allowedValues": [
"string"
]
}
}
]
}
{
"traceId": "00-1234567890abcdef0123456789abcdef-0123456789abcdef-00",
"errors": [
{
"message": "Resource not found.",
"code": "not_found"
}
]
}
Internal Server Error
For error handling, please refer to this section.
- application/json
- Schema
- Example (from schema)
- Example
Schema
Array [
]
Internally generated trace_id
for this error message so it can be found easily in the logs.
errors
object[]
A predefined string which describes the error. The purpose of the message is to allow for future usage of translation.
A pre-defined code from the list of error codes.
The property from the request object which the error is linked to.
context
object
A json object containing a list of predefined properties which are filled based on the error.
{
"traceId": "string",
"errors": [
{
"message": "string",
"code": "string",
"property": "string",
"context": {
"type": "string",
"minimum": 0,
"maximum": 0,
"maxLength": 0,
"allowedValues": [
"string"
]
}
}
]
}
{
"traceId": "00-1234567890abcdef0123456789abcdef-0123456789abcdef-00",
"errors": [
{
"message": "Internal server error."
}
]
}