Skip to content

Authentication and scopes

The Trade API uses OAuth2 client credentials. You exchange a client ID and secret for a bearer token, then send that token on every request.

Getting a token

POST /token with HTTP Basic authentication, your client ID as the username and your client secret as the password:

curl -s -X POST https://api.nuimarkets.com/api/1.0/token \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  -H "Content-Type: application/json" \
  -d '{"grant_type": "client_credentials"}'

The response carries the token, its lifetime in seconds, and the scopes it was actually granted:

{
  "access_token": "<token>",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": ["solution:abc123:trades:read", "solution:abc123:tenders:read"]
}

scope is the list your client was granted. It is not always the list your client can use: see "Two rules that surprise people" below.

Cache the token until expires_in runs down and exchange again. Do not request one per call: the token endpoint counts against your rate limits like any other request.

Using the token

curl -s "https://api.nuimarkets.com/api/1.0/trades?solution=$SOLUTION_ID" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

Every read is scoped to a solution. A client with access to more than one must say which it means on each request.

How scopes are written

solution:{solution_id}:{endpoint}:{permission}

For example solution:abc123:trades:read.

Part Values
endpoint trades, tenders, products for the integration routes described here
permission read, write

Scopes are granted per solution and per endpoint, so a client authorised for two solutions carries a separate scope string for each.

Which endpoints a client may call is decided by its scopes, not by the shape of the API. A client granted only trades:read gets 403 on everything else, including endpoints documented on this site.

An orders:read scope may appear on a customer token, but it does not grant access to GET /orders, GET /market-orders, or GET /orders/{id}. The collections require an internal client type, and the order-by-ID route also requires resource permissions that customer scopes do not grant. Use the web app's CSV export for order lists.

Two rules that surprise people

Both come from the same place: what the token response lists and what the server enforces are computed separately. The response reports the scopes granted to your client. Enforcement applies a second pass over them on every request. The two can differ, in both directions.

Write access needs more than a listed write scope. A client must also be configured for writes. Without that configuration its write scopes are dropped at enforcement time even if solution:abc123:tenders:write appears on the token. Data reads covered by retained read scopes may still work. Tender and offer writes and the four form-schema GETs require effective tenders:write; the listed grant alone does not provide it.

You cannot diagnose effective write access from scope alone. A listed write scope followed by 403 may mean the client is not configured for writes; resource and solution permission checks can also refuse a request. Contact support@nuimarkets.com to confirm the cause.

A client with effective tenders:write also gets products:read, implicitly. You cannot build a tender offer without selecting a product, so the read is added for you at enforcement time. It works, and it does not appear in the scope list on the token response. An absent products:read is not a reason to ask for one. The same implicit grant applies to effective orders:write, though external order writes are not supported.

401 and 403 mean different things

Status Meaning What fixes it
401 The token is missing, invalid, or expired Exchange your credentials again
403 The client lacks the scope for what you asked, or a permission check refused it Nothing your client can do at runtime

Handle them separately. Retrying a 403 with a fresh token gets you another 403; the request was understood and refused.

On an authentication failure the response also carries X-Auth-Failure-Reason summarising the cause, and the body may carry an auth_failure_details object with more. Log both. A Reason header is sent alongside for older clients and is deprecated: read X-Auth-Failure-Reason instead.

Getting credentials

Credentials are issued by Nui Markets during onboarding, not self-served. To request them, or to check which scopes a workflow needs, contact support@nuimarkets.com.

You will need three things before your first call: the client ID and secret, the solution id for the marketplace you are trading in, and the scopes your integration needs.


Updated 2026-10