Skip to content

REST API Guide

Every OpexMX instance serves its own REST API and OpenAPI specification. Authenticate with an API key, call your tenant’s base URL, and generate a client — or use the TypeScript SDK.

1. Authenticate with an API key

In your OpexMX instance, go to Integrations → API → API Keys and create a key (mx_…). Send it as a Bearer token on every request. The key carries the permissions of the user who created it, so create it under a role with only the access your integration needs. Expired or revoked keys answer 401.

curl "https://<your-instance-domain>/api/rpc/assets?limit=5" \
  -H "Authorization: Bearer mx_your_api_key"

Send a descriptive User-Agent header. Requests with the default agent of Python’s urllib are blocked by the edge firewall (HTTP 403, Cloudflare error 1010). curl, requests, Node, Bun and the SDK send an accepted agent already.

import json, urllib.request

req = urllib.request.Request(
    "https://<your-instance-domain>/api/rpc/assets?limit=5",
    headers={
        "Authorization": "Bearer mx_your_api_key",
        # Required: the default "Python-urllib/x.y" agent is blocked (error 1010)
        "User-Agent": "acme-integration/1.0",
    },
)
print(json.load(urllib.request.urlopen(req)))

2. Use your tenant’s base URL

There is no shared global API host: each tenant is served from its own domain (for example https://acme.opexmx.com, or your on-prem host). All paths start with /api.

  • OpenAPI document: https://<your-instance-domain>/api/openapi.json
  • Interactive reference (Scalar UI, with “try it out”): https://<your-instance-domain>/api/openapi

Feed the OpenAPI document to any generator (openapi-typescript, openapi-generator, …) to produce a client in your language.

3. TypeScript SDK

@opexcg/opexmx-sdk is a typed client generated from the OpenAPI spec: every path, query parameter, request body and response is checked by the compiler. It adds API-key auth and tenant base URL handling on top of openapi-fetch.

npm install @opexcg/opexmx-sdk
import { createOpexmxClient } from '@opexcg/opexmx-sdk'

const opexmx = createOpexmxClient({
  baseUrl: 'https://<your-instance-domain>',
  apiKey: process.env.OPEXMX_API_KEY!, // mx_your_api_key
})

const { data, error, response } = await opexmx.GET('/api/rpc/assets', {
  params: { query: { limit: 20, search: 'pump' } },
})
if (error) throw new Error(`HTTP ${response.status}`)

4. Rate limits

Limits are per API key: 600 requests per 60 seconds by default, shared across the REST API and the MCP endpoint. Self-hosted deployments can change the limit. When a key exceeds it, the API answers 429 with a Retry-After header (seconds; also in the body as data.retryAfter) — wait that long, then retry.

HTTP/1.1 429 Too Many Requests
Retry-After: 12
Content-Type: application/json

{"code":"TOO_MANY_REQUESTS","status":429,"data":{"retryAfter":12}}

5. AI agents (MCP)

The same API key also connects AI assistants to your instance over MCP at /api/mcp. See the MCP setup guide.