إرسال
SMS

List Messages

Retrieve a paginated list of sent messages

Endpoint

GET /api/sms/messages

Query parameters

FieldTypeRequiredDescription
pageintegerNoPage number, minimum 1 (default: 1)
per_pageintegerNoResults per page, 1100 (default: 10)
fromdateNoReturn messages created on/after this date (YYYY-MM-DD)
todateNoReturn messages created on/before this date (YYYY-MM-DD)

Messages are returned newest first. Passing per_page above 100 returns 422.

Example

curl "https://sms.lamah.com/api/sms/messages?page=1&per_page=20&from=2024-01-01&to=2024-01-31" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Response

The response is wrapped in a data key containing a Laravel paginator object:

{
  "data": {
    "current_page": 1,
    "data": [
      {
        "short_message": "Your appointment is confirmed for Tuesday at 4:30 PM.",
        "message_type": "sms",
        "send_type": "single",
        "contact_group_id": null,
        "message_consumption": 1,
        "created_at": "2024-01-15T10:30:00Z",
        "updated_at": "2024-01-15T10:30:00Z",
        "receiver": [
          {
            "number": "00218912345678",
            "sent_at": "2024-01-15T10:30:02Z",
            "delivered_at": "2024-01-15T10:30:15Z",
            "status": "delivered",
            "delivery_report": null,
            "created_at": "2024-01-15T10:30:00Z",
            "updated_at": "2024-01-15T10:30:15Z"
          }
        ]
      }
    ],
    "first_page_url": "https://sms.lamah.com/api/sms/messages?page=1",
    "from": 1,
    "last_page": 5,
    "last_page_url": "https://sms.lamah.com/api/sms/messages?page=5",
    "links": [
      { "url": null, "label": "« Previous", "active": false },
      { "url": "https://sms.lamah.com/api/sms/messages?page=1", "label": "1", "active": true },
      { "url": "https://sms.lamah.com/api/sms/messages?page=2", "label": "2", "active": false },
      { "url": "https://sms.lamah.com/api/sms/messages?page=2", "label": "Next »", "active": false }
    ],
    "next_page_url": "https://sms.lamah.com/api/sms/messages?page=2",
    "path": "https://sms.lamah.com/api/sms/messages",
    "per_page": 20,
    "prev_page_url": null,
    "to": 20,
    "total": 95
  }
}

Top-level response fields

FieldTypeDescription
dataobjectLaravel paginator containing message records

Pagination fields

FieldTypeDescription
current_pageintegerCurrent page number
dataarrayMessage records on the current page
first_page_urlstringURL of the first page
frominteger|nullIndex of the first record on the current page
last_pageintegerTotal number of pages
last_page_urlstringURL of the last page
linksarrayLaravel pagination navigation links
next_page_urlstring|nullURL of the next page
pathstringBase URL for this paginated resource
per_pageintegerMessages per page
prev_page_urlstring|nullURL of the previous page
tointeger|nullIndex of the last record on the current page
totalintegerTotal number of messages matching filters

Message object fields

FieldTypeDescription
short_messagestringMessage content
message_typestringAlways sms for SMS messages
send_typestringsingle or multiple
contact_group_idstring|nullContact group UUID if applicable
message_consumptionintegerSMS parts consumed
created_atstringISO 8601 timestamp
updated_atstringISO 8601 timestamp
receiverarrayList of receipt objects for each recipient

Receipt object fields

FieldTypeDescription
numberstringRecipient phone number
sent_atstringISO 8601 timestamp when message was sent
delivered_atstringISO 8601 timestamp when message was delivered
statusstringDelivery status — see Get Message for the full list
delivery_reportstring|nullRaw delivery report if available
created_atstringISO 8601 creation timestamp
updated_atstringISO 8601 last update timestamp

Only messages that have been persisted appear here. A send accepted moments ago may still be in the ingest queue and absent from this list — fetch it by message_id via Get Message instead.

Error responses

422 Unprocessable Entity — Validation failed

{
  "message": "The per page field must not be greater than 100.",
  "errors": {
    "per_page": ["The per page field must not be greater than 100."]
  }
}

401 Unauthorized

{ "message": "Invalid or missing token." }

Pagination example

const getAllMessages = async () => {
  let allMessages = [];
  let currentPage = 1;
  let hasNextPage = true;

  while (hasNextPage) {
    const response = await fetch(
      `https://sms.lamah.com/api/sms/messages?page=${currentPage}&per_page=50`,
      { headers: { 'Authorization': 'Bearer YOUR_API_TOKEN' } }
    );

    const data = await response.json();
    allMessages = allMessages.concat(data.data.data);

    hasNextPage = data.data.current_page < data.data.last_page;
    currentPage++;
  }

  return allMessages;
};

On this page