webhookSubscription
Returns a webhook subscription by ID.
Building an app? If you only use app-specific webhooks, you won't need this. App-specific webhook subscriptions specified in your shopify.app.toml
may be easier. They are automatically kept up to date by Shopify & require less maintenance. Please read About managing webhook subscriptions.
Anchor to Possible returnsPossible returns
- Anchor to WebhookSubscriptionWebhook•
Subscription A webhook subscription is a persisted data object created by an app using the REST Admin API or GraphQL Admin API. It describes the topic that the app wants to receive, and a destination where Shopify should send webhooks of the specified topic. When an event for a given topic occurs, the webhook subscription sends a relevant payload to the destination. Learn more about the webhooks system.
- Get a single webhook subscription's ID, topic, and endpoint
- Get a specific webhook subscription using the node field and a GraphQL fragment
- Get the dates a webhook subscription was created and updated
- Get the format in which the webhook subscription serializes the payload
- Get the topic of a webhook subscription
- Receive a single Webhook
Examples
query {
webhookSubscription(id: "gid://shopify/WebhookSubscription/892403750") {
id
topic
endpoint {
__typename
... on WebhookHttpEndpoint {
callbackUrl
}
... on WebhookEventBridgeEndpoint {
arn
}
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query { webhookSubscription(id: \"gid://shopify/WebhookSubscription/892403750\") { id topic endpoint { __typename ... on WebhookHttpEndpoint { callbackUrl } ... on WebhookEventBridgeEndpoint { arn } } } }"
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query {
webhookSubscription(id: "gid://shopify/WebhookSubscription/892403750") {
id
topic
endpoint {
__typename
... on WebhookHttpEndpoint {
callbackUrl
}
... on WebhookEventBridgeEndpoint {
arn
}
}
}
}`,
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `query {
webhookSubscription(id: "gid://shopify/WebhookSubscription/892403750") {
id
topic
endpoint {
__typename
... on WebhookHttpEndpoint {
callbackUrl
}
... on WebhookEventBridgeEndpoint {
arn
}
}
}
}`,
});
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 {
webhookSubscription(id: "gid://shopify/WebhookSubscription/892403750") {
id
topic
endpoint {
__typename
... on WebhookHttpEndpoint {
callbackUrl
}
... on WebhookEventBridgeEndpoint {
arn
}
}
}
}
QUERY
response = client.query(query: query)