Internal API Contract (UI↔BE)

*Status:* v1.0 authoritative · Owner: Backend and Frontend (shared; the person running the session signs off) · Last reviewed: 2026-06-26

This is the internal POST-RPC contract between the Angular UI and its own Java backend (oneiot-ui / iotw). Frontend (FE) and backend (BE) engineers read it. It is hand-kept (no code generation), so a change lands here first and identically on both sides.

The outward-facing northbound API (REST + OpenAPI) is a different surface. See the External API Contract. The Java and Angular standards both link here.
contract-flow

The contract

Element Shape Who proposes a change

Envelope

ICollection<T> = { items: T[] }; paged lists use ICollectionWithPagination<T>

BE

Pagination

{ pageNumbers, pageSize, sorts: [{ field, direction }] }

BE

Error codes

Numeric 90xx, for example 9024 (device not found) and 9018 (domain denied). The rule: the BE answers with the correct HTTP status and the code in the body. This is a goal, not a guarantee, so the FE maps the code to a user message and does not rely on the status. This is the internal catalog. The External API has its own catalog (100 and 20X). Do not mix them.

BE (the BE also owns the list of codes)

Error body

Three fields: code (number, the 90xx code), message (string) and description (string). Source: class ErrorDetails of the compiled ft-exceptions 0.0.3 library, returned by oneiot-ui in GlobalExceptionHandler.java:134-141.

BE

URL style

POST-RPC /{controller}/{action}

Either side (both sides must agree)

Verb and path of an operation

One verb per kind of operation, and the path /{controller}/{action}. See API operations.

Either side (both sides must agree)

Identity

serial (string): the serial number of the device. deviceId (number): the device id. The serial number is never sent in deviceId. Log lines carry serial= (a string) and deviceId= (a number), and sessionId= when a session or transaction exists.

Either side (both sides must agree)

The last column names the side that proposes a change. Every change lands on both sides in one coordinated pull request (see Changing the contract).

In oneiot-ui each entry of the error registry stores an HTTP status, and the handler sends that status (GlobalExceptionHandler.java:137). Examples: 9024 is sent with 404, and 9018 with 403 (ServicesErrorRegistryEnum.java:110-153).

API operations: verb, path and types

The URL is /{controller}/{action}, where action is a resource noun. Reads carry their filter or id in the request body, not the query string. The HTTP verb is fixed per kind of operation (reference: angular-ui ApiService + device.service.ts). Do not apply this table to the northbound REST APIs (ft-northbound-api, ft-service-api, ft-provision-api). The External API Contract and the Java standard, J13 govern them.

Operation Verb Path (action) Request body → Response FE service method

List / query

POST

/{controller}/items

filter + { pageNumbers, pageSize, sorts } → ICollectionWithPagination<T> (or ICollection<T> if unpaged)

getXxxList(payload)

Get by id

POST

/{controller}/<resource> (e.g. deviceInfo)

{ id } → T

getXxx(id) / getXxxInfo(id)

Create

PUT

/{controller}/item

the new DTO → boolean / created id

addXxx(payload)

Update

PUT

/{controller}/<resource>

the changed DTO → boolean / updated

updateXxx(params) / setXxx(params)

Delete (bulk by id)

DELETE

/{controller}/items

{ ids: number[] } (in the body) → void

deleteXxxs(ids)

Sub-resource

POST

/{controller}/<resource>/<sub> (e.g. history/details)

{ id } or filter → ICollection<…​>

getXxx…​(…)

Rule Why / detail

Reads use POST (not GET)

The filter, the paging and the id travel in the JSON body. Complex queries stay uniform.

item (singular) and items (plural)

Singular means one entity (create, get one). Plural means a collection (list, bulk delete).

Create and update both use PUT

FT convention. The action tells them apart, not the verb: item creates, a named resource updates.

DELETE carries ids in the body

Bulk delete by { ids: […​] }, not by a path id.

action casing

camelCase resource noun (deviceInfo, accountInfo). Nest sub-resources with /.

FE method naming

getXxxList, getXxx(id), addXxx, updateXxx or setXxx, deleteXxxs. The verb names the operation.

The BE controller must expose exactly these verb+path pairs, and the FE service must call them by these names. Do not add a REST-style GET /items/{id} on one side only.

How each side uses it

Backend (Java) Frontend (Angular)
  • Returns the envelope / pagination shape verbatim.

  • Logs serial, deviceId and sessionId as key=value (J5).

  • Owns the error-code list.

  • Calls POST-RPC through a thin ApiService.

  • Maps error codes to user-facing messages in NgRx effects.

Changing the contract

  1. Edit this page first.

  2. Edit the matching Java standard, J8 section and the Angular FE↔BE checklist (C8).

  3. Update both sides in the same change set. They must never drift.

  4. A contract change is a coordinated pull request of both teams, not a backend-only change, because there is no code generation.