subscription Contract Atomic Createmutation
mutation
2024-10latest
Requires write
access scope. Also: The user must have manage_orders_information permission.
Creates a Subscription Contract.
Arguments
The properties of the new Subscription Contract.
Was this section helpful?
SubscriptionContractAtomicCreatePayload returns
The new Subscription Contract object.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: subscriptionContractAtomicCreate
Query Reference for MUTATION: subscriptionContractAtomicCreate
"mutation subscriptionContractAtomicCreate($input: SubscriptionContractAtomicCreateInput!) {\n subscriptionContractAtomicCreate(input: $input) {\n contract {\n # SubscriptionContract fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: subscriptionContractAtomicCreate
"{\n \"input\": {\n \"contract\": {\n \"billingPolicy\": {\n \"anchors\": [\n {\n \"cutoffDay\": 1,\n \"day\": 1,\n \"month\": 1,\n \"type\": \"MONTHDAY\"\n }\n ],\n \"interval\": \"DAY\",\n \"intervalCount\": 1,\n \"maxCycles\": 1,\n \"minCycles\": 1\n },\n \"customAttributes\": [\n {\n \"key\": \"<your-key>\",\n \"value\": \"<your-value>\"\n }\n ],\n \"deliveryMethod\": {\n \"localDelivery\": {\n \"address\": {\n \"address1\": \"<your-address1>\",\n \"address2\": \"<your-address2>\",\n \"city\": \"<your-city>\",\n \"company\": \"<your-company>\",\n \"countryCode\": \"AC\",\n \"firstName\": \"<your-firstName>\",\n \"lastName\": \"<your-lastName>\",\n \"phone\": \"<your-phone>\",\n \"provinceCode\": \"<your-provinceCode>\",\n \"zip\": \"<your-zip>\"\n },\n \"localDeliveryOption\": {\n \"code\": \"<your-code>\",\n \"description\": \"<your-description>\",\n \"instructions\": \"<your-instructions>\",\n \"phone\": \"<your-phone>\",\n \"presentmentTitle\": \"<your-presentmentTitle>\",\n \"title\": \"<your-title>\"\n }\n },\n \"pickup\": {\n \"pickupOption\": {\n \"code\": \"<your-code>\",\n \"description\": \"<your-description>\",\n \"locationId\": \"gid://shopify/<objectName>/10079785100\",\n \"presentmentTitle\": \"<your-presentmentTitle>\",\n \"title\": \"<your-title>\"\n }\n },\n \"shipping\": {\n \"address\": {\n \"address1\": \"<your-address1>\",\n \"address2\": \"<your-address2>\",\n \"city\": \"<your-city>\",\n \"company\": \"<your-company>\",\n \"countryCode\": \"AC\",\n \"firstName\": \"<your-firstName>\",\n \"lastName\": \"<your-lastName>\",\n \"phone\": \"<your-phone>\",\n \"provinceCode\": \"<your-provinceCode>\",\n \"zip\": \"<your-zip>\"\n },\n \"shippingOption\": {\n \"carrierServiceId\": \"gid://shopify/<objectName>/10079785100\",\n \"code\": \"<your-code>\",\n \"description\": \"<your-description>\",\n \"presentmentTitle\": \"<your-presentmentTitle>\",\n \"title\": \"<your-title>\"\n }\n }\n },\n \"deliveryPolicy\": {\n \"anchors\": [\n {\n \"cutoffDay\": 1,\n \"day\": 1,\n \"month\": 1,\n \"type\": \"MONTHDAY\"\n }\n ],\n \"interval\": \"DAY\",\n \"intervalCount\": 1\n },\n \"deliveryPrice\": \"29.99\",\n \"nextBillingDate\": \"2019-09-07T15:50:00Z\",\n \"note\": \"<your-note>\",\n \"paymentMethodId\": \"gid://shopify/<objectName>/10079785100\",\n \"status\": \"ACTIVE\"\n },\n \"currencyCode\": \"AED\",\n \"customerId\": \"gid://shopify/<objectName>/10079785100\",\n \"discountCodes\": [\n \"<your-discountCodes>\"\n ],\n \"lines\": [\n {\n \"discounts\": [\n {\n \"recurringCycleLimit\": 1,\n \"title\": \"<your-title>\",\n \"value\": {\n \"fixedAmount\": {\n \"amount\": 1.1,\n \"appliesOnEachItem\": true\n },\n \"percentage\": 1\n }\n }\n ],\n \"line\": {\n \"currentPrice\": \"29.99\",\n \"customAttributes\": [\n {\n \"key\": \"<your-key>\",\n \"value\": \"<your-value>\"\n }\n ],\n \"pricingPolicy\": {\n \"basePrice\": \"29.99\",\n \"cycleDiscounts\": [\n {\n \"adjustmentType\": \"FIXED_AMOUNT\",\n \"adjustmentValue\": {\n \"fixedValue\": \"29.99\",\n \"percentage\": 1.1\n },\n \"afterCycle\": 1,\n \"computedPrice\": \"29.99\"\n }\n ]\n },\n \"productVariantId\": \"gid://shopify/<objectName>/10079785100\",\n \"quantity\": 1,\n \"sellingPlanId\": \"gid://shopify/<objectName>/10079785100\",\n \"sellingPlanName\": \"<your-sellingPlanName>\"\n }\n }\n ],\n \"nextBillingDate\": \"2019-09-07T15:50:00Z\"\n }\n}"
Schema Reference for MUTATION: subscriptionContractAtomicCreate
"input SubscriptionContractAtomicCreateInput {\n contract: SubscriptionDraftInput!\n currencyCode: CurrencyCode!\n customerId: ID!\n discountCodes: [String!]\n lines: [SubscriptionAtomicLineInput!]!\n nextBillingDate: DateTime!\n}\n\ninput SubscriptionDraftInput {\n billingPolicy: SubscriptionBillingPolicyInput\n customAttributes: [AttributeInput!]\n deliveryMethod: SubscriptionDeliveryMethodInput\n deliveryPolicy: SubscriptionDeliveryPolicyInput\n deliveryPrice: Decimal\n nextBillingDate: DateTime\n note: String\n paymentMethodId: ID\n status: SubscriptionContractSubscriptionStatus\n}\n\ninput SubscriptionAtomicLineInput {\n discounts: [SubscriptionAtomicManualDiscountInput!]\n line: SubscriptionLineInput!\n}\n"
Display Examples for MUTATION: subscriptionContractAtomicCreate
[ { "example": { "type_name": "subscriptioncontractatomiccreate", "title": "Create a subscription contract with a single line item", "description": "Creates a subscription contract with a line item with a single GraphQL call.\n", "query_string": "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}", "variables": { "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": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/sales/subscriptions/test/unit/graph_api/admin/mutations/subscription_contract_atomic_create_test.rb", "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", "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", "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", "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", "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" }, "titleStringKey": "variables", "inputVariableEntries": [] } ]