Cozify OneAPI (3.0)

Download OpenAPI specification:

The OpenAPI specification for the Cozify ONE platform.

Graph API

Cozify Graph is the primary, unified API surface. Instead of per-resource REST endpoints, a single pair of endpoints dispatches a polymorphic set of typed messages, each selected by its type discriminator:

  • PUT /graph/command — change state.
  • POST /graph/query — read state.

Commands that start long-running work return an operation you can track to completion, and server-side changes are delivered live as push messages over the SignalR hub stream. The classic per-provider REST endpoints (Hub, Hubs, DeviceRegister) are deprecated in favor of Graph.

Terminology

If you are new to Cozify Services, there are some terms you might not be familiar with.

  • resource — A manageable item available through the platform. Hubs, Devices and Sites are examples of resources; resource groups, subscriptions and tags are too.
  • resource group — A container that holds related resources for a platform solution. You decide which resources belong to a group based on what makes the most sense for your organization.
  • resource provider — A service that supplies platform resources. For example, the canonical site resource provider is Cozify.Sites, which supplies the structural management of site (a.k.a. building) resources. Cozify.Site is accepted as a compatibility alias for clients that model the provider namespace separately from the plural resource type. Cozify.DeviceRegister is another common resource provider.

SignalR (/hub/v1)

In addition to the REST endpoints described here, the API is available over a persistent SignalR connection at the /hub/v1 endpoint. See Microsoft's guide to SignalR streaming for how to consume it from a .NET / JavaScript / Java client.

Graph over SignalR

The Graph command/query API is exposed as hub methods that carry the same envelopes as the REST endpoints:

  • Command(CommandRequest) returns CommandResponse — the equivalent of PUT /graph/command.
  • Query(QueryRequest) returns QueryResponse — the equivalent of POST /graph/query.

Device events — deprecated

Deprecated. This whole feature — the DeviceEventsStream stream, the four subscribe methods, and their request payloads — is superseded by the contracted push stream. Use Push and its DeviceStateDeviceRegisterPush message instead: it carries the same device state, is part of this document rather than hand-copied by each consumer, and delivers the current state of every device in the register as its first messages, so a subscriber has nothing to poll for an initial value.

It still works and is not scheduled for removal. One known consumer remains on it; removal waits on that migration rather than on a date.

  1. To receive device events you must open the event stream — otherwise no events are delivered, regardless of subscriptions. Open the DeviceEventsStream stream; its messages are delivered over SignalR and are not part of this OpenAPI document — which is itself a reason to prefer the push.
  2. To manage event subscriptions, use the following hub methods:
    • DeviceEventsSubscribeAll(deviceRegisterId) — subscribe to events from all devices in the register.
    • DeviceEventsUnsubscribeAll(deviceRegisterId) — unsubscribe from all device events from the register.
    • DeviceEventsSubscribe(request) — subscribe to events from specific devices in the register. Warning: if you previously subscribed to all events from the same register, this changes nothing — you will still receive events from every device.
    • DeviceEventsUnsubscribe(request) — unsubscribe from specific devices in the register. Warning: if you previously subscribed to all events from the same register, this changes nothing — use DeviceEventsUnsubscribeAll instead.

Note: Cozify supports Transport Layer Security (TLS) 1.2 or later only.

DeviceRegister

Operations for managing device registers, such as executing commands on device registers and querying device register states.

DeviceRegisterCommand Deprecated

Deprecated. Use /graph/command with migrated device register Graph commands instead.

Authorizations:
Bearer
path Parameters
deviceRegisterId
required
string (DeviceRegisterId) [ 3 .. 64 ] characters ^[A-Za-z0-9_-]+$
Example: default-devices

Globally unique device register identifier.

Request Body schema: application/json
required

Request object for command.

required
object (DeviceRegisterCommand)

Base type for all device register commands. Abstract base; never instantiated directly. Use a concrete subtype.

Responses

Request samples

Content type
application/json
{
  • "command": {
    }
}

Response samples

Content type
application/json
{
  • "result": {
    }
}

