Anchor to subscriptionBillingCyclesubscription
subscriptionBillingCycle
query
Returns a subscription billing cycle found either by cycle index or date.
Anchor to Arguments
Arguments
- Anchor to billingCycleInputbilling•
Cycle Input SubscriptionBilling requiredCycle Input! Input object used to select and use billing cycles.
Was this section helpful?
Anchor to Possible returnsPossible returns
- Anchor to SubscriptionBillingCycleSubscription•
Billing Cycle A subscription billing cycle.
Was this section helpful?
- Get a billing cycle by cycle index
- Get a billing cycle by date
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 query subscriptionBillingCycle($contractId: ID!, $index: Int!) {6 subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {index: $index}}) {7 billingAttemptExpectedDate8 }9 }`,10 {11 variables: {12 "contractId": "gid://shopify/SubscriptionContract/593791907",13 "index": 114 },15 },16);1718const data = await response.json();19
query subscriptionBillingCycle($contractId: ID!, $index: Int!) {
subscriptionBillingCycle(billingCycleInput: {contractId: $contractId, selector: {index: $index}}) {
billingAttemptExpectedDate
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/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
}
}'
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 data = await response.json();
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
},
},
});
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
JSON1{2 "contractId": "gid://shopify/SubscriptionContract/593791907",3 "index": 14}
Response
JSON1{2 "subscriptionBillingCycle": {3 "billingAttemptExpectedDate": "2022-01-02T11:59:59Z"4 }5}