WORKFORCEOS

FRONTEND GUIDE FOR AI CODING AGENTS - PART 13 - AnnouncementManagement Service

This document is a part of a REST API guide for the workforceos project. It is designed for AI agents that will generate frontend code to consume the project’s backend.

This document provides extensive instruction for the usage of announcementManagement

Service Access

AnnouncementManagement service management is handled through service specific base urls.

AnnouncementManagement service may be deployed to the preview server, staging server, or production server. Therefore,it has 3 access URLs. The frontend application must support all deployment environments during development, and the user should be able to select the target API server on the login page (already handled in first part.).

For the announcementManagement service, the base URLs are:

Tenant URL Prefix and Header Forwarding

Tenant context is resolved by frontend routing strategy:

Then backend API calls must always claim target tenant with header:

headers["mbx-company-codename"] = tenantCodenameFromUrl;

URL prefix/subdomain is frontend-only tenant selection. Use header forwarding for all tenant-scoped calls to announcementManagement service.

Scope

AnnouncementManagement Service Description

Handles company-wide and department-specific announcements, supporting scheduled or immediate delivery. Enables admins/managers to create, edit, and manage rich-text announcements, assign audience (all/company/department/users), and triggers events for notification delivery. Employees see relevant announcements in history/detail. Fully tenant-scoped.

AnnouncementManagement service provides apis and business logic for following data objects in workforceos application. Each data object may be either a central domain of the application data structure or a related helper data object for a central concept. Note that data object concept is equal to table concept in the database, in the service database each data object is represented as a db table scheme and the object instances as table rows.

announcement Data Object: A company announcement created by admin/manager for company- or department-wide communication. Supports scheduled (future) or immediate send, rich-text content, explicit audience assignment, and visibility expiry.

AnnouncementManagement Service Frontend Description By The Backend Architect

Announcement Management: UX Guide

API Structure

Object Structure of a Successful Response

When the service processes requests successfully, it wraps the requested resource(s) within a JSON envelope. This envelope includes the data and essential metadata such as configuration details and pagination information, providing context to the client.

HTTP Status Codes:

Success Response Format:

For successful operations, the response includes a "status": "OK" property, signaling that the request executed successfully. The structure of a successful response is outlined below:

{
  "status":"OK",
  "statusCode": 200,   
  "elapsedMs":126,
  "ssoTime":120,
  "source": "db",
  "cacheKey": "hexCode",
  "userId": "ID",
  "sessionId": "ID",
  "requestId": "ID",
  "dataName":"products",
  "method":"GET",
  "action":"list",
  "appVersion":"Version",
  "rowCount":3,
  "products":[{},{},{}],
  "paging": {
    "pageNumber":1, 
    "pageRowCount":25, 
    "totalRowCount":3,
    "pageCount":1
  },
  "filters": [],
  "uiPermissions": []
}

Additional Data

Each API may include additional data besides the main data object, depending on the business logic of the API. These will be provided in each API’s response signature.

Error Response

If a request encounters an issue—whether due to a logical fault or a technical problem—the service responds with a standardized JSON error structure. The HTTP status code indicates the nature of the error, using commonly recognized codes for clarity:

Each error response is structured to provide meaningful insight into the problem, assisting in efficient diagnosis and resolution.

{
  "result": "ERR",
  "status": 400,
  "message": "errMsg_organizationIdisNotAValidID",
  "errCode": 400,
  "date": "2024-03-19T12:13:54.124Z",
  "detail": "String"
}

Announcement Data Object

A company announcement created by admin/manager for company- or department-wide communication. Supports scheduled (future) or immediate send, rich-text content, explicit audience assignment, and visibility expiry.

Announcement Data Object Frontend Description By The Backend Architect

Announcement Data Object Properties

Announcement data object has got following properties that are represented as table fields in the database scheme. These properties don’t stand just for data storage, but each may have different settings to manage the business logic.

