# SFTP Server sessions APIs

These APIs can be used to retrieve detailed information about open SFTP server sessions and to terminate a specific session currently open on the SFTP server.

They facilitate effective management of server connections and ensure control over ongoing session activities.

## Monitor STENG SFTP server sessions

**Context**: /data-one-application/api/v1\
**Endpoint**: /infrastructure/clusters/server-sessions/query\
**Method**: POST\
**Description**: This API retrieves all SFTP open sessions\
**Parameters**: Json payload

Requested body parameters:

| Parameter   | Value | Description         | Data Type | Required |
| ----------- | ----- | ------------------- | --------- | -------- |
| clusterName |       | Name of the cluster | string    | Yes      |
| peerName    |       | Name of the peer    | string    | Yes      |
| protocol    |       | Protocol type       | string    | Yes      |
| serverName  |       | Name of the server  | string    | Yes      |
| maxItem     | 100   | Defaul value        | integer   | No       |
| sort        | ASC   | Defaul value        | string    | No       |

**Example:**

```
curl -X 'POST' \
  'https://localhost:9443/data-one-application/api/v1/infrastructure/clusters/server-sessions/query' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer {authorization token here}' \
  -H 'Content-Type: application/json' \
  -d '
{   "clusterName": "cluster1",   "peerName": "peer1",   "protocol": "SFTP",   "serverName": "sftp-server",   "maxItem": 100,   "sort": "asc" }' 
```

**Response**:

| HTTP Status code | Description                                                                                        |
| ---------------- | -------------------------------------------------------------------------------------------------- |
| 200              | SUCCESS                                                                                            |
| 401              | Not authorized (login not performed or token expired)                                              |
| 400              | Bad request, details in the error message (i.e. mandatory fields not present or with wrong values) |

The response is a list of JSON objects, each representing an SFTP session.

```
[  
   {
        "sessionId": "",  
        "userName": "",  
        "clientIp": "",  
        "clientPort": "",  
        "clientVersion": ""
    }
]  
```

**Example:**

JSON

```json
[
    {
        "sessionId": "B536CBB1D9D09A3586D642D792BBB98840846CAA1123AD40952739B8FD8BFA61AE6D7FE2394B825524C7B77566C2DD5C9DA956C3223B6BB09787C031E3B6E327",
        "userName": "part1",
        "clientIp": "/10.0.0.2:38666",
        "clientPort": "38666",
        "clientVersion": "SSH-2.0-FileZilla_3.58.0"
    },
    {
        "sessionId": "CE2E5639EE79A86B14CF8D8AAF3C852C8278C05AF17EADAA7F76CF1F7ECA68EBCDCA834DC1A15AA7D10AFF2BAE1084CF6856D332B632313E253AD6EEA7715FE3",
        "userName": "part1",
        "clientIp": "/10.0.0.2:41488",
        "clientPort": "41488",
        "clientVersion": "SSH-2.0-FileZilla_3.58.0"
    },
    {
        "sessionId": "DDD00B8BFE2060D9D143ED78178AFFB34BDC4ABF17D364E95553BB5550F816B85E51E3BDD2DA93C7473A42DDC11A232547F3B9FF22C5E58696BA71F8B308B027",
        "userName": "part1",
        "clientIp": "/10.0.0.2:41470",
        "clientPort": "41470",
        "clientVersion": "SSH-2.0-FileZilla_3.58.0"
    },
    {
        "sessionId": "FF48C9755158EE02E0506266ED50DBA9D7D0B2265CE239AACBF71AEF8EA9465E4DE08D073E50347D6C6D7A7643A38EC517E411FE31FD030261BED9B105349EFB",
        "userName": "part1",
        "clientIp": "/10.0.0.2:41486",
        "clientPort": "41486",
        "clientVersion": "SSH-2.0-FileZilla_3.58.0"
    }
]
 
```

## Terminate STENG SFTP server sessions

**Context**: /data-one-application/api/v1\
**Endpoint**: /infrastructure/clusters/server-sessions\
**Method**: DELETE\
**Description**: This API kills a specific SFTP session by sessionId\
**Parameters**: Json payload

Requested body parameters:

| Parameter   | Description                   | Data Type | Required |
| ----------- | ----------------------------- | --------- | -------- |
| clusterName | Name of the cluster           | string    | Yes      |
| peerName    | Name of the peer              | string    | Yes      |
| protocol    | Protocol type. Use SFTP       | string    | Yes      |
| serverName  | Name of the server            | string    | Yes      |
| sessionId   | ID of the SFTP server session | string    | Yes      |

**Example**:

```curl
curl -X 'DELETE' \ 'https://localhost:9443/data-one-application/api/v1/infrastructure/clusters/server-sessions' \ 
-H 'accept: */*' \ 
-H 'Authorization: Bearer {authorization token here}' \ 
-H 'Content-Type: application/json' \ 
-d '{  "clusterName": "cluster1",  "peerName": "peer1",  "protocol": "sftp",  "serverName": "sftp-server",  "sessionId": "17B63E2D99659D7B806BC47B866EBDC0F16FDAFE21AF072563EBBB07C0E267AD54D253AAE5F2A49F3D779D0F254630F15030F5D3235A3EF2C45B23C8A7ABEE5E"}'
```

**Response**:

| HTTP Status code | Description                                                                                        |
| ---------------- | -------------------------------------------------------------------------------------------------- |
| 200              | SUCCESS                                                                                            |
| 401              | Not authorized (login not performed or token expired)                                              |
| 400              | Bad request, details in the error message (i.e. mandatory fields not present or with wrong values) |

The response is a list of JSON objects, with the sessionID.

**Example:**

```
{
    "sessionId": "17B63E2D99659D7B806BC47B866EBDC0F16FDAFE21AF072563EBBB07C0E267AD54D253AAE5F2A49F3D779D0F254630F15030F5D3235A3EF2C45B23C8A7ABEE5E",
    "userName": "",
    "clientIp": "",
    "clientPort": "",
    "clientVersion": ""

} 
```


---

# 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://docs.primeur.com/data-mover-1.21/api/sftp-server-sessions-apis.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.
