Skip to content

Subscriptions 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.

The Subscriptions API allows you to retrieve information about user subscriptions in your school. Each subscription represents a user’s access to a membership plan, including billing period details and cancellation status.

Returns a paginated list of subscriptions for the authenticated school.

Parameters:

ParameterTypeDescription
filterAdminSubscriptionFilterFilter criteria (see Filtering)
pageIntPage number for pagination
perPageIntNumber of items per page (default: 20, max: 50)
limitIntAlternative to perPage

Returns:

  • AdminSubscriptionPage object with:
    • nodes: Array of AdminSubscription objects
    • currentPage: Current page number
    • hasNextPage: Whether there are more pages
    • hasPreviousPage: Whether there are previous pages
    • nodesCount: Total number of items matching the query
    • totalPages: Total number of pages

Example:

query {
subscriptions(
page: 1,
perPage: 10
) {
nodes {
id
state
startAt
endAt
currentPeriodStart
currentPeriodEnd
planId
isCanceling
isCancellable
nextChargeDate
createdAt
updatedAt
plan {
id
name
}
user {
id
name
email
}
}
currentPage
hasNextPage
hasPreviousPage
nodesCount
totalPages
}
}

The AdminSubscription object contains the following fields:

FieldTypeDescription
idString!Unique identifier
stateString!Current state of the subscription (e.g., active, canceled, past_due)
startAtIntUnix Timestamp. When the subscription starts
endAtIntUnix Timestamp. When the subscription ends. For cancelled subscriptions, this represents the final termination date
currentPeriodStartIntUnix Timestamp. Start of the current billing period
currentPeriodEndIntUnix Timestamp. End of the current billing period. For active subscriptions, this represents when the next payment will be due
planIdString!The unique identifier of the associated membership plan
planMembershipPlan!The membership plan associated with this subscription
isCancelingBoolean!Whether the subscription is scheduled for cancellation in the next billing cycle
isCancellableBoolean!Whether the subscription can be cancelled
nextChargeDateIntTimestamp of the next scheduled charge. Null for non-recurring or inactive subscriptions
userUser!The user who owns this subscription
createdAtInt!Unix Timestamp. When the subscription was created
updatedAtInt!Unix Timestamp. When the subscription was last updated
cancelReasonStringThe reason for cancellation if the subscription has been cancelled
cancelTypeStringThe type of cancellation (e.g., immediate, at_period_end)

The subscriptions query accepts a filter parameter of type AdminSubscriptionFilter. This allows you to narrow down results based on various criteria.

Filter FieldTypeDescription
idStringOperatorFilter by subscription ID
stateStringOperatorFilter by subscription state (e.g., active, canceled, past_due)
planIdStringOperatorFilter by membership plan ID
userEmailStringOperatorFilter by user email address

The StringOperator used in filters has these operations:

OperationDescription
eqEqual to
neqNot equal to
inIn a list of values
ninNot in a list of values
likeMatch text values against a pattern using wildcards (case-sensitive)
containsContains substring (case-insensitive)

Find active subscriptions:

query {
subscriptions(
filter: {
state: { eq: "active" }
}
) {
nodes {
id
state
startAt
endAt
user {
id
name
email
}
}
nodesCount
}
}

Find canceled subscriptions:

query {
subscriptions(
filter: {
state: { eq: "canceled" }
}
) {
nodes {
id
state
cancelReason
cancelType
endAt
user {
id
email
}
}
nodesCount
}
}

Find subscriptions by plan:

query {
subscriptions(
filter: {
planId: { eq: "plan-123" }
}
) {
nodes {
id
state
startAt
endAt
plan {
id
name
}
}
nodesCount
}
}

Find subscriptions by user email:

query {
subscriptions(
filter: {
userEmail: { contains: "alice" }
}
) {
nodes {
id
state
user {
id
name
email
}
}
nodesCount
}
}

Find active subscriptions for a specific plan:

query {
subscriptions(
filter: {
state: { eq: "active" },
planId: { eq: "plan-123" }
}
) {
nodes {
id
state
currentPeriodStart
currentPeriodEnd
nextChargeDate
}
nodesCount
}
}

Find subscriptions with multiple states:

query {
subscriptions(
filter: {
state: { in: ["active", "past_due"] }
}
) {
nodes {
id
state
user {
id
email
}
}
nodesCount
}
}