Prompt
How do I send a webhook when a record is created in my app?
Latest observation
Oct 5, 2026
OpenAI APIWeb search: off
To send a webhook when a record is created, you generally do this in your app’s “create record” flow:
- Save the record
- Trigger a webhook call to the external URL
- Include the new record data in the request payload
Basic approach
1) Define the webhook URL
This is the endpoint on the receiving system, for example:
https://example.com/webhooks/record-created
2) Send an HTTP POST after creation
Most webhooks are sent as a POST request with JSON.
Example payload:
{
"event": "record.created",
"id": "123",
"name": "New Record",
"created_at": "2026-10-05T12:34:56Z"
}
3) Implement it in your app
Here’s a simple example in Node.js using fetch:
async function createRecord(data) {
const record = await db.records.insert(data);
await fetch("https://example.com/webhooks/record-created", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Webhook-Event": "record.created"
},
body: JSON.stringify({
event: "record.created",
record
})
});
return record;
}
Important best practices
- Don’t block the user request if the webhook is slow
- Prefer sending it asynchronously via a job queue/background worker.
- Retry on failure
- Webhooks can fail due to network issues.
- Sign the payload
- Add an HMAC signature header so the receiver can verify authenticity.
- Avoid sending sensitive data unless necessary.
- Log deliveries
- Store success/failure for debugging.
Better production pattern
Instead of calling the webhook directly in the request, you can:
- create the record
- enqueue a background job
- worker sends the webhook
- retry if needed
That makes your app more reliable.
If you want, I can show you:
- a Node.js, Python, PHP, or Ruby example
- how to secure webhook signatures
- how to do this with a queue/background job