# Example Webhooks
In this example we are going to register a webhook for product events.
Query:
mutation {
webhookCreate(input: {
active: true
callbackUrl: "https://example.com/orderchamp_webhook"
events: [PRODUCT_CREATED, PRODUCT_DELETED, PRODUCT_UPDATED]
}) {
webhook {
id
callbackUrl
events
active
}
}
}
Response:
{
"data": {
"webhookCreate": {
"webhook": {
"id": "V2ViaG9vazo1NzEzNDgwMDA4NjYzMDU",
"callbackUrl": "https://example.com/orderchamp_webhook",
"events": [
"PRODUCT_CREATED",
"PRODUCT_DELETED",
"PRODUCT_UPDATED"
],
"active": true
}
}
},
}
# Using the Orderchamp-client
If you happen to use the Orderchamp/orderchamp-laravel
package, you could run this query by using the PHP client
<?php
$gql = <<GRAPHQL
mutation ($input: WebhookCreateInput!) {
webhookCreate(input: $input) {
webhook {
id
callbackUrl
events
active
}
}
}
GRAPHQL;
$variables = [
'input' => [
'active' => true,
'callbackUrl' => 'https://example.com/orderchamp_webhook',
'events' => ['PRODUCT_CREATED', 'PRODUCT_DELETED', 'PRODUCT_UPDATED'],
],
];
$response = Orderchamp::api()->graphql($gql, $variables);
var_dump($response);
← Example App Contact →