Plans
Membership plans: a monthly or weekly allowance of sessions or hours for a recurring price, the services it covers, and whether it is sold on your public Plans page.
The plan object
Every plan record carries these fields in this order, after object, which is always "plan".
| Field | Type | Description |
|---|---|---|
id | integer | |
name | string, up to 100 characters | The plan name, shown to clients wherever the plan is offered. |
description | text, nullable | What the plan includes, in your words (plain text); null or empty when none. |
category_id | integer | The plan category it is listed under (GET /api/v1/plan-categories); 0 = no category. |
category_name | string, up to 100 characters | The category's name; null when the plan has no category. Read-only. |
ordering | integer | The plan's place within its category, lowest first; plans with the same number are listed by name. |
price | decimal | The price of one period, 2 decimals. |
count_by | string | What the allowance counts: sessions or hours. Locked once anyone has held the plan (see locked). |
allowance | decimal | How many sessions (a whole number) or hours each period includes. |
period | string | How often the plan renews and the allowance refills: week or month. Locked once anyone has held the plan. |
topup_price | decimal | What one extra session or hour costs once the allowance is used up; 0 = extra bookings are charged at the normal service rate. |
taxable | integer | 1 = tax is added at the rate in taxes for the state on the member's record, 0 = no tax. |
taxes | object | Tax rate by state: {"state": percent}, the state exactly as client records hold it. {} when none. Used when taxable is 1. |
missed_counts | integer | 1 = a missed session still uses the allowance, 0 = it does not. |
cancelled_counts | integer | 1 = a cancelled session still uses the allowance, 0 = it does not. |
grace_days | integer | Days after an unpaid renewal the member may still book (0 to 31). |
online | integer | 1 = sold on your public Plans page (needs a price above 0 and client card payments through Stripe), 0 = enrolled by your office only. |
status | integer | 1 = active (offered for enrolment and plan changes), 0 = inactive. |
popular | integer | 1 = highlighted on the Plans page with popular_label (one plan per category), 0 = not. |
popular_label | string, up to 30 characters | The highlight's words, e.g. Most popular or Best value. |
service_ids | array | The ids of the services the plan covers (GET /api/v1/services), ascending. |
members | integer | Current members: enrolments that are active or awaiting payment. Read-only. |
locked | boolean | true once anyone has held the plan (or is waiting to switch to it): count_by and period can no longer change and the plan cannot be deleted (set status 0 instead). Read-only. |
Example
{
"object": "plan",
"id": 42,
"name": "Example name",
"description": "An example description.",
"category_id": 7,
"category_name": "Example name",
"ordering": 1,
"price": 25.5,
"count_by": "sessions",
"allowance": 25.5,
"period": "month",
"topup_price": 25.5,
"taxable": 1,
"taxes": {
"NY": 8.88,
"NJ": 6.63
},
"missed_counts": 1,
"cancelled_counts": 1,
"grace_days": 1,
"online": 1,
"status": 1,
"popular": 1,
"popular_label": "Most popular",
"service_ids": [
3,
5
],
"members": 1,
"locked": true
} List plans
Parameters
| Parameter | In | Description |
|---|---|---|
limit | query | Records per page, 1 to 1000 (default 100). |
offset | query | Records to skip (default 0). |
status | query | Only plans with this status: 1 active, 0 inactive (or 0,1). |
online | query | Only plans sold online (1) or not (0). |
category_id | query | Only plans in this plan category. |
Returns
A list envelope of plan records (see Pagination).
Request
curl "https://www.bizstim.com/api/v1/plans" \
-H "X-API-KEY: YOUR_API_KEY" \
-H "Accept: application/json"<?php
$ch = curl_init('https://www.bizstim.com/api/v1/plans');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-KEY: YOUR_API_KEY', 'Accept: application/json'],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);const response = await fetch('https://www.bizstim.com/api/v1/plans', {
headers: { 'X-API-KEY': 'YOUR_API_KEY', 'Accept': 'application/json' }
});
const data = await response.json();Response
{
"object": "list",
"total": 2,
"limit": 100,
"offset": 0,
"has_more": false,
"data": [
{
"object": "plan",
"id": 42,
"name": "Example name",
"description": "An example description.",
"category_id": 7,
"category_name": "Example name",
"ordering": 1,
"price": 25.5,
"count_by": "sessions",
"allowance": 25.5,
"period": "month",
"topup_price": 25.5,
"taxable": 1,
"taxes": {
"NY": 8.88,
"NJ": 6.63
},
"missed_counts": 1,
"cancelled_counts": 1,
"grace_days": 1,
"online": 1,
"status": 1,
"popular": 1,
"popular_label": "Most popular",
"service_ids": [
3,
5
],
"members": 1,
"locked": true
},
{
"object": "plan",
"id": 43,
"name": "Example name",
"description": "An example description.",
"category_id": 7,
"category_name": "Example name",
"ordering": 1,
"price": 25.5,
"count_by": "sessions",
"allowance": 25.5,
"period": "month",
"topup_price": 25.5,
"taxable": 1,
"taxes": {
"NY": 8.88,
"NJ": 6.63
},
"missed_counts": 1,
"cancelled_counts": 1,
"grace_days": 1,
"online": 1,
"status": 1,
"popular": 1,
"popular_label": "Most popular",
"service_ids": [
3,
5
],
"members": 1,
"locked": true
}
]
} Retrieve a plan
Parameters
| Parameter | In | Description |
|---|---|---|
id | path | The record's id. |
Returns
One plan record, or 404 not_found when no record with that id exists on your account.
Request
curl "https://www.bizstim.com/api/v1/plans/42" \
-H "X-API-KEY: YOUR_API_KEY" \
-H "Accept: application/json"<?php
$ch = curl_init('https://www.bizstim.com/api/v1/plans/42');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-KEY: YOUR_API_KEY', 'Accept: application/json'],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);const response = await fetch('https://www.bizstim.com/api/v1/plans/42', {
headers: { 'X-API-KEY': 'YOUR_API_KEY', 'Accept': 'application/json' }
});
const data = await response.json();Response
{
"object": "plan",
"id": 42,
"name": "Example name",
"description": "An example description.",
"category_id": 7,
"category_name": "Example name",
"ordering": 1,
"price": 25.5,
"count_by": "sessions",
"allowance": 25.5,
"period": "month",
"topup_price": 25.5,
"taxable": 1,
"taxes": {
"NY": 8.88,
"NJ": 6.63
},
"missed_counts": 1,
"cancelled_counts": 1,
"grace_days": 1,
"online": 1,
"status": 1,
"popular": 1,
"popular_label": "Most popular",
"service_ids": [
3,
5
],
"members": 1,
"locked": true
} Create a plan
Request body
A JSON object (Content-Type: application/json) with these fields.
| Field | Type | Required | Description |
|---|---|---|---|
name | string, up to 100 characters | yes | The plan name. |
price | number, 0 to 99999999.99 | yes | The price of one period. Above 0 to sell the plan online. |
allowance | number, more than 0, up to 9999.99 | yes | Sessions (a whole number) or hours each period includes. |
service_ids | array of integers | yes | The services the plan covers, at least one: active services, never the Smart Learn service. |
description | string, up to 2000 characters | no | What the plan includes (plain text; tags are removed). |
category_id | integer | no | A plan category id (GET /api/v1/plan-categories); 0 = none (default). |
ordering | integer, 0 to 9999 | no | The place within the category, lowest first. Default 0. |
count_by | string | no | sessions (default) or hours. |
period | string | no | month (default) or week. |
topup_price | number, 0 to 99999999.99 | no | What one extra session or hour costs once the allowance is used up; 0 (default) = the normal service rate. |
grace_days | integer, 0 to 31 | no | Days after an unpaid renewal the member may still book. Default 0. |
missed_counts | boolean | no | A missed session uses the allowance. Default true. |
cancelled_counts | boolean | no | A cancelled session uses the allowance. Default false. |
taxable | boolean | no | Tax is added at the rates in taxes. Default false. |
taxes | object | no | Tax rate by state, {"state": percent from 0 to 100}, stored with 2 decimals. Default none. |
online | boolean | no | Sold on your public Plans page. Needs a price above 0 and services visible to all users. Default false. |
status | integer | no | 1 active (default), 0 inactive. |
popular | boolean | no | Highlight this plan on the Plans page; clears the highlight of the other plans in its category. Default false. |
popular_label | string, up to 30 characters | no | The highlight's words. Default Most popular. |
Returns
201 with the new plan record. Fields left out take the app's Add plan defaults: counts sessions, renews monthly, missed sessions use the allowance, active, not sold online, no tax. 400 invalid_request names the field to fix; 409 conflict when the app refuses the plan (e.g. a plan sold online that covers a service hidden from clients, or no active service).
Request
curl -X POST "https://www.bizstim.com/api/v1/plans" \
-H "X-API-KEY: YOUR_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "Monthly 4 sessions",
"price": 240,
"allowance": 4,
"service_ids": [
3,
5
]
}'<?php
$ch = curl_init('https://www.bizstim.com/api/v1/plans');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"name": "Monthly 4 sessions",
"price": 240,
"allowance": 4,
"service_ids": [
3,
5
]
}',
CURLOPT_HTTPHEADER => ['X-API-KEY: YOUR_API_KEY', 'Accept: application/json', 'Content-Type: application/json'],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);const response = await fetch('https://www.bizstim.com/api/v1/plans', {
method: 'POST',
headers: { 'X-API-KEY': 'YOUR_API_KEY', 'Accept': 'application/json', 'Content-Type': 'application/json' },
body: JSON.stringify({
"name": "Monthly 4 sessions",
"price": 240,
"allowance": 4,
"service_ids": [
3,
5
]
})
});
const data = await response.json();Response (201)
{
"object": "plan",
"id": 42,
"name": "Example name",
"description": "An example description.",
"category_id": 7,
"category_name": "Example name",
"ordering": 1,
"price": 25.5,
"count_by": "sessions",
"allowance": 25.5,
"period": "month",
"topup_price": 25.5,
"taxable": 1,
"taxes": {
"NY": 8.88,
"NJ": 6.63
},
"missed_counts": 1,
"cancelled_counts": 1,
"grace_days": 1,
"online": 1,
"status": 1,
"popular": 1,
"popular_label": "Most popular",
"service_ids": [
3,
5
],
"members": 1,
"locked": true
} Update a plan
Parameters
| Parameter | In | Description |
|---|---|---|
id | path | The record's id. |
Request body
A JSON object (Content-Type: application/json) with these fields.
| Field | Type | Required | Description |
|---|---|---|---|
name | string, up to 100 characters | no | The plan name (cannot be emptied). |
price | number, 0 to 99999999.99 | no | The price of one period. |
allowance | number, more than 0, up to 9999.99 | no | Sessions (a whole number) or hours each period includes. |
service_ids | array of integers | no | The whole list of covered services (at least one). A service the plan does not cover yet must be active. |
description | string, up to 2000 characters | no | What the plan includes; "" removes it. |
category_id | integer | no | A plan category id; 0 = none. |
ordering | integer, 0 to 9999 | no | The place within the category. |
count_by | string | no | sessions or hours (409 once the plan is locked). |
period | string | no | month or week (409 once the plan is locked). |
topup_price | number, 0 to 99999999.99 | no | What one extra session or hour costs; 0 = the normal service rate. |
grace_days | integer, 0 to 31 | no | Days after an unpaid renewal the member may still book. |
missed_counts | boolean | no | A missed session uses the allowance. |
cancelled_counts | boolean | no | A cancelled session uses the allowance. |
taxable | boolean | no | Tax is added at the rates in taxes. |
taxes | object | no | The whole set of rates, {"state": percent}; {} removes them all. |
online | boolean | no | Sold on your public Plans page. |
status | integer | no | 1 active, 0 inactive. |
popular | boolean | no | Highlight this plan in its category. |
popular_label | string, up to 30 characters | no | The highlight's words; "" = Most popular. |
Returns
200 with the updated plan record. Fields left out keep their values; service_ids and taxes, when sent, replace the whole list. 400 invalid_request names the field to fix; 404 not_found; 409 conflict when the app refuses the change (count_by or period on a locked plan, a removed service that members have upcoming sessions on, a plan sold online that covers a hidden service).
Request
curl -X PATCH "https://www.bizstim.com/api/v1/plans/42" \
-H "X-API-KEY: YOUR_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"price": 260,
"online": true
}'<?php
$ch = curl_init('https://www.bizstim.com/api/v1/plans/42');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_POSTFIELDS => '{
"price": 260,
"online": true
}',
CURLOPT_HTTPHEADER => ['X-API-KEY: YOUR_API_KEY', 'Accept: application/json', 'Content-Type: application/json'],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);const response = await fetch('https://www.bizstim.com/api/v1/plans/42', {
method: 'PATCH',
headers: { 'X-API-KEY': 'YOUR_API_KEY', 'Accept': 'application/json', 'Content-Type': 'application/json' },
body: JSON.stringify({
"price": 260,
"online": true
})
});
const data = await response.json();Response
{
"object": "plan",
"id": 42,
"name": "Example name",
"description": "An example description.",
"category_id": 7,
"category_name": "Example name",
"ordering": 1,
"price": 25.5,
"count_by": "sessions",
"allowance": 25.5,
"period": "month",
"topup_price": 25.5,
"taxable": 1,
"taxes": {
"NY": 8.88,
"NJ": 6.63
},
"missed_counts": 1,
"cancelled_counts": 1,
"grace_days": 1,
"online": 1,
"status": 1,
"popular": 1,
"popular_label": "Most popular",
"service_ids": [
3,
5
],
"members": 1,
"locked": true
} Delete a plan
Parameters
| Parameter | In | Description |
|---|---|---|
id | path | The record's id. |
Returns
200 with {"id", "object": "plan", "deleted": true}: the plan, its services and its tax rates are removed. 404 not_found; 409 conflict for a plan anyone has held (locked true): set status 0 instead.
Request
curl -X DELETE "https://www.bizstim.com/api/v1/plans/42" \
-H "X-API-KEY: YOUR_API_KEY" \
-H "Accept: application/json"<?php
$ch = curl_init('https://www.bizstim.com/api/v1/plans/42');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['X-API-KEY: YOUR_API_KEY', 'Accept: application/json'],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);const response = await fetch('https://www.bizstim.com/api/v1/plans/42', {
method: 'DELETE',
headers: { 'X-API-KEY': 'YOUR_API_KEY', 'Accept': 'application/json' }
});
const data = await response.json();Response
{
"id": 42,
"object": "plan",
"deleted": true
}