List Messages
GET /api/messages
Section titled “ /api/messages”Gets a paginated list of all messages sent through the platform.
Query Parameters
Section titled “Query Parameters”Parameter | Type | Required | Description |
---|---|---|---|
page | number | No | Page number (default: 1) |
limit | number | No | Items per page (default: 20, max: 100) |
type | string | No | Filter by type: sms or email |
status | string | No | Filter by status: PENDING , SENT , DELIVERED , FAILED |
startDate | string | No | Start date filter (ISO 8601) |
endDate | string | No | End date filter (ISO 8601) |
search | string | No | Search in message content |
Successful Response (200)
Section titled “Successful Response (200)”{ "data": [ { "id": "msg-uuid-123", "type": "sms", "message": "Welcome to our service!", "status": "DELIVERED", "recipient": "3001234567", "countryCode": "57", "sentAt": "2024-01-15T10:30:00.000Z", "deliveredAt": "2024-01-15T10:30:15.000Z", "organizationId": "org-uuid", "createdAt": "2024-01-15T10:30:00.000Z" }, { "id": "msg-uuid-456", "type": "email", "subject": "Welcome Email", "message": "Welcome to our platform!", "status": "SENT", "sentAt": "2024-01-15T09:15:00.000Z", "organizationId": "org-uuid", "createdAt": "2024-01-15T09:15:00.000Z" } ], "pagination": { "currentPage": 1, "totalPages": 5, "totalItems": 87, "itemsPerPage": 20, "hasNextPage": true, "hasPreviousPage": false }}
Possible Errors
Section titled “Possible Errors”Code | Description |
---|---|
400 | Invalid query parameters |
401 | Missing or invalid API Key |
422 | Validation errors in filters |
500 | Internal server error |
Usage Examples
Section titled “Usage Examples”curl -X GET "https://app.sendme123.com/api/messages?page=1&limit=20&type=sms" \ -H "api-key: your-api-key-here" \ -H "Content-Type: application/json"
const listMessages = async (filters = {}) => { try { const params = new URLSearchParams(filters); const response = await axios.get(`https://app.sendme123.com/api/messages?${params}`, { headers: { 'api-key': 'your-api-key-here', 'Content-Type': 'application/json' } });
console.log('Messages:', response.data); return response.data; } catch (error) { console.error('Error getting messages:', error.response?.data || error.message); throw error; }};
// UsagelistMessages({ page: 1, limit: 20, type: 'sms', status: 'DELIVERED'});
import requests
headers = {'api-key': 'your-api-key-here', 'Content-Type': 'application/json'}params = { 'page': 1, 'limit': 20, 'type': 'sms', 'status': 'DELIVERED'}
response = requests.get('https://app.sendme123.com/api/messages', headers=headers, params=params)
if response.status_code == 200: data = response.json() print('Messages:', data['data']) print('Pagination:', data['pagination'])
Use Cases
Section titled “Use Cases”Get recent SMS messages
Section titled “Get recent SMS messages”const getRecentSMS = async () => { try { const response = await axios.get('https://app.sendme123.com/api/messages', { params: { type: 'sms', limit: 10, status: 'DELIVERED' }, headers: { 'api-key': 'your-api-key-here' } });
console.log('Recent SMS messages:', response.data.data); return response.data.data; } catch (error) { console.error('Error getting recent SMS:', error.response?.data || error.message); throw error; }};
Search messages by content
Section titled “Search messages by content”const searchMessages = async (searchTerm) => { try { const response = await axios.get('https://app.sendme123.com/api/messages', { params: { search: searchTerm, limit: 50 }, headers: { 'api-key': 'your-api-key-here' } });
console.log(`Messages containing "${searchTerm}":`, response.data.data); return response.data.data; } catch (error) { console.error('Error searching messages:', error.response?.data || error.message); throw error; }};