# Search Message logs

### <mark style="color:green;">`GET`</mark> `/message`

Search message logs will allow you to search for any messages between two set dates.

{% tabs %}
{% tab title="Curl" %}

```hsts
curl -X GET \
"https://api.mobivatebulksms.com/message?startDate=2023-01-01&endDate=2023-01-02&pageSize=100" \
-H 'Authorization: Bearer [API Key]'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'Authorization': 'Bearer [API Key]',
}

params = {
    'startDate': '2023-01-01',
    'endDate': '2023-01-02',
    'pageSize': '100',
}

response = requests.get('https://api.mobivatebulksms.com/message', params=params, headers=headers)
```

{% endtab %}
{% endtabs %}

Retrieve 100 Messages between 2023-01-01 00:00:00 (UTC) and 2023-01-02 00:00:00 (UTC):

{% tabs %}
{% tab title="Curl" %}

```hsts
curl -X GET \
"https://api.mobivatebulksms.com/message?startDate=2023-01-01&endDate=2023-01-02&pageSize=100" \
-H 'Authorization: Bearer [API Key]'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'Authorization': 'Bearer [API Key]',
}

params = {
    'startDate': '2023-01-01',
    'endDate': '2023-01-02',
    'pageSize': '100',
}

response = requests.get('https://api.mobivatebulksms.com/message', params=params, headers=headers)
```

{% endtab %}
{% endtabs %}

Retrieve Messages between 2023-01-01 12:00:00 (AEST) and 2023-01-02 12:00:00 (AEST):

{% tabs %}
{% tab title="Curl" %}

```hsts
curl -X GET \
"https://api.mobivatebulksms.com/message?startDate=2023-01-01T12:00:00%2B1200&endDate=2023-01-02T12:00:00%2B1200" \
-H 'Authorization: Bearer [API Key]'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'Authorization': 'Bearer [API Key]',
}

response = requests.get(
    'https://api.mobivatebulksms.com/message?startDate=2023-01-01T12:00:00%2B1200&endDate=2023-01-02T12:00:00%2B1200',
    headers=headers,
)
```

{% endtab %}
{% endtabs %}

Retrieve Incoming Messages between 2023-01-01 and 2023-01-02:

{% tabs %}
{% tab title="Curl" %}

```hsts
curl -X GET \
"https://api.mobivatebulksms.com/message?startDate=2023-01-01&endDate=2023-01-02&direction=MO" \
-H 'Authorization: Bearer [API Key]'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'Authorization': 'Bearer [API Key]',
}

params = {
    'startDate': '2023-01-01',
    'endDate': '2023-01-02',
    'direction': 'MO',
}

response = requests.get('https://api.mobivatebulksms.com/message', params=params, headers=headers)
```

{% endtab %}
{% endtabs %}

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer [API Key]` |

**Body**

<table><thead><tr><th>Name</th><th width="131">Type</th><th width="111">Required?</th><th>Description</th></tr></thead><tbody><tr><td>startDate</td><td>string</td><td>Yes</td><td><p></p><p>Start Date Format(s):</p><ul><li>YYYY-MM-DD</li><li>YYYY-MM-DDTHH:MM:SS+TZ </li></ul><p><strong>Examples</strong>:</p><ul><li><code>2023-01-01</code></li><li><code>2023-01-01T00:00:00+0000</code></li><li><code>2023-01-01T00:09:00+0900</code>.</li></ul></td></tr><tr><td>endDate</td><td>string</td><td>Yes</td><td><p>End Date. </p><p><strong>Examples</strong>: See startDate. </p></td></tr><tr><td>page</td><td>integer</td><td>No</td><td>Page number.<br><strong>Default</strong>: <em>1.</em></td></tr><tr><td>pageSize</td><td>integer</td><td>No</td><td>Number of message records to return.<br><strong>Default</strong>: <em>10</em><br><strong>Max</strong>: 1000.</td></tr><tr><td>direction</td><td>string</td><td>No</td><td>By default we'll retrieve both Mobile Originated (<em>MO</em> / Incoming) and Mobile Terminated (<em>MT</em> / Outgoing) messages.<br>Optional Values: <em><strong>MO</strong></em> or <em><strong>MT</strong>.</em></td></tr></tbody></table>

**Response**

Upon a successful send request, our server will respond with a 200 (success) HTTP response code, and respond with an array of messages.

{% tabs %}
{% tab title="200" %}

```json
[
   {
      "id":"9A0C23DD0A000A9D2FBD4671D780AFDA",
      "created":"2023-07-01T01:10:34+0000",
      "modified":"2023-07-01T01:10:39+0000",
      "originator":"Sender ID",
      "recipient":"4400011223",
      "body":"Test Message 1",
      "status":"DELIVERED",
      "direction":"MT",
      "inReplyTo":null,
      "routeId":"mglobal",
      "parts":1,
      "cost":0.01,
      "currency":"GBP",
      "senderReference":"ref-001",
      "campaignId":null
   },
   {
      "id":"9A70B34A0A000A9D2FBD46712E56AB02",
      "created":"2023-07-01T03:00:24+0000",
      "modified":"2023-07-01T03:00:29+0000",
      "originator":"Brand",
      "recipient":"4400011223",
      "body":"Test Message 2",
      "status":"DELIVERED",
      "direction":"MT",
      "inReplyTo":null,
      "routeId":"FFBB2AA70A931B3100A1223E5804510B",
      "parts":1,
      "cost":0.02,
      "currency":"GBP",
      "senderReference":null,
      "campaignId":"9A70B2FE0A000A9D2FBD4671B0E64F3D"
   }
]
```

{% endtab %}

{% tab title="200 (No messages)" %}

```json
[
]
```

{% endtab %}

{% tab title="400" %}

```json
{
   "code":400,
   "message":"startDate: Invalid format: \"2023-01-011\" is malformed at \"1\""
}
```

{% endtab %}

{% tab title="401" %}

```json
{
   "code":401,
   "message":"Unauthorized"
}
```

{% endtab %}
{% endtabs %}

We use conventional HTTP response codes to indicate the success or failure of an API request. In general:

**2xx** indicate success\
**4xx** indicate an error that failed given the information provided (e.g., a required parameter was omitted)\
**5xx** errors indicate an error with ours servers (these are rare).

To see a full list of our **Response codes**, please [click here](https://wiki.mobivatebulksms.com/overview/introduction/understanding-response-codes).
