AAttendrix Docsv1.0
API
ReferenceImplemented

Payload & Queue Message Schemas

Authoritative JSON contracts for PGMQ message queues, Edge Function invocations, and OneSignal push payloads.

Payload & Queue Message Schemas

Attendrix decouples high-throughput database writes from external API invocations (OneSignal, Google Calendar) using PGMQ (PostgreSQL Message Queues). This page specifies the exact JSON schemas exchanged between database triggers, message queues, and Edge Function workers.


PGMQ: gcal_sync_queue

Messages placed on gcal_sync_queue represent calendar synchronization requests.

Message Envelope

{
  "msg_id": 1042,
  "read_ct": 1,
  "enqueued_at": "2026-09-04T07:15:00.000Z",
  "vt": "2026-09-04T07:18:00.000Z",
  "message": {
    "type": "INITIAL_SYNC",
    "user_id": "00000000-0000-0000-0000-000000000002",
    "batch_id": "CSE_2023",
    "reason": "oauth_connected",
    "enqueued_at": "2026-09-04T07:15:00.000Z"
  }
}

Payload Types

1. INITIAL_SYNC

Enqueued when a student connects their Google account. Reconciles all future scheduled classes for that specific user.

  • Required Fields: type, user_id, reason.

2. STATEMENT_COALESCED

Enqueued by database trigger fn_classes_gcal_statement_coalesce when classes are inserted, modified, or canceled in bulk.

  • Required Fields: type, batch_id.
  • Worker Action: Fan out across all students enrolled in the affected batch who have Google Calendar sync enabled.

PGMQ: notification_queue

Messages placed on notification_queue trigger push notifications to mobile devices.

Schema Specification

Field / PropTypeDefaultDescription
notification_typerequired
stringType key: 'class_reminder', 'class_cancelled', 'class_rescheduled', 'extra_class_added', 'mess_reminder', 'task_published', 'task_due_soon', 'exam_reminder', 'daily_brief'.
recipient_user_id
string (uuid)Direct student target ID. Mutually exclusive with recipient_batch_id.
recipient_batch_id
stringTarget batch key. Worker fans out to all batch students with matching course enrollments.
course_id
stringCourse identifier used to filter elective enrollments.
payloadrequired
objectTemplate token variables (course_code, building_name, timeFormatted, etc.).
dedup_keyrequired
stringUnique key preventing duplicate dispatches upon worker retry.
scheduled_atrequired
string (ISO timestamp)Target delivery timestamp.

Sample Class Reminder Payload

{
  "notification_type": "class_reminder",
  "recipient_batch_id": "CSE_2023",
  "course_id": "CS301_L1",
  "payload": {
    "class_id": "00000000-0000-0000-0000-000000000001",
    "course_id": "CS301_L1",
    "course_code": "CS301",
    "course_name": "Database Engineering",
    "building_name": "Academic Block 2 - Room 204",
    "scheduled_start": "2026-09-04T10:00:00.000Z",
    "timeFormatted": "10:00 AM",
    "minutesRemaining": 10
  },
  "dedup_key": "class_reminder:CSE_2023:00000000-0000-0000-0000-000000000001:10",
  "scheduled_at": "2026-09-04T09:50:00.000Z"
}

OneSignal REST API Payload

notify-worker translates internal notifications into OneSignal v1 push requests:

{
  "app_id": "00000000-0000-0000-0000-000000000000",
  "include_subscription_ids": [
    "00000000-0000-0000-0000-000000000003"
  ],
  "target_channel": "push",
  "headings": {
    "en": "Class Reminder: CS301"
  },
  "contents": {
    "en": "Database Engineering starts in 10 minutes at Academic Block 2 - Room 204."
  },
  "data": {
    "schema_version": 1,
    "notification_type": "class_reminder",
    "class_id": "00000000-0000-0000-0000-000000000001",
    "course_id": "CS301_L1",
    "course_code": "CS301",
    "deep_link": "/class/00000000-0000-0000-0000-000000000001"
  },
  "small_icon": "ic_notification",
  "android_accent_color": "FF6366F1",
  "priority": 5
}

Was this page helpful?

Your feedback directly guides the engineering documentation roadmap.

On this page