Setting up webhooks

Overview

Ordoo allows you to subscribe to webhook events that notify your application in real-time when an event occurs. This is especially useful for events like orders being placed at a store that are not triggered by an API request that originated from your application.

Ordoo implements strict API rate limiting to ensure good quality of service. Our API endpoints should not be polled unless otherwise stated. Instead utilise webhooks to ensure that interactions are delivered in real-time and in an efficient manor.

Events

The following events can be subscribed to:

Event Name

Description

Resources included

order.created

An order was placed

User, Order Products, Order Product

order.updated

An order was updated (e.g. canceled by the user)

User, Order Products, Order Product

collection.created

A collection was created

Collection

collection.updated

A collection was updated (e.g. changed title)

Collection

collection.destroyed

A collection was deleted

-

product.created

A product was created

Product

product.updated

A product was updated (e.g. changed title)

Product

product.destroyed

A product was deleted

-

trait.created

A trait was created

Trait

trait.updated

A trait was updated (e.g. changed title)

Trait

trait.destroyed

A trait was deleted

-

trait_option.created

A trait option was created

Trait Option

trait_option.updated

A trait option was updated (e.g. changed title)

Trait Option

trait_option.destroyed

A trait option was deleted

-

Subscribing to events

To subscribe to webhooks you can use the Developers dashboard to register a new Webhook Endpoint or use the Ordoo API to create a Webhook Endpoint.

Here is an example of subscribing to a couple of events using the API:

curl https://api.ordoo.app/webhook_endpoints \
-H 'Accept: application/vnd.ordoo.v2' \
-H 'Authorization: Bearer {access_token}' \
-d callback_uri="https://example.com/my/webhook/endpoint" \
-d enabled_events[]="order.created" \
-d enabled_events[]="order.updated"

For more details and examples you can visit the API reference:

Receiving events

All events are sent you you in real-time to your provided callback URI as POST requests. Here is an example event based on the order.created event:

