# Feed 'R' - Settlement requests

**Requests**

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

```json
{"event": "bind", "feed": "R"}
```

{% endtab %}

{% tab title="Unsubscribe" %}

```json
{"event": "unbind", "feed": "R"}
```

{% endtab %}
{% endtabs %}

**Feed handling**

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

```json
settlementRequest = [
  0: counterpartyId (Efx::ClientId)
  1: currencyName (string)
  2: flags (unsigned int16)
  3: amount (Efx::Size)
  4: comment (string)
  5: expirationTimestamp(Efx::Timestamp)
  6: network (string)
  7: requestId (unsigned int64)
  8: creationTimestamp(Efx::Timestamp)
]
```

For detailed settlement requests description

{% content-ref url="/pages/I88DzG9Kh5a8clNwX1Ux" %}
[settlementRequests](/api-reference/rest-api/settlements/settlementrequests.md)
{% endcontent-ref %}
{% endtab %}

{% tab title="Possible updates" %}

```json
// snapshot
['R', 0, 'S', [
  array of incoming settlementRequest,
  array of outgoing settlementRequest
]]

// add new settlement requests
['R', 0, '+', [
  array of new incoming settlementRequest,
  array of new outgoing settlementRequest
]]

// remove settlement requests
['R', 0, '-', [
  array of removed incoming settlementRequest,
  array of removed outgoing settlementRequest
]]

// failed to subscribe
['R', 0, 'Z', 2]

// unsubscribed
['R', 0, 'U', 0]
```

{% endtab %}

{% tab title="Feed update example" %}

```javascript
applyToSnapshot(prevSnapshot, feed, action, data) {
    switch (feed) {
        case 'R': {
            switch (action) {
                case 'S' : {
                    return [[...data[0]], [...data[1]]]
                }
                case '+' : {
                    for (let incoming of data[0]) {
                        prevSnapshot[0].push(incoming)
                    }
                    for (let outgoing of data[1]) {
                        prevSnapshot[1].push(outgoing)
                    }
                    break
                }
                case '-' : {
                    for (let incoming of data[0]) {
                        for (var i in prevSnapshot[0]) {
                            if (prevSnapshot[0][i][0] == incoming[0] &&
                                prevSnapshot[0][i][1] == incoming[1]) {
                                prevSnapshot[0].splice(i, 1)
                                break
                            }
                        }
                    }
                    for (let outgoing of data[1]) {
                        for (var i in prevSnapshot[1]) {
                            if (prevSnapshot[1][i][0] == outgoing[0] &&
                                prevSnapshot[1][i][1] == outgoing[1]) {
                                prevSnapshot[1].splice(i, 1)
                                break
                            }
                        }
                    }
                    break
                }
            }
            break
        }
    }
    return prevSnapshot
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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://faq.finerymarkets.com/api-reference/websocket-api/feed-r-settlement-requests.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.
