Skip to content
On this page

Services

Service specification

The rules every Factory+ service follows for identification, discovery through the Directory, the HTTP interface, authentication, change notification and an optional Sparkplug presence.

13 min read Edit this page
ACS implementationACS service API librarySee how the AMRC Connectivity Stack implements this.View on GitHub

A Factory+ service is a network service that provides one framework function. The Directory, the Configuration Store and the Auth service are examples.

Every service is found, called and authenticated in the same way, because clients and other services work with many of these functions and each one may be supplied by a different implementation. A service that follows the rules below can be discovered by any Factory+ client and can use any other Factory+ service without special handling.

Each service page builds on these rules and assumes all of them. It states the service’s own UUID, its API paths, the permissions it checks and the change-notify paths it offers.

Requirement keywords

The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, SHOULD NOT, RECOMMENDED, NOT RECOMMENDED, MAY and OPTIONAL on this site are to be interpreted as described in RFC 2119 and RFC 8174 when, and only when, they appear in capitals. The same reading applies on every page of the framework documentation.

Identification

Every service function has a well-known service UUID. A client asks for a function by this UUID, never by a hostname or product name. A site can therefore replace one implementation with another without changing its clients.

  • A service MUST identify the function it provides by its service UUID.
  • One service URL provides exactly one function. If a program provides several functions, it MUST expose each one at its own URL, under its own service UUID.
  • A new service function, such as a plugin service, MUST have its own service UUID.
  • A new service UUID SHOULD be registered in the Configuration Store as a member of the Service function class. Tools use that membership to show the function by name.
  • A service that also publishes on Sparkplug has a device UUID for its Sparkplug Node. The device UUID identifies that one running instance. The service UUID identifies the function.
ClassService function
265d481f-87a7-4f93-8fc6-53fa64dc11bb
The Configuration Store class whose members are service function UUIDs.

Each framework service gives its service UUID on its own page, and Well-known UUIDs collects them all. The table repeats them for quick reference.

FunctionService UUID
Directoryaf4a1d66-e6f7-43c4-8a67-0fa3be2b1cf9
Configuration Storeaf15f175-78a0-4e05-97c0-2a0bb82b9f3b
Authcab2642a-f7d9-42e5-8845-8f35affe1fd4
Command Escalation78ea7071-24ac-4916-8351-aa3e549d8ccd
MQTT brokerfeb27ba3-bd2c-4916-9269-79a61ebc4a47
Filesa2a6efc5-9793-4486-9fd9-7caf9e3b5451
Data Access06cee697-29d3-4972-9479-bc392e24946e
i3X018854a1-a312-46d3-b904-c274b59088c7

Discovery

Clients find services through the Directory. The Directory is the only service whose address a client needs in advance. Client configuration is therefore a single URL, and services can move without their clients being reconfigured.

sequenceDiagram
    participant C as Client
    participant D as Directory
    participant S as Service
    C->>D: GET /v1/service/{service UUID}
    D-->>C: 200 [{"device": ..., "url": "https://..."}]
    C->>S: GET {url}/ping
    S-->>C: 200 {"service": ..., "version": ...}
  1. A client MUST be given the URL of the Directory by configuration. It is the one service URL that cannot be discovered.
  2. To find any other service, the client sends GET /v1/service/{uuid} to the Directory with the service UUID. The response is a JSON array with at most one entry, because a Directory holds one URL per service. The entry has a url and a device. The device is the service’s Sparkplug device UUID, or null.
  3. If the response is an empty array or a 404, no URL is registered for that service. The client MUST treat this as “service not available” and not as an error in its own request.
  4. A client MAY cache a URL it has looked up. If the client cannot reach the service at the cached URL, it SHOULD look the URL up again.
  5. A client MAY let local configuration override the Directory for a particular service. This is for testing, or for a service the Directory cannot describe.

How a service URL gets into the Directory is implementation-defined. An implementation might load the URLs from its deployment configuration or offer an administrative interface for registering them. A Directory MAY also take URLs from service birth certificates on Sparkplug, as described in Sparkplug presence. This is a legacy method, and new implementations SHOULD NOT rely on it.

Most service URLs are HTTP or HTTPS URLs. A service whose protocol is not HTTP registers a URL in its own scheme. The MQTT broker, for example, is registered with an mqtt:, mqtts:, ws: or wss: URL.

HTTP interface

Service URLs

  • A service SHOULD be offered over HTTPS.
  • If a service is offered over HTTPS, its registered URL SHOULD use the https: scheme.
  • A server certificate MUST be verifiable by every client expected to use the service.
  • A service URL does not have to point at the root of a server. It MAY include a path prefix, such as https://example.com/factoryplus/files/.
  • A client MUST resolve every API path relative to the service URL, keeping any prefix.
  • A client MUST NOT resolve an API path from the server root. The client joins the path to the service URL and does not replace the URL’s path with it.

