Miridia
Portal
Developers

Authentication

Log in with the Global API, send a bearer token or an API key, and choose the business for each request.

Miridia accepts two credentials:

  • A bearer token acts for a person. Use it in an application where a person logs in.
  • An API key acts for your organisation, without a person. Use it for a server, a script, or a connector.

The Global API issues both credentials. The Core API accepts both.

Log in

Send the email address and the password of the user to POST /api/auth/login on the Global API.

Terminal
curl -X POST https://global.miridia.io/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"you@example.com","password":"<your-password>"}'

The response has one of two shapes.

The user is a member of one organisation. The response holds a session.

Response
{
  "data": {
    "requiresOrganizationSelection": false,
    "session": {
      "accessToken": "eyJhbGciOiJSUzI1NiIs...",
      "expiresAtUtc": "2026-09-29T09:00:00Z",
      "organization": { "id": "...", "slug": "your-company", "name": "Your Company" }
    }
  },
  "statusCode": 200,
  "messages": []
}

Use data.session.accessToken as the bearer token.

Send a bearer token

Send the access token in the Authorization header. Send the business in the X-Business-Id header.

Terminal
curl https://api.miridia.io/api/v1/purchase-orders \
  -H "Authorization: Bearer $MIRIDIA_TOKEN" \
  -H "X-Business-Id: $MIRIDIA_BUSINESS_ID"

To find the businesses of the user, send GET /api/me to the Core API. This operation does not need the X-Business-Id header.

Refresh the session

An access token is valid for a short time. The value of expiresAtUtc tells you when it expires. The login response also sets a refresh cookie. To get a new access token, send POST /api/auth/new-token with that cookie. A browser application sends the cookie automatically.

To end the session, send POST /api/auth/logout.

Use an API key

An API key does not expire unless you give it a time to live. It is the correct credential for a system that calls Miridia.

Make the key

Log in as an owner of the organisation. Then send POST /api/auth/tokens to the Global API.

Terminal
curl -X POST https://global.miridia.io/api/auth/tokens \
  -H "Authorization: Bearer $MIRIDIA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"label":"Warehouse scanner","businessId":"<business-id>","ttlMinutes":null,"scopes":null}'
FieldRequiredDescription
businessIdYesThe business that the key acts for.
labelNoA name that tells you where the key is in use.
ttlMinutesNoThe life of the key, in minutes. Leave it empty for a key that does not expire.
scopesNoThe permissions of the key, as JSON: { "ModuleName": bitmask }. Leave it empty for a key with full access.

Keep the key secret

The response holds the key in data.token. Miridia shows the key only one time. Put it in a secret store. Do not put it in source code or in a browser application.

Send the key

Send the key in the x-dispatch-api-key header.

Terminal
curl https://api.miridia.io/api/v1/Products \
  -H "x-dispatch-api-key: $MIRIDIA_API_KEY"

Limit a key with scopes

A scope gives the key a permission on one module. The bitmask adds the actions: 1 is view, 2 is modify, and 4 is delete. For example, 7 gives all three actions.

Scopes
{ "Products": 1, "PurchaseOrders": 3 }

This key can read products. It can read and change purchase orders. It cannot do anything else.

The modules are Orders, Shipments, Customers, Products, Vehicles, Integrations, TeamAndRoles, Billing, Workflows, Settings, Insights, Suppliers, PurchaseOrders, WorkOrders, TransferOrders, and Schedule. Each operation in the reference tells you the permission that it needs.

Give each system its own key, with only the scopes that it needs. Then you can revoke one key without an effect on the other systems.

List and revoke keys

  • To list the keys of your organisation, send GET /api/auth/tokens.
  • To revoke a key, send DELETE /api/auth/tokens/{id}. The key stops at once.

Permissions

Each operation of the Core API needs a permission on one module, for example PurchaseOrders view. The role of the user gives the permissions of a bearer token. The scopes give the permissions of an API key.

If the credential does not have the permission, the API returns 403. Read Users and roles for the roles.

Errors

StatusCause
401The credential is missing or not valid, or the X-Business-Id header names a business that the user cannot use.
403The credential is valid, but it does not have the permission. An expired token also gives 403 on the Core API.

Read Conventions for the error body.

Reference