Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Messages API handler

Return a collection of messages.

HTTP Verb – GET

URL – /api/v1/messages

Description – Return a collection messages

Base – HandlerBase<GetMessageCollectionParameter, GetMessageCollectionResult>

Handlers

OrderHandlerDescription
500GetMessageCollectionHandlerIf no logged in user is found, then a Forbidden error result is returned. Otherwise gets all messages with a DateToDisplay that is less than the current date and either has no DateToHide or DateToHide is greater than current date and language is the same as the current language. Also filters by removing any messages that don't have MessageTargets target types for "WebSite", "Customer", "CustomerType", "UserProfile" and user profile "Role" where the TargetKey's don't match the current Id's of those values.
OrderHandlerDescription
500GetMessagesQueryIf UserProfile object has no value, a forbidden error is returned. Creates the messages query and stores it in the MessageQuery property in the result object. Creates the message statuses query and stores it in the MessageStatusQuery property in the result object.
600GetMessagesForCustomerOrderIf CustomerOrderId parameter has no value, then bypasses this handler. If customer order was nor found by CustomerOrderId parameter, then a not found error is returned. Validates CustomerOrder properties. Applies additional filters to MessageQuery using CustomerOrderId parameter. Executes the MessageQuery and MessageStatusQuery. By each message id retrieves message using GetMessageHandler handler chain. The messages are stored in the GetMessageResults property in the result object.
700GetMessageCollectionResultIf CustomerOrderId parameter has value or MessageQuery didn't return any messages, then bypasses this handler. Executes the MessageQuery and MessageStatusQuery. By each message id retrieves message using GetMessageHandler handler chain. The messages are stored in the GetMessageResults property in the result object.

HTTP Verb – GET

URL – /api/v1/messages/{messageid:guid}

Description – Return a message record

Base – HandlerBase<GetMessageParameter, GetMessageResult>

Handlers

OrderHandlerDescription
500GetMessageHandlerSame as above, but just gets the message for the matching messageid. If the found message is not connected with the current "WebSite", "Customer", "CustomerType", "UserProfile" or user profile "Role", then a Not Found error message is returned.
OrderHandlerDescription
500ValidateMessageIf SkipValidation parameter is true, then stores Message parameter in the MessageObject property in the result object and bypasses this handler. If UserProfile is null, then a forbidden error is returned. Validates the message and stores it in the MessageObject property in the result object.
600GetMessageCreates MessageDto object by MessageObject and MessageStatuses parameter. The MessageDto object is stored in the MessageDto property in the result object.

HTTP Verb – POST

URL – /api/v1/messages

Description – Adds a message record.

Base – HandlerBase<AddMessageParameter, AddMessageResult>

Handlers

OrderHandlerDescription
500CreateMessageIf UserProfile object has no value, a forbidden error is returned. Creates a message and stores it in the MessageObject property in the result object.
600CreateMessageTargetCreates a MessageTarget and add it to the MessageObject.MessageTargets result property. Creates a MessageStatus and add it to the MessageObject.MessageStatuses result property.
700CreateMessageAuditCreates a MessageAudit and add it to the MessageObject.MessageAudits result property.

HTTP Verb – PATCH

URL – /api/v1/messages/{messageid:guid}

Description – Updates a single message record

Base – HandlerBase<UpdateMessageParameter, UpdateMessageResult>

Handlers

OrderHandlerDescription
500UpdateMessageHandlerIf no logged in user is found, then a Forbidden error result is returned. If no matching message record is found, then Not Found error message is returned. Otherwise updates the message for the messageid.
OrderHandlerDescription
500ValidateMessageIf UserProfile is null, then a forbidden error is returned. Retrieves a message by MessageId parameter. The message is stored in the MessageObject property in the result object. The MessageId parameter value is stored in the MessageId property in the result object.
600UpdateMessageStatusIf IsRead parameter has no value, then bypasses this handler. Retrieves MessageStatus entity or creates new MessageStatus entity if it doesn't exist. Update HasRead property value in MessageStatus entity. Sets HasRead property in the result object to MessageStatus.HasRead value.