# Alerts New message --------- ```eval_rst .. http:put:: /aalam/base/message ``` Post a new message to list of users, or groups of users, or userswith select permissions. The message can be a grouped one which uses afixed template from message map of the source app, or a dynamic one. **Permissions** *Flags* - deny_anon **Outputs** - Successfully posted the message *Status code*: 200 - Some of the input fields are wrong. *Status code*: 400 **Inputs** - In the input fields, 'from', 'app' and 'receiver' are mandatory at all times. If 'index' is not null, the 'content' is optional depending on the message template for that 'index'. Else 'content' is mandatory. Other parameters are completely optional. *Content type*: application/json *Content specification* ``` { "message": { "from": "A name conveying the source of the message", "app": "String of format 'provider_code/app_code' The provider_code and the app_code should be that of the source application that is sending this message" "receiver": [ { "type": "One among ['users', 'groups', 'permissions']" "value": [List of strings] The significance varies with the choice of 'type'. If type is; 'users' => This sould be a list of user email ids or mobile phone numbers. 'groups' => This should be a list of group names. 'permissions' => This should be a list of permissions. }, ... ], "index": "The message index value as desribed the sending app's message map. This is an optional field. When this field is present, the content of this messgae will be used against the template mentioned by this index." "frontend_url": "The url to be presented for the user who view this message." "backend_url": "The url to be invoked by the base application whenever an action is performed on the message. A user reading the message or deleting it are the actions for which the backend url will invoked." "private_data": "A small data identifier to be passed along as a parameter to the frontend_url and the backend_url. One can find this data in the urls as 'private_data' parameter. "content": "If index is valid, the content should be a JSON content, with the key-values to substitue the keys in the template pointed by the message index. If index is null, the content can be anything and there will be no post processing working done using this value." "persist": "True/False, if true - save this message, else just notify and not save. Default value - True" } } ``` Get messages --------- ```eval_rst .. http:get:: /aalam/base/messages ``` Get the messages entitled for the requesting user. **Permissions** *Flags* - deny_anon **Parameters** - date_floor > Message posted after time specified by the value. The format of the value should be user chosen format as part of the baseapp settings 'date_format'. - count > Limit the number output items to this value. **Outputs** - *Status code*: 200 *Content type*: application/json *Content specification* ``` { "id": "The content identifier of this message that will be used by other apis" "from": "The source name of this message", "frontend_url": "The frontend url for user to act on", "content": "Fully processed content of this message", "private_data"; "Private data set by the source of this message", "isread": "Boolean value", "time": "Time at which the message was posted. It will be the user chosen format as set in the base application setting's date_format" } ``` - This user is unauthorized to use this api. *Status code*: 401 Delete message --------- ```eval_rst .. http:delete:: /aalam/base/message/{message_content_id} ``` Delete a message that was posted to the calling user. **Permissions** *Flags* - deny_anon **Outputs** - Successfully deleted a message. *Status code*: 200 - Message not found. *Status code*: 404 Message actions --------- ```eval_rst .. http:post:: /aalam/base/message/{message_content_id} ``` This API's usage differs by the calling context. It can be called by auser - A user can mark the 'read' status of the messageinternal applications - The application can alter the message detailsthat it posted earlier. The {message_content_id} will be posted tothe app as a parameter to the frontend_url and backend_url that itregistered while it posted this message. The parameter name to readthe message id is 'message_id'. **Permissions** *Flags* - deny_anon **Parameters** - read > This parameter is applicable only when called by a user. This should be a boolean value with 'true' meaning the is read. - private_data > This parameter is applicable only when called by another application. This replaces the exisiting private_data for the message. - from > This parameter is applicable only when called by another application. This replaces the 'from' field of the message which the app posted earlier. - content > This parameter is applicable only when called by another application. This replaces the message 'content'. **Outputs** - Action successfull. *Status code*: 200 - Message not found. *Status code*: 404 - Some input parameters are not valid *Status code*: 400 Message preferences --------- ```eval_rst .. http:post:: /aalam/base/messages/preference ``` This API is used on in the user context. The user can choose whichmessage to follow or unfollow. The user will not receiving messagewhich unfollowed. **Permissions** *Flags* - deny_anon **Parameters** - provider_code > Provider code of the app to unfollow/follow. - app_code > App code of the app to unfollow/follow. - msg_group > (optional) Message group of the app to unfollow/follow. If not set it will unfollow/follow the ungrouped messages. - unfollow > Boolean value - true means unfollow messages. **Outputs** - Successfully modified the preferences. *Status code*: 200 - Either the app or the message group is not found. *Status code*: 404 - Invalid parameters. Some of the mandator parameters are not set. *Status code*: 400