Maton

Odoo

Access Odoo 19 and later through its JSON-2 API with managed authentication. Search, read, count, and group records of any installed app, such as contacts, CRM, sales, invoicing, inventory, and projects; create, update, and delete records, run business actions, and post on a record's chatter. All access runs through the Maton gateway and the maton CLI.

Permissions

Suggested read access

In the Console, Read limits the connection to these 17 read-only endpoints, plus deny rules for any write endpoint a broader rule would otherwise match. Endpoints Maton has found to return credentials, start jobs, or spend credits are left out; a few reads that can change state or return a secret depending on their parameters stay in, and their descriptions say how. It is a suggestion: the saved rules are exactly the ones you see, and you can change them with Custom. See Access policy.

Reference

Every call is a POST to json/2/{model}/{method}: https://mycompany.odoo.com/json/2/res.partner/search_read becomes /odoo/json/2/res.partner/search_read. The method name, not the HTTP verb, decides whether a call reads or writes. The body is a JSON object of the method's named parameters, plus ids for methods that act on records and an optional context such as {"lang": "en_US"}; the response is the method's return value. Empty fields come back as false, and a many2one field as [id, "Display Name"].

Connect with maton connection create odoo. The connect page asks for the Odoo server's hostname, an optional database and key expiration date, and an API key; the Odoo connection guide shows where to find each one and what the server needs (Odoo 19 or later, reachable over HTTPS, and a Custom plan on Odoo Online).

Session

Get the Current User

maton api '/odoo/json/2/res.users/context_get' -X POST -H 'Content-Type: application/json' --input - <<<'{}'

Response:

{"lang": "en_US", "tz": "Europe/Brussels", "uid": 2}

The connection's metadata holds the host, database, user_id, login, name, company_name, and expires_at.

Discover Models and Methods

maton api '/odoo/doc-bearer/index.json' -q '.models[] | {model, name}'
maton api '/odoo/doc-bearer/res.partner.json' -q '.methods.search_read.signature'

The models and fields available depend on the apps installed on the database. doc-bearer/index.json lists the installed modules and every model the user can reach; doc-bearer/{model}.json returns one model's fields and methods with their signatures. They are Odoo's built-in API documentation (the api_doc module, installed by default in Odoo 19), also shown in a browser at /doc.

Search and Read

Search and Read Records

maton api '/odoo/json/2/res.partner/search_read' -X POST -H 'Content-Type: application/json' --input - <<'JSON'
{"domain": [["is_company", "=", true]], "fields": ["name", "email", "phone", "country_id"], "limit": 20, "order": "name asc"}
JSON

Response:

[
  {"id": 14, "name": "Azure Interior", "email": "azure.interior24@example.com", "phone": "+1 555 0101", "country_id": [233, "United States"]},
  {"id": 10, "name": "Deco Addict", "email": false, "phone": "+1 555 0102", "country_id": [233, "United States"]}
]

Parameters: domain (a list of [field, operator, value] conditions, combined with "&", "|", and "!"), fields, offset, limit, order. Operators include =, !=, >, >=, <, <=, in, not in, like, ilike, and child_of. Without fields, every field of every matching record comes back.

Count, Search IDs, Read by ID

maton api '/odoo/json/2/res.partner/search_count' -X POST -H 'Content-Type: application/json' --input - <<'JSON'
{"domain": [["is_company", "=", true]]}
JSON
maton api '/odoo/json/2/res.partner/search' -X POST -H 'Content-Type: application/json' --input - <<'JSON'
{"domain": [], "limit": 3, "order": "id desc"}
JSON
maton api '/odoo/json/2/res.partner/read' -X POST -H 'Content-Type: application/json' --input - <<'JSON'
{"ids": [14], "fields": ["name", "email", "phone"]}
JSON

search_count returns a number, search a list of IDs, and read the records for the given ids.

List a Model's Fields

maton api '/odoo/json/2/sale.order/fields_get' -X POST -H 'Content-Type: application/json' --input - <<'JSON'
{"attributes": ["string", "type", "required", "relation", "selection"]}
JSON

