Skip to content
GPLWP Guides

How to connect WordPress with webhooks

Developer Tools Time About 30–60 minutes for custom code, or about 15 minutes with a plugin 6 steps Updated 14 Nov 2026

DEVELOPER TOOLS
The short answer

WordPress can send webhooks with its HTTP API and receive them through a custom REST API route, but you must write and secure the integration yourself. For two-way connections, retries, and event-based workflows without custom code, a webhook automation plugin is the faster option.

The route
  1. 01Define the webhook flow
  2. 02Create the receiving endpoint
  3. 03Send an outgoing webhook
  4. 04Authenticate and limit access
  5. 05Test the complete request
  6. 06Choose the fast route

What you need

  • A WordPress site with administrator access
  • An HTTPS site with REST API access
  • The receiving service's webhook URL or API documentation
  • A test event and sample payload

Define the webhook flow

Decide whether WordPress will send data to another service, receive data from another service, or do both. Write down the event, the HTTP method, the payload fields, the expected response, and what should happen if the request fails.

Use HTTPS for both sides. Treat webhook URLs, bearer tokens, and signing secrets as credentials, not as ordinary settings that can be exposed in page content.

Create the receiving endpoint

For incoming webhooks, create a small plugin or site-specific integration that registers a custom REST API route. WordPress requires custom routes to be registered through register_rest_route() on the rest_api_init hook, and the route can accept a POST request handled by your callback.

Read the request body in the callback, validate the content type and required fields, then check a shared secret or signature before changing anything in WordPress. Do not use a browser nonce as the authentication method for a third-party server calling your endpoint; WordPress documents nonces primarily for requests made by logged-in users in the site context.

Send an outgoing webhook

For outgoing webhooks, call the receiving service with WordPress's HTTP API. The usual function for a JSON POST is wp_remote_post(); pass the destination URL, JSON body, content type, authentication header, and a sensible timeout. The function returns either a response array or WP_Error, so handle both outcomes.

Trigger the request from the event you care about, such as a form submission, a published post, or an order status change. Keep the webhook code in a small custom plugin or site-specific plugin rather than the active theme, so a theme change does not remove the integration.

Authenticate and limit access

Use the authentication method required by the receiving service, commonly a bearer token, basic authentication, or a signature calculated from the raw request body. Store secrets outside templates and never print them in logs or return them in the response. Validate incoming fields, reject unexpected methods, and check permissions before creating or updating WordPress data.

A public endpoint can attract repeated or forged requests. Add rate limiting or upstream protection where appropriate, and make the handler idempotent by recording an event ID or rejecting duplicates. A successful HTTP response should mean the request was accepted, not that every downstream action has completed.

Test the complete request

Send a test request with the exact method, headers, and JSON structure expected by the other service. Confirm the receiving endpoint returns the expected status code and that WordPress or the external app performs only one action.

When an integration fails, inspect the HTTP status, response body, server error log, and webhook delivery log. A 401 usually points to missing or incorrect authentication, a 403 often indicates a firewall, security plugin, or permission rule, and a timeout can indicate DNS, TLS, hosting, or a slow callback.

Choose the fast route

For a small, stable integration, the manual route is fine and gives you full control. It becomes costly when you need several WordPress events, incoming and outgoing connections, field mapping, delivery logs, retries, or integrations that non-developers must maintain.

For the faster route, use AutomatorWP with its Webhooks extension. It provides two-way webhook triggers and actions for connecting WordPress to APIs and external apps through configured workflows, so you can avoid maintaining a separate custom integration for each connection.

The fast route

Let AutomatorWP do it

Two-way webhook triggers and actions for connecting WordPress to APIs and external apps without custom integration code.

Get AutomatorWP

Sources

  1. developer.wordpress.org /reference/functions/register_rest_route/?utm_source=openai
  2. developer.wordpress.org /rest-api/using-the-rest-api/authentication/?trk=article-ssr…
  3. developer.wordpress.org /reference/functions/wp_remote_post/?utm_source=openai
  4. developer.wordpress.org /advanced-administration/wordpress/loopback/?utm_source=open…

Questions

Can WordPress send webhooks without a plugin?
Yes, WordPress can send an outgoing webhook without a plugin by making an HTTP POST with <code>wp_remote_post()</code> from custom code. You still need to connect that request to a real WordPress event, build the payload, authenticate it, handle errors, and decide whether failed deliveries should be retried. A plugin is mainly useful when you want configuration, logs, retries, and multiple workflows without maintaining PHP code.
How does WordPress receive an incoming webhook?
WordPress receives an incoming webhook through a custom REST API route that accepts a POST request. Register the route on <code>rest_api_init</code>, parse and validate the request body, authenticate the sender with a secret or signature, and then perform the required action. Do not leave a state-changing endpoint unauthenticated just because its URL is difficult to guess.
Why is my WordPress webhook returning 401 or 403?
A 401 or 403 response usually means the request is being stopped by authentication, permissions, a security plugin, a web application firewall, or hosting rules. Check the token or signature first, then review the endpoint's permission callback and server logs. Cloudflare, ModSecurity, and blocked loopback requests can also interfere with WordPress HTTP traffic, so ask your host to check those rules if the code looks correct.
Should webhook requests run immediately or through a queue?
Small, non-critical webhook requests can run immediately, but important or slow integrations are safer when queued and retried outside the page request. WordPress relies on loopback requests for WP-Cron, and failed loopbacks can stop scheduled events from running. Low-traffic sites can also delay WP-Cron work until someone visits, so use a reliable server cron or a queue when delivery timing matters.