What is the Payload and Webhooks? In Laravel Forge Deployment

What is the Payload and Webhooks? In Laravel Forge Deployment

If you are working with Laravel Forge and want to build a custom script that responds to the deployment webhooks than you likely encountered a basic problem: Laravel Forge doesn’t tell you what is provided in the Laravel Forge deployment webhook payload!

Today I am going to show you that payload so you know what to expect when building your webhook script.

Today I am going to show you that payload so you know what to expect when building your webhook script.

laravel1.png

Laravel Forge Deployment Webhook Payload

I get really annoyed when websites allow you to set up webhooks but don’t tell you what to expect in the payload.

After each deployment, Forge will send an HTTP POST request to each of the URLs listed here. The payload of the request will contain the server ID, site ID, deployment status, and the relevant commit information.

Well it seems that Laravel Forge attempted to help us out here. But despite the valiant effort, I can’t write a script on my server that says: let commit = relevant commit information. I need something more precise than that.

To save the day, here is the payload script that Forge Sends to its webhooks:

{
    status: 'success|failure',
    server: {
        id: 123456,
        name: 'Server-Name'
    },
    site: {
        id: 654321,
        name: 'mywebsite.com'
    },
    commit_hash: 'f6991ebebd234565432f811816bddf18d1646ee',
    commit_url: 'https://github.com/username/repository/commit/commit-hash',
    commit_author: 'Your Name',
    commit_message: 'Your commit message here'
}

With this information now you can write a webhook that actually uses this information since now you know not only what is provided, but also how the object is structured and what the keys are called.

Come on guys, if you write a service that sends a mysterious payload off to my server, would it be super hard to paste a demo payload like the one I just did above onto your website.

With great power, comes great responsibility. If you are going to send webhooks, be nice and tell me what you are sending us.