Returns each field's label and type, and for relational fields the related model.

Grouped Totals

maton api '/odoo/json/2/crm.lead/formatted_read_group' -X POST -H 'Content-Type: application/json' --input - <<'JSON'
{"domain": [["type", "=", "opportunity"]], "groupby": ["stage_id"], "aggregates": ["expected_revenue:sum", "__count"]}
JSON

Response:

[
  {"stage_id": [1, "New"], "__extra_domain": [["stage_id", "=", 1]], "expected_revenue:sum": 42000.0, "__count": 6},
  {"stage_id": [2, "Qualified"], "__extra_domain": [["stage_id", "=", 2]], "expected_revenue:sum": 18500.0, "__count": 3}
]

One row per group: aggregates are field:sum, avg, min, max, or count_distinct, plus __count for the number of records.

Create, Update, Delete

maton api '/odoo/json/2/res.partner/create' -X POST -H 'Content-Type: application/json' --input - <<'JSON'
{"vals_list": [{"name": "Acme Corp", "is_company": true, "email": "info@acme.example"}]}
JSON
maton api '/odoo/json/2/res.partner/write' -X POST -H 'Content-Type: application/json' --input - <<'JSON'
{"ids": [15], "vals": {"phone": "+1 555 0100"}}
JSON
maton api '/odoo/json/2/res.partner/unlink' -X POST -H 'Content-Type: application/json' --input - <<'JSON'
{"ids": [15]}
JSON

create returns the new IDs ([15]); write and unlink return true. Relational fields take IDs ("country_id": 233), and many2many fields commands such as [[6, 0, [1, 2]]] (replace with these IDs) or [[4, 7]] (add ID 7). unlink deletes for good; many records can be archived instead with write and {"active": false}. Each call runs in its own transaction.

Business Actions and Chatter

maton api '/odoo/json/2/sale.order/action_confirm' -X POST -H 'Content-Type: application/json' --input - <<'JSON'
{"ids": [42]}
JSON
maton api '/odoo/json/2/res.partner/message_post' -X POST -H 'Content-Type: application/json' --input - <<'JSON'
{"ids": [15], "body": "Called about the renewal.", "message_type": "comment", "subtype_xmlid": "mail.mt_note"}
JSON

Any public method of a model can be called the same way, such as action_confirm to confirm a quotation or action_post to post an invoice. On message_post, subtype_xmlid mail.mt_note logs an internal note, while mail.mt_comment sends the message to the record's followers.

Common Models

ModelRecordsApp
res.partnerContacts and companiesContacts
res.users, res.companyUsers and companies(base)
crm.leadLeads and opportunitiesCRM
sale.order, sale.order.lineQuotations and sales ordersSales
account.move, account.move.lineInvoices, bills, and journal entriesInvoicing
product.template, product.productProducts and variantsSales, Inventory
stock.picking, stock.quantTransfers and on-hand stockInventory
purchase.orderPurchase ordersPurchase
project.project, project.taskProjects and tasksProject
hr.employeeEmployeesEmployees
calendar.eventMeetingsCalendar

A model exists only when its app is installed.

Notes

  • Errors keep their HTTP status, with a JSON body holding name (the Odoo exception), message, arguments, and debug (a traceback): 401 the key is invalid, revoked, or expired; 403 the user's access rights or record rules refuse the operation; 404 an unknown model or method, or a record that no longer exists; 409 a concurrent update locked the record; 422 invalid arguments, or a validation or business rule refused the change. A domain or field list naming a field the model doesn't have fails with 500 and ValueError: Invalid field ....
  • Host errors come from Maton with 400: the Odoo URL isn't a hostname Maton can call, doesn't resolve, or resolves to a private address.
  • Dates are "YYYY-MM-DD" and datetimes "YYYY-MM-DD HH:MM:SS" in UTC; translated fields follow context.lang.
  • Archived records (active = false) are left out of searches unless the domain asks for them, as in [["active", "in", [true, false]]].
  • The gateway calls only the connection's host over HTTPS and doesn't follow redirects. The older XML-RPC and JSON-RPC endpoints aren't covered here.

Resources

On this page