Webhooks
Webhooks
Our API can be used to configure webhook subscriptions for when an event is saved, and when an order is saved.
Webhook subscriptions are scoped to a single client account. It is not possible to subscribe to webhooks for a client account that you don't have access to.
Event Saved - Fires when an event or any of it's associated objects gets created or modified. Order Saved - Fires when a ticket on an order is sold via any channel, when a ticket on an order is refunded, reissued, or cancelled.
Event driven integrations that consume our webhooks need to be idempotent, because the same message can be delivered multiple times for different reasons, and the payload doesn't clearly identify why the webhook has been fired. Therefore the integration needs to implement it's own business rules to determine action that should be taken e.g. if Moshtix tickets are valid, ensure barcode is loaded into turnstiles, otherwise invalidate them in turnstile system.
The following example demonstrates how to configure a webhook subscription for a client for the order saved system event i.e. it will deliver a HTTP POST to the specified URL every time an order is sold, refunded, reissued, cancelled etc.
mutation {
viewer(token: "your-token-here") {
saveWebhook(webhook: {
client: {
id: 6080,
},
url: "https://webhook.site/36b55298-164a-43e0-83a4-fe9599399892",
headers: {
items: [
{
name: "Content-Type",
value: "application/json"
}
]
},
body: "{ \"eventType\": \"@eventType\", \"contextId\": @contextId, \"data\": @data}",
systemEventTypes: {
items: [
{
systemEventType: ORDER_SAVED
}
]
},
enabled: true
}) {
id
client{
id
}
url
headers{
items{
id
name
value
}
}
body
systemEventTypes{
items{
id
systemEventType
}
}
enabled
}
}
}
An example webhook payload for ORDER_SAVED is below.
{
"eventType": "order-saved-prepare-full-message",
"contextId": 37228036,
"data": {
"id": 37228036,
"createdDate": "2021-11-02T07:47:57.000Z",
"channel": "ONLINE",
"refCode": "",
"offerCode": "",
"customer": {
"id": 6702175,
"email": "test@moshtix.com",
"firstName": "Fred",
"lastName": "Durst",
"telephone": "0433567777"
},
"event": {
"id": 132218,
"name": "Test API Event",
"startDate": "2023-12-31T22:30:00.000Z",
"endDate": "2023-12-31T23:30:00.000Z",
"client": null,
"tags": {
"items": []
}
},
"tickets": {
"items": [
{
"id": 29734124,
"firstName": null,
"lastName": null,
"valid": true,
"barcode": "F2D705C60392480385CD7BEF6C0A70DF",
"unitCost": 0,
"bookingFee": 0,
"totalCost": 0,
"discount": 0,
"ticketType": {
"id": 360875,
"name": "free",
"tags": {
"items": []
}
}
}
]
},
"transactions": {
"items": [
{
"id": 12894177,
"type": "PURCHASE",
"status": "SUCCESS",
"ipAddress": "2001:8004:1140:7f9e:64bc:1ec4:94a7:de87"
}
]
}
}
}
The following example demonstrates how to configure a webhook subscription for a client for the event saved system event i.e. it will deliver a HTTP POST to the specified URL every time an event is created or changed etc.
mutation {
viewer(token: "your-token-here") {
saveWebhook(webhook: {
client: {
id: 6080,
},
url: "https://webhook.site/36b55298-164a-43e0-83a4-fe9599399892",
headers: {
items: [
{
name: "Content-Type",
value: "application/json"
}
]
},
body: "{ \"eventType\": \"@eventType\", \"contextId\": @contextId, \"data\": @data}",
systemEventTypes: {
items: [
{
systemEventType: EVENT_SAVED
}
]
},
enabled: true
}) {
id
client{
id
}
url
headers{
items{
id
name
value
}
}
body
systemEventTypes{
items{
id
systemEventType
}
}
enabled
}
}
}