Skip to content
Documentation

ARXD API

Rendered from the repository’s own documentation directory.

ARXD API

Three distinct interfaces share the /api prefix and none of them are interchangeable:

| Prefix | Caller | Credential | | --- | --- | --- | | /api/v1 | Partner systems and customer tooling | Bearer API token, or a signed-in session | | /api/agent | The ARXD device agent | Device credential issued at enrolment | | /api/health | Anything | None — deliberately information-poor |

docs/api.md is the long-form reference with full field lists. This file is the contract summary: what exists, what it costs, and what it will never do.


1. Base URL and format

https://arxd.org/api/v1

application/json in both directions. Every response is a JSON object; there is no bare array at the top level, so a response can gain a field without breaking a client.


2. Authentication

2.1 API tokens

Created in the console under Settings → Integrations. The plaintext token is shown once, prefixed arxd_pat_. Only its SHA-256 hash is stored, so a database read does not yield a usable credential.

Authorization: Bearer arxd_pat_...

A token carries an abilities list — either ["*"] or specific permissions such as ["device.view", "ticket.create"]. Requesting an endpoint whose ability the token lacks returns 403, and the refusal is audited with the missing ability.

A supplied token is authoritative. If a bearer token is present, the session is not consulted as a fallback. Otherwise a revoked token would keep working for anyone who also held a browser session, which would defeat revocation entirely.

2.2 Sessions

The same endpoints back the console, so a signed-in browser session is accepted where no token is supplied.

2.3 Device credentials

The agent does not use API tokens. It enrols once with a single-use enrolment token, then authenticates with a per-device credential. The agent middleware rejects a user credential on an agent route, and a device credential on a user route.


3. Endpoints

Health — GET /api/health

No credential. Returns status, service name, version, database reachability and time. It deliberately returns no topology, no hostname, no tenant name and no version of anything else, because an unauthenticated endpoint is an inventory leak waiting to happen.

{
  "status": "ok",
  "service": "arxd-control",
  "version": "…",
  "database": "ok",
  "time": "2026-11-15T06:11:42Z"
}

503 when the database is unreachable, with "status": "degraded".

Integration API

| Method | Path | Ability | | --- | --- | --- | | GET | /api/v1/devices | device.view | | GET | /api/v1/devices/{id} | device.view | | GET | /api/v1/tickets | ticket.view | | POST | /api/v1/tickets | ticket.create | | GET | /api/v1/alerts | alert.view | | GET | /api/v1/customers | customer.view |

Every request is scoped to the tenant derived from the credential. There is no tenant parameter. Supplying one will not widen the result set; it is ignored.

Agent channel

| Method | Path | Purpose | | --- | --- | --- | | POST | /api/agent/enroll | Exchange a single-use enrolment token for a device credential | | POST | /api/agent/heartbeat | Liveness; drives derived availability | | POST | /api/agent/inventory | Hardware and software metadata | | POST | /api/agent/telemetry | Metrics | | GET | /api/agent/commands | Poll for queued commands | | POST | /api/agent/commands/{id}/result | Report a command outcome | | POST | /api/agent/shell/sync | Long-poll the interactive shell in both directions | | POST | /api/agent/compliance/report | Post file metadata only | | GET | /api/agent/deployments/{id}/artefact | Download a packed website archive to publish on the customer's own server | | GET | /api/agent/config | Agent-side configuration | | POST | /api/agent/unenroll | Retire the credential |

The agent never touches the database and never uploads file contents. A compliance scan reads files locally and posts what it found — paths, sizes, patterns — not the files. That is a deliberate boundary: the platform is not a place where a customer's documents accumulate.

GET /api/agent/deployments/{id}/artefact

Streams the zip built for a deploy_site command, as application/zip with Content-Disposition: attachment and a Content-Length taken from the file. The body is the file itself; there is no JSON envelope and no base64 step.

This endpoint serves a customer's website, so it is allowed only when all three of these hold:

  1. The deployment's device_id is the device presenting the credential.
  2. The command that caused it is in dispatched or running — not yet

collected, not already finished.

  1. The archive is still on disk. Archives expire after twelve hours, and the

sweep removes them.

A fetch that succeeds moves the deployment from queued to transferring and stamps fetched_at. Fetching again is allowed and harmless while the file exists, because a transfer that failed halfway needs a second attempt.

Every refusal is the same 404 with a different message, deliberately: another device must not be able to learn whether a deployment id exists.

{
  "error": "not_available",
  "message": "The archive for this deployment is no longer available. Queue the deployment again to send a fresh copy."
}

A 200 is not a claim that anything was published. The deployment is recorded as active only when the agent posts a result whose artefact_sha256 matches the digest the server packed — see §3 Agent channel in docs/agent-protocol.md.


4. Rate limits

All /api/v1 routes sit behind throttle:api. Exceeding the limit returns 429 with a Retry-After header. Back off by that value; retrying immediately extends the window.

Rate-limit state lives in the database, not in Redis, because there is no Redis on this host. A lockout can be cleared deliberately:

/opt/plesk/php/8.3/bin/php tools/console.php rate:clear

5. Errors

Errors are JSON with a stable machine-readable error code and a human message. The code is the contract; the message may be reworded.

{
  "error": "unauthenticated",
  "message": "Sign in or supply an API token in the Authorization header."
}

| Status | error | Meaning | | --- | --- | --- | | 400 | invalid_request | Malformed body or a field that cannot be interpreted | | 401 | unauthenticated | No credential, or a credential that does not resolve | | 403 | forbidden | Authenticated, but the ability is missing | | 404 | not_found | No such resource in this tenant | | 409 | conflict | State transition not legal from the current state | | 422 | validation_failed | Well-formed but rejected; fields explains which | | 429 | rate_limited | Over the limit; read Retry-After | | 503 | unavailable | Dependency down |

A 404 for a resource that exists in another tenant is intentional. Returning 403 there would confirm the resource exists, which is an enumeration leak.


6. Examples

# Liveness
curl -s https://arxd.org/api/health

# First page of devices, filtered
curl -s -H "Authorization: Bearer $ARXD_TOKEN" \
  'https://arxd.org/api/v1/devices?hostname=web&limit=25'

# One device
curl -s -H "Authorization: Bearer $ARXD_TOKEN" \
  'https://arxd.org/api/v1/devices/1042'

# Create a ticket
curl -s -X POST -H "Authorization: Bearer $ARXD_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"subject":"Printer offline","body":"Second floor.","priority":"normal"}' \
  'https://arxd.org/api/v1/tickets'

7. What the API will not do

Stated plainly, because these are the requests a partner integration asks for first:

  • No organisation selector. The credential decides the tenant. There is no

header, query parameter or body field that widens scope.

  • No agent shell over /api/v1. The interactive shell exists only on the

agent channel, authenticated by a device credential, and every command is queued and audited. An API token cannot open one.

  • No bulk delete. Destructive operations are per-resource and audited, so a

leaked token cannot erase an estate in one call.

  • No unauthenticated metrics. /api/health returns liveness only.
  • No webhook subscription API yet. Provider webhooks are configured by

environment variable and verified with paypal:check / stripe:check. Tenant- facing webhook delivery is not built; when it is, it will be documented here with the signature scheme before it is switched on.


8. Versioning

/api/v1 is the version. A breaking change means /api/v2 beside it, with v1 kept working until callers have moved. Additive fields — a new key in a response object — are not breaking and do not bump the version, which is the reason the top level of every response is an object rather than an array.

Rendered from docs/ in the repository and escaped before display. The directory itself is not served.