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
In Odoo, navigate to Integrations > Webhooks.
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
).
Step 2: Access Webhook Settings in Magento 2
Log in to your Magento 2 Admin Panel.
Navigate to System > Webhook > Manage Hooks.
Click the arrow next to Add New to reveal the dropdown.
Select the appropriate webhook type depending on the event you want to handle.
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 domainX-Hook
:order_updated
Integration-Api-Key
: (from Odoo > Settings > Integration)
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.
🚚 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 domainX-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 domainX-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 domainX-Hook
:product_created
,product_updated
, orproduct_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/