ReferenceDevice driversHTTPWrite task

HTTP write task

Learn how to send commands to HTTP endpoints with Synnax.

This task follows the standard task lifecycle.

Task configuration reference

Parameter Type Required Default Description
device string - Key of the HTTP server device
endpoints array - List of endpoint configurations

Endpoint configuration reference

Each endpoint maps a single Synnax command channel to an HTTP request. When the channel receives a value, the Driver builds the JSON body and sends the request.

Parameter Type Required Default Description
method string "POST" HTTP method (POST, PUT, PATCH, or any method that accepts a body)
path string - URL path relative to the device base URL (e.g., /api/v1/setpoint)
headers array - Additional request headers as {name, value} pairs
query_params array - Query parameters as {parameter, value} pairs
disabled boolean false Excludes the endpoint from the task
channel object - Command channel field configuration
fields array [] Additional static or generated fields

Field types reference

The request body is constructed from three types of fields, each placed at a JSON Pointer location in the body.

Channel field (required)

The channel field is the primary field on each endpoint. Its value comes from a Synnax command channel — when a value is written to the channel, the Driver places it in the request body at the specified pointer.

Parameter Type Required Default Description
pointer string "" JSON Pointer where the value goes (e.g., /value). Empty sends the bare value as the body
json_type string "number" JSON type to serialize as: number, string, boolean. Timestamp channels use time_format instead
channel number - Synnax command channel key
data_type string "float64" Data type of the channel
time_format string "iso8601" Timestamp format (only for TIMESTAMP data type): iso8601, unix_sec, unix_ms, unix_us, unix_ns
enum_values array - String-to-number mapping for enum fields (e.g., [{"label": "OFF", "value": 0}, {"label": "ON", "value": 1}])
http.ChannelField(
    pointer="/value",
    json_type="number",
    channel=setpoint_cmd.key,
)

Enum values

When the HTTP request body should contain string values that represent discrete states, use enum_values to map them to numbers. The Driver converts matching strings to their numeric equivalents before writing to the channel.

http.ChannelField(
    pointer="/source",
    json_type="string",
    channel=source_cmd.key,
    enum_values=[{"label": "OFF", "value": 0}, {"label": "ON", "value": 1}],
)

Static fields

Static fields place a fixed value in every request.

Parameter Type Required Default Description
pointer string "" JSON Pointer where the value goes (e.g., /unit)
json_type string "number" JSON type to serialize as: number, string, boolean
value any - Fixed JSON value placed at the pointer
http.StaticWriteField(
    pointer="/unit",
    json_type="string",
    value="psi",
)

Generated fields

Generated fields produce a new value for each request. Two generator types are supported:

Parameter Type Required Default Description
pointer string - JSON Pointer where the value goes (e.g., /request_id)
generator string "uuid" Generator type: uuid or timestamp
time_format string "iso8601" Timestamp format (only for timestamp generator): iso8601, unix_sec, unix_ms, unix_us, unix_ns
# UUID generator - produces a unique ID per request
http.GeneratedWriteField(
    pointer="/request_id",
    generator="uuid",
)

# Timestamp generator - produces current time per request
http.GeneratedWriteField(
    pointer="/timestamp",
    generator="timestamp",
    time_format="iso8601",
)

How-to