DeviceRegisterQuery Deprecated

Deprecated. Use /graph/query with migrated device register Graph queries instead.

Authorizations:
Bearer
path Parameters
deviceRegisterId
required
string (DeviceRegisterId) [ 3 .. 64 ] characters ^[A-Za-z0-9_-]+$
Example: default-devices

Globally unique device register identifier.

Request Body schema: application/json
required

Request object for query.

required
object (DeviceRegisterQuery)

Base type for all device register queries. Abstract base; never instantiated directly. Use a concrete subtype.

Responses

Request samples

Content type
application/json
{
  • "query": {
    }
}

Response samples

Content type
application/json
{
  • "result": {
    }
}

Graph

Cozify Graph is the unified gateway to data and actions in Cozify One. In place of per-resource REST endpoints, a single pair of endpoints - PUT /graph/command to change state and POST /graph/query to read it - dispatches a polymorphic set of typed commands and queries, each selected by its type discriminator. Commands that start long-running work return an operation you can track to completion, and server-side changes are delivered live as push messages over stream.

Query

Allows the execution of a specific query.

Authorizations:
Bearer
Request Body schema: application/json
required

Request object for query.

required
object (Query)

Base type for queries. Abstract base; never instantiated directly. Use a concrete subtype.

correlationId
string (CorrelationId) [ 1 .. 128 ] characters

Client-chosen opaque identifier for an operation. Supplied on the request and echoed back on the response, and attached to server logs and traces so the caller can correlate their request with server-side activity.

traceparent
string (Traceparent) ^[0-9a-f]{2}-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-...

W3C Trace Context traceparent ("00---"). On a request it continues the caller's distributed trace on the server, carried in the body so it also works on transports without headers (SignalR); over HTTP the traceparent header takes precedence. On a response it is the server-side trace of the operation, for support and log/trace lookup.

Responses

Request samples

Content type
application/json
{
  • "query": {
    },
  • "correlationId": "string",
  • "traceparent": "string"
}

Response samples

Content type
application/json
{
  • "result": {
    },
  • "correlationId": "string",
  • "traceparent": "string"
}

Command

Allows the execution of a specific command.

Authorizations:
Bearer
Request Body schema: application/json
required

Request object for command.

required
object (Command)

Base type commands. Abstract base; never instantiated directly. Use a concrete subtype.

correlationId
string (CorrelationId) [ 1 .. 128 ] characters

Client-chosen opaque identifier for an operation. Supplied on the request and echoed back on the response, and attached to server logs and traces so the caller can correlate their request with server-side activity.

traceparent
string (Traceparent) ^[0-9a-f]{2}-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-...

W3C Trace Context traceparent ("00---"). On a request it continues the caller's distributed trace on the server, carried in the body so it also works on transports without headers (SignalR); over HTTP the traceparent header takes precedence. On a response it is the server-side trace of the operation, for support and log/trace lookup.

Responses

Request samples

Content type
application/json
{
  • "command": {
    },
  • "correlationId": "string",
  • "traceparent": "string"
}

Response samples

Content type
application/json
{
  • "result": {
    },
  • "correlationId": "string",
  • "traceparent": "string"
}

Push

Fetches the pushes waiting for one session. The same stream the SignalR Push method serves, over a request a client can make from anywhere - a client that cannot hold a socket open uses this and receives identical data.

The response is a JSON array written as the pushes arrive rather than at the end, so a client reading it as an asynchronous enumeration receives each push as it happens. The elements are the same PushMessage envelopes the stream delivers, so the code handling one handles the other.

One fetch ends once its wait is up and the client asks again. The subscription survives the gap between one fetch and the next - a caller between fetches is still a caller - for as long as the service's idle grace, which is comfortably longer than the longest wait this endpoint allows. Stop fetching for longer than that and the subscription is released as any departed client's is: the fetches still answer, with heartbeats and nothing else, until a subscribe asks for it again.

