Send your first OpenMRP API request
Get started with the OpenMRP API.
To interact with the OpenMRP API, you'll need a secret API key. Once you sign up for an OpenMRP account, we provide you with keys for both testing and live environments. Before diving into production, ensure your account is activated.
Preparation
This guide will walk you through listing units of measurement using the List UnitsAPI endpoint. For a comprehensive understanding of how OpenMRP API components work together, consider taking an API tour or visiting the API referenceAPI.
Making your first API request
Begin your interaction with the OpenMRP API by sending HTTP requests to the designated endpoints.
import OpenMRP from '@openmrp/sdk';
const client = new OpenMRP({
bearerToken: 'YOUR_API_KEY',
openMRPAccountID: 'YOUR_SANDBOX_ACCOUNT_ID',
});
const units = await client.catalog.units.list();
console.log(units.data);
import OpenMRP from '@openmrp/sdk';
const client = new OpenMRP({
bearerToken: 'YOUR_API_KEY',
openMRPAccountID: 'YOUR_SANDBOX_ACCOUNT_ID',
});
const units = await client.catalog.units.list();
console.log(units.data);
Upon success, expect a response like this:
{
"object": "list",
"page_info": {
"next_page_url": "/v1/catalog/units?cursor=eyJjIjoiMjAyNi0wNS0xMFQwMDowMDowMFoiLCJzIjoidW5fMDE5NjYyNjNmNzRhNWEwY2FlMzU2MDAwYTEiLCJkIjoiZiJ9._fcFG5yqAn5oIA388jA_bOqkqHdBbhCGRdomkbG_wvY",
"previous_page_url": null,
"has_next_page": true,
"has_prev_page": false
},
"data": [
{
"id": "un_01966263f74a5a0cae356000a1",
"object": "unit",
"name": "Kilogram",
"abbreviation": "kg",
"type": "mass",
"ratio_numerator": "1000",
"ratio_denominator": "1",
"offset_numerator": "0",
"offset_denominator": "1",
"is_base_unit": false,
"owner": {
"object": "owner",
"type": "system",
"account": null
},
"created_at": "2026-05-10T00:00:00Z",
"updated_at": "2026-05-10T00:23:00Z"
}
]
}
{
"object": "list",
"page_info": {
"next_page_url": "/v1/catalog/units?cursor=eyJjIjoiMjAyNi0wNS0xMFQwMDowMDowMFoiLCJzIjoidW5fMDE5NjYyNjNmNzRhNWEwY2FlMzU2MDAwYTEiLCJkIjoiZiJ9._fcFG5yqAn5oIA388jA_bOqkqHdBbhCGRdomkbG_wvY",
"previous_page_url": null,
"has_next_page": true,
"has_prev_page": false
},
"data": [
{
"id": "un_01966263f74a5a0cae356000a1",
"object": "unit",
"name": "Kilogram",
"abbreviation": "kg",
"type": "mass",
"ratio_numerator": "1000",
"ratio_denominator": "1",
"offset_numerator": "0",
"offset_denominator": "1",
"is_base_unit": false,
"owner": {
"object": "owner",
"type": "system",
"account": null
},
"created_at": "2026-05-10T00:00:00Z",
"updated_at": "2026-05-10T00:23:00Z"
}
]
}
Monitoring your requests
Every API request you make is logged and generates an event for your organization account. The API key you use determines whether the data is stored in a sandbox or production environment. For example, using a test API key creates data in the test environment.
To review your API request logs, visit the logs page. For event details, check the events page.
Managing your API keys
Each account is equipped with two API keys: one for sandbox testing and another for live production.
- Sandbox Secret Key: Ideal for testing in a sandbox environment, this key allows unrestricted API requests. Use it for development to prevent accidental changes to live data.
- Production Secret Key: This key is for live mode requests and also allows unrestricted API requests.
Access your secret and publishable keys in the Dashboard under the API keys tab. If you can't see your keys, request the necessary permissions from your organization account owner.
When logged into OpenMRP, our documentation will automatically populate code examples with your sandbox API key. These values are visible only to you. If you're not logged in, the examples will use placeholder API keys. Replace these with your own keys or log in to see your personalized keys.
| Type | Value | Usage |
|---|---|---|
| Secret | mrp_...WNXD | Sandbox |