v1

latestSwagger 2.02026-07-13151175.7 KB
Message

Retrieve Messages

Retrieve the messages you have sent or received.

Scheduled messages are available for retrieval only after the delivery date.

All the parameters are optional. If a value is not supplied for filter, the messages are not filtered.

Messages can be filtered by supplying query clauses in the filter parameter. Each clause has the form name=value where name is the name of a filter field and value is a valid value for that field. A value for a field is optional. Include a clause for a field in the filter only when there is a need to fetch messages that match some value for that field. For a numeric filter field, you can also use the less than operator (<).

If present, the filter value must have at least one clause, but it can contain a combination of clauses. Multiple clauses are separated with the & symbol. Semantically, multiple clauses form a logical conjunction.

For example, if you want to list all messages that were sent as part of a particular submission, your filter contains two clauses and will look something like this

type%3DSENT&submission.id%3D1-00000000000522347562

Because filter is a request parameter, it is important to note that the value for this parameter must be URL encoded. In particular, the = encodes to %3D and the & encodes to %26. Note that you do not have to encode the < character.

Using the previous example to illustrate; after encoding and encasing it, the clauses are transformed into a request that looks like this

GET /v1/messages?filter=type%3DSENT%26submission.id%3D1-00000000000522347562

If the field name or the field value of a clause is not valid, a bad_request error is returned instead of the usual result. The detail field of this error provides more information about the problem.

The table below lists the fields available for filtering

FieldTypeValuesNote and example
idIntegerPositive integerUse the id field with < (or with >) to fetch messages that are older (or newer) than those that are already fetched. <br/>filter=id<123456
typeStringSENT, RECEIVEDSENT are Mobile Terminating (MT) SMSs; RECEIVED are Mobile Originating (MO) SMSs.<br/>filter=type%3DSENT
submission.idStringfilter=submission.id%3D1-00000000000522347562
status.typeStringACCEPTED, SENT, DELIVERED, FAILEDSee the message status.type field for more information. <br/>filter=status.type%3DDELIVERED
status.idStringSee the message status.id field for more information. filter=status.id%3DFAILED.EXPIRED
submission.dateStringFormatted DateA fully specified date (e.g. 2017-01-01T10:00:00+01:00). Use this field with <=, <, > or >= to limit the values. <br/>filter=submission.date%3E%3D2017-01-01T10%3A00%3A00%2B01%3A00
userSuppliedIdStringUse a string value you specified in the userSuppliedId property when you sent the message. Only SENT messages will be retrieved. <br/>filter=userSuppliedId%3Dacc009876
get/messages

Query parameters

limitnumber

The maximum number of messages that are returned. The default is 1000. The value of limit is not a guarantee that a specific number of messages will be in the response, even if there are more messages available. Consider the case where you have 150 messages and you specify limit=50. It is possible that only 49 messages will be returned. The way to make sure that there are no more messages is to submit a new call using the id filter field with the < operator (described below).

filterstring

See the message filtering for more information.

sortOrder'ASCENDING'

The default value is DESCENDING

If the sortOrder is DESCENDING, the newest messages be first in the result. ASCENDING places the oldest messages on top of the response.

Response

Contains the requested array of messages

idstring required

A unique identifier that is assigned when the message is created.

type'SENT' | 'RECEIVED' required

The message direction

fromstring

The address part of the sender id

tostring required

The phone number of the recipient

bodystring required

The content of the message

encoding'TEXT' | 'UNICODE' | 'BINARY'

The type of the content. See the encoding field for more information.

protocolIdinteger

See the protocolId field for more information.

messageClassinteger

See the messageClass field for more information.

numberOfPartsinteger

The number of parts. If this is a concatenated message, the number of parts will be more than 1. Note that this field does not have a value in the submission response.

creditCostnumber float

The cost of the message (in credits). Note that this field does not have a value in the submission response.

relatedSentMessageIdstring

This field has a value only if the type is RECEIVED. With SMS messages, it is not possible to link a reply directly with a specific sent message. However, if you specified REPLIABLE in the from property, BulkSMS will link any reply to the most recent message sent to a given phone number.

The relatedSentMessageId property keeps the information about this link.

You can use this property to derive an implicit conversation from a set of messages.

  • If a received reply message has a relatedSentMessageId, you can use it to retrieve the last message that was sent before the reply was received.
  • If you have the id of the sent message and you want all the received messages that relate to it, you can use the List Related Messages Operation.
userSuppliedIdstring

This is the value you supplied in the userSuppliedId field. Has a value only if the type is SENT.