REST API Reference

The TR-069 Emulator exposes two REST controllers. Both are served on the same host/port (8555) and documented interactively in Swagger UI.

Overview

Base path UI mode Purpose

/api

Load Test Mode

Configure and run a batch of emulated CPEs; device-level speed/WiFi/invoke helpers.

/apiV2

Single Emulator Mode

Full per-device lifecycle: start/stop individual devices, browse and edit the parameter tree, trigger events, read logs. MCP-friendly.

Base URLs

http://localhost:8555/api      # Load Test controller
http://localhost:8555/apiV2    # Single Mode controller

The emulator also serves /farm/stats, /farm/serials and /farm/decisions. These read-only endpoints are not part of the /api control contract and are not in Swagger UI. See Farm Endpoints.

Interactive Documentation

http://localhost:8555/swagger-ui.html   # Swagger UI
http://localhost:8555/v3/api-docs        # OpenAPI 3 spec (JSON)

For a lightweight liveness check use GET /api/status (returns 200 with Running/Stopped) or GET /apiV2/activeEmulators. The Spring Boot Actuator endpoints (/actuator/**) are not exposed by the running service.

Content Type

Request and response bodies are application/json unless noted otherwise (some endpoints return text/plain or application/octet-stream).

Load Test API (/api)

Backs Load Test Mode. The emulator keeps one shared configuration (the EmulatorParameter set, persisted to start_params.properties); Start launches a batch from it.

Configuration & Status

Method & Path Description Body / Response

GET /api/properties

Get the current emulator configuration

Response: EmulatorPropertiesDto

POST /api/properties

Update the configuration (ACS, batch size, options) and persist it

Body: EmulatorPropertiesDto → 204

GET /api/status

Current run status

text/plain: Running or Stopped

GET /api/deviceCounts

Header Total / Active counters: devices the batch started and has not stopped, and those of them in a CWMP session with the ACS right now (Single Emulator devices are not counted)

{ "total": 15, "active": 3 }

GET /api/periodic

Get the periodic-inform interval

Response: { "periodic": 30 }

POST /api/periodic

Set the periodic-inform interval (seconds)

Body: { "periodic": 60 } → 204

Lifecycle

Method & Path Description Body / Response

POST /api/start

Start the configured batch

no body → 204

POST /api/stop

Stop everything: the batch and the Single Emulator devices too

no body → 204

POST /api/stop

Stop everything, optionally clearing caches

Body: { "clearCaches": true } → 204

POST /api/stop?scope=load

Stop only the Load Test devices and the batch runner. Single Emulator devices keep their schedule, sessions, XMPP connection and updatable parameters; with clearCaches only the Load devices' caches are dropped. The Load Test can be started again afterwards

Either body above → 204

A Load Start right after a stop waits (at most 30 seconds) for the runner of the stopped run to end before it begins. A stop that arrives during that wait cancels the Start: the run does not begin, whichever scope the stop had.

Every stop answers 204 with the header X-Stopped-Devices: <n>, the number of devices it stopped (all devices without scope, the Load Test devices with scope=load). scope is all (the default) or load; any other value answers 400 INVALID_STOP_SCOPE.

A stop of everything also ends the servers and threads all devices share: the Connection Request listener, the bulk-data scheduler and the updatable-parameters thread. scope=load leaves them running. A Single Emulator device started after a stop of everything (POST /apiV2/start, /apiV2/startStored, /apiV2/startProtocol, /apiV2/factoryReset) starts them again, so its Connection Requests, Bulk Data reports and updatable parameters work without a Load Test start or a restart. A device’s Bulk Data schedule lives exactly as long as the configuration its ACS set (BulkData.Enable, BulkData.Profile.N.*), and reports are sent only while the device is running. The stop of one Single Emulator device, a stop of everything that clears the caches (the plain POST /api/stop, which does), and a factory reset drop that configuration and the schedule with it; the device starts without its ACS-set profiles. A stop of everything with clearCaches: false (POST /api/stop with a body), and the Load Test stop with clearCaches: false (POST /api/stop?scope=load with that body; without a body it clears the caches), keep both — the Load Test devices' too, whose serials the next Load Test Start builds again over the kept configuration — so a profile that is still enabled reports again at the next start; a device never shows Enable=true while sending nothing. The deletion of a stored Single Emulator device (POST /apiV2/deleteStoredDevice) drops its ACS-set configuration with the schedule.

Device Actions

All take a serial body: { "serial": "SERIAL001" }.

Method & Path Description

POST /api/invokeSerial

Trigger a 6 CONNECTION REQUEST event for the device. If the device is not in a session, a session starts. If the device is in a session, the request is queued and the answer is 204. At most one follow-up session is pending.

POST /api/makeSpeedDelay

Apply a 3-second speed delay to the device

POST /api/resetDelay

Clear the speed delay for the device

POST /api/resetWifi

Reset WiFi parameters (channel and SNR) for the device

Parameter Tree Files

Method & Path Description Body / Response

GET /api/paramsXmlList

List XML files in parameterstree/

Response: ["cpe_params.xml", …​]

GET /api/paramsXml

Get the active device-tree file

Response: { "paramsXml": "cpe_params.xml" }

POST /api/paramsXml

Set the active device-tree file (reloads the tree)

Body: { "paramsXml": "cpe_params.xml" } → 204

POST /api/uploadParamsXml

Upload an XML file (form field file)

multipart/form-data → { success, message, filename }

POST /api/deleteParamsXml

Delete an XML file (not the active one)

Body: { "paramsXml": "old.xml" } → { success, message, filename }

Updatable Parameters

Method & Path Description Body / Response

GET /api/updatableParameters

Get the global auto-update list

Response: array of Parameter

POST /api/updatableParameters

Replace the global auto-update list; an empty array [] deletes all parameters (the panel’s Delete all)

Body: array of Parameter → 204

POST /api/updatableParameters/upload

Replace the global auto-update list from an updatableParameters.yaml file, or an older cpe_self_updated_params.properties (name=min max step stepType lines, recognised by the .properties extension), form field file. Accepted only as a whole: an unreadable file, an unknown field, a repeated key inside an entry, a file without a parameters list (upload parameters: [] to clear the list) or an unusable parameter keeps the current list. The file is written atomically; if the write fails (500 { error }) the current file stays

multipart/form-data → 204; 400 { error } when rejected; 500 { error } when the file cannot be read or written

Logs

Used by the Logs panels of both modes.

Method & Path Description Body / Response

GET /api/logs/main

Download logs/main.log: everything the emulator logs outside a device’s session

text/plain attachment main.log; 404 { error } when it is not written yet

GET /api/logs/device?serial=

Download logs/log_cpe_<serial>.log (written while fileLogEnabled is on)

text/plain attachment; 400 { error } when the serial is blank or holds /, \ or :; 404 { error } when the serial has no log

GET /api/logs/archive

Download every log of logs/ — main.log, the device logs and the parts rolled over into *.log.zip — as one zip, streamed; a log rolled over while the zip is written is left out

application/zip attachment emulator-logs-<yyyyMMdd-HHmmss>.zip (empty zip when there are no logs)

Single Mode API (/apiV2)

Backs Single Emulator Mode. Operations are per device, addressed by serial. Designed to be automation/MCP friendly.

Configuration

Method & Path Description Body / Response

GET /apiV2/config

Frontend config (default ACS URL)

Response: { "defaultAcsUrl": "http://ftacs:8080/ftacs/ACS" }

Device Lifecycle

Method & Path Description Body / Response

POST /apiV2/start

Start a new device. Query saveConfig (default true) also stores the config.

Body: InitDeviceDto → { success, serial, message } (200); a refusal adds code (409 DEVICE_RUNNING for a device that runs, or whose start is still in progress, 400 INVALID_SERIAL for an invalid serial, 400 INVALID_REQUEST for a parameterFile that is unsafe or does not exist, invalid updatable parameters, a TR-098 tree with enableHttpConnectionRequest=false, or an invalid device identity member (see Device identity members), 503 STOP_IN_PROGRESS while a stop of everything that was accepted has not ended), see [start-errors]

POST /apiV2/stop

Stop and remove a running device

Body: { "serial": "FT001SN00001" } → 204

GET /apiV2/activeEmulators

List running devices

Response: array of { serial, manufacturer, productClass, oui, modelName, parameterFile, acsUrl, isRunning }

GET /apiV2/isEmulatorRunning?serial=

Is the device running?

Response: { serial, running }

GET /apiV2/sessionStatus?serial=

Is the device in an active TR-069 session?

Response: { serial, inSession }

POST /apiV2/reboot

Reset uptime and fire a 1 BOOT event

Body: { "serial": "…​" } → 204

POST /apiV2/factoryReset

Restart from stored config and fire 0 BOOTSTRAP

Body: { "serial": "…​" } → 204/404; 409 { success, serial, message, code: "RESET_REFUSED" } when the device did not stop within 3 s, the stop of an earlier reset is still running, or the restart was refused, also because a start of this device is still in progress (refused at once, nothing stopped or wiped; the message says which; after a stop timeout the device may still be stopping, retry the reset once that stop ended); 503 STOP_IN_PROGRESS (same body) when the restart waited in vain for a stop of everything (the device is stopped, retry the reset)

POST /apiV2/cloneDevice

Copy a device config to a new serial

Body: { sourceSerial, newSerial } → InitDeviceDto (200/404); the copy includes the device identity members. 400 INVALID_REQUEST for a stored source that is a TR-098 tree with enableHttpConnectionRequest=false or has an invalid identity member, with the { success, serial, message, code } body of [start-errors]

GET /apiV2/deviceId?serial=

TR-069 DeviceId (Manufacturer, OUI, ProductClass, SerialNumber, …​). It returns the values applied from the identity members.

Response: string map

GET /apiV2/statistics

Overall counts

Response: { activeEmulators, storedConfigurations, emulatorsInSession }

Stored Devices

Method & Path Description Body / Response

GET /apiV2/storedDevices

List saved configurations

Response: array of InitDeviceDto

GET /apiV2/storedDevice?serial=

Get one saved configuration

Response: InitDeviceDto (200/404)

POST /apiV2/saveDevice

Save a configuration without starting

Body: InitDeviceDto → 204; 400 INVALID_REQUEST for a TR-098 tree with enableHttpConnectionRequest=false or an invalid device identity member, with the { success, serial, message, code } body of [start-errors]

POST /apiV2/deleteStoredDevice

Delete a saved configuration. A device the engine still runs (scheduled or in a session), or whose start is still in progress, is not deleted

Body: { "serial": "…​" } → 204, or 409 { "code": "DEVICE_RUNNING", "message": "…​", "details": null } while the device runs or a start or factory reset of it is in progress

POST /apiV2/startStored

Start from a saved configuration

Body: { "serial": "…​" } → { success, serial, message } (200); a refusal adds code: 409 DEVICE_RUNNING (the device runs, or its start is still in progress), 404 DEVICE_NOT_FOUND, 400 INVALID_SERIAL, 400 INVALID_REQUEST for an invalid stored device identity member (see Device identity members), 503 STOP_IN_PROGRESS

POST /apiV2/startProtocol

Start from a base tree in parameterstree/base/ (TR-098 / TR-181)

Body: { protocol, serial?, acsUrl? } → { success, serial, message } (200); a refusal adds code: 409 DEVICE_RUNNING (the device runs, or its start is still in progress), 400 INVALID_REQUEST (unknown protocol) or INVALID_SERIAL, 500 INTERNAL_ERROR (the emulator’s own base tree is missing or has no usable serial: a fault of the installation), 503 STOP_IN_PROGRESS

Parameter Operations

Method & Path Description Body / Response

GET /apiV2/parameters?serial=

Full parameter tree (can be large)

Response: array of { name, value, type, notification, writable }

GET /apiV2/parametersByPrefix?serial=&prefix=

Parameters under a path prefix

Response: array of ParameterInfo

GET /apiV2/parameterNames?serial=&path=&nextLevel=

Names under a path (TR-069 GetParameterNames). nextLevel=true → immediate children only

Response: array of { name, isObject }

GET /apiV2/parameterValue?serial=&parameterName=

Single value lookup

Response: { name, value, type } (200/404)

GET /apiV2/parameterFullInfo?serial=&parameterName=

Full metadata for one parameter

Response: ParameterInfo (200/404)

GET /apiV2/parameterExists?serial=&pattern=

Existence check; {i} = numeric index, * = wildcard

Response: { exists, count, matchingParameters[] }

GET /apiV2/searchParameters?serial=&nameContains=&valueContains=&limit=

Search by name/value (default limit=100)

Response: array of ParameterInfo

POST /apiV2/changeParameter

Set one value (no ValueChange event)

Body: { serial, parameterName, parameterValue } → 204

POST /apiV2/changeParameters

Set many values; fires ValueChange if any has active notification

Body: { serial, parameters: { "Path": "value" } } → 200/204

POST /apiV2/setParameterValue

Set one value the way a real CPE does; fires a 4 VALUE CHANGE Inform if the parameter has active notification. Preserves the existing type.

Body: { serial, parameterName, parameterValue } → 200 (ValueChange fired) / 204; 400 { code: INVALID_REQUEST, message, details } when parameterName or parameterValue is missing

POST /apiV2/changeNotification

Set notification level: 0 off, 1 passive, 2 active

Body: { serial, parameterName, notification } → 204

POST /apiV2/addObject

Add an object instance (e.g. a new SSID)

Body: { serial, parentPath } → { instanceNumber, objectPath }

POST /apiV2/addParameter

Add one parameter; type/writable/notification resolved from the CWMP template

Body: { serial, name, value } → 204

POST /apiV2/deleteObject

Delete an object/branch and everything under it

Body: { serial, objectName } → 204

Events

Method & Path Description Body / Response

POST /apiV2/invoke

Trigger a TR-069 event (see TR-069 Event Codes). A ConnectionRequest during a session answers 204: the request is queued, and at most one follow-up session is pending. Other events during a session answer 409. An unknown, blank or missing eventName, the M …​ events, TransferComplete and DUStateChangeComplete answer 400 { code: "EVENT_NOT_INVOCABLE", message }.

Body: { serial, eventName } → 204/400/409

POST /apiV2/changePeriodic

Set the periodic-inform interval (seconds; 0 disables)

Body: { serial, value } → 204

Logs

Method & Path Description Body / Response

GET /apiV2/getLog?serial=

Download the full log file

application/octet-stream (200/404)

GET /apiV2/getLogContent?serial=&lines=&fromPosition=

Log content for live viewing; supports incremental reads

text/plain; header X-File-Position for the next read

GET /apiV2/logStatistics?serial=

Log counts

Response: { totalLines, fileSizeBytes, errorCount, warnCount, infoCount, debugCount }

POST /apiV2/clearLog

Clear the device log

Body: { "serial": "…​" } → 204/404

Updatable Parameters & Tree Files

Method & Path Description Body / Response

GET /apiV2/updatableParameters?serial=

Get the device’s auto-update list

Response: array of Parameter

POST /apiV2/updatableParameters

Set the device’s auto-update list

Body: { serial, parameters: [Parameter, …​] } → 204

POST /apiV2/updatableParameters/parse

Read an auto-update list from an updatableParameters.yaml file, or an older cpe_self_updated_params.properties (recognised by the .properties extension), form field file — read and checked as by POST /api/updatableParameters/upload, but nothing is stored: pass the list to POST /apiV2/start or POST /apiV2/updatableParameters

multipart/form-data → 200 array of Parameter; 400 { error } when rejected; 500 { error } when the file cannot be read

GET /apiV2/paramsXmlList

List available parameter-tree templates

Response: ["cpe_params.xml", …​]

POST /apiV2/uploadParamTree

Upload a parameter-tree XML (form field file)

multipart/form-data → filename (200, text); errors are { code, message, details }: 400 INVALID_REQUEST, 409 TREE_IN_USE (the tree of the active configuration), 500 INTERNAL_ERROR

TR-069 Event Codes

Used by POST /apiV2/invoke (TransferComplete and DUStateChangeComplete answer 400; eventName, case-sensitive — use the exact names below). See also Protocol Support — Event Codes.

Event Name Code Meaning

BootStrap

0

Initial setup / factory reset

Boot

1

Device reboot

Periodic

2

Scheduled inform

ValueChange

4

Parameter with active notification changed

ConnectionRequest

6

ACS-initiated connection request

TransferComplete

7

Download/upload completed (refused by /apiV2/invoke with 400: raised only by its RPC)

Diagnostics

8

Diagnostics complete

DUStateChangeComplete

11

Deployment-unit state change complete (refused by /apiV2/invoke with 400: raised only by its RPC)

The Single Mode Invoke Event dropdown exposes codes 0, 1, 2, 4, 6, 8. TransferComplete (7) and DUStateChangeComplete (11) cannot be triggered by hand: only the RPC that raises them (Download/Upload, ChangeDUState) does.

Data Models

EmulatorPropertiesDto (/api)

Mirrors the EmulatorParameter set. Used by GET/POST /api/properties.

Field Type Example Description

protocol

string

http

ACS protocol (http/https)

host

string

localhost

ACS host

port

integer

8080

ACS port

url

string

ftacs/ACS

ACS URL path

groups

integer

1

Number of device groups

concurrent

integer

1

Devices per group

registrationGroup

integer

0

Registration group id

delay

integer

0

Delay between registration batches (seconds)

spread

integer

0

Startup spread

startDateTime

string

``

Scheduled start (DD-MM-YYYY HH24:MI:SS)

periodicInformEnabled

boolean

true

Enable periodic inform

connectionRequestEnabled

boolean

true

Enable Connection Request listener

withoutInitialInform

boolean

false

Skip the initial inform

randomRetryCount

boolean

false

Randomise retry counts

transferEmulation

boolean

false

Emulate Download/Upload transfers

transferEmulationDelay

string

0,100,500

Transfer delay(s)

initialEvent

string

BOOTSTRAP

Event of the first session of every device after a start: BOOTSTRAP, BOOT or PERIODIC, case-insensitive. An empty value leaves it unchanged; any other value, a text of spaces included, is refused with 400 and nothing of the request is applied

loadingMode

boolean

false

Lightweight (inform-only) mode

fileLogEnabled

boolean

true

Per-device file logging

paramsXml

string

cpe_params.xml

Active parameter-tree file

taskDelayGetParameterValues

integer

11

GetParameterValues execution delay (s)

taskDelaySetParameterValues

integer

11

SetParameterValues execution delay (s)

taskDelayGetParameterNames

integer

11

GetParameterNames execution delay (s)

taskDelayGetParameterAttributes

integer

11

GetParameterAttributes execution delay (s)

taskDelaySetParameterAttributes

integer

11

SetParameterAttributes execution delay (s)

taskDelayAddObject

integer

11

AddObject execution delay (s)

taskDelayDeleteObject

integer

11

DeleteObject execution delay (s)

taskDelayDownload

integer

11

Download execution delay (s)

taskDelayUpload

integer

11

Upload execution delay (s)

taskDelayReboot

integer

11

Reboot execution delay (s)

taskDelayFactoryReset

integer

11

FactoryReset execution delay (s)

taskDelayChangeDuState

integer

11

ChangeDUState (TR-157) execution delay (s)

taskDelayGetRpcMethods

integer

11

GetRPCMethods execution delay (s)

Task execution delays hold the emulated CPE for the given number of seconds before it processes each ACS-issued RPC, modelling real-CPE "thinking time". The default is 11 seconds for every task type; set a value to 0 to disable the delay for that task. The delay is applied globally (all devices) and reactively (non-blocking). Kicked (Kick URL) is not emulated and therefore has no delay. For Download/Upload/ChangeDUState this delay is added on top of their transfer/DU-state emulation delays. When start_params.properties predates these keys (upgrade from a version before 5.0.1), the defaults apply automatically and are listed in a single log line at startup — sessions that used to complete near-instantly will now take ~11 seconds per RPC until the delays are tuned or set to 0.

InitDeviceDto (/apiV2)

Used by start, saveDevice, cloneDevice and the storedDevices responses.

Field Type Example Required Description

serial

string

FT001SN00001

Yes

Unique device serial

acsUrl

string

http://localhost:8080/acs

No

ACS URL (defaults to DEFAULT_ACS_URL)

parameterFile

string

cpe_params.xml

No

Tree file from parameterstree/

enableHttpConnectionRequest

boolean

true

No

Start value of the TR-181 parameter Device.ManagementServer.HTTPConnectionRequestEnable (written into the device’s tree at Start, Start Stored and boot restore; a tree that has none gets it only for false: with true or no field the tree stays as it is, the model of a CPE older than TR-181 2.11 whose mechanism is always on, and a SetParameterValues of the name is then the unknown-parameter fault). Default true: a request without the field (or with null) is enabled, and so is every device stored by an earlier version of the emulator, whatever it stored; only an explicit false sent to this version or later disables it. With the parameter false, ConnectionRequestURL is empty and an HTTP Connection Request for the device is dropped without any HTTP response (connection reset, one INFO log line, no session); the shared listener port stays open for the other devices. The ACS can change the parameter with SetParameterValues, and the device follows at once. That write starts no session (TR-069 3.2.1: a change made by the ACS itself via SetParameterValues does not), but ConnectionRequestURL changes with it, a change the CPE makes, and it is a parameter required in every Inform: the next Inform carries 4 VALUE CHANGE with the new URL (TR-069 A.3.3.1). A TR-098 (InternetGatewayDevice) tree has no such parameter: POST /apiV2/start with false on one answers 400 { success: false, serial, message, code: INVALID_REQUEST }, as do POST /apiV2/saveDevice and POST /apiV2/cloneDevice (a stored source); a stored one starts enabled with an ERROR log line. A factory reset (ACS or POST /apiV2/factoryReset) puts the parameter back to its factory value (the tree’s own; a parameter that only the flag added is removed and the device is enabled); the stored flag is kept but not read. UDP/STUN and XMPP Connection Requests, Load Test devices (always enabled) and the global connectionRequestEnabled switch are not affected. TR-069 3.2.2.2, TR-181 ManagementServer.HTTPConnectionRequestEnable.

manufacturer

string

Acme

No

Device identity: written to <root>DeviceInfo.Manufacturer before the first 0 BOOTSTRAP Inform. See Device identity members.

manufacturerOui

string

0A1B2C

No

Device identity: written to <root>DeviceInfo.ManufacturerOUI. Exactly 6 upper-case hexadecimal digits. See Device identity members.

productClass

string

AcmeBox

No

Device identity: written to <root>DeviceInfo.ProductClass. See Device identity members.

softwareVersion

string

1.2.3

No

Device identity: written to <root>DeviceInfo.SoftwareVersion. See Device identity members.

updatableParameters

array

see Parameter

No

Auto-updating parameters

running

boolean

true

No

Managed by the system

Device identity members

manufacturer, manufacturerOui, productClass and softwareVersion set the DeviceInfo identity of one Single Mode device. <root> is InternetGatewayDevice. for a TR-098 tree and Device. for a TR-181 tree.

  • The emulator writes each member that is set to <root>DeviceInfo.<Name> before the first 0 BOOTSTRAP Inform. The Inform DeviceId carries the values.

  • If a member is absent or null, the device keeps the value of its parameter tree.

  • manufacturer, productClass and softwareVersion are 1 to 64 printable ASCII characters. The characters " and = are not allowed. A blank value is refused.

  • manufacturerOui is exactly 6 upper-case hexadecimal digits.

  • If a member is invalid, the answer is 400 INVALID_REQUEST and the message names the member. The message and the log never show the value. Nothing is started, stored or cloned.

  • If the tree has no matching DeviceInfo parameter, start answers 400 INVALID_REQUEST and nothing is left for the serial. saveDevice checks only the member values, so it stores such a device and a later start is refused. A boot restore logs one WARN with the member name and skips the device.

  • A factory reset keeps the identity.

  • POST /apiV2/cloneDevice copies the four members from the source. An invalid stored member refuses the clone with 400 INVALID_REQUEST.

  • GET /apiV2/deviceId?serial= returns the applied Manufacturer, OUI and ProductClass, because it reads the tree.

  • POST /apiV2/startProtocol, Load Test devices and Farm devices do not take these members.

  • An older emulator ignores the members and answers 200 with the values of the tree. To prove that the emulator applied them, read <root>DeviceInfo.ProductClass after the start.

Parameter (auto-update entry)

Field Type Description

name

string

Full parameter path

type

INT | BOOL | STRING

Data type (default INT)

stepType

RANDOM | INCREMENT | DECREMENT | DEFAULT

Update mode (default DEFAULT)

min / max

integer

Value range (numeric types)

step

integer

Step size for increment/decrement

array

string[]

Optional fixed value set

Error Handling

Standard HTTP status codes are used:

Status Meaning

200 OK

Success with a response body

204 No Content

Success, no body (most mutations)

400 Bad Request

Invalid parameters or file

404 Not Found

Device, parameter or stored config not found

409 Conflict

Operation conflicts with current state (e.g. already running, device in session)

500 Internal Server Error

Unexpected server error

503 Service Unavailable

A start waited up to 25 seconds for a stop of everything that was accepted and has not ended; nothing was started, retry later

Error responses of /apiV2 use the body

{ "code": "INVALID_SERIAL", "message": "Error message description", "details": null }

code is a stable name to branch on; message is for people and may change, so never match on its text. The codes are INVALID_SERIAL and EVENT_NOT_INVOCABLE (400), INVALID_REQUEST (400), DEVICE_NOT_FOUND (404), DEVICE_RUNNING, TREE_IN_USE and RESET_REFUSED (409), INTERNAL_ERROR (500), STOP_IN_PROGRESS (503). Spring’s own request errors (a missing or mistyped parameter, an unreadable body) keep their status (400) and carry this body too.

Two /apiV2 endpoints still answer a rejected auto-update list with the older body { "error": "…​" } (400): POST /apiV2/updatableParameters and POST /apiV2/updatableParameters/parse (the latter also 500 { error } when the file cannot be read). /api (v1) endpoints, including /api/updatableParameters/upload and /api/logs/*, answer their refusals (400, 404, 500 of a known cause) with { "error": "…​" } too.

An unexpected exception on any controller under api.** — /apiV2, /api (v1), /api/logs, /farm — answers 500 { "code": "INTERNAL_ERROR", "message": "…​", "details": null } as JSON with a fixed message, also on the text/plain endpoints (/api/status, /farm/serials, /farm/serial-prefix): its text and stack trace go to the emulator log only. A client that disconnects mid-response (an aborted log download) and an exception after the response was committed are not answered with JSON.

start, startStored, startProtocol, a refused factoryReset (409 RESET_REFUSED) and the 400 INVALID_REQUEST of saveDevice and cloneDevice (a TR-098 tree with enableHttpConnectionRequest=false, or an invalid device identity member) and of startStored (an invalid stored identity member) keep the older body { success: false, serial, message } and add code with the same names. A successful start has no code. The HTTP status comes from code, not from the message. The 500 of an unexpected exception during a start is the general { code, message, details } body, without success.

503 STOP_IN_PROGRESS: a stop of everything holds the lock of the shared servers for its whole run, and it can take minutes (its XMPP connections close one after the other). It also waits for the starts that are already building their device, and POST /api/stop answers 204 before the stop has taken the lock. start, startStored, startProtocol and the restart of factoryReset therefore wait for every stop of everything that has been accepted and has not finished, also while it waits for starts already building, at most 25 seconds in all (one deadline), then answer 503 with nothing registered or started, not even the device’s first session to the ACS; the same request succeeds once the stop ended. While no such stop exists, starts of different devices run side by side and do not wait for each other. The 25 seconds are below the 30 seconds that emulator-client waits for an answer by default, so a refusal always arrives as the 503 instead of a timeout of the client’s own request. The bound covers the wait for the stop only: a start that gets through late builds its device afterwards (the parameter tree, the DNS lookup of the ACS host), and a slow build can end after the client’s 30 seconds — the client then does not know whether the device started and reads parameterValue(serial, <root>DeviceInfo.SerialNumber), which equals the serial once the device is registered (the stored flag of GET /apiV2/isEmulatorRunning is not the engine’s truth). A start that was already building when the stop was accepted is completed first; the stop then ends the device with the rest. The stop itself never gives up waiting.

409 DEVICE_RUNNING for a start: the device runs, or a start or factory reset of the same serial is still in progress (building, or waiting for a stop; a client that repeats a request after its own timeout). The second start is refused at once and waits for nothing; the first goes on. Starts of different serials are not affected. factoryReset and deleteStoredDevice take the same per-serial guard: while a start or a factory reset (up to 3 s of stop plus a start wait of up to 25 s) of the serial is in progress they are refused at once with 409 and touch nothing (no stop, no cache wipe, no change of the stored configuration).