Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Discord: POST to Channels via Webhooks

Premium
6:33

Let's explore more complex HTTP Client usage by building a Discord webhook notification to alert your community when new tutorials are published.

We will send a message to the Discord server after submitting this long form:

Discord Notification Preview

This is the message we'll see on Discord:

Discord doesn't provide an official PHP package, unlike many APIs, so we must use the Laravel HTTP Client.


What You'll Learn

By the end of this lesson, you will learn how to:

  • Send POST requests with complex JSON structures and nested data
  • Retries: implement exponential backoff with jitter in cases when webhook doesn't work from the first attempt

Setting Up Your Discord Webhook

Discord webhooks are HTTP endpoints that allow external applications to send messages directly to Discord channels.

Before diving into code, you need a webhook URL from Discord:

  1. Navigate to your Discord server → Server Settings → Integrations
  2. Click "Create Webhook" or "View Webhooks"
  3. Choose your target channel and copy the webhook URL
  4. Optionally customize the webhook's name and avatar (we'll override these in code)

The webhook URL looks like: https://discord.com/api/webhooks/123456789/abcdefghijklmnop

This is the URL we would send our POST request to:

$webhookUrl = 'https://discord.com/api/webhooks/123456789/abcdefghijklmnop';
$payload = []; // we will later fill this array
Http::withHeaders(...)
->post($webhookUrl, $payload);

Critical note: Treat webhook URLs like...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (29 h 46 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

No comments yet…

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.