Skip to main content

Plan CRUD

Our API enables you to perform basic CRUD operations on the plan entity.

CREATE plan

If you want to create a product plan use a request similar to this one:

curl -X 'POST' \
'https://stage-api.payments.ai/v1/organizations/:organizationId/plans' \
-H 'accept: application/json' \
-H 'Authorization: ApiKey <keyValue>' \
-H 'Content-Type: application/json' \
-d '{
"name":"Test plan",
"currency":"currencyCode",
"productId":"productId",
"pricing":{
"price":123,
"formula":"pricingFormula"
},
"description":"test",
"richDescription":"test",
"isActive":true,
"isTrialOnly":false
}' \
-v

If you want to create a plan with trial only, use a request similar to this one:

curl -X 'POST' \
'https://stage-api.payments.ai/v1/organizations/:organizationId/plans' \
-H 'accept: application/json' \
-H 'Authorization: ApiKey <keyValue>' \
-H 'Content-Type: application/json' \
-d '{
"name": "Test plan",
"currency": "currencyCode",
"productId": "productId",
"pricing": {
"price": 1,
"formula": "pricingFormula",
},
"trial": {
"price": 0,
"period": {
"unit": "day",
"length": 1,
},
},
"description": "test",
"richDescription": "test",
"isActive": true
}' \
-v

If you want to create a plan with subscription, use a request similar to this one:

curl -X 'POST' \
'https://stage-api.payments.ai/v1/organizations/:organizationId/plans' \
-H 'accept: application/json' \
-H 'Authorization: ApiKey <keyValue>' \
-H 'Content-Type: application/json' \
-d '{
"name": "Test plan",
"currency": "currencyCode",
"productId": "productId",
"pricing": {
"price": 1,
"formula": "pricingFormula",
},
"recurringInterval": {
"periodAnchorInstruction": {
"method": "day-of-month",
"day": 20,
},
"unit": "month",
"limit": 1,
"length": 1,
"billingTiming": "prepaid",
},
"trial": {
"price": 0,
"period": {
"unit": "day",
"length": 1,
},
},
"description": "test",
"richDescription": "test",
"isActive": true,
}' \
-v

READ plans

To get list of plans related to your organization please use a request similar to this one:

curl -X 'GET' \
'https://dev-api.payments.ai/v1/organizations/:organizationId/plans' \
-H 'accept: application/json' \
-H 'Authorization: ApiKey <keyValue>'

READ Plan by Id

After you have created a product you can view its properties by using a request similar to this one:

curl -X 'GET' \
'https://stage-api.payments.ai/v1/organizations/:organizationId/plans/:planId' \
-H 'accept: application/json' \
-H 'Authorization: ApiKey <keyValue>'

UPDATE plan

In addition, you are able to update the product by using a request similar to this one:

curl -X 'PUT' \
'https://stage-api.payments.ai/v1/organizations/:organizationId/plans/:planId' \
-H 'accept: application/json' \
-H 'Authorization: ApiKey <keyValue>' \
-H 'Content-Type: application/json' \
-d '{
"name":"Updated test plan",
"currency":"currencyCode",
"productId":"productId",
"pricing":{
"price":456,
"formula":"pricingFormula"
},
"description":"updated test",
"richDescription":"updated test"
}'

DELETE plan

Finally, if can delete a ceated plan by using a request similar to this one:

curl -X 'DELETE' \
'https://stage-api.payments.ai/v1/organizations/:organizationId/plans/:planId' \
-H 'accept: application/json' \
-H 'Authorization: ApiKey <keyValue>'