Paths

Service APIs live under a version prefix. A service can then change its API without breaking old clients, and the top level stays free for paths that every service shares.

  • Every service-specific endpoint MUST be under a path whose first segment is a version, matching the pattern ^v[0-9] (for example /v1/device or /v2/object).
  • All other top-level paths are reserved for this specification. The table lists the reserved paths defined so far.
PathDefined by
GET /pingPing on this page
POST /tokenAuthentication
/notify/v2Change-notify. The whole /notify/ prefix is reserved for change-notify.
  • A service MUST NOT define its own endpoints at other top-level paths. A few older endpoints break this rule, such as the Auth service’s /authz paths. They are deprecated and listed on their service pages.

Requests and responses

  • Request and response bodies SHOULD be JSON (application/json) unless there is a strong reason for another format, such as file content.
  • A response with a JSON body MUST say so in its Content-Type.
  • An endpoint that accepts a partial update with PATCH SHOULD accept a JSON Merge Patch (RFC 7396) with the content type application/merge-patch+json.
  • A service MAY limit the size of a request body. It SHOULD reject a body that is too large with 413.
  • A service MAY set Cache-Control on GET responses. A client that caches responses MUST honour it.
  • A service SHOULD allow cross-origin requests with credentials so that browser applications on other origins can call it.

Status codes

Services report the outcome of a request with plain HTTP status codes. An error response does not need a body. A service MAY include a short plain-text description for people reading logs, and a client MUST NOT depend on its content.

StatusMeaning in Factory+
200 OKThe request succeeded and the body holds the result.
201 CreatedA new resource was created.
204 No ContentThe request succeeded and there is no body.
304 Not ModifiedA conditional GET matched the current ETag (see ETags).
400 Bad RequestThe request was malformed, such as a header that cannot be parsed.
401 UnauthorizedThe request had no credentials, or the service refused them. The response MUST include a WWW-Authenticate header.
403 ForbiddenThe caller is authenticated but does not hold the permission the request needs.
404 Not FoundThe resource does not exist. If telling the caller that a resource exists would itself leak information, a service MAY return 404 instead of 403. A service that does this MUST do it consistently.
405 Method Not AllowedThe resource exists but does not support this method.
409 ConflictThe request conflicts with the current state of the resource.
410 GoneThe request can never succeed, such as a path parameter that is not a well-formed UUID, or an endpoint that has been withdrawn.
412 Precondition FailedAn If-Match or If-None-Match condition was not met.
415 Unsupported Media TypeThe request body has a content type the endpoint does not accept.
422 Unprocessable ContentThe body was understood but is not valid, such as a document that fails its schema.
503 Service UnavailableThe service could not complete the request because something it depends on is unavailable. This includes failing to reach the Auth service, or the identity provider, to check the caller’s credentials or permissions.

On every route of every service, a path parameter that MUST be a UUID but is not a well-formed one MUST get 410 Gone rather than 404 or 400. No resource can ever exist at that path. The 410 tells the client that retrying or creating the resource will not help.

The difference between 401 and 503 matters to clients. A 401 tells the client its credentials are bad. The client then discards any token it holds and authenticates again. A 503 tells the client the service could not check anything at the moment. The client SHOULD then keep its credentials and retry later. If a service could not check the credentials at all, it MUST NOT return 401.

ETags

Some resources change in ways that two clients could race on, such as a configuration entry. Services protect these with entity tags, defined in RFC 9110 section 8.8.3.

  • If a service offers ETags, it SHOULD use strong ETags whose opaque value is a UUID, such as "0d0b6b5e-6d0c-4b47-9b2d-0d6a3c3f9b8a". Clients written to this specification look only at strong ETags in this form.
  • A client makes a write conditional by sending If-Match with the ETag it last read. If the resource has changed since, the service MUST refuse the write with 412.
  • A client can send If-None-Match: * to create a resource only if it does not already exist. If the resource exists, the client receives 412.
  • A GET with If-None-Match that matches the current ETag returns 304 with no body.

Each service page says which of its resources carry ETags.

Ping

Every service MUST provide GET /ping. A client uses it to confirm that it has reached the right function and that its credentials are accepted. The call needs no permission on the service.

  • The service MUST answer any authenticated principal with 200 and a JSON object holding the fields below.
  • If a request has no valid credentials, the service MUST answer it with 401.
