--- title: subscriptionBillingCycle - GraphQL Admin description: Returns a subscription billing cycle found either by cycle index or date. api_version: 2025-10 api_name: admin type: query api_type: graphql source_url: html: https://shopify.dev/docs/api/admin-graphql/latest/queries/subscriptionBillingCycle md: https://shopify.dev/docs/api/admin-graphql/latest/queries/subscriptionBillingCycle.md --- # subscription​Billing​Cycle query Returns a subscription billing cycle found either by cycle index or date. ## Arguments * billing​Cycle​Input [Subscription​Billing​Cycle​Input!](https://shopify.dev/docs/api/admin-graphql/latest/input-objects/SubscriptionBillingCycleInput) required Input object used to select and use billing cycles. *** ## Possible returns * Subscription​Billing​Cycle [Subscription​Billing​Cycle](https://shopify.dev/docs/api/admin-graphql/latest/objects/SubscriptionBillingCycle) A subscription billing cycle. *** ## Examples * ### Get a billing cycle by cycle index #### Description Retrieves a billing cycle with cycle index \`1\` and returns the \`billingAttemptExpectedDate\`. #### Query ```graphql query subscriptionBillingCycle($contractId: ID!, $index: Int!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {index: $index}}) { billingAttemptExpectedDate } } ``` #### Variables ```json { "contractId": "gid://shopify/SubscriptionContract/593791907", "index": 1 } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query subscriptionBillingCycle($contractId: ID!, $index: Int!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {index: $index}}) { billingAttemptExpectedDate } }", "variables": { "contractId": "gid://shopify/SubscriptionContract/593791907", "index": 1 } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query subscriptionBillingCycle($contractId: ID!, $index: Int!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {index: $index}}) { billingAttemptExpectedDate } }`, { variables: { "contractId": "gid://shopify/SubscriptionContract/593791907", "index": 1 }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query subscriptionBillingCycle($contractId: ID!, $index: Int!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {index: $index}}) { billingAttemptExpectedDate } } QUERY variables = { "contractId": "gid://shopify/SubscriptionContract/593791907", "index": 1 } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query subscriptionBillingCycle($contractId: ID!, $index: Int!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {index: $index}}) { billingAttemptExpectedDate } }`, "variables": { "contractId": "gid://shopify/SubscriptionContract/593791907", "index": 1 }, }, }); ``` #### Response ```json { "subscriptionBillingCycle": { "billingAttemptExpectedDate": "2022-01-02T11:59:59Z" } } ``` * ### Get a billing cycle by date #### Description Retrieves the billing cycle that includes the date \`2022-12-01\` and returns the \`billingAttemptExpectedDate\`. #### Query ```graphql query subscriptionBillingCycle($contractId: ID!, $date: DateTime!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {date: $date}}) { billingAttemptExpectedDate } } ``` #### Variables ```json { "contractId": "gid://shopify/SubscriptionContract/593791907", "date": "2022-12-01T00:00:00Z" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query subscriptionBillingCycle($contractId: ID!, $date: DateTime!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {date: $date}}) { billingAttemptExpectedDate } }", "variables": { "contractId": "gid://shopify/SubscriptionContract/593791907", "date": "2022-12-01T00:00:00Z" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query subscriptionBillingCycle($contractId: ID!, $date: DateTime!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {date: $date}}) { billingAttemptExpectedDate } }`, { variables: { "contractId": "gid://shopify/SubscriptionContract/593791907", "date": "2022-12-01T00:00:00Z" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query subscriptionBillingCycle($contractId: ID!, $date: DateTime!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {date: $date}}) { billingAttemptExpectedDate } } QUERY variables = { "contractId": "gid://shopify/SubscriptionContract/593791907", "date": "2022-12-01T00:00:00Z" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query subscriptionBillingCycle($contractId: ID!, $date: DateTime!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {date: $date}}) { billingAttemptExpectedDate } }`, "variables": { "contractId": "gid://shopify/SubscriptionContract/593791907", "date": "2022-12-01T00:00:00Z" }, }, }); ``` #### Response ```json { "subscriptionBillingCycle": { "billingAttemptExpectedDate": "2022-12-02T01:00:00Z" } } ``` [Open in GraphiQL](http://localhost:3457/graphiql?query=query%20subscriptionBillingCycle\(%24contractId%3A%20ID!%2C%20%24index%3A%20Int!\)%20%7B%0A%20%20subscriptionBillingCycle\(billingCycleInput%3A%20%7BcontractId%3A%20%24contractId%2C%20selector%3A%20%7Bindex%3A%20%24index%7D%7D\)%20%7B%0A%20%20%20%20billingAttemptExpectedDate%0A%20%20%7D%0A%7D\&variables=%7B%0A%20%20%22contractId%22%3A%20%22gid%3A%2F%2Fshopify%2FSubscriptionContract%2F593791907%22%2C%0A%20%20%22index%22%3A%201%0A%7D) ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query subscriptionBillingCycle($contractId: ID!, $index: Int!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {index: $index}}) { billingAttemptExpectedDate } }`, { variables: { "contractId": "gid://shopify/SubscriptionContract/593791907", "index": 1 }, }, ); const json = await response.json(); return json.data; } ``` ##### GQL ``` query subscriptionBillingCycle($contractId: ID!, $index: Int!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {index: $index}}) { billingAttemptExpectedDate } } ``` ##### cURL ``` curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query subscriptionBillingCycle($contractId: ID!, $index: Int!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {index: $index}}) { billingAttemptExpectedDate } }", "variables": { "contractId": "gid://shopify/SubscriptionContract/593791907", "index": 1 } }' ``` ##### React Router ``` import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query subscriptionBillingCycle($contractId: ID!, $index: Int!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {index: $index}}) { billingAttemptExpectedDate } }`, { variables: { "contractId": "gid://shopify/SubscriptionContract/593791907", "index": 1 }, }, ); const json = await response.json(); return json.data; } ``` ##### Node.js ``` const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query subscriptionBillingCycle($contractId: ID!, $index: Int!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {index: $index}}) { billingAttemptExpectedDate } }`, "variables": { "contractId": "gid://shopify/SubscriptionContract/593791907", "index": 1 }, }, }); ``` ##### Ruby ``` session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query subscriptionBillingCycle($contractId: ID!, $index: Int!) { subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {index: $index}}) { billingAttemptExpectedDate } } QUERY variables = { "contractId": "gid://shopify/SubscriptionContract/593791907", "index": 1 } response = client.query(query: query, variables: variables) ``` ## Input variables JSON ```json { "contractId": "gid://shopify/SubscriptionContract/593791907", "index": 1 } ``` ## Response JSON ```json { "subscriptionBillingCycle": { "billingAttemptExpectedDate": "2022-01-02T11:59:59Z" } } ```