TerraGo API

Templates

Reusable message templates for notifications (SMS/email/WhatsApp), categorized by purpose. Create or update, fetch, and delete templates that the Communication endpoints render when notifying parents.

6 endpoint(s)
GET List Message Templates {{url}}/templates

Retrieve a paginated list of reusable SMS/WhatsApp/email message templates (e.g. "Child checked in", "Trip delayed").

Query Parameters

  • per_page (integer, optional, default 10, max 20)
  • supervisor_id (string UUID, optional): Templates scoped to a school; org-wide templates have no owner.
  • categories (string, optional): Comma-separated category keys to filter by.
  • is_active (boolean, optional)
  • channel (string, optional): e.g. SMS, WHATSAPP, EMAIL.
  • search (string, optional): Matches name, category, subject, or content.

Response

List of message templates (data).

Auth
Bearer token
Used On
Request Body
{
    "is_active": true, //only use: rue, false
    "search": "",
    "supervisor_id": "d0672893-35bb-4fe5-819f-dc073b786d23",
    "per_page": 10,
    "page": 1
}
Sample Response (200 OK)
{
    "data": [
        {
            "id": "909e0d32-1913-4847-94fc-747fd5727513",
            "name": "Test Template",
            "category": "CHECK_IN",
            "subject": "Child Checkin",
            "content": "Mzazi Mpendwa Mtoto amepanda basi"
        }
    ],
    "links": {
        "first": "http://terrago.test/api/templates?page=1",
        "last": "http://terrago.test/api/templates?page=1",
        "prev": null,
        "next": null
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 1,
        "links": [
            {
                "url": null,
                "label": "« Previous",
                "page": null,
                "active": false
            },
            {
                "url": "http://terrago.test/api/templates?page=1",
                "label": "1",
                "page": 1,
                "active": true
            },
            {
                "url": null,
                "label": "Next »",
                "page": null,
                "active": false
            }
        ],
        "path": "http://terrago.test/api/templates",
        "per_page": 10,
        "to": 1,
        "total": 1
    },
    "status": 200,
    "message": "Templates Retrieved Successfully"
}
POST Create/Update Message Template {{url}}/templates/add

Create a message template, or update it in place if one already exists for the same category + channel + target + school (upsert).

Request Body

  • name (string, required)
  • category (string, required): Must be a known template category.
  • subject (string, required)
  • content (string, required): The message body, likely supporting placeholders.
  • channel (string, optional, default SMS)
  • target (string, optional): Who the template is aimed at.
  • is_active (boolean, optional, default true)
  • administrativestaffid (string UUID, optional): School that owns this template; omit for an org-wide template.

Notes

  • The uniqueness key for the upsert is (category, channel, target, administrativestaffid) — posting the same combination again edits the existing template instead of creating a duplicate.

Response

The created/updated template (data).

Auth
Bearer token
Used On
Request Body
{
    "administrative_staff_id" : "d0672893-35bb-4fe5-819f-dc073b786d23",
    "name": "Test Template",
    "category": "CHECK_IN", //only use: GENERAL, CHECK_IN, CHECK_OUT, TRAFFIC_DELAY, VEHICLE_ISSUE, WEATHER_ISSUE, SAFETY_INCIDENT
    "subject": "Child Checkin",
    "content": "Mzazi Mpendwa Mtoto amepanda basi",
    "target": "SINGLE", //only use: GLOBAL, SINGLE
    "suffix": "powered by us."
}
Sample Response (200 OK)
{
    "status": 200,
    "data": {
        "id": "909e0d32-1913-4847-94fc-747fd5727513",
        "name": "Test Template",
        "category": "CHECK_IN",
        "subject": "Child Checkin",
        "content": "Mzazi Mpendwa Mtoto amepanda basi"
    },
    "message": "Template created successfully"
}
PUT Update Message Template {{url}}/templates/update/909e0d32-1913-4847-94fc-747fd5727513

Update an existing message template.

Path Parameters

  • id (string UUID, required): Template UUID.

Request Body

Same fields as Create/Update Message Template.

⚠️ Notes

  • If content is submitted empty/blank, the template is deleted instead of being updated — this endpoint doubles as a soft "clear to delete" action, so don't send an empty content field by accident.

Response

The updated template (data).

Auth
Bearer token
Used On
Request Body
{
    "name": "Test Template",
    "category": "CHECK_IN", //only use: GENERAL, CHECK_IN, CHECK_OUT, TRAFFIC_DELAY, VEHICLE_ISSUE, WEATHER_ISSUE, SAFETY_INCIDENT
    "subject": "Child Checkin",
    "content": "Mzazi Mpendwa Mtoto amepanda basi saa hii",
    "target": "SINGLE", //only use: GLOBAL, SINGLE
    "suffix": "powered by us."
}
Sample Response (200 OK)
{
    "status": 200,
    "data": {
        "id": "909e0d32-1913-4847-94fc-747fd5727513",
        "name": "Test Template",
        "category": "CHECK_IN",
        "subject": "Child Checkin",
        "content": "Mzazi Mpendwa Mtoto amepanda basi saa hii"
    },
    "message": "Template updated successfully"
}
GET Get Message Template {{url}}/templates/909e0d32-1913-4847-94fc-747fd5727513

Retrieve a single message template by UUID (used for SMS/email/WhatsApp notification content).

Path Parameters

  • id (string UUID, required): The template's UUID.

Response

The template (TemplateResource).

Notes

  • Returns 404 if no template matches the UUID.
  • Requires a bearer token (auth:api).
Auth
Bearer token
Sample Response (200 OK)
{
    "status": 200,
    "data": {
        "id": "909e0d32-1913-4847-94fc-747fd5727513",
        "name": "Test Template",
        "category": "CHECK_IN",
        "subject": "Child Checkin",
        "content": "Mzazi Mpendwa Mtoto amepanda basi saa hii"
    },
    "message": "Template retrieved successfully"
}
DELETE Delete Message Template {{url}}/templates/delete/909e0d32-1913-4847-94fc-747fd5727513

Delete a message template by UUID.

Path Parameters

  • id (string UUID, required): The template's UUID.

Notes

  • Returns 404 if no template matches the UUID.
  • Deletion is permanent for that template record.
  • Requires a bearer token (auth:api).
Auth
Bearer token
Used On
Sample Response (200 OK)
{
    "status": 200,
    "data": {
        "id": "909e0d32-1913-4847-94fc-747fd5727513",
        "name": "Test Template",
        "category": "CHECK_IN",
        "subject": "Child Checkin",
        "content": "Mzazi Mpendwa Mtoto amepanda basi saa hii"
    },
    "message": "Template retrieved successfully"
}
POST Download Import Template {{url}}/templates/import-template

Download a pre-filled .xlsx bulk-import template for parents, children, devices, or wearables — used by the admin dashboard's bulk-upload flow.

Query Parameters

  • entity (string, required): one of parents, dependants, devices, wearables.
  • administrative_id (string UUID): the school (Administrative Staff) to scope the template to. Required when entity=dependants (needed to populate route/tag choices); optional for the other entity types.

Response

Binary .xlsx file download (Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet), not JSON.

Notes

  • Also reachable via GET on the same path (Route::match(['get','post'], ...)); the frontend calls it as POST.
  • Does not require auth at the route level, but is only ever called from within the authenticated admin dashboard.
Auth
Bearer token