What arrives during a gap is not held for later either, so a client that stops fetching for a while comes back to the stream as it is rather than to a backlog. That is the guarantee the socket carries too: every push states whole current state rather than a change to apply, so the next one for a device corrects whatever was missed, and a client that wants everything at once re-subscribes and is answered with a snapshot.

Subscribe first, through PUT /graph/command, naming the same sessionId there as here. Over the SignalR hub that field is replaced with the connection id and may be left out; over HTTP there is no connection to take it from, so the caller names its own.

SignalR method: Push.

Authorizations:
Bearer
Request Body schema: application/json
required

The session to fetch for, and how long to wait.

sessionId
required
string (PushSessionId) [ 1 .. 128 ] characters

This governs release, never delivery. Delivery is per user: every connection of a user receives everything that user is watching, whichever session asked for it and whatever this field says. There is no per-session delivery path, so this is not a way to address one connection. What the session decides is who may give a subscription back — a subscription belongs to the user, so without counting the sessions holding it the first tab to navigate away would silence the rest. Over the SignalR hub the server replaces whatever is sent here with the connection id, so on that transport the field is inert and may be left out; it is replaced rather than trusted because the connection id is how the server recognises a session that has stopped reading, and gives back what a closed tab held without it having unsubscribed. Set it yourself only over plain HTTP, where there is no connection to take it from — callers that send nothing there share one anonymous session and can release each other's subscriptions.

wait
integer [ 1 .. 55 ]
Default: 25

How long this fetch waits for pushes before completing, in seconds. Bounded by the service at 55, which is under the time most proxies will hold an idle response open, and at one second below - a fetch that waits for nothing answers before the stream has handed anything over, so it comes back empty however much was waiting for it.

Responses

Request samples

Content type
application/json
{
  • "sessionId": "string",
  • "wait": 25
}

Response samples

Content type
application/json
[
  • {
    }
]

Hub

Operations related to the Cozify Hub, including command execution and querying the state of the hub and its connected devices.

HubCommand Deprecated

Deprecated. Use /graph/command with migrated hub Graph commands instead.

Authorizations:
Bearer
path Parameters
hubId
required
string <uuid> (HubIdProperty)
Deprecated
Example: 3ee5d62c-fa38-42a0-a5ac-0c4b315d75fb

The identifier of the Cozify Hub.

Request Body schema: application/json
required

Request object for command.

required
object (HubCommand)
Deprecated

Deprecated. Use base Graph hub commands through /graph/command. Abstract base; never instantiated directly. Use a concrete subtype.

Responses

Request samples

Content type
application/json
{
  • "command": {
    }
}

Response samples

Content type
application/json
{
  • "result": {
    }
}

HubQuery Deprecated

Deprecated. Use /graph/query with migrated hub Graph queries instead.

Authorizations:
Bearer
path Parameters
hubId
required
string <uuid> (HubIdProperty)
Deprecated
Example: 3ee5d62c-fa38-42a0-a5ac-0c4b315d75fb

The identifier of the Cozify Hub.

Request Body schema: application/json
required

Request object for query.

required
object (HubQuery)
Deprecated

Deprecated. Use base Graph hub queries through /graph/query. Abstract base; never instantiated directly. Use a concrete subtype.

Responses

Request samples

Content type
application/json
{
  • "query": {
    }
}

Response samples

Content type
application/json
{
  • "result": {
    }
}

Hubs

Operations related to the Cozify Hubs services, including command execution and querying the state of the fleet.

HubsQuery Deprecated

Deprecated. Use /graph/query with migrated hubs Graph queries instead.

Authorizations:
Bearer
Request Body schema: application/json
required

Request object for query.

required
object (HubsQuery)
Deprecated

Base type for all hubs queries. Abstract base; never instantiated directly. Use a concrete subtype.

Responses

Request samples

Content type
application/json
{
  • "query": {
    }
}

Response samples

Content type
application/json
{
  • "result": {
    }
}

Service

Service-level operational endpoints, such as the anonymous status/version probe.

Status

Returns service status, including the running version. Anonymous - no authentication is required.

Responses

Response samples

Content type
application/json
{
  • "version": "3.0.1+build.42"
}