Edit this page
The Things specification defines all Ditto Protocol commands, responses, and events for managing Things and their sub-resources (attributes, features, properties, definitions).
TL;DR: You interact with Things through four command types – create/modify, merge, retrieve, and delete – each targeting the Thing itself or any sub-resource. All commands use the topic pattern namespace/thingName/things/channel/commands/action.
Topic structure for Things
A valid topic consists of six elements:
<namespace>/<thingName>/things/<channel>/<criterion>/<action>
namespace: the namespace of the Thing.
thingName: the name of the Thing.
group: always things.
channel: either live or twin.
criterion: commands, events, search, or messages.
action: depends on criterion – see sections below.
All topics contain a <channel> which may be either twin or live.
For the meaning of those two channels see Twin and live channels.
Thing representation
The JSON representation of a Thing in API version 2:
Common errors
Every Thing command can result in an error response. You correlate errors to commands via the correlation-id header.
| status |
Description |
400 |
Bad Format - malformed request syntax. |
401 |
Unauthorized - missing authentication. |
403 |
Forbidden - insufficient permissions (WRITE required). |
404 |
Not Found - Thing not found for the authenticated user. |
412 |
Precondition Failed - If-Match or If-None-Match header check failed. |
413 |
Request Entity Too Large - entity exceeds the size limit (default: 100 kB). |
429 |
Too Many Requests - too many outstanding modifying requests to this Thing. |
Response and Event conventions
All commands produce a response and (for successful state changes) an event. Both use the
same topic and path as the command, with the criterion set to events for events.
Response fields
| Field |
Description |
| topic |
Mirrors the command topic, with criterion replaced by events for events. |
| path |
Same as the command path. |
| status |
HTTP-semantics status code. |
| value |
The affected resource (conditional – see below). |
| headers |
Includes correlation-id from the command. |
Status codes by command type
| Command type |
Success status |
value in response |
| Create |
201 Created |
The created resource |
| Modify (resource existed) |
204 Modified |
Not present |
| Modify (resource did not exist) |
201 Created |
The created resource |
| Merge |
204 Modified (or 201 if Thing created at root) |
Not present (or created Thing) |
| Retrieve |
200 OK |
The requested resource |
| Delete |
204 Deleted |
Not present |
Event fields
Events use the same path as the command. The value field always contains the affected resource
(the full resource for create/modify, the merge patch for merge, omitted for delete).
Permissions
All modify, merge, and delete commands require WRITE permission on the targeted resource path.
Retrieve commands require READ permission.
Create and modify commands
Create and modify commands use the modify or create action in the topic path. A modify command with path / creates the Thing if it does not exist, or replaces it if it does.
Create a Thing
Create a new Thing. The Policy must include at least one subject with READ and WRITE permissions. If you do not provide a Policy, Ditto creates a default Policy granting all permissions to the authorized subject.
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/create |
| path |
/ |
| value |
Complete Thing as JSON. See payload. |
Response: 201 (created), value contains the created Thing. Event: created at path / with the Thing as value. |
Create a Thing |
Create or modify a Thing
If the Thing exists, replace it. If not, create it.
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/modify |
| path |
/ |
| value |
Complete Thing as JSON. See payload. |
Response: 201 (created, value contains the Thing) or 204 (modified, no value). Event: created or modified at path /. |
Modify a Thing |
Create or modify Attributes
Replace all Attributes of a Thing.
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/modify |
| path |
/attributes |
| value |
Attributes as JSON object. |
Create or modify a single Attribute
Create or update a specific attribute. Use JSON Pointer (RFC-6901) notation for the path.
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/modify |
| path |
/attributes/<attributePath> |
| value |
The attribute value as JSON. |
Response: 201 (created, value contains the resource) or 204 (modified, no value). Event: created or modified at path /attributes/<attributePath>. |
Modify Attribute |
Create Attribute |
Create or modify a Definition
Create or update the Thing’s definition.
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/modify |
| path |
/definition |
| value |
Definition as JSON string. |
Create or modify all Features
Replace all Features of a Thing.
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/modify |
| path |
/features |
| value |
All Features as JSON. See payload. |
Response: 201 (created, value contains the resource) or 204 (modified, no value). Event: created or modified at path /features. |
Modify Features |
Create Features |
Create or modify a single Feature
Create or update a specific Feature identified by <featureId>.
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/modify |
| path |
/features/<featureId> |
| value |
The Feature as JSON. |
Response: 201 (created, value contains the resource) or 204 (modified, no value). Event: created or modified at path /features/<featureId>. |
Modify Feature |
Create Feature |
Create or modify a Feature Definition
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/modify |
| path |
/features/<featureId>/definition |
| value |
Definition as JSON array. |
Create or modify Feature Properties
Replace all Properties of a Feature.
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/modify |
| path |
/features/<featureId>/properties |
| value |
Properties as JSON object. |
Response: 201 (created, value contains the resource) or 204 (modified, no value). Event: created or modified at path /features/<featureId>/properties. |
Modify Properties |
Create Properties |
Create or modify a single Feature Property
Use JSON Pointer (RFC-6901) to address nested properties.
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/modify |
| path |
/features/<featureId>/properties/<propertyPath> |
| value |
The property value as JSON. |
Response: 201 (created, value contains the resource) or 204 (modified, no value). Event: created or modified at path /features/<featureId>/properties/<propertyPath>. |
Modify Property |
Create Property |
Create or modify desired Properties
Replace all desired Properties of a Feature.
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/modify |
| path |
/features/<featureId>/desiredProperties |
| value |
Desired properties as JSON object. |
Create or modify a single desired Property
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/modify |
| path |
/features/<featureId>/desiredProperties/<desiredPropertyPath> |
| value |
The desired property value as JSON. |
Merge commands
Merge commands use JSON Merge Patch (RFC-7396) to partially update a Thing or its sub-resources. In case of conflicts, the patch value overwrites the existing value. Setting a field to null removes it.
Merge a Thing
Apply a JSON Merge Patch to the entire Thing. Creates the Thing if it does not exist.
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/merge |
| path |
/ |
| value |
JSON Merge Patch for the Thing. |
Response: 201 (created, value contains the Thing) or 204 (merged, no value). Event: merged at path / with the merge patch as value. |
Merge a Thing |
Merge Attributes
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/merge |
| path |
/attributes |
| value |
JSON Merge Patch for attributes. |
Merge a single Attribute
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/merge |
| path |
/attributes/<attributePath> |
| value |
JSON Merge Patch for the attribute. |
Response: 204 (no value). Event: merged at path /attributes/<attributePath>. |
Merge Attribute |
Merge the Definition
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/merge |
| path |
/definition |
| value |
A valid Thing definition. |
Merge the Policy ID
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/merge |
| path |
/policyId |
| value |
A valid Policy ID. |
Response: 204.
Merge all Features
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/merge |
| path |
/features |
| value |
JSON Merge Patch for features. |
Response: 204 (no value). Event: merged at path /features. |
Merge Features |
Merge a single Feature
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/merge |
| path |
/features/<featureId> |
| value |
JSON Merge Patch for the Feature. |
Response: 201 (created). Event: merged at path /features/<featureId>. |
Merge Feature |
Merge a Feature Definition
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/merge |
| path |
/features/<featureId>/definition |
| value |
JSON Merge Patch for the definition. |
Merge Feature Properties
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/merge |
| path |
/features/<featureId>/properties |
| value |
JSON Merge Patch for properties. |
Response: 204 (no value). Event: merged at path /features/<featureId>/properties. |
Merge Properties |
Merge a single Feature Property
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/merge |
| path |
/features/<featureId>/properties/<propertyPath> |
| value |
JSON Merge Patch for the property. |
Response: 204 (no value). Event: merged at path /features/<featureId>/properties/<propertyPath>. |
Merge Property |
Merge desired Properties
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/merge |
| path |
/features/<featureId>/desiredProperties |
| value |
JSON Merge Patch for desired properties. |
Merge a single desired Property
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/merge |
| path |
/features/<featureId>/desiredProperties/<desiredPropertyPath> |
| value |
JSON Merge Patch for the desired property. |
Response: 204 (no value). Event: merged at path /features/<featureId>/desiredProperties/<desiredPropertyPath>. |
Merge Desired Property |
Retrieve commands
Retrieve commands read the current state of a Thing or its sub-resources. Use the optional fields parameter to select specific fields.
Retrieve a Thing
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/retrieve |
| path |
/ |
| fields |
Optional comma-separated list of fields to include. |
Retrieve multiple Things
Use the placeholder _ for <thingName> in the topic. Specify the Thing IDs in the value.
| Field |
Value |
| topic |
<namespace>/_/things/<channel>/commands/retrieve |
| path |
/ |
| value |
JSON object with a thingIds array. |
| fields |
Optional comma-separated list of fields to include. |
Retrieve Attributes
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/retrieve |
| path |
/attributes |
Retrieve a single Attribute
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/retrieve |
| path |
/attributes/<attributePath> |
Retrieve the Definition
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/retrieve |
| path |
/definition |
Retrieve all Features
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/retrieve |
| path |
/features |
Retrieve a single Feature
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/retrieve |
| path |
/features/<featureId> |
Retrieve a Feature Definition
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/retrieve |
| path |
/features/<featureId>/definition |
Retrieve Feature Properties
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/retrieve |
| path |
/features/<featureId>/properties |
Retrieve a single Feature Property
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/retrieve |
| path |
/features/<featureId>/properties/<propertyPath> |
Retrieve desired Properties
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/retrieve |
| path |
/features/<featureId>/desiredProperties |
Retrieve a single desired Property
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/retrieve |
| path |
/features/<featureId>/desiredProperties/<desiredPropertyPath> |
Delete commands
Delete commands remove a Thing or one of its sub-resources. All delete responses return status 204 on success.
Delete a Thing
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/delete |
| path |
/ |
Delete all Attributes
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/delete |
| path |
/attributes |
Delete a single Attribute
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/delete |
| path |
/attributes/<attributePath> |
Response: 204. Event: deleted at path /attributes/<attributePath>. |
Delete Attribute |
Delete the Definition
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/delete |
| path |
/definition |
Delete all Features
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/delete |
| path |
/features |
Delete a single Feature
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/delete |
| path |
/features/<featureId> |
Response: 204. Event: deleted at path /features/<featureId>. |
Delete Feature |
Delete a Feature Definition
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/delete |
| path |
/features/<featureId>/definition |
Delete Feature Properties
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/delete |
| path |
/features/<featureId>/properties |
Delete a single Feature Property
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/delete |
| path |
/features/<featureId>/properties/<propertyPath> |
Delete desired Properties
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/delete |
| path |
/features/<featureId>/desiredProperties |
Delete a single desired Property
| Field |
Value |
| topic |
<namespace>/<thingName>/things/<channel>/commands/delete |
| path |
/features/<featureId>/desiredProperties/<desiredPropertyPath> |
Response: 204. Event: deleted at path /features/<featureId>/desiredProperties/<desiredPropertyPath>. |
Delete Desired Property |
Further reading