Membership Plans Query
Note: The Teachify Admin API is currently under development and not yet available for public use. This documentation is provided for preview purposes only.
Overview
The Membership Plans API allows you to retrieve information about subscription options available to students in your school. Each plan has specific features, pricing, and duration settings.
Available Queries
membershipPlans
Returns a paginated list of membership plans for the authenticated school.
Parameters:
Parameter | Type | Description |
---|---|---|
filter | AdminMembershipPlanFilter | Filter criteria (see Filtering) |
page | Int | Page number for pagination |
perPage | Int | Number of items per page (default: 20, max: 50) |
limit | Int | Alternative to perPage |
Returns:
- AdminMembershipPlanPage object with:
nodes
: Array of AdminMembershipPlan objectscurrentPage
: Current page numberhasNextPage
: Whether there are more pageshasPreviousPage
: Whether there are previous pagesnodesCount
: Total number of items in the current pagetotalPages
: Total number of pages
Example:
query { membershipPlans( filter: { active: true }, page: 1, perPage: 10 ) { nodes { id name description price currency interval intervalCount active visible createdAt updatedAt totalRevenue subscriptions ( filter: { planId: { eq: "abc123-983dsf8" } } ) { nodes { id planId state createdAt } } } currentPage hasNextPage hasPreviousPage nodesCount totalPages }}
Membership Plan Object
The AdminMembershipPlan object contains the following fields based on the schema:
Field | Type | Description |
---|---|---|
id | ID! | Unique identifier |
name | String! | Plan name |
description | String | Plan description |
price | Float! | Price of the plan |
currency | String! | Currency code (e.g., USD, EUR) in ISO 4217 format |
interval | String! | Billing interval (month, year, day) |
intervalCount | Int! | Number of intervals (e.g., 1, 3, 6) |
active | Boolean! | Whether the plan is active |
visible | Boolean! | Whether the plan is visible to students |
createdAt | ISO8601DateTime! | When the plan was created |
updatedAt | ISO8601DateTime! | When the plan was last updated |
soldItemsCount | Int | Number of sold subscriptions |
totalRevenue | Float | Total revenue generated by this plan |
subscriptions | AdminSubscriptionPage | Paginated list of subscriptions for this plan |
Subscriptions Fields
The AdminMembershipPlan object includes subscription information through the subscriptions
field. This returns a paginated list of subscriptions associated with the plan.
Field | Type | Description |
---|---|---|
id | ID! | Unique identifier for the subscription |
state | String! | Current state of the subscription |
startAt | ISO8601DateTime! | When the subscription starts |
endAt | ISO8601DateTime | When the subscription ends |
currentPeriodStart | ISO8601DateTime! | Start of current billing period |
currentPeriodEnd | ISO8601DateTime! | End of current billing period |
isCanceling | Boolean! | Whether the subscription is scheduled for cancellation |
isCancellable | Boolean! | Whether the subscription can be cancelled |
User Information in Subscriptions
Each subscription includes user information through the user
field:
Field | Type | Description |
---|---|---|
id | ID! | User’s unique identifier |
name | String! | User’s full name |
email | String! | User’s email address |
Subscriptions Filter Parameters
Parameter | Type | Description |
---|---|---|
id | StringOperator | Filter by subscription ID |
planId | StringOperator | Filter by subscription plan ID |
state | StringOperator | Filter by subscription state |
Example with filtered subscriptions:
query { membershipPlans(page: 1, perPage: 10) { nodes { id name subscriptions ( filter: { state: { eq: "active" } } ) { nodes { id state startAt endAt currentPeriodStart currentPeriodEnd isCanceling isCancellable user { id name email } } currentPage nodesCount } } }}
Detailed Query Structure
Below is a comprehensive view of fields available in the membershipPlans query based on the schema:
query { membershipPlans( filter: { id: { eq: "plan-123" }, active: true, visible: true }, page: 1, perPage: 20 ) { nodes { id # Unique identifier (ID!) name # Plan name (String!) description # Plan description (String)
# Plan pricing details price # Price amount (Float!) currency # Currency code (String!)
# Subscription details interval # Billing interval (String!) intervalCount # Number of intervals (Int!)
# Plan status active # Whether the plan is active (Boolean!) visible # Whether the plan is visible (Boolean!)
# Timestamps createdAt # When the plan was created (ISO8601DateTime!) updatedAt # When the plan was last updated (ISO8601DateTime!)
# Statistics soldItemsCount # Number of sold subscriptions (Int) totalRevenue # Total revenue generated (Float)
# Related subscriptions subscriptions ( filter: { planId: { eq: "abc123-983dsf8" } } ) { # Subscriptions for this plan (AdminSubscriptionPage) nodes { id state startAt endAt currentPeriodStart currentPeriodEnd isCanceling isCancellable user { id name email } } currentPage hasNextPage nodesCount } }
# Pagination information currentPage # Current page number (Int!) hasNextPage # Whether there are more pages (Boolean!) hasPreviousPage # Whether there are previous pages (Boolean!) nodesCount # Number of items in current page (Int!) totalPages # Total number of pages (Int!) }}
Filtering
The membershipPlans
query accepts a filter
parameter of type AdminMembershipPlanFilter
. This allows you to narrow down results based on various criteria.
Available Filters
Filter Field | Type | Description |
---|---|---|
id | StringOperator | Filter by plan ID |
active | Boolean | Filter by active status |
visible | Boolean | Filter by visibility |
StringOperator
The StringOperator
used in filters has these operations:
Operation | Description |
---|---|
eq | Equal to |
neq | Not equal to |
in | In a list of values |
nin | Not in a list of values |
like | Match text values against a pattern using wildcards (case-sensitive) |
Filter Examples
Find active membership plans:
query { membershipPlans( filter: { active: true } ) { nodes { id name price currency } nodesCount }}
Find visible membership plans:
query { membershipPlans( filter: { visible: true } ) { nodes { id name price currency } nodesCount }}
Find membership plans by ID:
query { membershipPlans( filter: { id: { eq: "plan-123" } } ) { nodes { id name price currency } nodesCount }}