Admin Announcements

Back-office announcements and broadcast notifications for clients, drivers, and admins. Supports immediate delivery, scheduled broadcasting, recurring recurrence (daily, weekly, monthly), and targeting by city and by audience segment. Paths are relative to the /api/v1 prefix; all routes require an admin bearer token (Authorization: Bearer {token}).

Requires an admin bearer token (see Admin auth). Admin only.

See Common errors.

Endpoints

Method URI Access Description
GET /admin/announcements Admin List announcements history with pagination
POST /admin/announcements Admin Create and dispatch or schedule an announcement
POST /admin/announcements/preview Admin Count the recipients a targeting would reach
PATCH /admin/announcements/{announcementId} Admin Edit a scheduled announcement not yet sent
DELETE /admin/announcements/{announcementId} Admin Delete a scheduled announcement not yet sent

GET /admin/announcements

Lists historical, scheduled, and active announcements, ordered by scheduled/created date (newest first).

Query

Field Type Required Rules
limit integer no 1–100; defaults to 15
page integer no Current page number (1-based)

Response 200

{
  "items": [
    {
      "id": 14,
      "admin_id": 1,
      "title": "Mantenimiento programado de plataforma",
      "body": "La plataforma estará en mantenimiento breve este domingo de 02:00 a 03:00 AM.",
      "severity": "info",
      "audience": ["client", "driver"],
      "city_id": 3,
      "driver_segment": "ALL",
      "client_segment": "INACTIVE",
      "inactivity_days": 30,
      "status": "sent",
      "scheduled_at": null,
      "sent_at": "2026-09-22T10:00:00+00:00",
      "recurrence": "none",
      "recurrence_end_at": null,
      "next_send_at": null,
      "created_at": "2026-09-22T10:00:00+00:00",
      "updated_at": "2026-09-22T10:00:05+00:00",
      "admin": {
        "id": 1,
        "name": "Administrador General"
      },
      "city": {
        "id": 3,
        "name": "Caracas"
      }
    }
  ],
  "meta": {
    "total": 45,
    "per_page": 15,
    "current_page": 1,
    "last_page": 3
  }
}

POST /admin/announcements

Creates a new announcement. If scheduled_at is omitted or in the past, the announcement is immediately dispatched (status: "pending" -> "sent") to the target audience via push notifications (FCM) and the notifications inbox. If scheduled_at is in the future, it is stored with status: "scheduled" and processed automatically by the scheduler.

When recurrence is set (daily, weekly, monthly), future instances will be automatically scheduled and dispatched until recurrence_end_at (if specified).

Request Body

Field Type Required Rules
title string yes max: 100 chars
body string yes max: 500 chars
severity string yes one of info, warning, error
audience array yes array of client, driver, admin (min: 1)
scheduled_at string (ISO8601) no future date/time for scheduled broadcasting
recurrence string no one of none, daily, weekly, monthly (defaults to none)
recurrence_end_at string (ISO8601) no deadline after which recurrence terminates
city_id integer no city the announcement is limited to; null or omitted = whole platform
driver_segment string no one of ALL, OFFLINE, PENDING_DOCS (defaults to ALL); stored as ALL when audience has no driver
client_segment string no one of ALL, INACTIVE (defaults to ALL); stored as ALL when audience has no client
inactivity_days integer no 1–365; window the INACTIVE segment measures (defaults to 30)

Example payload (immediate delivery):

{
  "title": "Promoción de fin de semana",
  "body": "Obtén recargas con tarifa preferencial durante todo el sábado.",
  "severity": "info",
  "audience": ["client"],
  "recurrence": "none"
}

Example payload (scheduled & recurring weekly):

{
  "title": "Recordatorio de liquidación semanal",
  "body": "Por favor revisa tus comprobantes y saldo en la billetera antes del corte.",
  "severity": "warning",
  "audience": ["driver"],
  "scheduled_at": "2026-09-28T08:00:00-04:00",
  "recurrence": "weekly",
  "recurrence_end_at": "2026-12-31T23:59:59-04:00"
}

Response 201

{
  "announcement": {
    "id": 15,
    "admin_id": 1,
    "title": "Recordatorio de liquidación semanal",
    "body": "Por favor revisa tus comprobantes y saldo en la billetera antes del corte.",
    "severity": "warning",
    "audience": ["driver"],
    "city_id": null,
    "driver_segment": "ALL",
    "client_segment": "ALL",
    "inactivity_days": null,
    "status": "scheduled",
    "scheduled_at": "2026-09-28T12:00:00+00:00",
    "recurrence": "weekly",
    "recurrence_end_at": "2026-12-31T23:59:59+00:00",
    "next_send_at": "2026-09-28T12:00:00+00:00",
    "created_at": "2026-09-22T11:00:00+00:00",
    "updated_at": "2026-09-22T11:00:00+00:00",
    "admin": {
      "id": 1,
      "name": "Administrador General"
    }
  }
}

