Subscriptions Queries

Query recurring subscriptions, billing cycles, and customer assignments.

Subscription — Returns a single recurring subscription by id

query GetSubscription($id: ID!) {
  Subscription(id: $id) {
    id
    label
    status
    frequency_unit
    frequency_interval
    starts_at
    ends_at
    next_run_at
    total
    customer { id label }
    line_items {
      id
      variant { id label }
      quantity
      price
    }
    runs {
      paginatorInfo { total }
      data {
        id
        run_at
        status
        invoice { id label }
      }
    }
  }
}

Subscriptions — Returns a paginated list of subscriptions with sorting and filters

query Subscriptions(
  $where: QuerySubscriptionsWhereWhereConditions,
  $orderBy: [QuerySubscriptionsOrderByOrderByClause!],
  $search: String,
  $first: Int,
  $page: Int
) {
  Subscriptions(
    where: $where,
    orderBy: $orderBy,
    search: $search,
    first: $first,
    page: $page
  ) {
    paginatorInfo {
      total
      currentPage
    }
    data {
      id
      label
      status
      next_run_at
      total
      customer { id label }
    }
  }
}

SubscriptionRuns — Returns a list of subscription execution history

query SubscriptionRuns(
  $where: QuerySubscriptionRunsWhereWhereConditions,
  $orderBy: [QuerySubscriptionRunsOrderByOrderByClause!],
  $first: Int,
  $page: Int
) {
  SubscriptionRuns(
    where: $where,
    orderBy: $orderBy,
    first: $first,
    page: $page
  ) {
    paginatorInfo { total }
    data {
      id
      run_at
      status
      subscription { id label }
      invoice { id label }
    }
  }
}

Available fields

Subscription

FieldTypeDescription
idIntUnique identifier.
labelStringSubscription reference number.
statusSubscriptionStatusCurrent status.
frequency_unitSubscriptionFrequencyUnitFrequency period (day, week, month, year).
frequency_intervalIntInterval between runs.
max_cyclesIntMaximum number of occurrences.
starts_atDateStart date.
ends_atDateEnd date.
next_run_atDateNext scheduled execution.
auto_create_shipping_orderBooleanCreate shipment automatically.
invoice_as_draftBooleanCreate invoice as draft.
currencyCurrencyBilling currency.
exchange_rateFloatExchange rate for currency conversion.
tax_typeTaxTypeTax calculation method.
default_discountFloatDefault discount rate.
discount_typeDiscountTypeDiscount type (amount or percentage).
total_unitsFloatTotal quantity per run.
subtotalFloatSubtotal per run.
total_without_taxFloatTotal before taxes.
total_ecotaxFloatTotal ecotaxes.
totalFloatGrand total per run.
total_taxes[DocumentTaxRate]List of taxes applied.
notesStringPublic notes for documents.
internal_notesStringPrivate notes.
for_the_attention_ofStringSpecific recipient name.
external_referenceStringMerchant internal reference.
created_atDateTimeCreation time.
updated_atDateTimeLast update time.
customerCustomerAssociated customer.
price_levelPriceLevelApplied price level.
account_representativeAccountRepresentativeAssigned representative.
seasonSeasonAssociated season.
invoice_pdf_templatePdfTemplateTemplate for invoices.
shipping_order_pdf_templatePdfTemplateTemplate for shipping orders.
billing_addressAddressDefault billing address.
shipping_addressAddressDefault shipping address.
line_items[LineItemSubscription]List of recurring items.
runs[SubscriptionRun]Execution history.
custom_fields[EntityCustomField]Custom fields for this entity.

Filters

Subscriptions Filters

The following fields can be used in the where parameter:

id, label, status, next_run_at, created_at, updated_at, customer_id, pending_shipping_order.

Example Filters:

FieldExample
status{ "column": "STATUS", "operator": "EQ", "value": "active" }
customer_id{ "column": "CUSTOMER_ID", "operator": "EQ", "value": 100001 }
pending_shipping_order{ "column": "PENDING_SHIPPING_ORDER", "operator": "EXISTS", "value": true }

SubscriptionRuns Filters

The following fields can be used in the where parameter:

id, run_at, status, subscription_id, invoice_id, shipping_order_id, created_at, updated_at.


Sorting

Subscriptions Sorting

  • id
  • label
  • status
  • next_run_at
  • created_at
  • updated_at
  • customer_id

SubscriptionRuns Sorting

  • id
  • run_at
  • status
  • subscription_id
  • invoice_id
  • shipping_order_id
  • created_at
  • updated_at

Data Types

SubscriptionRun

