Create a plan
curl --request POST \
--url https://coreapi.io/api/plans \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "pro-plan",
"name": "Pro Plan",
"tiers": [
{
"position": 0,
"name": "Starter",
"upgradeable": true,
"downgradeable": false,
"changeTiming": "immediately",
"creditType": "pro_rata",
"items": [
{
"productId": "1280792f-4e23-793d-8e9c-3a1bf36630bd",
"pricePlanId": "e0c546c5-eee0-7219-8847-c0ed16ae4a88",
"defaultQuantity": 1
}
]
},
{
"position": 1,
"name": "Pro",
"upgradeable": true,
"downgradeable": true,
"changeTiming": "immediately",
"creditType": "pro_rata",
"items": [
{
"productId": "f5ece259-08ea-77a4-8bd9-9f3a9ed9e246",
"pricePlanId": "295ad101-5d9f-7f1f-80f5-a9420c21eb1e",
"defaultQuantity": 1
},
{
"productId": "27e3a683-8829-73a8-8acb-5d9fbffb30b6",
"pricePlanId": "a1384760-a089-76a8-82e0-abd2993a39ac",
"defaultQuantity": 1,
"minQuantity": 0,
"maxQuantity": 50
}
]
},
{
"position": 2,
"name": "Business",
"upgradeable": false,
"downgradeable": true,
"changeTiming": "end_of_period",
"creditType": "none",
"items": [
{
"productId": "645077e0-f408-7f73-8f6e-585435440667",
"pricePlanId": "321d6d27-a4aa-7dd7-8395-a57ead3b5ffb",
"defaultQuantity": 1
}
]
}
]
}
'import requests
url = "https://coreapi.io/api/plans"
payload = {
"code": "pro-plan",
"name": "Pro Plan",
"tiers": [
{
"position": 0,
"name": "Starter",
"upgradeable": True,
"downgradeable": False,
"changeTiming": "immediately",
"creditType": "pro_rata",
"items": [
{
"productId": "1280792f-4e23-793d-8e9c-3a1bf36630bd",
"pricePlanId": "e0c546c5-eee0-7219-8847-c0ed16ae4a88",
"defaultQuantity": 1
}
]
},
{
"position": 1,
"name": "Pro",
"upgradeable": True,
"downgradeable": True,
"changeTiming": "immediately",
"creditType": "pro_rata",
"items": [
{
"productId": "f5ece259-08ea-77a4-8bd9-9f3a9ed9e246",
"pricePlanId": "295ad101-5d9f-7f1f-80f5-a9420c21eb1e",
"defaultQuantity": 1
},
{
"productId": "27e3a683-8829-73a8-8acb-5d9fbffb30b6",
"pricePlanId": "a1384760-a089-76a8-82e0-abd2993a39ac",
"defaultQuantity": 1,
"minQuantity": 0,
"maxQuantity": 50
}
]
},
{
"position": 2,
"name": "Business",
"upgradeable": False,
"downgradeable": True,
"changeTiming": "end_of_period",
"creditType": "none",
"items": [
{
"productId": "645077e0-f408-7f73-8f6e-585435440667",
"pricePlanId": "321d6d27-a4aa-7dd7-8395-a57ead3b5ffb",
"defaultQuantity": 1
}
]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: 'pro-plan',
name: 'Pro Plan',
tiers: [
{
position: 0,
name: 'Starter',
upgradeable: true,
downgradeable: false,
changeTiming: 'immediately',
creditType: 'pro_rata',
items: [
{
productId: '1280792f-4e23-793d-8e9c-3a1bf36630bd',
pricePlanId: 'e0c546c5-eee0-7219-8847-c0ed16ae4a88',
defaultQuantity: 1
}
]
},
{
position: 1,
name: 'Pro',
upgradeable: true,
downgradeable: true,
changeTiming: 'immediately',
creditType: 'pro_rata',
items: [
{
productId: 'f5ece259-08ea-77a4-8bd9-9f3a9ed9e246',
pricePlanId: '295ad101-5d9f-7f1f-80f5-a9420c21eb1e',
defaultQuantity: 1
},
{
productId: '27e3a683-8829-73a8-8acb-5d9fbffb30b6',
pricePlanId: 'a1384760-a089-76a8-82e0-abd2993a39ac',
defaultQuantity: 1,
minQuantity: 0,
maxQuantity: 50
}
]
},
{
position: 2,
name: 'Business',
upgradeable: false,
downgradeable: true,
changeTiming: 'end_of_period',
creditType: 'none',
items: [
{
productId: '645077e0-f408-7f73-8f6e-585435440667',
pricePlanId: '321d6d27-a4aa-7dd7-8395-a57ead3b5ffb',
defaultQuantity: 1
}
]
}
]
})
};
fetch('https://coreapi.io/api/plans', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://coreapi.io/api/plans",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => 'pro-plan',
'name' => 'Pro Plan',
'tiers' => [
[
'position' => 0,
'name' => 'Starter',
'upgradeable' => true,
'downgradeable' => false,
'changeTiming' => 'immediately',
'creditType' => 'pro_rata',
'items' => [
[
'productId' => '1280792f-4e23-793d-8e9c-3a1bf36630bd',
'pricePlanId' => 'e0c546c5-eee0-7219-8847-c0ed16ae4a88',
'defaultQuantity' => 1
]
]
],
[
'position' => 1,
'name' => 'Pro',
'upgradeable' => true,
'downgradeable' => true,
'changeTiming' => 'immediately',
'creditType' => 'pro_rata',
'items' => [
[
'productId' => 'f5ece259-08ea-77a4-8bd9-9f3a9ed9e246',
'pricePlanId' => '295ad101-5d9f-7f1f-80f5-a9420c21eb1e',
'defaultQuantity' => 1
],
[
'productId' => '27e3a683-8829-73a8-8acb-5d9fbffb30b6',
'pricePlanId' => 'a1384760-a089-76a8-82e0-abd2993a39ac',
'defaultQuantity' => 1,
'minQuantity' => 0,
'maxQuantity' => 50
]
]
],
[
'position' => 2,
'name' => 'Business',
'upgradeable' => false,
'downgradeable' => true,
'changeTiming' => 'end_of_period',
'creditType' => 'none',
'items' => [
[
'productId' => '645077e0-f408-7f73-8f6e-585435440667',
'pricePlanId' => '321d6d27-a4aa-7dd7-8395-a57ead3b5ffb',
'defaultQuantity' => 1
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "1280792f-4e23-793d-8e9c-3a1bf36630bd",
"code": "pro-plan",
"name": "Pro Plan",
"status": "draft",
"currency": "EUR",
"tiers": [
{
"id": "<string>",
"position": 1,
"name": "Pro",
"upgradeable": true,
"downgradeable": true,
"changeTiming": "immediately",
"creditType": "pro_rata",
"commitmentPeriod": "P1Y",
"items": [
{
"id": "<string>",
"productId": "<string>",
"productName": "Add-On",
"pricePlanId": "<string>",
"pricePlanName": "Add-On Monthly",
"currency": "EUR",
"defaultQuantity": 1,
"minQuantity": 123,
"maxQuantity": 123
}
]
}
],
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}{
"status": 404,
"type": "PLAN__NOT_FOUND",
"title": "An error occurred",
"detail": "Plan not found."
}{
"status": 404,
"type": "PLAN__NOT_FOUND",
"title": "An error occurred",
"detail": "Plan not found."
}{
"status": 404,
"type": "PLAN__NOT_FOUND",
"title": "An error occurred",
"detail": "Plan not found."
}{
"status": 422,
"type": "https://tools.ietf.org/html/rfc2616#section-10",
"title": "Validation Failed",
"violations": [
{
"propertyPath": "tiers[0].name",
"message": "This value should not be blank.",
"code": "<string>"
}
]
}Plan-Verwaltung
Create a plan
Create a new plan with its tiers and items. The plan starts in draft status. Activate it before you sell or switch into it.
POST
/
api
/
plans
Create a plan
curl --request POST \
--url https://coreapi.io/api/plans \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "pro-plan",
"name": "Pro Plan",
"tiers": [
{
"position": 0,
"name": "Starter",
"upgradeable": true,
"downgradeable": false,
"changeTiming": "immediately",
"creditType": "pro_rata",
"items": [
{
"productId": "1280792f-4e23-793d-8e9c-3a1bf36630bd",
"pricePlanId": "e0c546c5-eee0-7219-8847-c0ed16ae4a88",
"defaultQuantity": 1
}
]
},
{
"position": 1,
"name": "Pro",
"upgradeable": true,
"downgradeable": true,
"changeTiming": "immediately",
"creditType": "pro_rata",
"items": [
{
"productId": "f5ece259-08ea-77a4-8bd9-9f3a9ed9e246",
"pricePlanId": "295ad101-5d9f-7f1f-80f5-a9420c21eb1e",
"defaultQuantity": 1
},
{
"productId": "27e3a683-8829-73a8-8acb-5d9fbffb30b6",
"pricePlanId": "a1384760-a089-76a8-82e0-abd2993a39ac",
"defaultQuantity": 1,
"minQuantity": 0,
"maxQuantity": 50
}
]
},
{
"position": 2,
"name": "Business",
"upgradeable": false,
"downgradeable": true,
"changeTiming": "end_of_period",
"creditType": "none",
"items": [
{
"productId": "645077e0-f408-7f73-8f6e-585435440667",
"pricePlanId": "321d6d27-a4aa-7dd7-8395-a57ead3b5ffb",
"defaultQuantity": 1
}
]
}
]
}
'import requests
url = "https://coreapi.io/api/plans"
payload = {
"code": "pro-plan",
"name": "Pro Plan",
"tiers": [
{
"position": 0,
"name": "Starter",
"upgradeable": True,
"downgradeable": False,
"changeTiming": "immediately",
"creditType": "pro_rata",
"items": [
{
"productId": "1280792f-4e23-793d-8e9c-3a1bf36630bd",
"pricePlanId": "e0c546c5-eee0-7219-8847-c0ed16ae4a88",
"defaultQuantity": 1
}
]
},
{
"position": 1,
"name": "Pro",
"upgradeable": True,
"downgradeable": True,
"changeTiming": "immediately",
"creditType": "pro_rata",
"items": [
{
"productId": "f5ece259-08ea-77a4-8bd9-9f3a9ed9e246",
"pricePlanId": "295ad101-5d9f-7f1f-80f5-a9420c21eb1e",
"defaultQuantity": 1
},
{
"productId": "27e3a683-8829-73a8-8acb-5d9fbffb30b6",
"pricePlanId": "a1384760-a089-76a8-82e0-abd2993a39ac",
"defaultQuantity": 1,
"minQuantity": 0,
"maxQuantity": 50
}
]
},
{
"position": 2,
"name": "Business",
"upgradeable": False,
"downgradeable": True,
"changeTiming": "end_of_period",
"creditType": "none",
"items": [
{
"productId": "645077e0-f408-7f73-8f6e-585435440667",
"pricePlanId": "321d6d27-a4aa-7dd7-8395-a57ead3b5ffb",
"defaultQuantity": 1
}
]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: 'pro-plan',
name: 'Pro Plan',
tiers: [
{
position: 0,
name: 'Starter',
upgradeable: true,
downgradeable: false,
changeTiming: 'immediately',
creditType: 'pro_rata',
items: [
{
productId: '1280792f-4e23-793d-8e9c-3a1bf36630bd',
pricePlanId: 'e0c546c5-eee0-7219-8847-c0ed16ae4a88',
defaultQuantity: 1
}
]
},
{
position: 1,
name: 'Pro',
upgradeable: true,
downgradeable: true,
changeTiming: 'immediately',
creditType: 'pro_rata',
items: [
{
productId: 'f5ece259-08ea-77a4-8bd9-9f3a9ed9e246',
pricePlanId: '295ad101-5d9f-7f1f-80f5-a9420c21eb1e',
defaultQuantity: 1
},
{
productId: '27e3a683-8829-73a8-8acb-5d9fbffb30b6',
pricePlanId: 'a1384760-a089-76a8-82e0-abd2993a39ac',
defaultQuantity: 1,
minQuantity: 0,
maxQuantity: 50
}
]
},
{
position: 2,
name: 'Business',
upgradeable: false,
downgradeable: true,
changeTiming: 'end_of_period',
creditType: 'none',
items: [
{
productId: '645077e0-f408-7f73-8f6e-585435440667',
pricePlanId: '321d6d27-a4aa-7dd7-8395-a57ead3b5ffb',
defaultQuantity: 1
}
]
}
]
})
};
fetch('https://coreapi.io/api/plans', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://coreapi.io/api/plans",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => 'pro-plan',
'name' => 'Pro Plan',
'tiers' => [
[
'position' => 0,
'name' => 'Starter',
'upgradeable' => true,
'downgradeable' => false,
'changeTiming' => 'immediately',
'creditType' => 'pro_rata',
'items' => [
[
'productId' => '1280792f-4e23-793d-8e9c-3a1bf36630bd',
'pricePlanId' => 'e0c546c5-eee0-7219-8847-c0ed16ae4a88',
'defaultQuantity' => 1
]
]
],
[
'position' => 1,
'name' => 'Pro',
'upgradeable' => true,
'downgradeable' => true,
'changeTiming' => 'immediately',
'creditType' => 'pro_rata',
'items' => [
[
'productId' => 'f5ece259-08ea-77a4-8bd9-9f3a9ed9e246',
'pricePlanId' => '295ad101-5d9f-7f1f-80f5-a9420c21eb1e',
'defaultQuantity' => 1
],
[
'productId' => '27e3a683-8829-73a8-8acb-5d9fbffb30b6',
'pricePlanId' => 'a1384760-a089-76a8-82e0-abd2993a39ac',
'defaultQuantity' => 1,
'minQuantity' => 0,
'maxQuantity' => 50
]
]
],
[
'position' => 2,
'name' => 'Business',
'upgradeable' => false,
'downgradeable' => true,
'changeTiming' => 'end_of_period',
'creditType' => 'none',
'items' => [
[
'productId' => '645077e0-f408-7f73-8f6e-585435440667',
'pricePlanId' => '321d6d27-a4aa-7dd7-8395-a57ead3b5ffb',
'defaultQuantity' => 1
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "1280792f-4e23-793d-8e9c-3a1bf36630bd",
"code": "pro-plan",
"name": "Pro Plan",
"status": "draft",
"currency": "EUR",
"tiers": [
{
"id": "<string>",
"position": 1,
"name": "Pro",
"upgradeable": true,
"downgradeable": true,
"changeTiming": "immediately",
"creditType": "pro_rata",
"commitmentPeriod": "P1Y",
"items": [
{
"id": "<string>",
"productId": "<string>",
"productName": "Add-On",
"pricePlanId": "<string>",
"pricePlanName": "Add-On Monthly",
"currency": "EUR",
"defaultQuantity": 1,
"minQuantity": 123,
"maxQuantity": 123
}
]
}
],
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}{
"status": 404,
"type": "PLAN__NOT_FOUND",
"title": "An error occurred",
"detail": "Plan not found."
}{
"status": 404,
"type": "PLAN__NOT_FOUND",
"title": "An error occurred",
"detail": "Plan not found."
}{
"status": 404,
"type": "PLAN__NOT_FOUND",
"title": "An error occurred",
"detail": "Plan not found."
}{
"status": 422,
"type": "https://tools.ietf.org/html/rfc2616#section-10",
"title": "Validation Failed",
"violations": [
{
"propertyPath": "tiers[0].name",
"message": "This value should not be blank.",
"code": "<string>"
}
]
}Autorisierungen
Body
application/json
Full representation of a plan. PUT replaces the plan as a whole: send every tier and item you want to keep, provide ids to keep existing rows stable, and omit rows you want removed.
Antwort
The created plan.
War diese Seite hilfreich?