Skip to content

Templates

Templates save you from creating streams one by one. A template with the prefix events/ lets anything under events/ publish with the template’s password, events/stage_a, events/stage_b or whatever your crew comes up with on the day.

In the panel, open Templates and add one. Or write it in nyquist.toml:

[[template]]
name = "events"
prefixes = ["events/"]
password = "pick-something-long-and-random"
  • name is how you refer to the template. It shows up next to every stream it covers.
  • prefixes is the list of name beginnings it covers. One template can cover several, like ["events/", "conferences/"].
  • password is optional, just like for streams. Without it, anything under the prefixes can publish without a password, so set one unless you really mean it.

End your prefixes with a slash. events/ covers events/stage_a but not events_archive, while events covers both.

The API works too, PUT /api/v1/templates/events with the prefixes and the password, see The API.

When an encoder publishes, Nyquist looks for a rule in this order:

  1. A stream you created with exactly that name. Its own settings win. Its own password counts, or the password of the template it follows when it has none.
  2. The first template, in the order they’re written in the file, with a prefix the name starts with.

No match means the encoder gets turned away.

Streams that publish through a template don’t need to be in the config file at all. They show up in the panel and the API while they’re live, with the template’s name next to them, and drop off the list when they stop.

Need a title, a description, backups or a password of its own for one of them? Create that stream and it gets its own entry. To keep it tied to the template, set its template, and as long as the stream has no password of its own, encoders publish to it with the template’s password:

[[stream]]
name = "events/stage_a"
title = "Stage A"
template = "events"

Changes apply right away. Changing a template’s password sends away the publishers it covers, so they have to come back with the new one. That includes streams that follow the template without a password of their own. Removing a template, or changing its prefixes so a stream isn’t covered anymore, sends those publishers away too.

A template that streams follow can’t be removed. Nyquist names the stream that still follows it, so take template out of that stream first.