> For the complete documentation index, see [llms.txt](https://developer.ecall-messaging.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.ecall-messaging.com/api-references/https-interface/message-cache.md).

# Message cache

The cache stores inbound SMS messages for leased numbers when caching is enabled.

{% hint style="info" %}
Only messages received after the cache was enabled are stored.
{% endhint %}

Configure the cache in the portal under **Numbers / SMS Numbers** → **3. Forward received SMS (optional)**.

### Fetch the next message

Use `Api/Cache/GetNextMessage` to read the oldest cached message.

If you omit `MobileNumber`, the service returns the oldest message across all leased numbers on the account.

| Parameter      | Type     | Description                                           |
| -------------- | -------- | ----------------------------------------------------- |
| `UserName`     | Required | Username                                              |
| `Password`     | Required | Password                                              |
| `MobileNumber` | Optional | Leased SMS number in international or national format |

**Examples:**

```
/Api/Cache/GetNextMessage?Username=xxx&Password=yyy
/Api/Cache/GetNextMessage?Username=xxx&Password=yyy&MobileNumber=+41763331111
```

### Response structure

```xml
<IncomingSMS>
  <Result>
    <ResultCode></ResultCode>
    <ResultText></ResultText>
  </Result>
  <MessageID></MessageID>
  <SMS>
    <Message></Message>
    <AddressTo></AddressTo>
    <AddressFrom></AddressFrom>
    <TimeStamp></TimeStamp>
  </SMS>
</IncomingSMS>
```

{% hint style="info" %}
If the cache is empty, the service returns result code `11204`. The `<SMS>` and `<MessageID>` nodes are omitted.
{% endhint %}

### Delete a cached message

Use `Api/Cache/DeleteMessage` to remove a cached message after processing it.

This only deletes the cached copy. The message stays visible under **Received Messages**.

| Parameter   | Type     | Description                             |
| ----------- | -------- | --------------------------------------- |
| `UserName`  | Required | Username                                |
| `Password`  | Required | Password                                |
| `MessageID` | Required | Message ID returned by `GetNextMessage` |

**Example:**

```
/Api/Cache/DeleteMessage?UserName=xxx&Password=yyy&MessageID=123abc
```

### Delete response

```xml
<DeleteMsg>
  <Result>
    <ResultCode></ResultCode>
    <ResultText></ResultText>
  </Result>
</DeleteMsg>
```
