Get Messages

Get all messages to form conversation with pagination, filter, and sort.

Resource

https://api.infobip.com/ccaas/conversations/{conversationId}/messages

Path Params

Property name Type
ertertre  

 

Query Params

Property name Type Description
limit int (10) Size of the result page
page int (0) Index of the result page
orderBy string (id:ASC) property:direction(ASC,DESC)
messageIds array_string optional filter
channel string optional filter (SMS, VIBER, FACEBOOK_MESSENGER, WHATSAPP)
direction string optional filter (INBOUND, OUTBOUND)
createdAfter datetime optional filter (yyyy-MM-dd'T'HH:mm:ss.SSSZ)
createdBefore datetime optional filter (yyyy-MM-dd'T'HH:mm:ss.SSSZ)

Request Example

					GET /ccaas/1/conversations/9F1F21C198025CC026956A7E2E9C560F/messages HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
					
				

Response

					{
    "messages": [
        {
            "id": "81D8E15634FCBC40E1779C44C7554A00",
            "channel": "SMS",
            "from": "385976333666",
            "to": "385951116666",
            "direction": "INBOUND",
            "conversationId": "9F1F21C198025CC026956A7E2E9C560F",
            "createdAt": "2019-04-11T10:40:38.059+0000",
            "content": "Please help, it is dark here",
            "contentType": "TEXT"
        },
        {
            "id": "870118E54C33E290B533F29A74FD52EA",
            "channel": "VIBER",
            "from": "38598886456",
            "to": "38599345098",
            "direction": "OUTBOUND",
            "conversationId": "162F2489EAB28869860AFD7C573282CC",
            "createdAt": "2019-05-14T11:05:41.750+0000",
            "content": "Ciao da viber",
            "contentType": "TEXT"
        }
    ],
    "pagination": {
        "totalItems": 2,
        "page": 0,
        "limit": 10,
        "orderBy": "id:ASC"
    }
}
					
				
					{
  "statusCode": "ERROR",
  "message": "Invalid id '9F1F21C198025CC026956A7E2E9C560F' given! No such entity exists."
}
					
				
					{
    "statusCode": "ERROR",
    "message": "Page size must not be less than one!"
}
					
				

Use this method to get a list of messages from one conversation with pagination and filtering option. Using a filter is optional. The result can be filtered by one or many optional filters described in parameters.

Query Params

Property name Type Description
conversationId string Required - conversation id to get messages from the conversation
limit integer Size of the result page. If a limit count is given, no more than that many rows will be returned (but possibly less, if the query itself yields fewer rows). The default value is 10, the max value is 999.
page integer This parameter says to skip that many rows before beginning to return rows. If both *page *and *limit *appear, then page rows are skipped before starting to count the limit rows that are returned. The default value is 0.
orderBy string  This parameter is used to order your results. If an order is not given, the default order id:asc will be applied. Possible ordering fields are properties. Ordering direction can be specified with modifiers asc for the ascending ordering or desc for the descending one.
messageIds array of strings Optional filter. List of agents Id to match result.
channel string Optional filter. Match any of channel with the result. Possible values: SMS, VIBER, FACEBOOK_MESSENGER, WHATSAPP.
direction string Optional filter. Match any of direction with the result. Possible values: INBOUND, OUTBOUND.
createdAfter datetime Optional filter. Filter result with created after dateTime. Format: yyyy-MM-dd'T'HH:mm:ss.SSSZ
createdBefore datetime Optional filter. Filter result with created after dateTime. Format: yyyy-MM-dd'T'HH:mm:ss.SSSZ

 

Additional example:

Request example:
Searching for messages in conversation with channel "SMS", direction "INBOUND" and created before 22.05.2019. The result must be sorted by date of message creation in ascending order.

GET /ccaas/1/conversations/9F1F21C198025CC026956A7E2E9C560F/messages?channel=SMS&direction=INBOUND&createdBefore=2019-05-22T00:00:00.000+0000&orderBy=createdAt:asc HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==	
  

Response:

JSON

{
    "messages": [
        {
            "id": "81D8E15634FCBC40E1779C44C7554A00",
            "channel": "SMS",
            "from": "385976333666",
            "to": "385951116666",
            "direction": "INBOUND",
            "conversationId": "9F1F21C198025CC026956A7E2E9C560F",
            "createdAt": "2019-04-11T10:40:38.059+0000",
            "content": "Please help, it is dark here",
            "contentType": "TEXT"
        },
        {
            "id": "D52EA870118E54C33E290B533F29A74F",
            "channel": "SMS",
            "from": "38598886456",
            "to": "385993502222",
            "direction": "INBOUND",
            "conversationId": "162F2489EAB28869860AFD7C573282CC",
            "createdAt": "2019-05-14T11:05:41.750+0000",
            "content": "XT rear deraileur 11 spd not working properly",
            "contentType": "TEXT"
        },
      {
            "id": "D52EA870118E54C33E290B533F29A74F",
        		"channel": "SMS",
						"from": "38598886456",
						"to": "385993502222",
						"direction": "INBOUND",
						"conversationId": "573282CC162F2489EAB28869860AFD7C",
            "createdAt": "2019-05-10T12:07:55.350+0000",
            "content": "front suspension is loose, send me new FOX",
            "contentType": "TEXT";
      }
    ],
    "pagination": {
        "totalItems": 3,
        "page": 0,
        "limit": 10,
        "orderBy": "createdAt:ASC"
    }
}