Skip to Content

How to Set Up API Access for a User in Odoo 19

November 24, 2026 by

Integrations with external systems, online stores, BI tools, or custom scripts are an everyday reality for companies using Odoo. For such a connection to work securely, you need to know how to properly configure API access for a specific user. In this article, we show you how to do it in Odoo 19: how to create a dedicated account, generate an API key, restrict permissions, and send your first request.

Want to check everything on your own database? Try Odoo for free and test the steps described below in practice.

Try Odoo for free

How the Odoo API works and why the user is key

In Odoo, every API call is executed in the context of a specific user. This means the system applies exactly the same access rights, record rules, and company restrictions that apply in the graphical interface. If a user cannot see invoices in the app, they will not be able to retrieve them via the API either.

In Odoo 19, integrations are based on the external JSON-2 API, which replaces the older XML-RPC and JSON-RPC protocols. Authentication is done with an API key passed in the request header. In JSON-2, an API key is required, and the user's password alone is not accepted. This way, you do not have to share your account password with external applications, and you can delete the key at any time without changing the password.

Note: in Odoo Online, access to the external API depends on your plan (the Custom plan is required). This restriction does not apply to on-premise installations or Odoo.sh.

Step 1: Prepare a dedicated integration user

Instead of using an administrator account or an employee account, create a separate user solely for the integration. This makes it easier to control its permissions, analyze which operations it performs, and disable the integration without affecting your team's work.

Creating the user

  1. Go to Settings → Users & Companies → Users.
  2. Click New and enter a name (e.g., "Online store integration") and a login.
  3. Select the Internal User user type. Portal and public users have limited permissions and are not intended for integrations with company data.
  4. Assign only the permissions that are necessary for the given integration.
  5. Set a password or send an invitation so that you can log in to this account and generate an API key.

You can find more about managing accounts in the article how to manage users in Odoo 19 Enterprise. If you are wondering how external accounts differ, take a look at the post about public and portal users.

Step 2: Restrict permissions following the principle of least privilege

The most common mistake in integrations is granting overly broad permissions. If an external system only needs to read products and stock levels, it should not have the right to edit invoices or payroll data. Remember that an API key inherits all of the user's permissions, so they determine the extent of potential damage in the event of a leak.

Step 3: Generate an API key

An API key is created from the profile of the user it is meant for. So log in to the integration account (or ask the account owner to perform the steps below). An administrator cannot generate a key on behalf of another user.

  1. Click the avatar in the upper-right corner and select My Profile (Preferences).
  2. Go to the Account Security tab.
  3. In the API Keys section, click New API Key.
  4. Confirm your identity by entering your password.
  5. Give the key a descriptive name, e.g., "Online store integration", and choose a validity period. Longer or non-expiring periods may require developer mode.
  6. Copy the generated key and store it in a safe place, e.g., in a password manager.

Important: Odoo displays the key only once. If you lose it, you must generate a new one. An API key does not require a second authentication factor, even if the account has two-factor authentication enabled, so treat it like a password. Never put the key in a public code repository or in email messages.

Configuring permissions and secure integrations can be complex, especially in extensive databases. If you want to make sure everything works correctly, contact our consultants.

Contact us

Step 4: Send your first API request

Once API access is configured, you can test the connection. With the JSON-2 API, you send the request using the POST method to an address in the form /json/2/<model>/<method>, and you pass the key in the Authorization header as a Bearer token. You provide the method arguments in the request body in JSON format, as named fields.

Example: retrieving contacts

curl -X POST https://twoja-domena.odoo.com/json/2/res.partner/search_read \
  -H "Authorization: bearer TWOJ_KLUCZ_API" \
  -H "X-Odoo-Database: nazwa_bazy" \
  -H "Content-Type: application/json; charset=utf-8" \
  -d '{"domain": [["is_company", "=", true]], "fields": ["name", "email"], "limit": 5}'

Python example

import requests

response = requests.post(
    "https://twoja-domena.odoo.com/json/2/res.partner/search_read",
    headers={
        "Authorization": "bearer TWOJ_KLUCZ_API",
        "X-Odoo-Database": "nazwa_bazy",
    },
    json={"domain": [["is_company", "=", True]], "fields": ["name", "email"], "limit": 5},
)
print(response.status_code, response.json())

The X-Odoo-Database header is needed when multiple databases run on one server and Odoo cannot determine the right one on its own. If the response contains a list of records, the configuration was successful. A 401 code means an incorrect, expired, or deleted key, and a 403 code means the user lacks permission for the given model or operation.

You can find the external API documentation in the official Odoo documentation, and you can check model and field names in the system itself in developer mode. The older XML-RPC and JSON-RPC protocols are deprecated, and their removal has been announced for upcoming versions (Odoo 20), so new integrations should be built on JSON-2, and existing ones should be migrated as planned.

API access security – best practices

  • One key – one integration. This way, if a problem occurs, you only delete one key without disrupting other connections.
  • Set an expiration date. Use non-expiring keys only where truly necessary.
  • Use HTTPS. An API key should never be sent over an unencrypted channel.
  • Rotate keys regularly. Replace them periodically and after a person who had access to them leaves.
  • Store keys outside the code. Use environment variables or a secrets manager.
  • Monitor activity. Check the login history to detect unusual behavior. The post how to view login history in Odoo.
  • Take care of overall account security. We described session rules and timeouts in the article about sessions and account security in Odoo 19.

If you want to temporarily hand over some permissions to another person instead of creating a new account, also check out the article about delegating permissions in Odoo 19.

Try Odoo for free

Common problems and solutions

Authentication error (401)

Check that the key was copied in full, has not expired or been deleted, and that the Authorization header is correctly formatted. Also make sure you are specifying the right database and that the user is active.

No access to data (403)

If the API returns a permissions error, compare the integration user's rights with what the given model requires. Access to a single app or a specific company is often missing.

Empty query results

The cause may be record rules, a restriction to the wrong company, or a query domain that is too narrow. Verify that the user sees the same data in the Odoo interface.

FAQ – frequently asked questions

Can any user create an API key?

API keys are intended primarily for internal users. Portal and public users have limited permissions and should not be used for integrations, so it is worth creating a dedicated internal account with restricted permissions.

Does an API key replace the user's password?

For API calls, yes. In JSON-2, you authenticate with a key rather than a password, and you can delete it at any time without changing the account password. However, the key inherits all the permissions of the user it belongs to, so treat it as carefully as a password.

What should I do if an API key leaks?

Immediately delete it in the Account Security tab in the user's profile and generate a new one. Then check the login history and account activity to assess whether any unauthorized operations took place.

Can I still use XML-RPC or JSON-RPC?

For now, existing integrations may still work, but these protocols are deprecated and their removal has been announced for upcoming versions. New projects should use JSON-2, and older ones should be scheduled for migration.

Summary

Properly configuring API access in Odoo 19 comes down to a few simple principles: a dedicated internal user, minimal permissions, an API key with a limited validity period, and continuous activity monitoring. This keeps integrations running reliably and your company data secure.

Need help with an Odoo integration?

The KK Innovations team will help you design secure integrations, configure permissions, and implement Odoo tailored to your company's processes. Write to us and discuss your project with experienced consultants.

Contact us