FieldRequiredValue
serviceYesThe service UUID of the function this URL provides.
versionYesThe version of the API specification the service implements, as a string, such as "2.0.0". It is the version of the interface, not of the software.
deviceNoThe device UUID of the service’s Sparkplug Node, when it has one.
softwareNoAn object describing the software that provides the service. Its string fields vendor, application and revision are all optional.
{
    "service": "af4a1d66-e6f7-43c4-8a67-0fa3be2b1cf9",
    "version": "1.1.0",
    "device": "1b1e0c4c-2f4e-4a5c-9d7e-6c8b5a4f3e2d",
    "software": {
        "vendor": "Example Ltd",
        "application": "example-directory",
        "revision": "3f2a9c1"
    }
}

A client SHOULD check that service matches the UUID it asked the Directory for, because that check catches a URL registered against the wrong service.

Authentication

Every request to a Factory+ service MUST be authenticated as a Factory+ principal, except at any endpoint a service deliberately makes public. The full rules are on Authentication, and these are the main ones.

  • A service MUST accept Kerberos credentials in the Authorization header both as HTTP Basic and as Negotiate. HTTP Basic carries a principal name and password, and the service checks them against the Kerberos KDC. Negotiate carries a GSSAPI token.
  • A service SHOULD provide POST /token. It returns {"token": ..., "expiry": ...} for the authenticated caller, where expiry is in milliseconds since the Unix epoch. Until it expires, the token is accepted as Authorization: Bearer <token> by that service only. The token saves a Kerberos exchange on every request.
  • A service MAY accept OIDC bearer tokens that carry the fp_principal_uuid claim and take the caller’s identity from that claim. These tokens are JWTs.

If a caller authenticated with an OIDC token and a service calls another service on that caller’s behalf, the first service SHOULD forward the same token. The second service then applies the original caller’s permissions.

Authorisation

Authentication says who the caller is. The service then decides what the caller may do by checking the caller’s permissions. The permissions come from grants held by the Auth service, and the Auth service computes the permissions a principal holds but does not make the decision.

  • Each service MUST check the permissions its endpoints need itself.
  • If a permission check fails, the service MUST return 403, or 404 under the rule in the status code table.

Authorisation describes the model of principals, permissions, targets and grants.

A service’s permissions belong to a permission group that the service names on its page. The service needs the right to read its callers’ ACLs for that group.

Change notification

Clients often need to know when something held by a service changes, such as a configuration entry or an access control list. Polling the HTTP API is wasteful and slow to notice changes. Services offer change notification instead.

  • If a service’s data changes in ways clients act on, the service SHOULD offer the notify/v2 WebSocket interface at /notify/v2.
  • Each service page lists the paths that can be watched or searched through it.

Sparkplug presence

A service MAY have a Sparkplug Node on the Factory+ MQTT namespace. Most services have no need of one. A service publishes on Sparkplug when it has live data or events that clients consume over MQTT, such as the Directory’s change notices. These rules apply to a service that does publish on Sparkplug.

  • The service MUST follow the Factory+ Sparkplug conventions. In particular, its birth certificate MUST carry the Factory+ payload uuid 11ad7b32-1d32-4c4a-b0c9-fa049208939a.
  • The service MUST publish a Schema_UUID metric at the top level of its birth with the Service schema UUID 05688a03-730e-4cda-9932-172e2c62e45c, together with the metrics that schema defines. The table lists those metrics.
  • The service SHOULD use its Sparkplug device UUID as the device value in its Directory record and in its /ping response. A client can then get from the service record to the Sparkplug Node. The device UUID is the service’s top-level Instance_UUID.
  • The service MUST respond to Node Control/Rebirth by publishing a new birth.
MetricTypeRequiredValue
Schema_UUIDUUIDYes05688a03-730e-4cda-9932-172e2c62e45c
Instance_UUIDUUIDYesThe service’s device UUID.
Service_UUIDUUIDRecommendedThe service UUID of the function this Node provides.
Device_Information/...BranchRecommendedManufacturer, model and serial information, following the Device_Information schema 2dd093e9-1450-44c5-be8c-c0d78e48219b.
Service_URLStringNoThe service URL. It is the legacy way to register a service with the Directory.
Last_Changed/...BranchNoDeprecated change-notify version 0 metrics.

One birth certificate describes one service function. A program that provides several functions on Sparkplug publishes a separate birth for each, for example as several Sparkplug Devices under one Node.

The Sparkplug address a service publishes on is implementation-defined. To subscribe to a service’s Sparkplug traffic, a client finds the address through the Directory by taking the device from the service record and looking it up with GET /v1/device/{uuid}.

SchemaService
05688a03-730e-4cda-9932-172e2c62e45c
The top-level schema of a service's Sparkplug birth certificate.
Esc