Property Type IsArray Required Secret Description
creatorId ID false Yes No auth:user.id - Creator of the announcement
title String false Yes No Announcement subject/title (short display name).
body Text false Yes No Announcement content body (markdown/HTML string).
targetDepartmentIds ID true No No Department userGroup IDs (auth:userGroup.id) to target recipients. Null/empty means all departments. Used for scoping announcements to groups.
audienceUserIds ID true No No Explicit user IDs (auth:user.id) to target (optional, null=all applicable). Used for targeting specific individuals only if needed. Supercedes departments if set.
sendTime Date false Yes No Scheduled send time for the announcement (UTC). Immediate if now/past, future means scheduled/pending delivery. Used for status logic.
visibleUntil Date false No No Optional. Announcements are visible until this date (expiry). If null, visible for a platform-defined default duration (e.g., 30/90 days, or forever).
status Enum false Yes No Announcement status: scheduled (future, unsent); sent (visible/delivered); cancelled (withdrawn by admin/manager); status changes control delivery/event publishing.
companyId ID false Yes No An ID value to represent the tenant id of the company

Array Properties

targetDepartmentIds audienceUserIds

Array properties can hold multiple values. Array properties should be respected according to their multiple structure in the frontend in any user input for them. Please use multiple input components for the array proeprties when needed.

Enum Properties

Enum properties are defined with a set of allowed values, ensuring that only valid options can be assigned to them. The enum options value will be stored as strings in the database, but when a data object is created an additional property with the same name plus an idx suffix will be created, which will hold the index of the selected enum option. You can use the {fieldName_idx} property to sort by the enum value or when your enum options represent a hiyerarchy of values. In the frontend input components, enum type properties should only accept values from an option component that lists the enum options.

Relation Properties

creatorId targetDepartmentIds audienceUserIds

Mindbricks supports relations between data objects, allowing you to define how objects are linked together. The relations may reference to a data object either in this service or in another service. Id the reference is remote, backend handles the relations through service communication or elastic search. These relations should be respected in the frontend so that instaead of showing the related objects id, the frontend should list human readable values from other data objects. If the relation points to another service, frontend should use the referenced service api in case it needs related data. The relation logic is montly handled in backend so the api responses feeds the frontend about the relational data. In mmost cases the api response will provide the relational data as well as the main one.

In frontend, please ensure that,

1- instaead of these relational ids you show the main human readable field of the related target data (like name), 2- if this data object needs a user input of these relational ids, you should provide a combobox with the list of possible records or (a searchbox) to select with the realted target data object main human readable field.

The target object is a sibling object, meaning that the relation is a many-to-one or one-to-one relationship from this object to the target.

Required: Yes

The target object is a sibling object, meaning that the relation is a many-to-one or one-to-one relationship from this object to the target.

Required: No

The target object is a sibling object, meaning that the relation is a many-to-one or one-to-one relationship from this object to the target.

Required: No

Filter Properties

creatorId title sendTime status companyId

Filter properties are used to define parameters that can be used in query filters, allowing for dynamic data retrieval based on user input or predefined criteria. These properties are automatically mapped as API parameters in the listing API’s.

Default CRUD APIs

For each data object, the backend architect may designate default APIs for standard operations (create, update, delete, get, list). These are the APIs that frontend CRUD forms and AI agents should use for basic record management. If no default is explicitly set (isDefaultApi), the frontend generator auto-discovers the most general API for each operation.

Announcement Default APIs

Display Label Property: title — Use this property as the human-readable label when displaying records of this data object (e.g., in dropdowns, references).

Operation API Name Route Explicitly Set
Create createAnnouncement /v1/announcements Yes
Update updateAnnouncement /v1/announcements/:announcementId Yes
Delete deleteAnnouncement /v1/announcements/:announcementId Yes
Get getAnnouncement /v1/announcements/:announcementId Yes
List listAnnouncements /v1/announcements Yes

When building CRUD forms for a data object, use the default create/update APIs listed above. The form fields should correspond to the API’s body parameters. For relation fields, render a dropdown loaded from the related object’s list API using the display label property.

