How to Create a Webhook in a Namespaced Salesforce Org for Meta Messaging Integrations

By | November 25, 2025

Integrating Salesforce with Meta’s Messaging APIs (WhatsApp, Messenger, and Instagram DM) requires setting up a webhook to receive real-time inbound messages, delivery updates, and event notifications. While building a webhook endpoint in Salesforce is generally straightforward, additional considerations arise when your Salesforce org uses a namespace, especially in managed package or ISV environments.

This blog explains:

  • What a webhook is in Meta Messaging
  • Challenges introduced by Salesforce namespaces
  • How to create a webhook using Apex REST
  • How to expose and register the webhook URL

Let’s begin.

1. Understanding Meta Messaging Webhooks

In Meta Messaging, a webhook is a publicly accessible endpoint where Meta sends key events such as:

  • Incoming messages (text, media, interactive responses)
  • Message delivery status updates (sent, delivered, read)
  • Errors and webhook subscription events

Meta requires that your webhook:

  • Accepts POST requests (JSON payload)
  • Handles GET requests for webhook verification
  • Correctly returns the challenge token during validation
  • Responds with 200 OK for all valid events

This ensures smooth, real-time communication between Meta platforms and Salesforce.

2. Considerations When Using a Salesforce Org with a Namespace

If your org uses a namespace prefix, for example:

abcd__MyWebhookService

then:

  • All Apex REST classes automatically include the namespace
  • Your REST endpoint URL changes and must include the namespace
  • Meta must call the URL with this namespace
  • JSON deserialization may require namespaced classes

This affects everything, from routing to debugging.

3. Creating the Webhook Apex REST Service

Salesforce allows you to expose custom API endpoints using the @RestResource annotation.

Here is a namespace-compatible Apex REST structure:

Apex REST Webhook
Apex REST Webhook

4. Standard Processing Class

This is where your core logic for processing messages should exist—for example, handling incoming WhatsApp messages, delivery events, or errors.
You may structure it as a separate Apex class and call it from your REST service for clean maintainability.

5. Endpoint URL Structure with Namespace

Before registering your webhook, ensure your Meta Business Account is properly set up.

If your org’s namespace is xyz, your REST endpoint will be:

https://yourInstance.salesforce.com/services/apexrest/xyz/metaWebhook

If your org does not have a namespace, the endpoint becomes:

https://yourInstance.salesforce.com/services/apexrest/metaWebhook

Conclusion 

Setting up a webhook in a Salesforce org with a namespace requires careful attention to Apex REST routing and URL structure. When the namespace is correctly included, webhook verification, event processing, and JSON handling function reliably—making Salesforce an effective backend for Meta Messaging integrations.

This approach works seamlessly for WhatsApp Cloud API, Messenger, and Instagram DM, enabling your Salesforce applications to receive real-time message events and deliver a unified communication experience.

By following the above blog instructions, you will be able to learn “How to Create a Webhook in a Namespaced Salesforce Org for Meta Messaging Integrations”. If you still have queries or any related problems, don’t hesitate to contact us at salesforce@greytrix.com. More details about our integration product are available on our website and Salesforce AppExchange.

We hope you may find this blog resourceful and helpful. However, if you still have concerns and need more help, please contact us at salesforce@greytrix.com.

About Us

Greytrix – a globally recognized and one of the oldest Sage Development Partner and a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners and Sage PSG across the globe. We offer Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that require apex code incorporation into the Salesforce platform.

Greytrix has some unique solutions for Cloud CRM such as Salesforce Sage integration for Sage X3, Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data Migration, Integrated App development, Custom App development and Technical Support business partners and end users. Salesforce Cloud CRM integration offered by Greytrix works with Lightning web components and supports standard opportunity workflow. Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star rated app listed on Salesforce AppExchange.
The GUMU™ Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for processing and execution of application programs at the click of a button.

For more information on our Salesforce products and services, contact us at salesforce@greytrix.com. We will be glad to assist you.