Errors

Status Body When
401 { "error": "Unauthorized" } Invalid or missing admin token
403 { "error": "Forbidden" } Caller is not an admin
403 { "error": "Forbidden", "message": "No tenés acceso a esa ciudad." } city_id is outside the admin's assigned cities
422 { "error": "ValidationError", "details": { … } } Invalid fields, invalid date format, or city_id does not exist

PATCH /admin/announcements/{announcementId}

Edits an announcement whose status is scheduled and whose last_sent_at is null. The status stays scheduled.

Path

Field Type Required Rules
announcementId integer yes Announcement id

Request Body

All fields are optional; only the ones sent are changed.

Field Type Required Rules
title string no max: 100 chars; not empty when sent
body string no max: 500 chars; not empty when sent
severity string no one of info, warning, error
audience array no array of client, driver, admin (min: 1); duplicates collapsed
scheduled_at string (ISO8601) no must be after now; also becomes next_send_at
recurrence string no one of none, daily, weekly, monthly; null stores none
recurrence_end_at string (ISO8601) no null or empty clears the deadline
city_id integer no city the announcement is limited to; null clears it (whole platform)
driver_segment string no one of ALL, OFFLINE, PENDING_DOCS; stored as ALL when the resulting audience has no driver
client_segment string no one of ALL, INACTIVE; stored as ALL when the resulting audience has no client
inactivity_days integer no 1–365; null restores the default of 30

Example payload

{
  "title": "Mantenimiento reprogramado",
  "scheduled_at": "2026-10-30T09:00:00-04:00",
  "recurrence": "weekly",
  "recurrence_end_at": null
}

Response 200

{
  "announcement": {
    "id": 15,
    "admin_id": 1,
    "title": "Mantenimiento reprogramado",
    "body": "Por favor revisa tus comprobantes y saldo en la billetera antes del corte.",
    "severity": "warning",
    "audience": ["driver"],
    "status": "scheduled",
    "scheduled_at": "2026-10-30T13:00:00+00:00",
    "recurrence": "weekly",
    "recurrence_end_at": null,
    "last_sent_at": null,
    "next_send_at": "2026-10-30T13:00:00+00:00",
    "created_at": "2026-09-22T11:00:00+00:00",
    "updated_at": "2026-10-26T15:20:00+00:00",
    "admin": {
      "id": 1,
      "name": "Administrador General"
    }
  }
}

Errors

Status Body When
401 { "error": "Unauthorized" } Invalid or missing admin token
403 { "error": "Forbidden" } Caller is not an admin
404 { "error": "AnnouncementNotFound" } No announcement with that id
403 { "error": "Forbidden", "message": "No tenés acceso a esa ciudad." } The announcement's city, or the requested one, is outside the admin's assigned cities
409 { "error": "AnnouncementAlreadySent", "message": "…" } status is not scheduled, or last_sent_at is set
422 { "error": "ValidationError", "details": { … } } Invalid fields, scheduled_at not after now, or city_id does not exist

DELETE /admin/announcements/{announcementId}

Deletes an announcement whose status is scheduled and whose last_sent_at is null.

Path

Field Type Required Rules
announcementId integer yes Announcement id

Response 200

{
  "deleted": true
}

Errors

Status Body When
401 { "error": "Unauthorized" } Invalid or missing admin token
403 { "error": "Forbidden" } Caller is not an admin
404 { "error": "AnnouncementNotFound" } No announcement with that id
403 { "error": "Forbidden", "message": "No tenés acceso a esa ciudad." } The announcement's city is outside the admin's assigned cities
409 { "error": "AnnouncementAlreadySent", "message": "…" } status is not scheduled, or last_sent_at is set

POST /admin/announcements/preview

Counts how many recipients a targeting reaches. Creates nothing.

Request Body

Field Type Required Rules
audience array yes array of client, driver, admin (min: 1)
city_id integer no city the announcement would be limited to; null or omitted = whole platform
driver_segment string no one of ALL, OFFLINE, PENDING_DOCS (defaults to ALL)
client_segment string no one of ALL, INACTIVE (defaults to ALL)
inactivity_days integer no 1–365 (defaults to 30)

Example payload

{
  "audience": ["client", "driver"],
  "city_id": 3,
  "client_segment": "INACTIVE",
  "inactivity_days": 30
}

Response 200

One key per requested audience, plus total.

{
  "recipients": {
    "client": 412,
    "driver": 18,
    "total": 430
  }
}

Errors

Status Body When
401 { "error": "Unauthorized" } Invalid or missing admin token
403 { "error": "Forbidden" } Caller is not an admin
403 { "error": "Forbidden", "message": "No tenés acceso a esa ciudad." } city_id is outside the admin's assigned cities
422 { "error": "ValidationError", "details": { … } } Missing or invalid audience, invalid segment, or city_id does not exist