> 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>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.ecall-messaging.com/api-references/https-interface/message-cache.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
