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 pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) { pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) { webhookSubscription { id topic format endpoint { __typename ... on WebhookPubSubEndpoint { pubSubProject pubSubTopic } } } } }\",\n \"variables\": {\n \"topic\": \"ORDERS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n format\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"topic\": \"ORDERS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\"\n }\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 pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n format\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"topic\": \"ORDERS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\"\n }\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 = <<\"ORDERS_CREATE\",\n \"webhookSubscription\" => [\n \"pubSubProject\" => \"my-gcp-project\",\n \"pubSubTopic\" => \"my-gcp-topic\",\n \"format\" => \"JSON\",\n ],\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 pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n format\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"topic\": \"ORDERS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n format\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n }\n}"
input: { "topic": "ORDERS_CREATE", "webhookSubscription": { "pubSubProject": "my-gcp-project", "pubSubTopic": "my-gcp-topic", "format": "JSON" } }
response: { "data": { "pubSubWebhookSubscriptionCreate": { "webhookSubscription": { "id": "gid://shopify/WebhookSubscription/7768084096", "topic": "ORDERS_CREATE", "format": "JSON", "endpoint": { "__typename": "WebhookPubSubEndpoint", "pubSubProject": "my-gcp-project", "pubSubTopic": "my-gcp-topic" } } } } }
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 pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) { pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) { webhookSubscription { id topic filter format endpoint { __typename ... on WebhookPubSubEndpoint { pubSubProject pubSubTopic } } } userErrors { field message } } }\",\n \"variables\": {\n \"topic\": \"METAOBJECTS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\",\n \"filter\": \"type:lookbook\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n filter\n format\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"topic\": \"METAOBJECTS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\",\n \"filter\": \"type:lookbook\"\n }\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 pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n filter\n format\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"topic\": \"METAOBJECTS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\",\n \"filter\": \"type:lookbook\"\n }\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 = <<\"METAOBJECTS_CREATE\",\n \"webhookSubscription\" => [\n \"pubSubProject\" => \"my-gcp-project\",\n \"pubSubTopic\" => \"my-gcp-topic\",\n \"format\" => \"JSON\",\n \"filter\" => \"type:lookbook\",\n ],\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 pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n filter\n format\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"topic\": \"METAOBJECTS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\",\n \"filter\": \"type:lookbook\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n filter\n format\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "topic": "METAOBJECTS_CREATE", "webhookSubscription": { "pubSubProject": "my-gcp-project", "pubSubTopic": "my-gcp-topic", "format": "JSON", "filter": "type:lookbook" } }
response: { "data": { "pubSubWebhookSubscriptionCreate": { "webhookSubscription": { "id": "gid://shopify/WebhookSubscription/7768084097", "topic": "METAOBJECTS_CREATE", "filter": "type:lookbook", "format": "JSON", "endpoint": { "__typename": "WebhookPubSubEndpoint", "pubSubProject": "my-gcp-project", "pubSubTopic": "my-gcp-topic" } }, "userErrors": [] } } }
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 pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) { pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) { webhookSubscription { id topic format metafieldNamespaces endpoint { __typename ... on WebhookPubSubEndpoint { pubSubProject pubSubTopic } } } } }\",\n \"variables\": {\n \"topic\": \"ORDERS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\",\n \"metafieldNamespaces\": [\n \"MY_NAMESPACE\",\n \"ANOTHER_NAMESPACE\"\n ]\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n format\n metafieldNamespaces\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"topic\": \"ORDERS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\",\n \"metafieldNamespaces\": [\n \"MY_NAMESPACE\",\n \"ANOTHER_NAMESPACE\"\n ]\n }\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 pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n format\n metafieldNamespaces\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"topic\": \"ORDERS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\",\n \"metafieldNamespaces\": [\"MY_NAMESPACE\", \"ANOTHER_NAMESPACE\"]\n }\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 = <<\"ORDERS_CREATE\",\n \"webhookSubscription\" => [\n \"pubSubProject\" => \"my-gcp-project\",\n \"pubSubTopic\" => \"my-gcp-topic\",\n \"format\" => \"JSON\",\n \"metafieldNamespaces\" => [\"MY_NAMESPACE\", \"ANOTHER_NAMESPACE\"],\n ],\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 pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n format\n metafieldNamespaces\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"topic\": \"ORDERS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\",\n \"metafieldNamespaces\": [\n \"MY_NAMESPACE\",\n \"ANOTHER_NAMESPACE\"\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n format\n metafieldNamespaces\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n }\n}"
input: { "topic": "ORDERS_CREATE", "webhookSubscription": { "pubSubProject": "my-gcp-project", "pubSubTopic": "my-gcp-topic", "format": "JSON", "metafieldNamespaces": [ "MY_NAMESPACE", "ANOTHER_NAMESPACE" ] } }
response: { "data": { "pubSubWebhookSubscriptionCreate": { "webhookSubscription": { "id": "gid://shopify/WebhookSubscription/7768084098", "topic": "ORDERS_CREATE", "format": "JSON", "metafieldNamespaces": [ "MY_NAMESPACE", "ANOTHER_NAMESPACE" ], "endpoint": { "__typename": "WebhookPubSubEndpoint", "pubSubProject": "my-gcp-project", "pubSubTopic": "my-gcp-topic" } } } } }
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 pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) { pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) { webhookSubscription { id topic format includeFields endpoint { __typename ... on WebhookPubSubEndpoint { pubSubProject pubSubTopic } } } } }\",\n \"variables\": {\n \"topic\": \"ORDERS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\",\n \"includeFields\": [\n \"id\",\n \"note\"\n ]\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n format\n includeFields\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"topic\": \"ORDERS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\",\n \"includeFields\": [\n \"id\",\n \"note\"\n ]\n }\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 pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n format\n includeFields\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"topic\": \"ORDERS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\",\n \"includeFields\": [\"id\", \"note\"]\n }\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 = <<\"ORDERS_CREATE\",\n \"webhookSubscription\" => [\n \"pubSubProject\" => \"my-gcp-project\",\n \"pubSubTopic\" => \"my-gcp-topic\",\n \"format\" => \"JSON\",\n \"includeFields\" => [\"id\", \"note\"],\n ],\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 pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n format\n includeFields\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"topic\": \"ORDERS_CREATE\",\n \"webhookSubscription\": {\n \"pubSubProject\": \"my-gcp-project\",\n \"pubSubTopic\": \"my-gcp-topic\",\n \"format\": \"JSON\",\n \"includeFields\": [\n \"id\",\n \"note\"\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation pubSubWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: PubSubWebhookSubscriptionInput!) {\n pubSubWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n topic\n format\n includeFields\n endpoint {\n __typename\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n }\n}"
input: { "topic": "ORDERS_CREATE", "webhookSubscription": { "pubSubProject": "my-gcp-project", "pubSubTopic": "my-gcp-topic", "format": "JSON", "includeFields": [ "id", "note" ] } }
response: { "data": { "pubSubWebhookSubscriptionCreate": { "webhookSubscription": { "id": "gid://shopify/WebhookSubscription/7768084095", "topic": "ORDERS_CREATE", "format": "JSON", "includeFields": [ "id", "note" ], "endpoint": { "__typename": "WebhookPubSubEndpoint", "pubSubProject": "my-gcp-project", "pubSubTopic": "my-gcp-topic" } } } } }