Version: 2024-10
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\": \"mutation($customerId: ID!, $paymentMethodId: ID!, $variantId: ID!) { subscriptionContractAtomicCreate(input: {customerId: $customerId, nextBillingDate: \\\"2025-06-01\\\", currencyCode: USD, lines: [{line: {productVariantId: $variantId, quantity: 20, currentPrice: 25.0}}], contract: {status: ACTIVE, paymentMethodId: $paymentMethodId, billingPolicy: {interval: MONTH, intervalCount: 1, minCycles: 3}, deliveryPolicy: {interval: MONTH, intervalCount: 1}, deliveryPrice: 14.99, deliveryMethod: {shipping: {address: {firstName: \\\"John\\\", lastName: \\\"King\\\", address1: \\\"1483 rue Mossoro\\\", city: \\\"Montreal\\\", province: \\\"Quebec\\\", country: \\\"Canada\\\", zip: \\\"H2S1Z5\\\"}}}}}) { contract { id lines(first: 10) { nodes { id quantity } } } userErrors { field message } } }\",\n \"variables\": {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"paymentMethodId\": \"gid://shopify/CustomerPaymentMethod/b7cc6e3267aace169e516ed48be72dff\",\n \"variantId\": \"gid://shopify/ProductVariant/30322695\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation($customerId: ID!, $paymentMethodId: ID!, $variantId: ID!) {\n subscriptionContractAtomicCreate(input: {customerId: $customerId, nextBillingDate: \"2025-06-01\", currencyCode: USD, lines: [{line: {productVariantId: $variantId, quantity: 20, currentPrice: 25.0}}], contract: {status: ACTIVE, paymentMethodId: $paymentMethodId, billingPolicy: {interval: MONTH, intervalCount: 1, minCycles: 3}, deliveryPolicy: {interval: MONTH, intervalCount: 1}, deliveryPrice: 14.99, deliveryMethod: {shipping: {address: {firstName: \"John\", lastName: \"King\", address1: \"1483 rue Mossoro\", city: \"Montreal\", province: \"Quebec\", country: \"Canada\", zip: \"H2S1Z5\"}}}}}) {\n contract {\n id\n lines(first: 10) {\n nodes {\n id\n quantity\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"paymentMethodId\": \"gid://shopify/CustomerPaymentMethod/b7cc6e3267aace169e516ed48be72dff\",\n \"variantId\": \"gid://shopify/ProductVariant/30322695\"\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 mutation($customerId: ID!, $paymentMethodId: ID!, $variantId: ID!) {\n subscriptionContractAtomicCreate(input: {customerId: $customerId, nextBillingDate: \"2025-06-01\", currencyCode: USD, lines: [{line: {productVariantId: $variantId, quantity: 20, currentPrice: 25.0}}], contract: {status: ACTIVE, paymentMethodId: $paymentMethodId, billingPolicy: {interval: MONTH, intervalCount: 1, minCycles: 3}, deliveryPolicy: {interval: MONTH, intervalCount: 1}, deliveryPrice: 14.99, deliveryMethod: {shipping: {address: {firstName: \"John\", lastName: \"King\", address1: \"1483 rue Mossoro\", city: \"Montreal\", province: \"Quebec\", country: \"Canada\", zip: \"H2S1Z5\"}}}}}) {\n contract {\n id\n lines(first: 10) {\n nodes {\n id\n quantity\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"paymentMethodId\": \"gid://shopify/CustomerPaymentMethod/b7cc6e3267aace169e516ed48be72dff\",\n \"variantId\": \"gid://shopify/ProductVariant/30322695\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation($customerId: ID!, $paymentMethodId: ID!, $variantId: ID!) {\n subscriptionContractAtomicCreate(input: {customerId: $customerId, nextBillingDate: \"2025-06-01\", currencyCode: USD, lines: [{line: {productVariantId: $variantId, quantity: 20, currentPrice: 25.0}}], contract: {status: ACTIVE, paymentMethodId: $paymentMethodId, billingPolicy: {interval: MONTH, intervalCount: 1, minCycles: 3}, deliveryPolicy: {interval: MONTH, intervalCount: 1}, deliveryPrice: 14.99, deliveryMethod: {shipping: {address: {firstName: \"John\", lastName: \"King\", address1: \"1483 rue Mossoro\", city: \"Montreal\", province: \"Quebec\", country: \"Canada\", zip: \"H2S1Z5\"}}}}}) {\n contract {\n id\n lines(first: 10) {\n nodes {\n id\n quantity\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"customerId\" => \"gid://shopify/Customer/544365967\",\n \"paymentMethodId\" => \"gid://shopify/CustomerPaymentMethod/b7cc6e3267aace169e516ed48be72dff\",\n \"variantId\" => \"gid://shopify/ProductVariant/30322695\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation($customerId: ID!, $paymentMethodId: ID!, $variantId: ID!) {\n subscriptionContractAtomicCreate(input: {customerId: $customerId, nextBillingDate: \"2025-06-01\", currencyCode: USD, lines: [{line: {productVariantId: $variantId, quantity: 20, currentPrice: 25.0}}], contract: {status: ACTIVE, paymentMethodId: $paymentMethodId, billingPolicy: {interval: MONTH, intervalCount: 1, minCycles: 3}, deliveryPolicy: {interval: MONTH, intervalCount: 1}, deliveryPrice: 14.99, deliveryMethod: {shipping: {address: {firstName: \"John\", lastName: \"King\", address1: \"1483 rue Mossoro\", city: \"Montreal\", province: \"Quebec\", country: \"Canada\", zip: \"H2S1Z5\"}}}}}) {\n contract {\n id\n lines(first: 10) {\n nodes {\n id\n quantity\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"paymentMethodId\": \"gid://shopify/CustomerPaymentMethod/b7cc6e3267aace169e516ed48be72dff\",\n \"variantId\": \"gid://shopify/ProductVariant/30322695\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation($customerId: ID!, $paymentMethodId: ID!, $variantId: ID!) {\n subscriptionContractAtomicCreate(input: {customerId: $customerId, nextBillingDate: \"2025-06-01\", currencyCode: USD, lines: [{line: {productVariantId: $variantId, quantity: 20, currentPrice: 25.0}}], contract: {status: ACTIVE, paymentMethodId: $paymentMethodId, billingPolicy: {interval: MONTH, intervalCount: 1, minCycles: 3}, deliveryPolicy: {interval: MONTH, intervalCount: 1}, deliveryPrice: 14.99, deliveryMethod: {shipping: {address: {firstName: \"John\", lastName: \"King\", address1: \"1483 rue Mossoro\", city: \"Montreal\", province: \"Quebec\", country: \"Canada\", zip: \"H2S1Z5\"}}}}}) {\n contract {\n id\n lines(first: 10) {\n nodes {\n id\n quantity\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "customerId": "gid://shopify/Customer/544365967", "paymentMethodId": "gid://shopify/CustomerPaymentMethod/b7cc6e3267aace169e516ed48be72dff", "variantId": "gid://shopify/ProductVariant/30322695" }
response: { "data": { "subscriptionContractAtomicCreate": { "contract": { "id": "gid://shopify/SubscriptionContract/975257121", "lines": { "nodes": [ { "id": "gid://shopify/SubscriptionLine/93b63eb2-70d1-43db-98a8-031a9b1c8042", "quantity": 20 } ] } }, "userErrors": [] } } }