API Reference

Create Announcement API

[Default create API] — This is the designated default create API for the announcement data object. Frontend generators and AI agents should use this API for standard CRUD operations. Admins/managers create a new announcement for company or targeted audience. Supports scheduled and immediate announcements. Upon creation, if sendTime <= now and not cancelled, triggers event for notification delivery.

API Frontend Description By The Backend Architect

Rest Route

The createAnnouncement API REST controller can be triggered via the following route:

/v1/announcements

Rest Request Parameters

The createAnnouncement api has got 6 regular request parameters

Parameter Type Required Population
title String true request.body?.[“title”]
body Text true request.body?.[“body”]
targetDepartmentIds ID false request.body?.[“targetDepartmentIds”]
audienceUserIds ID false request.body?.[“audienceUserIds”]
sendTime Date true request.body?.[“sendTime”]
visibleUntil Date false request.body?.[“visibleUntil”]
title : Announcement subject/title (short display name).
body : Announcement content body (markdown/HTML string).
targetDepartmentIds : Department userGroup IDs (auth:userGroup.id) to target recipients. Null/empty means all departments. Used for scoping announcements to groups.
audienceUserIds : Explicit user IDs (auth:user.id) to target (optional, null=all applicable). Used for targeting specific individuals only if needed. Supercedes departments if set.
sendTime : Scheduled send time for the announcement (UTC). Immediate if now/past, future means scheduled/pending delivery. Used for status logic.
visibleUntil : Optional. Announcements are visible until this date (expiry). If null, visible for a platform-defined default duration (e.g., 30/90 days, or forever).

REST Request To access the api you can use the REST controller with the path POST /v1/announcements

  axios({
    method: 'POST',
    url: '/v1/announcements',
    data: {
            title:"String",  
            body:"Text",  
            targetDepartmentIds:"ID",  
            audienceUserIds:"ID",  
            sendTime:"Date",  
            visibleUntil:"Date",  
    
    },
    params: {
    
        }
  });

REST Response

