Skip to main content
Odoo Community Association

Endpoint

Beta License: LGPL-3 OCA/web-api Translate me on Weblate Try me on Runboat

Provide an endpoint framework allowing users to define their own custom endpoint.

Thanks to endpoint mixin the endpoint records are automatically registered as real Odoo routes.

You can easily code what you want in the code snippet.

NOTE: for security reasons any kind of RPC call is blocked on endpoint records.

Table of contents

Configuration

Endpoints are managed under Technical → Endpoints.

Each record represents a single HTTP route exposed by Odoo and executed according to its configuration.

Identification

  • Name: human-readable label used in lists and logs.

  • Route: URL path served by the endpoint (e.g. /my/custom/path). Routes must be unique across all endpoint-consumer models, not only within endpoint.endpoint.

  • Route group: free-text tag to classify related routes together. Useful for filtering and for downstream modules that group endpoints.

Authentication

  • Auth type:

    • User: the request must be authenticated as an Odoo user (default).

    • Public: the route is accessible without authentication.

  • Exec as user: the user under which the code snippet runs.

    • Mandatory when Auth type is Public (the public user has no real privileges, so the endpoint must impersonate a real user to perform any meaningful work).

    • Optional otherwise; if set, the snippet is evaluated as that user instead of the caller.

Request

  • Request method: GET, POST, PUT or DELETE. Requests using any other method are rejected with 405 Method Not Allowed.

  • Request content type: expected Content-Type of the incoming request body. Mandatory for POST/PUT. Available values:

    • text/plain, text/csv

    • application/json

    • application/xml

    • application/x-www-form-urlencoded

    When set, requests with a different Content-Type header are rejected with 415 Unsupported Media Type.

Request content schema (optional)

For POST/PUT endpoints whose content type is application/json or application/xml, an optional Request Schema tab is shown. When a schema is provided, the request body is validated against it before the code snippet runs; on failure, the request is rejected with a structured validation error (RequestValidationError).

The accepted schema format depends on the content type:

  • JSON (application/json): a JSON Schema (Draft 2020-12). The field accepts both JSON and YAML syntax — YAML is convenient when authoring schemas inline.

  • XML (application/xml): an XML Schema (XSD).

Example JSON Schema (YAML form):

type: object
required: [name, qty]
properties:
  name: { type: string }
  qty:  { type: integer, minimum: 1 }

Example XSD:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="greeting" type="xs:string"/>
</xs:schema>

Tip: when shipping endpoints from a module, the schema can live in a separate file and be loaded into the field at install time using the file attribute on the data record:

<field name="request_content_schema" type="char" file="endpoint/demo/content_schema.xsd" />

Execution

  • Exec mode: how the request is handled. The base module ships Execute code; downstream modules can register additional modes.

  • Code snippet (when exec mode is ``code``): Python code evaluated via safe_eval for every request. The snippet must assign a dict to the result variable; it can either contain a ready-made Response (under the response key) or payload, headers and status_code to be assembled by the framework.

    Variables exposed to the snippet (see the Code Help tab on the form for the live, up-to-date list):

    • env, user, endpoint, request

    • datetime, dateutil, time, json

    • Response (Odoo’s http.Response)

    • werkzeug (limited to NotFound, BadRequest, Unauthorized)

    • exceptions (limited to UserError, ValidationError)

    • hashlib, hmac (subset of the standard library)

    • log(message, level="info") — writes to ir.logging

    Raising UserError or ValidationError from the snippet is converted to 400 Bad Request.

Minimal snippet:

result = {"response": Response("Hello, World!")}

Registry synchronization

Endpoints are registered in a routing registry that lives outside the ORM. After creating, modifying or archiving a record, the warning “Registry out of sync” appears on the form, and the record is shown in the To sync filter on the list view. Run the Sync registry action to commit the changes to the live routing table — until then, the new configuration is not served.

Usage

Accessing request parameters

Code snippets receive the current HTTP request as the request variable. There are two ways to read the parameters sent by the client:

  • request.params: a flat dict populated by Odoo’s dispatcher. For http routes it merges the query string, form-encoded body fields, uploaded files and path arguments; for json routes it contains the parsed JSON body and path arguments. Convenient for simple cases:

    name = request.params.get("your_name", "")

    Since it is a plain dict, repeated keys (e.g. ?tag=a&tag=b) collapse into a single value.

  • request.httprequest.args: a Werkzeug MultiDict containing only the query string parameters, regardless of the route type. Use it when you need to tell query string values apart from body fields, or when the same key is sent multiple times:

    # GET /my/endpoint?tag=red&tag=blue&page=2
    tags = request.httprequest.args.getlist("tag")  # ["red", "blue"]
    page = request.httprequest.args.get("page")     # "2"

    getlist() is the only way to retrieve all the values of a repeated query string key.

For form-encoded POST/PUT bodies, request.httprequest.form provides the same MultiDict interface for body fields. A JSON body sent to an http route is not exposed through request.params; read it with request.get_json_data() instead.

Known issues / Roadmap

  • add api docs generation

  • handle multiple routes per endpoint

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits

Authors

  • Camptocamp

Contributors

Maintainers

This module is maintained by the OCA.

Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

Current maintainer:

simahawk

This module is part of the OCA/web-api project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

Metadata

Release files for odoo-addon-endpoint 19.0.1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for odoo-addon-endpoint 19.0.1.2.2
File Interpreter ABI Platform Actions
odoo_addon_endpoint-19.0.1.2.2-py3-none-any.whl Python 3 none any Details for odoo_addon_endpoint-19.0.1.2.2-py3-none-any.whl

Release files / odoo_addon_endpoint-19.0.1.2.2-py3-none-any.whl

Download URL odoo_addon_endpoint-19.0.1.2.2-py3-none-any.whl
Size 58.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
387cbc2ace5689018f04906998a54c08f8b2aa7ed10de44cb92bfb6a4c48ed97
BLAKE2b-256 checksum
How to use checksums
8ad12c1c29fc5d912c0e998c12f2a15f52245f0a6d56022462c2708614911949
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for odoo-addon-endpoint 19.0.1.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

19.0.1.2.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page