Preview: the PushFleet API isn't live yet. Join the waitlist
Templates
A template is a message you save once and send by ID. It keeps requests tiny, which matters when you send at volume, and it keeps your copy out of your code.
Why requests stay small
Section titled “Why requests stay small”A plain send is 74 bytes:
{"to":"user_8f3k","title":"Your order shipped","body":"Arriving Thursday"}The same send through a template is 66 bytes, and the gap grows with longer copy, sounds, images and data:
{"to":"user_8f3k","template":"order_shipped","vars":{"eta":"Thu"}}Variables
Section titled “Variables”Put {{name}} anywhere in a template’s fields and pass the value in vars when you send. A variable with no value is left empty.
Create a template
Section titled “Create a template”You choose the template’s ID as a readable slug. Saving the same ID again replaces it.
await fleet.templates.put("order_shipped", {
title: "Your order shipped",
body: "Arriving {{eta}}",
});fleet.templates.put(
"order_shipped",
title="Your order shipped",
body="Arriving {{eta}}",
)fleet.Templates.Put(ctx, "order_shipped", pushfleet.TemplatesPutParams{
Title: "Your order shipped",
Body: "Arriving {{eta}}",
})fleet
.templates()
.put("order_shipped")
.title("Your order shipped")
.body("Arriving {{eta}}")
.await?;fleet.templates.put(
"order_shipped",
title: "Your order shipped",
body: "Arriving {{eta}}"
)curl -X PUT https://api.pushfleet.com/v1/templates/order_shipped \
-H "Authorization: Bearer $PUSHFLEET_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"title":"Your order shipped","body":"Arriving {{eta}}"}'Send with it
Section titled “Send with it”await fleet.send({
to: "user_8f3k",
template: "order_shipped",
vars: { eta: "Thu" },
});fleet.send(
to="user_8f3k",
template="order_shipped",
vars={"eta": "Thu"},
)fleet.Send(ctx, pushfleet.SendParams{
To: "user_8f3k",
Template: "order_shipped",
Vars: map[string]any{"eta": "Thu"},
})fleet
.send()
.to("user_8f3k")
.template("order_shipped")
.vars(json!({ "eta": "Thu" }))
.await?;fleet.push(
to: "user_8f3k",
template: "order_shipped",
vars: { eta: "Thu" }
)curl https://api.pushfleet.com/v1/send \
-H "Authorization: Bearer $PUSHFLEET_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"to":"user_8f3k","template":"order_shipped","vars":{"eta":"Thu"}}'Any field you send alongside the template overrides it for that one message.