FieldTypeDescription
idIntRun ID.
run_atDateDate of execution.
statusStringStatus of the run (success/error).
errorStringError message if failed.
subscriptionSubscriptionParent subscription.
invoiceInvoiceGenerated invoice.
shipping_orderShippingOrderGenerated shipping order.

SubscriptionRunInvoice

FieldTypeDescription
idIntRun invoice ID.
company_idIntCompany ID.
subscription_run_idIntParent run ID.
subscription_customer_idIntCustomer ID.
statusStringStatus (pending, processed, error).
errorStringError message if failed.
subscription_runSubscriptionRunParent run.
subscription_customerSubscriptionCustomerCustomer relationship.
invoiceInvoiceGenerated invoice.
shipping_orderShippingOrderGenerated shipping order.

SubscriptionCustomer

FieldTypeDescription
idIntSubscription customer ID.
company_idIntCompany ID.
subscription_idIntParent subscription ID.
customer_idIntCustomer ID.
statusStringStatus (active, paused, left).
joined_atDateDate customer joined.
left_atDateDate customer left.
discountFloatCustomer-specific discount.
discount_typeDiscountTypeDiscount type (percentage/amount).
customerCustomerCustomer relationship.
subscriptionSubscriptionParent subscription.
billing_addressAddressBilling address.
shipping_addressAddressShipping address.

LineItemSubscription

FieldTypeDescription
idIntLine item ID.
variantVariantProduct variant.
locationLocationStock location.
quantityFloatQuantity per cycle.
priceFloatUnit price.
subscriptionSubscriptionParent subscription.

BatchUpdateSubscriptionLineItemPricesResult

FieldTypeDescription
updated_subscriptions_countIntNumber of subscriptions updated.
updated_line_items_countIntNumber of line items updated.
queuedBooleanWhether the update was queued for background processing.
job_batch_idStringBatch job ID if queued.

Data Types

ErplainSubscription

This is the full subscription entity with all available fields.

FieldTypeDescription
idIntSubscription ID.
labelStringSubscription label.
statusSubscriptionStatusCurrent status.
frequency_unitSubscriptionFrequencyUnitFrequency unit (day, week, month, year).
frequency_intervalIntInterval between runs.
max_cyclesIntMaximum number of cycles.
starts_atDateStart date.
ends_atDateEnd date.
next_run_atDateNext scheduled execution.
auto_create_shipping_orderBooleanCreate shipment automatically.
invoice_as_draftBooleanCreate invoice as draft.
currencyCurrencyBilling currency.
exchange_rateFloatExchange rate for currency conversion.
tax_typeTaxTypeTax calculation method.
default_discountFloatDefault discount rate.
discount_typeDiscountTypeDiscount type (amount or percentage).
total_unitsFloatTotal quantity per run.
subtotalFloatSubtotal per run.
total_without_taxFloatTotal before taxes.
total_ecotaxFloatTotal ecotaxes.
totalFloatGrand total per run.
total_taxes[DocumentTaxRate]List of taxes applied.
notesStringPublic notes for documents.
internal_notesStringPrivate notes.
for_the_attention_ofStringSpecific recipient name.
external_referenceStringMerchant internal reference.
invoice_pdf_templatePdfTemplateTemplate for invoices.
shipping_order_pdf_templatePdfTemplateTemplate for shipping orders.
created_atDateTimeCreation time.
updated_atDateTimeLast update time.
hard_deleted_atDateTimeHard deletion time.
customerCustomerAssociated customer (deprecated, use customers).
customers[SubscriptionCustomer]List of customers.
price_levelPriceLevelApplied price level.
account_representativeAccountRepresentativeAssigned representative.
seasonSeasonAssociated season.
line_items[LineItemSubscription]List of recurring items.
invoices[Invoice]Generated invoices.
shipping_orders[ShippingOrder]Generated shipping orders.
runs[SubscriptionRun]Execution history.

SubscriptionCustomer

FieldTypeDescription
idIntCustomer subscription ID.
customerCustomerAssociated customer.
joined_atDateDate customer joined.
left_atDateDate customer left.
statusStringCustomer status.
billing_addressAddressBilling address.
shipping_addressAddressShipping address.
discountFloatCustomer-specific discount.
discount_typeDiscountTypeDiscount type (amount or percentage).

Enums

SubscriptionStatus

ValueDescription
draftNot yet active.
activeRunning as scheduled.
pausedTemporarily stopped.
cancelledPermanently stopped.

SubscriptionFrequencyUnit

ValueDescription
dayExecutes daily.
weekExecutes weekly.
monthExecutes monthly.
yearExecutes yearly.

DiscountType

ValueDescription
amountFixed discount amount.
percentagePercentage-based discount.

TaxType

ValueDescription
exclusiveTax calculated on top of the net price.
inclusiveTax included in the displayed price.