ReferenceDriverHTTPWrite Task

HTTP Write Task

Learn how to send commands to HTTP endpoints with Synnax.

For task lifecycle management, see the Task Basics page.

How Commands Work

HTTP Write Tasks use command channels to send values to HTTP endpoints:

  • When a value is written to a command channel, the driver sends an HTTP request to the corresponding endpoint.
  • The channel value is placed in the JSON request body at a location specified by a JSON Pointer.
  • Each endpoint has exactly one command channel that drives it, plus optional static and generated fields that are included in every request.

Task Configuration Reference

ParameterTypeRequiredDefaultDescription
namestringYes-Human-readable task name
devicestringYes-Key of the HTTP server device
auto_startbooleanNofalseAutomatically start task after configuration
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)
headersobjectNo-Additional request headers
query_paramsobjectNo-Query parameters
enabledbooleanNotrueWhether this endpoint is active
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
pointerstringYes-JSON Pointer where the value goes (e.g., /value)
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}],
)

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)
generatorstringYes-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.GeneratedField(
    pointer="/request_id",
    generator="uuid",
)

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

How-To

Console

Python