{
	"status": "OK",
	"statusCode": "201",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "announcement",
	"method": "POST",
	"action": "create",
	"appVersion": "Version",
	"rowCount": 1,
	"announcement": {
		"id": "ID",
		"creatorId": "ID",
		"title": "String",
		"body": "Text",
		"targetDepartmentIds": "ID",
		"audienceUserIds": "ID",
		"sendTime": "Date",
		"visibleUntil": "Date",
		"status": "Enum",
		"status_idx": "Integer",
		"companyId": "ID",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}

Update Announcement API

[Default update API] — This is the designated default update API for the announcement data object. Frontend generators and AI agents should use this API for standard CRUD operations. Admins/managers update a scheduled/cancelled announcement. Not allowed if already sent. If sendTime changes to now or past, triggers sent event and status update on save.

API Frontend Description By The Backend Architect

Rest Route

The updateAnnouncement API REST controller can be triggered via the following route:

/v1/announcements/:announcementId

Rest Request Parameters

The updateAnnouncement api has got 7 regular request parameters

Parameter Type Required Population
announcementId ID true request.params?.[“announcementId”]
title String false request.body?.[“title”]
body Text false request.body?.[“body”]
targetDepartmentIds ID false request.body?.[“targetDepartmentIds”]
audienceUserIds ID false request.body?.[“audienceUserIds”]
sendTime Date true request.body?.[“sendTime”]
visibleUntil Date false request.body?.[“visibleUntil”]
announcementId : This id paremeter is used to select the required data object that will be updated
title : Announcement subject/title (short display name).
body : Announcement content body (markdown/HTML string).
targetDepartmentIds : Department userGroup IDs (auth:userGroup.id) to target recipients. Null/empty means all departments. Used for scoping announcements to groups.
audienceUserIds : Explicit user IDs (auth:user.id) to target (optional, null=all applicable). Used for targeting specific individuals only if needed. Supercedes departments if set.
sendTime : Scheduled send time for the announcement (UTC). Immediate if now/past, future means scheduled/pending delivery. Used for status logic.
visibleUntil : Optional. Announcements are visible until this date (expiry). If null, visible for a platform-defined default duration (e.g., 30/90 days, or forever).

REST Request To access the api you can use the REST controller with the path PATCH /v1/announcements/:announcementId

  axios({
    method: 'PATCH',
    url: `/v1/announcements/${announcementId}`,
    data: {
            title:"String",  
            body:"Text",  
            targetDepartmentIds:"ID",  
            audienceUserIds:"ID",  
            sendTime:"Date",  
            visibleUntil:"Date",  
    
    },
    params: {
    
        }
  });

REST Response

{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "announcement",
	"method": "PATCH",
	"action": "update",
	"appVersion": "Version",
	"rowCount": 1,
	"announcement": {
		"id": "ID",
		"creatorId": "ID",
		"title": "String",
		"body": "Text",
		"targetDepartmentIds": "ID",
		"audienceUserIds": "ID",
		"sendTime": "Date",
		"visibleUntil": "Date",
		"status": "Enum",
		"status_idx": "Integer",
		"companyId": "ID",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}

Delete Announcement API

[Default delete API] — This is the designated default delete API for the announcement data object. Frontend generators and AI agents should use this API for standard CRUD operations. Soft delete (mark as cancelled) for scheduled/cancelled announcements. Sent announcements cannot be deleted.

API Frontend Description By The Backend Architect

Admins/managers can cancel (soft delete) announcements that have not been sent yet; sent announcements stay in history, cannot be deleted for auditability/accountability.

Rest Route

The deleteAnnouncement API REST controller can be triggered via the following route:

/v1/announcements/:announcementId

Rest Request Parameters

The deleteAnnouncement api has got 1 regular request parameter

Parameter Type Required Population
announcementId ID true request.params?.[“announcementId”]
announcementId : This id paremeter is used to select the required data object that will be deleted

REST Request To access the api you can use the REST controller with the path DELETE /v1/announcements/:announcementId

  axios({
    method: 'DELETE',
    url: `/v1/announcements/${announcementId}`,
    data: {
    
    },
    params: {
    
        }
  });

REST Response

{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "announcement",
	"method": "DELETE",
	"action": "delete",
	"appVersion": "Version",
	"rowCount": 1,
	"announcement": {
		"id": "ID",
		"creatorId": "ID",
		"title": "String",
		"body": "Text",
		"targetDepartmentIds": "ID",
		"audienceUserIds": "ID",
		"sendTime": "Date",
		"visibleUntil": "Date",
		"status": "Enum",
		"status_idx": "Integer",
		"companyId": "ID",
		"isActive": false,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}

Get Announcement API

[Default get API] — This is the designated default get API for the announcement data object. Frontend generators and AI agents should use this API for standard CRUD operations. Get details of a single announcement if user is within company and eligible audience. Employees see only those sent & visible; admins/managers see all for own company.

API Frontend Description By The Backend Architect

Rest Route

The getAnnouncement API REST controller can be triggered via the following route:

/v1/announcements/:announcementId

Rest Request Parameters

The getAnnouncement api has got 1 regular request parameter

Parameter Type Required Population
announcementId ID true request.params?.[“announcementId”]
announcementId : This id paremeter is used to query the required data object.

REST Request To access the api you can use the REST controller with the path GET /v1/announcements/:announcementId

  axios({
    method: 'GET',
    url: `/v1/announcements/${announcementId}`,
    data: {
    
    },
    params: {
    
        }
  });

REST Response

This route’s response is constrained to a select list of properties, and therefore does not encompass all attributes of the resource.

{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "announcement",
	"method": "GET",
	"action": "get",
	"appVersion": "Version",
	"rowCount": 1,
	"announcement": {
		"creator": {
			"email": "String",
			"fullname": "String",
			"avatar": "String"
		},
		"departments": [
			null,
			null,
			null
		],
		"isActive": true
	}
}

List Announcements API

[Default list API] — This is the designated default list API for the announcement data object. Frontend generators and AI agents should use this API for standard CRUD operations. List announcements visible to user: employees get only those sent and addressed to their dept/user/all; admin/manager see all for their company; sorted by sendTime desc.

API Frontend Description By The Backend Architect

Rest Route

The listAnnouncements API REST controller can be triggered via the following route:

/v1/announcements

Rest Request Parameters The listAnnouncements api has got no request parameters.

REST Request To access the api you can use the REST controller with the path GET /v1/announcements

  axios({
    method: 'GET',
    url: '/v1/announcements',
    data: {
    
    },
    params: {
    
        }
  });

REST Response

This route’s response is constrained to a select list of properties, and therefore does not encompass all attributes of the resource.

{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "announcements",
	"method": "GET",
	"action": "list",
	"appVersion": "Version",
	"rowCount": "\"Number\"",
	"announcements": [
		{
			"creator": [
				{
					"email": "String",
					"fullname": "String",
					"avatar": "String"
				},
				{},
				{}
			],
			"departments": [
				null,
				null,
				null
			],
			"isActive": true
		},
		{},
		{}
	],
	"paging": {
		"pageNumber": "Number",
		"pageRowCount": "NUmber",
		"totalRowCount": "Number",
		"pageCount": "Number"
	},
	"filters": [],
	"uiPermissions": []
}

Process Scheduledannouncements API

Background job that runs every minute to check for scheduled announcements whose sendTime has passed and updates their status to ‘sent’. This triggers the announcement.sent event for notification delivery.

API Frontend Description By The Backend Architect

Internal cron job - no frontend endpoint. Runs automatically every minute to process scheduled announcements.

Rest Route

The processScheduledAnnouncements API REST controller can be triggered via the following route:

/v1/processscheduledannouncements

Rest Request Parameters

Filter Parameters

The processScheduledAnnouncements api supports 4 optional filter parameters for filtering list results:

creatorId (ID): auth:user.id - Creator of the announcement

title (String): Announcement subject/title (short display name).

sendTime (Date): Scheduled send time for the announcement (UTC). Immediate if now/past, future means scheduled/pending delivery. Used for status logic.

status (Enum): Announcement status: scheduled (future, unsent); sent (visible/delivered); cancelled (withdrawn by admin/manager); status changes control delivery/event publishing.

REST Request To access the api you can use the REST controller with the path GET /v1/processscheduledannouncements

  axios({
    method: 'GET',
    url: '/v1/processscheduledannouncements',
    data: {
    
    },
    params: {
    
        // Filter parameters (see Filter Parameters section above)
        // creatorId: '<value>' // Filter by creatorId
        // title: '<value>' // Filter by title
        // sendTime: '<value>' // Filter by sendTime
        // status: '<value>' // Filter by status
            }
  });

REST Response

{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "announcements",
	"method": "GET",
	"action": "list",
	"appVersion": "Version",
	"rowCount": "\"Number\"",
	"announcements": [
		{
			"id": "ID",
			"creatorId": "ID",
			"title": "String",
			"body": "Text",
			"targetDepartmentIds": "ID",
			"audienceUserIds": "ID",
			"sendTime": "Date",
			"visibleUntil": "Date",
			"status": "Enum",
			"status_idx": "Integer",
			"companyId": "ID",
			"isActive": true,
			"recordVersion": "Integer",
			"createdAt": "Date",
			"updatedAt": "Date",
			"_owner": "ID"
		},
		{},
		{}
	],
	"paging": {
		"pageNumber": "Number",
		"pageRowCount": "NUmber",
		"totalRowCount": "Number",
		"pageCount": "Number"
	},
	"filters": [],
	"uiPermissions": []
}

After this prompt, the user may give you new instructions to update the output of this prompt or provide subsequent prompts about the project.