How to Configure Magento 2 Webhooks?

How to Configure Magento 2 Webhooks?

Introduction

Webhooks in Magento 2 allow real-time communication with Odoo by sending event-based notifications. This guide explains how to set up Magento 2 webhooks to seamlessly integrate with Odoo’s webhook system.

Step 1: Copy the Webhook URL from Odoo

  1. In Odoo, navigate to Integrations > Webhooks.

  2. Copy the Payload URL, which follows this format:

    http://your-odoo-instance.com/{db_name}/magento2/{integration_id}/{type}
    • Replace {your-odoo-instance.com} with your actual Odoo instance.

    • {db_name} is the name of your Odoo database. It should match the database you are using in your Odoo instance.

    • {integration_id} is the unique ID of your Magento integration in Odoo.

    • {type} is the event type (e.g., orders, products, shipments, invoices).

      Screenshot 2025-03-18 at 17.00.43.png

Step 2: Access Webhook Settings in Magento 2

  1. Log in to your Magento 2 Admin Panel.

  2. Navigate to System > Webhook > Manage Hooks.

  3. Click the arrow next to Add New to reveal the dropdown.

  4. Select the appropriate webhook type depending on the event you want to handle.

Screenshot 2025-03-18 at 17.02.56.png

Screenshot 2025-03-26 at 10.00.01.png

Step 3: Configure Webhooks by Type

✉️ Order

  • Name: Assign a meaningful name (e.g., “Order”).

  • Status: Enabled

  • Order Status: All or select specific statuses to trigger the webhook

  • Store Views: Select store views that this hook applies to

  • Payload URL: Paste the URL from Odoo

  • Method: POST

  • Headers:

    • X-Magento2-Shop-Domain: Your Magento domain

    • X-Hook: order_updated

    • Integration-Api-Key: (from Odoo > Settings > Integration)

      Screenshot 2025-03-18 at 17.12.46.png
  • Content Type: application/json

  • Body:

    {
    	"id":  "{{ item.entity_id }}",
    	"status": "{{ item.status }}"
    }
  • Save the Hook

ℹ️ Note: This webhook handles both order creation and order status updates. If the order does not exist in Odoo when the webhook is received, it will be created. If it already exists, its status will be updated accordingly.

Screenshot 2025-03-26 at 10.10.40.pngScreenshot 2025-03-18 at 17.16.25.png

🚚 New Shipment

  • Name: “New Shipment”

  • Status: Enabled

  • Store Views: Select store views

  • Payload URL: Paste the URL from Odoo

  • Method: POST

  • Headers:

    • X-Magento2-Shop-Domain: Your Magento domain

    • X-Hook: shipment_created

    • Integration-Api-Key: (from Odoo > Settings > Integration)

  • Content Type: application/json

  • Body:

    {
      "id": "{{ item.entity_id }}",
      "status": "{{ item.status }}"
    }
  • Save the Hook


📈 New Invoice

  • Name: “New Invoice”

  • Status: Enabled

  • Store Views: Select store views

  • Payload URL: Paste the URL from Odoo

  • Method: POST

  • Headers:

    • X-Magento2-Shop-Domain: Your Magento domain

    • X-Hook: invoice_created

    • Integration-Api-Key: (from Odoo > Settings > Integration)

  • Content Type: application/json

  • Body:

    {
      "id": "{{ item.entity_id }}",
      "status": "{{ item.status }}"
    }
  • Save the Hook


🏢 New Product / Update Product / Delete Product Webhooks

For each action, create a separate hook:

  • Name: e.g., “New Product”, “Update Product”, “Delete Product”

  • Status: Enabled

  • Store Views: Select store views

  • Payload URL: Paste the URL from Odoo

  • Method: POST

  • Headers:

    • X-Magento2-Shop-Domain: Your Magento domain

    • X-Hook: product_created, product_updated, or product_deleted

    • Integration-Api-Key: (from Odoo > Settings > Integration)

  • Content Type: application/json

  • Body:

    {
    	"id":  "{{ item.entity_id }}",
    	"name": "{{ item.name }}",
    	"type": "{{ item.type_id }}",
    	"visibility": "{{ item.visibility }}"
    }
  • Save the Hook

Supported Webhook Events

Our Magento 2 connector supports the following webhook events:

  • order_created (also handles updates to order status)

  • shipment_created

  • invoice_created

  • product_created

  • product_updated

  • product_deleted

Conclusion

By following these steps, you can ensure a smooth Magento 2-to-Odoo webhook integration. If issues arise, check the Webhook Logs in both Magento and Odoo for troubleshooting.


💡 Need More Help?

If you encounter issues, please contact our support team:
https://support.ventor.tech/

Related Posts