ReferenceDriverHTTPWrite Task

HTTP Write Task

Learn how to send commands to HTTP endpoints with Synnax.

For the task lifecycle, see Task Basics.

Task Configuration Reference

ParameterTypeRequiredDefaultDescription
devicestringYes-Key of the HTTP server device
endpointsarrayYes-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.

ParameterTypeRequiredDefaultDescription
methodstringNo"POST"HTTP method (POST, PUT, PATCH, or any method that accepts a body)
pathstringYes-URL path relative to the device base URL (e.g., /api/v1/setpoint)
headersarrayNo-Additional request headers as {name, value} pairs
query_paramsarrayNo-Query parameters as {parameter, value} pairs
disabledbooleanNofalseExcludes the endpoint from the task
channelobjectYes-Command channel field configuration
fieldsarrayNo[]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.

ParameterTypeRequiredDefaultDescription
pointerstringNo""JSON Pointer where the value goes (e.g., /value). Empty sends the bare value as the body
json_typestringNo"number"JSON type to serialize as: number, string, boolean
channelnumberYes-Synnax command channel key
data_typestringNo"float64"Data type of the channel
time_formatstringNo-Timestamp format (only for TIMESTAMP data type): iso8601, unix_sec, unix_ms, unix_us, unix_ns
enum_valuesarrayNo-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.

ParameterTypeRequiredDefaultDescription
pointerstringNo""JSON Pointer where the value goes (e.g., /unit)
json_typestringNo"number"JSON type to serialize as: number, string, boolean
valueanyYes-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:

ParameterTypeRequiredDefaultDescription
pointerstringYes-JSON Pointer where the value goes (e.g., /request_id)
generatorstringNo"uuid"Generator type: uuid or timestamp
time_formatstringNo"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