ReferenceDriverHTTPWrite Task

HTTP write task

Learn how to send commands to HTTP endpoints with Synnax.

This task follows the standard task lifecycle.

Task configuration reference

Table

Parameter Type Required Default Description
device string Yes - Key of the HTTP server device
endpoints array Yes - 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.

Table

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

Table

Parameter Type Required Default Description
pointer string No "" JSON Pointer where the value goes (e.g., /value). Empty sends the bare value as the body
json_type string No "number" JSON type to serialize as: number, string, boolean
channel number Yes - Synnax command channel key
data_type string No "float64" Data type of the channel
time_format string No - Timestamp format (only for TIMESTAMP data type): iso8601, unix_sec, unix_ms, unix_us, unix_ns
enum_values array No - 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.

Table

Parameter Type Required Default Description
pointer string No "" JSON Pointer where the value goes (e.g., /unit)
json_type string No "number" JSON type to serialize as: number, string, boolean
value any Yes - 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:

Table

Parameter Type Required Default Description
pointer string Yes - JSON Pointer where the value goes (e.g., /request_id)
generator string No "uuid" Generator type: uuid or timestamp
time_format string No "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