OdooWiki OCA HUB

Endpoint route handler

endpoint_route_handler folder_open OCA/web-api open_in_new
Uncategorised License: LGPL-3

Technical module that provides a base handler for adding and removing controller routes on the fly.

Can be used as a mixin or as a tool.

auto_awesome What this module does

AI-generated from the code · Odoo 19.0

Technical module that lets developers register custom web endpoints (URLs) directly from Odoo records, without editing code. It provides a base model and a tool to add or remove routes on the fly.

This is a technical module aimed at developers building other modules. It does not add menus or screens for end users; instead it provides a reusable base model endpoint.route.handler and a helper tool endpoint.route.handler.tool that other modules can inherit to expose custom web endpoints.

  • Each endpoint record stores a name, a route (URL path), the HTTP method (GET, POST, PUT, DELETE), the authentication type (Public, User, API Key), the request content type, CORS origins, CSRF and read-only flags.
  • Routes are automatically normalised: a leading slash is added and a configurable prefix can be applied.
  • Business rules: routes must be unique across all models using this handler, and some paths such as / and /web are blacklisted. For POST and PUT requests a content type is mandatory.
  • When a record is created, modified or deleted, the module synchronises the routing registry so the new endpoint becomes available (or is removed) without restarting Odoo. A registry_sync flag indicates pending changes.
  • It hooks into ir.http to inject the custom rules into the routing map and adds a special user_endpoint authentication that returns a proper Unauthorized error instead of redirecting to the login page.
  • Access rights allow system administrators to manage endpoint records; other users have read-only access.

Depends on

base

Required by other modules

Models and fields (4)
  • ir.http · extends an existing model
  • endpoint.route.handler · new modelcors, csrf, name, route, readonly, auth_type, route_type, route_group, endpoint_hash, request_method, request_content_type
  • endpoint.route.sync.mixin · new modelactive, registry_sync
  • endpoint.route.handler.tool · new model

Text generated by AI (DeepSeek) from reading the Odoo 19.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 5 confirmed, 4 with no information of 9 versions.

terminal Installation and usage

OCA documentation · Odoo 19.0

As a mixin

Use standard Odoo inheritance:

class MyModel(models.Model): _name = "my.model" _inherit = "endpoint.route.handler"

Once you have this, each my.model record will generate a route. You can have a look at the endpoint module to see a real life example.

The options of the routing rules are defined by the method _default_endpoint_options. Here's an example from the endpoint module:

def _default_endpoint_options_handler(self): return { "klass_dotted_path": "odoo.addons.endpoint.controllers.main.EndpointController", "method_name": "auto_endpoint", "default_pargs": (self.route,), }

As you can see, you have to pass the references to the controller class and the method to use when the endpoint is called. And you can prepare some default arguments to pass. In this case, the route of the current record.

As a tool

Initialize non stored route handlers and generate routes from them. For instance:

route_handler = self.env["endpoint.route.handler.tool"] endpoint_handler = MyController()._my_handler vals = { "name": "My custom route", "route": "/my/custom/route", "request_method": "GET", "auth_type": "public", } new_route = route_handler.new(vals) new_route._register_controller()

Available auth_type values:

  • public: no authentication required
  • user_endpoint: session-based user authentication (default)
  • bearer: API key authentication via Authorization: Bearer header (uses Odoo's built-in res.users.apikeys)

You can override options and define - for instance - a different controller method:

options = { "handler": { "klass_dotted_path": "odoo.addons.my_module.controllers.SpecialController", "method_name": "my_special_handler", } } new_route._register_controller(options=options)

Of course, what happens when the endpoint gets called depends on the logic defined on the controller method.

In both cases (mixin and tool) when a new route is generated or an existing one is updated, the ir.http.routing_map (which holds all Odoo controllers) will be updated.

You can see a real life example on shopfloor.app model.

No verified information in OCA: Installation, Configuration.

info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.