Server-side API

Authentication

Send your API key on every request, keep it secret, and know which failure is which.

Every Developer API request carries your API key. There is no token to exchange, nothing to sign and no keypair to manage.

1. Create a key

In the dashboard, go to Workspace Settings → API Keys (/dashboard/workspace-settings/api-keys).

Choose Add API Key, set Key Type to Developer API.

Add the IP addresses your servers call from. At least one is required. See IP allowlist.

Create the key and copy the API key (mk_…).

You see the key in full exactly once

After you close that dialog the dashboard shows it masked, for good, and there is no way to retrieve it. Put it in your secret manager before you do anything else. If you lose it, rotate: create a replacement and retire the old one.

2. Send it

x-api-key: mk_…

That is the whole credential, on every route.

const res = await fetch("https://api.medos.one/v1/patients?mrn=MRN-0774", {
  headers: { "x-api-key": process.env.MEDOS_API_KEY },
});
import os, requests

requests.get(
    "https://api.medos.one/v1/patients",
    params={"mrn": "MRN-0774"},
    headers={"x-api-key": os.environ["MEDOS_API_KEY"]},
)
HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://api.medos.one/v1/patients?mrn=MRN-0774"))
        .header("x-api-key", System.getenv("MEDOS_API_KEY"))
        .GET()
        .build();

HttpResponse<String> response = HttpClient.newHttpClient()
        .send(request, HttpResponse.BodyHandlers.ofString());

Optionally, add X-Acting-User-Id to say which staff member the call is for. See Acting user.

What is checked, in order

Each check runs before the next, so the first failure is the one you see:

#CheckFailure
1A credential is present401
2The key is a live Developer API key: known, active, not expired401 UNAUTHENTICATED
3Your source address is on the key's allowlist403 IP_NOT_ALLOWED, naming the address seen
4The route is one of the twenty-four403 ROUTE_NOT_AVAILABLE; any /v2 path is 404; a listed path with the wrong method is 405
5You are within the rate limits429 RATE_LIMITED
6The workspace's plan includes the route403 FEATURE_NOT_ENTITLED, with requiredFeature
7X-Acting-User-Id, if sent, is an active staff member400 INVALID_ACTING_USER or 403 ACTING_USER_NOT_A_MEMBER

One exception to the order: the per-source-IP rate limit is counted before the key is even looked up, so an address spraying guessed keys gets a 429 before anything else.

The key is read from the database on every request, so deactivating one takes effect on the very next call.

Keeping the key safe

The API key authenticates on its own, so anyone holding it can call the API as you, from an address on your allowlist. Treat it like a database password.

DoDon't
Keep it in a secret manager or an environment variableCommit it to a repository, even a private one
Send it only from server-side code, over HTTPSPut it in a browser, a mobile app or a desktop client
Register the narrowest addresses you canRegister a whole cloud provider's range if you can pin your egress
Rotate it when someone with access leavesShare one key across unrelated integrations

The allowlist is your safety net

If the key does leak, the allowlist is what stops it being used: a request from any address you did not register is refused with a 403, even with the right key. Rotate anyway. An allowlist limits what a leaked key can do; it does not make the key safe again.

The two kinds of key do not stand in for each other

  • A widget key is refused here even though it is a valid key. It ships in page source, and where the key alone is the credential, accepting it would turn a public value into a server secret.
  • A Developer API key is refused by the widget's session endpoint, because a session minted from it would no longer be bound to your allowlist.
  • A widget session (Authorization: Bearer st_…) on a Developer API route is a 403. These routes are for your server, not a patient's browser.

On this page