Anchor to section titled 'undefined'

subscriptionBillingCycle
query

Returns a subscription billing cycle found either by cycle index or date.


Input object used to select and use billing cycles.


Was this section helpful?

Anchor to SubscriptionBillingCycle
SubscriptionBillingCycle
Access requirements

A subscription billing cycle.


Was this section helpful?

Examples

Hide code
DescriptionCopy
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/2024-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();
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)
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
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$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]);
Hide code
Input variables
Copy
{
  "contractId": "gid://shopify/SubscriptionContract/593791907",
  "index": 1
}
Hide code
Response
JSON
{
  "subscriptionBillingCycle": {
    "billingAttemptExpectedDate": "2022-01-02T11:59:59Z"
  }
}