{
"data": {
"id": "12345",
"type": "webhook_event",
"attributes": {
"id": 12345,
"created_at": "2020-01-01T14:00:00.000Z",
"event_type": "order.created",
"uri": "https://example.com/webhooks/ordoo"
},
"relationships": {
"subject": {
"data": {
"id": "12345",
"type": "order"
}
},
"resource_owner": {
"data": {
"id": "12345",
"type": "user"
}
}
}
},
"included": [
{
"id": "12345",
"type": "order",
"attributes": {
"id": 12345,
"note": null,
"due_at": "2020-01-01T14:00:00.000Z",
"for_pickup?": false,
"status": "pending",
"created_at": "2020-01-01T14:00:00.000Z",
"order_dependencies_are_present_and_available_for_reorder?": true,
"delivery_method": {
"type": "eat_in",
"table": "10"
},
"subtotal": {
"cents": 440,
"format": "£4.40",
"currency": {
"iso_code": "GBP"
}
},
"total": {
"cents": 140,
"format": "£1.40",
"currency": {
"iso_code": "GBP"
}
},
"history": [
{
"transitioned_at_human": "just now",
"status": "pending",
"transitioned_at": "2020-01-01T14:00:00.000Z",
"most_recent": true
}
]
},
"relationships": {
"order_products": {
"data": [
{
"id": "12345",
"type": "order_product"
}
]
},
"store": {
"data": {
"id": "12345",
"type": "store"
}
},
"user": {
"data": {
"id": "12345",
"type": "user"
}
},
"table": {
"data": {
"id": "12345",
"type": "table"
}
},
"feedback": {
"data": null
}
}
},
{
"id": "12345",
"type": "order_product_trait_option",
"attributes": {
"id": 12345,
"cost": {
"cents": 150,
"format": "£1.50",
"currency": {
"iso_code": "GBP"
}
}
},
"relationships": {
"trait_option": {
"data": {
"id": "12345",
"type": "trait_option"
}
}
}
},
{
"id": "12345",
"type": "trait_option",
"attributes": {
"id": 12345,
"title": "Gordons Gin & Lemonade",
"description": null,
"available": true,
"default": false,
"cost_adjustment": {
"GBP": {
"cents": 150,
"format": "£1.50",
"currency": {
"iso_code": "GBP"
}
}
}
},
"relationships": {
"trait": {
"data": {
"id": "12345",
"type": "trait"
}
}
}
},
{
"id": "12345",
"type": "trait",
"attributes": {
"id": 12345,
"title": "Add Spirit (25ml) and Mixer",
"description": "",
"required": false,
"allow_multiple": false
},
"relationships": {
"trait_options": {
"data": [
{
"id": "12345",
"type": "trait_option"
}
]
}
}
},
{
"id": "12345",
"type": "order_product",
"attributes": {
"id": 12345,
"note": null,
"quantity": 1,
"total": 440,
"unit_total": 440,
"cost": {
"cents": 290,
"format": "£2.90",
"currency": {
"iso_code": "GBP"
}
}
},
"relationships": {
"product": {
"data": {
"id": "12345",
"type": "product"
}
},
"order_product_trait_options": {
"data": [
{
"id": "12345",
"type": "order_product_trait_option"
}
]
}
}
},
{
"id": "12345",
"type": "product",
"attributes": {
"id": 12345,
"title": "BBQ Chicken Melt",
"description": "Chicken, mozzarella, red onions, BBQ sauce",
"available": true,
"base_cost": {
"GBP": {
"cents": 290,
"format": "£2.90",
"currency": {
"iso_code": "GBP"
}
}
}
},
"relationships": {
"traits": {
"data": [
{
"id": "12345",
"type": "trait"
},
]
},
"externally_managed_product_override": {
"data": null
}
}
},
{
"id": "12345",
"type": "store",
"attributes": {
"id": 12345,
"title": "Example",
"description": "Food & Drink",
"brand_color": "#7bdcb5",
"latitude": 51.450428,
"longitude": -2.594726,
"opening_times": {
"monday": [["11:00", "22:00"]],
"tuesday": [["11:00", "22:00"]],
"wednesday": [["11:00", "22:00"]],
"thursday": [["11:00", "22:00"]],
"friday": [["9:00", "22:00"]],
"saturday": [["11:00", "22:00"]],
"sunday": [["11:00", "22:00"]]
},
"status": "open",
"demo": false,
"active": true,
"due_at_options_mode": "basic",
"created_at": "2020-01-01T14:00:00.000Z",
"is_takeout": false,
"is_restaurant": true,
"geocoded_address": null,
"prevent_orders_being_placed_outside_of_opening_times": true,
"table_is_required_for_eat_in_orders": true,
"accepting_orders?": true,
"due_at_options": [
{
"text": "As soon as possible",
"value": 3,
"type": "relative"
},
{
"text": "5 minutes",
"value": 5,
"type": "relative"
},
{
"text": "10 minutes",
"value": 10,
"type": "relative"
},
{
"text": "15 minutes",
"value": 15,
"type": "relative"
}
],
"logo": {
"x1": "https://d3cvmho5o9maab.cloudfront.net/stores/logos/000/000/12345/x1/Example_LOGO_FINAL.png?1571916000",
"x2": "https://d3cvmho5o9maab.cloudfront.net/stores/logos/000/000/12345/x2/Example_LOGO_FINAL.png?1571916000",
"x3": "https://d3cvmho5o9maab.cloudfront.net/stores/logos/000/000/12345/x3/Example_LOGO_FINAL.png?1571916000"
},
"distance": null,
"walking_distance": null
},
"relationships": {
"photos": {
"data": [
{
"id": "12345",
"type": "photo"
}
]
},
"tables": {
"data": [
{
"id": "12345",
"type": "table"
},
]
},
"loyalty_scheme": {
"data": {
"id": "12345",
"type": "loyalty_scheme"
}
}
}
}
]
}

Important

Your server should respond to webhook events with a 2XX status code.

If we receive we receive a status code that is not successful then we'll re-attempt delivery of the webhook up to 5 times.