Fetching data after a webhook
Webhook payloads only contain the ID and a few key fields. To get the full object, fetch it via the GraphQL API with an API key.
For *.deleted events there is nothing to fetch.
Orders
- NodeJS
const fetch = require("node-fetch")
// event.type === 'companyorder.updated'
const orderId = event.data.object.id
const response = await fetch("https://backend.impargo.eu/", {
method: "POST",
headers: {
"authorization": token,
"content-type": "application/json",
},
body: JSON.stringify({
"operationName": "GetCompanyOrder",
"variables": { "query": { "_id": orderId } },
"query": `query GetCompanyOrder($query: CompanyOrderQuery) {
companyOrders(query: $query) {
items {
_id
details {
reference
status
}
price
updatedAt
}
}
}`
})
})
- Response
{
"data": {
"companyOrders": {
"items": [
{
"_id": "64b7f0c2a1b2c3d4e5f60718",
"details": { "reference": "ORD-2026-0042", "status": "PLANNED" },
"price": 1250,
"updatedAt": "2026-10-12T08:15:30.000Z"
}
]
}
}
}
Customers
- NodeJS
const fetch = require("node-fetch")
// event.type === 'customer.created'
const customerId = event.data.object.id
const response = await fetch("https://backend.impargo.eu/", {
method: "POST",
headers: {
"authorization": token,
"content-type": "application/json",
},
body: JSON.stringify({
"operationName": "GetCustomer",
"variables": { "ids": [customerId] },
"query": `query GetCustomer($ids: [ObjectId!]) {
costprofilesCustomer(ids: $ids) {
_id
name
email
telephone
}
}`
})
})
- Response
{
"data": {
"costprofilesCustomer": [
{
"_id": "64b7f0c2a1b2c3d4e5f60719",
"name": "ACME Logistics GmbH",
"email": "dispo@acme.example",
"telephone": "+49 30 123456"
}
]
}
}
Partners
- NodeJS
const fetch = require("node-fetch")
// event.type === 'partner.updated'
const partnerId = event.data.object.id
const response = await fetch("https://backend.impargo.eu/", {
method: "POST",
headers: {
"authorization": token,
"content-type": "application/json",
},
body: JSON.stringify({
"operationName": "GetPartner",
"variables": { "ids": [partnerId] },
"query": `query GetPartner($ids: [ObjectId!]) {
costprofilesSubcontractor(ids: $ids) {
_id
name
email
telephone
}
}`
})
})
- Response
{
"data": {
"costprofilesSubcontractor": [
{
"_id": "64b7f0c2a1b2c3d4e5f60720",
"name": "Fast Freight GmbH",
"email": "dispo@fastfreight.example",
"telephone": "+49 40 654321"
}
]
}
}