# subscriptionBillingCycles - admin-graphql - QUERY Version: 2024-10 ## Description Returns subscription billing cycles for a contract ID. ### Access Scopes ## Arguments * [after](/docs/api/admin-graphql/2024-10/scalars/String): String - The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * [before](/docs/api/admin-graphql/2024-10/scalars/String): String - The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * [billingCyclesDateRangeSelector](/docs/api/admin-graphql/2024-10/input-objects/SubscriptionBillingCyclesDateRangeSelector): SubscriptionBillingCyclesDateRangeSelector - Select subscription billing cycles within a date range. * [billingCyclesIndexRangeSelector](/docs/api/admin-graphql/2024-10/input-objects/SubscriptionBillingCyclesIndexRangeSelector): SubscriptionBillingCyclesIndexRangeSelector - Select subscription billing cycles within an index range. * [contractId](/docs/api/admin-graphql/2024-10/scalars/ID): ID! - The ID of the subscription contract to retrieve billing cycles for. * [first](/docs/api/admin-graphql/2024-10/scalars/Int): Int - The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * [last](/docs/api/admin-graphql/2024-10/scalars/Int): Int - The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * [reverse](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean - Reverse the order of the underlying list. * [sortKey](/docs/api/admin-graphql/2024-10/enums/SubscriptionBillingCyclesSortKeys): SubscriptionBillingCyclesSortKeys - Sort the underlying list using a key. If your query is slow or returns an error, then [try specifying a sort key that matches the field used in the search](https://shopify.dev/api/usage/pagination-graphql#search-performance-considerations). ## Returns * [edges](/docs/api/admin-graphql/2024-10/objects/SubscriptionBillingCycleEdge): SubscriptionBillingCycleEdge! The connection between the node and its parent. Each edge contains a minimum of the edge's cursor and the node. * [nodes](/docs/api/admin-graphql/2024-10/objects/SubscriptionBillingCycle): SubscriptionBillingCycle! A list of nodes that are contained in SubscriptionBillingCycleEdge. You can fetch data about an individual node, or you can follow the edges to fetch data about a collection of related nodes. At each node, you specify the fields that you want to retrieve. * [pageInfo](/docs/api/admin-graphql/2024-10/objects/PageInfo): PageInfo! An object that’s used to retrieve [cursor information](https://shopify.dev/api/usage/pagination-graphql) about the current page. ## Examples ### Get the billing cycles between specific dates Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query subscriptionBillingCycles($contractId: ID!) { subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesDateRangeSelector: {startDate: \\\"2022-12-15T00:00:00Z\\\", endDate: \\\"2023-02-15T00:00:00Z\\\"}) { edges { node { billingAttemptExpectedDate } } } }\",\n \"variables\": {\n \"contractId\": \"gid://shopify/SubscriptionContract/593791907\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query subscriptionBillingCycles($contractId: ID!) {\n subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesDateRangeSelector: {startDate: \"2022-12-15T00:00:00Z\", endDate: \"2023-02-15T00:00:00Z\"}) {\n edges {\n node {\n billingAttemptExpectedDate\n }\n }\n }\n }`,\n \"variables\": {\n \"contractId\": \"gid://shopify/SubscriptionContract/593791907\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query subscriptionBillingCycles($contractId: ID!) {\n subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesDateRangeSelector: {startDate: \"2022-12-15T00:00:00Z\", endDate: \"2023-02-15T00:00:00Z\"}) {\n edges {\n node {\n billingAttemptExpectedDate\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"contractId\": \"gid://shopify/SubscriptionContract/593791907\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query subscriptionBillingCycles($contractId: ID!) {\n subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesDateRangeSelector: {startDate: \"2022-12-15T00:00:00Z\", endDate: \"2023-02-15T00:00:00Z\"}) {\n edges {\n node {\n billingAttemptExpectedDate\n }\n }\n }\n }`,\n {\n variables: {\n \"contractId\": \"gid://shopify/SubscriptionContract/593791907\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query subscriptionBillingCycles($contractId: ID!) {\n subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesDateRangeSelector: {startDate: \"2022-12-15T00:00:00Z\", endDate: \"2023-02-15T00:00:00Z\"}) {\n edges {\n node {\n billingAttemptExpectedDate\n }\n }\n }\n}" #### Graphql Input { "contractId": "gid://shopify/SubscriptionContract/593791907" } #### Graphql Response { "data": { "subscriptionBillingCycles": { "edges": [ { "node": { "billingAttemptExpectedDate": "2023-01-02T01:00:00Z" } }, { "node": { "billingAttemptExpectedDate": "2023-02-02T01:00:00Z" } }, { "node": { "billingAttemptExpectedDate": "2023-03-02T01:00:00Z" } } ] } } } ### Get the billing cycles between specific indexes Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query subscriptionBillingCycles($contractId: ID!) { subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesIndexRangeSelector: {startIndex: 1, endIndex: 3}) { edges { node { billingAttemptExpectedDate } } } }\",\n \"variables\": {\n \"contractId\": \"gid://shopify/SubscriptionContract/593791907\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query subscriptionBillingCycles($contractId: ID!) {\n subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesIndexRangeSelector: {startIndex: 1, endIndex: 3}) {\n edges {\n node {\n billingAttemptExpectedDate\n }\n }\n }\n }`,\n \"variables\": {\n \"contractId\": \"gid://shopify/SubscriptionContract/593791907\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query subscriptionBillingCycles($contractId: ID!) {\n subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesIndexRangeSelector: {startIndex: 1, endIndex: 3}) {\n edges {\n node {\n billingAttemptExpectedDate\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"contractId\": \"gid://shopify/SubscriptionContract/593791907\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query subscriptionBillingCycles($contractId: ID!) {\n subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesIndexRangeSelector: {startIndex: 1, endIndex: 3}) {\n edges {\n node {\n billingAttemptExpectedDate\n }\n }\n }\n }`,\n {\n variables: {\n \"contractId\": \"gid://shopify/SubscriptionContract/593791907\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query subscriptionBillingCycles($contractId: ID!) {\n subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesIndexRangeSelector: {startIndex: 1, endIndex: 3}) {\n edges {\n node {\n billingAttemptExpectedDate\n }\n }\n }\n}" #### Graphql Input { "contractId": "gid://shopify/SubscriptionContract/593791907" } #### Graphql Response { "data": { "subscriptionBillingCycles": { "edges": [ { "node": { "billingAttemptExpectedDate": "2022-01-02T11:59:59Z" } }, { "node": { "billingAttemptExpectedDate": "2020-11-25T15:00:00Z" } }, { "node": { "billingAttemptExpectedDate": "2022-03-01T00:00:00Z" } } ] } } }