> For the complete documentation index, see [llms.txt](https://docs.primeur.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.primeur.com/data-mover-1.20/api/http-mft-rest-apis.md).

# HTTP MFT Rest APIs

The HTTP MFT Rest APIs let applications perform file transfer operations - listing, upload, download, and deletion - as well as metadata management over HTTP/HTTPS.

Users can authenticate and access Virtual File Systems according to the Connection Contract configuration and can operate on files and Virtual Paths according to ACLs.

As a result, file operations executed via this API may trigger contracts and downstream processing configured on the platform.

## Pre-requisites

* HTTP/S server is configured: an HTTP or HTTPS server must exist and be reachable. Details here: [Server Connections](/data-mover-1.20/transfer-protocols-and-connectors/server-connections.md) and [Server Connection: HTTP](/data-mover-1.20/transfer-protocols-and-connectors/server-connections/server-connection-http.md) or [Server Connection: HTTPS](/data-mover-1.20/transfer-protocols-and-connectors/server-connections/server-connection-https.md)
* Actor and User exist: an Actor is configured (typically a Partner) and a User is defined under that Actor and will authenticate to this API
* In the Actor, a VFS is available
* HTTP/S Connection contract binding the Actor/User to the target VFS/Virtual Path is configured; details here: [Create a Connection Contract](/data-mover-1.20/contracts/create-your-first-contract/create-a-connection-contract.md)

## Base URL

API calls must be sent to an HTTP/S server active on any STENG Peer that belongs to the target STENG Cluster.

* host and port depend on your deployment setup:
  * If the HTTP/S server is enabled on a specific STENG Peer, use that peer’s host and port.
  * If a load balancer is configured in front of the cluster, use the balancer’s host and port; requests will be routed automatically to the active peers.
* the protocol (`http` or `https`) must match the configuration of the HTTP/S server on that STENG Peer.

The following Base URLs define the entry point for all API calls, depending on your deployment setup.

* Base URL (STENG peer): https\://\<peer-host>:/2.0/
* Base URL (load balancer): https\://\<lb-host>:/2.0/

Notes:

* the /2.0/ path is constant across peers; the protocol must match the HTTP/S server config
* from there, each endpoint shows only the path (relative to the Base URL).

## AUTHENTICATION

### Login

* **Endpoint**: `/login/basic`
* **Method**: `POST`
* **Content-Type**: `application/x-www-form-urlencoded`

#### Description

Authenticates a user and starts a new session on the configured HTTP / HTTPS server.\
The server returns two session cookies (`sp-http-usr` and `sp-http-ses`) that identify the user in subsequent API calls.

#### Request parameters

| Parameter  | Description       | Data Type | Required |
| ---------- | ----------------- | --------- | -------- |
| `username` | Username          | String    | yes      |
| `password` | The user password | String    | yes      |

#### Responses

| HTTP Status | Description                    | Example                                                                                                                                                                                     | Notes                                                                           |
| ----------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| 200         | Authentication successful      | <p>No response body.<br>Session cookie returned:</p><p></p><p><code>Set-Cookie: sp-http-usr=; Path=/; HttpOnly</code><br></p><p><code>Set-Cookie: sp-http-ses=; Path=/; HttpOnly</code></p> | Save both cookies and include them in every subsequent request (Cookie: header) |
| 401         | Invalide username and password | <p><code>{</code><br><code>"result":"failed",</code><br><code>"message":"Invalid username or password",</code><br><code>"errorType":"authentication"</code></p><p><code>}</code></p>        | Returned when credentials do not match                                          |
| 404         | Missing Parameters             | <p><code>{</code><br><code>"result":"failed",</code><br><code>"message":"No username or password",</code><br><code>"errorType":"request\_syntax"</code><br><code>}</code></p>               | Returned when one or both parameters are missing                                |

Cookies returned from the call can be placed in a file (-c filename), which is then used in subsequent calls via curl, as in the example below:

```curl
curl -v "https://myHostName:21080/2.0/login/basic" 
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8'  
-d 'username=jdoe&password=secret'
-c cookies.txt
```

This command authenticates the user `jdoe` and stores the session cookiies in the `cookies.txt` file.

## FILES

### Upload file

* **Endpoint**: `/files/<path>/<file>`
* **Method**: `PUT`
* **Authentication:** session cookies (`sp-http-usr`, `sp-http-ses`) from `POST /login/basic`
* **Content-Type**: `multipart/form-data`

#### Description

Uploads a file to the specified `<path>` .

#### Request parameters

**Path parameters**

| Parameter | Description                                         | Data Type | Required | Note                          |
| --------- | --------------------------------------------------- | --------- | -------- | ----------------------------- |
| `path`    | Destination folder                                  | string    | yes      | URL-encode special characters |
| `file`    | Target filename to create in the destination folder | string    | yes      | URL-encode special characters |

**Multipart form fields**

| Parameter | Description                        | Data Type | Required | Note                                |
| --------- | ---------------------------------- | --------- | -------- | ----------------------------------- |
| `file`    | The content of the file to upload. | binary    | yes      | Use `@<local-filename>` with `curl` |

#### Responses

| HTTP Status code | Description                        | Example                                                                                                                                                                                                                                         | Notes                                                                                                                                                       |
| ---------------- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 201              | File uploaded successfully         | <p><code>{</code><br><code>"result":"ok",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Upload successful",</code><br><code>"fileset":"251",</code><br><code>}</code></p>                                   | <p>id : long value that represents the file<br><br>Timestamp: UTC representation of the response creation using ISO-8601</p>                                |
| 400              | Missing filename                   | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"No filename specified",</code><br><code>"errorType":"request\_syntax"</code><br><code>}</code></p>              | <p>Example if specified only path of folder.<br><br>Timestamp: UTC representation of the response creation using ISO-8601</p>                               |
| 400              | Missing parameters or syntax error | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Missing parameters or syntax error",</code><br><code>"errorType":"request\_syntax"</code><br><code>}</code></p> | <p>Example if metadata has syntax error or content-type header is missing.<br><br>Timestamp: UTC representation of the response creation using ISO-8601</p> |
| 401              | Connection contract not configured | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Connection contract not configured",</code><br><code>"errorType":"configuration"</code><br><code>}</code></p>   | Timestamp: UTC representation of the response creation using ISO-8601                                                                                       |
| 401              | Authentication error               | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Invalid username or password",</code><br><code>"errorType":"authentication"</code><br><code>}</code></p>        | <p>Messages depends on authentication type.<br>timestamp: UTC representation of the response creation using ISO-8601</p>                                    |
| 403              | No write permission                | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"No write permission",</code><br><code>"errorType":"authorization"</code><br><code>}</code></p>                  | Timestamp: UTC representation of the response creation using ISO-8601                                                                                       |
| 404              | Path not found                     | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Path '' doesn't exist",</code><br><code>"errorType":"io"</code><br><code>}</code></p>                           | Timestamp: UTC representation of the response creation using ISO-8601                                                                                       |

#### Examples

Upload the file `HttpUploadV2.txt` in folder `http_api` as `HttpUploadV2.txt`:

```curl
curl -i -X PUT -v "http://myHostName:21080/2.0/files/http_api/HttpUploadV2.txt" 
-H "Content-Type: multipart/form-data"  
-F "file=@test.sh;type=application/octet-stream"  
-b cookies.txt
```

### Upload file with metadata

* **Endpoint**: `/files/<path>`
* **Method**: `POST`
* **Authentication:** session cookies (`sp-http-usr`, `sp-http-ses`) from `POST /login/basic`
* **Content-Type**: `multipart/form-data`

#### Description

Uploads a file and associates one or more metadata with it.\
The file is stored in the specified `<path>`.\
Metadata can include Generic and Spazio2 classes.

#### Request parameters

**Path parameters**

| Parameter | Description                                         | Data Type | Required | Note                          |
| --------- | --------------------------------------------------- | --------- | -------- | ----------------------------- |
| `path`    | Destination folder                                  | string    | yes      | URL-encode special characters |
| `file`    | Target filename to create in the destination folder | string    | yes      | URL-encode special characters |

&#x20;**Multipart form fields**

| Parameter  | Description                                               | Data Type     | Required | Note                                                                                                                                                                                                                                                                      |
| ---------- | --------------------------------------------------------- | ------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `file`     | The content of the file to upload                         | binary        | yes      | `@<local-filename>` with `curl`.                                                                                                                                                                                                                                          |
| `metadata` | Optional JSON object containing metadata key–value pairs. | string (JSON) | no       | <p>Supported classes: Generic, Spazio2.<br>Example: <code>{"QUEUE\_NAME":"QUEUE1","CORRELATION\_ID":"invoices.xlsx"}</code></p><p>See <a href="/data-mover-1.20/how-to.../...-manage-metadata-in-data-mover.md">How to manage metadata in Data Mover</a> for details.</p> |

#### Responses

| HTTP Status code | Description                        | Response example                                                                                                                                                                         | Notes                                                              |
| ---------------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| 201              | File uploaded successfully         | <p><code>{</code><br><code>"result":"ok",</code><br><code>"message":"Upload successful",</code><br><code>"fileset":"251" ,</code><br><code>}</code></p>                                  |                                                                    |
| 400              | Missing filename                   | <p><code>{</code><br><code>"result":"failed",</code><br><code>"message":"No filename specified",</code><br><code>"errorType":"request\_syntax"</code><br><code>}</code></p>              |                                                                    |
| 400              | Missing parameters or syntax error | <p><code>{</code><br><code>"result":"failed",</code><br><code>"message":"Missing parameters or syntax error",</code><br><code>"errorType":"request\_syntax"</code><br><code>}</code></p> | Metadata has a syntax error or the content-type header is missing. |
| 401              | Connection contract not configured | <p><code>{</code><br><code>"result":"failed",</code><br><code>"message":"Connection contract not configured",</code><br><code>"errorType":"configuration"</code><br><code>}</code></p>   | Messages depend on authentication type.                            |
| 401              | Authentication error               | <p><code>{</code><br><code>"result":"failed",</code><br><code>"message":"Invalid username or password",</code><br><code>"errorType":"authentication"</code><br><code>}</code></p>        |                                                                    |
| 403              | No write permission                | <p><code>{</code><br><code>"result":"failed",</code><br><code>"message":"No write permission",</code><br><code>"errorType":"authorization"</code><br><code>}</code></p>                  |                                                                    |
| 404              | Path not found                     | <p><code>{</code><br><code>"result":"failed",</code><br><code>"message":"Path '' doesn't exist",</code><br><code>"errorType":"io"</code><br><code>}</code></p>                           |                                                                    |

#### Examples

Uploads the local file `test.txt` to folder `httpapi`, setting Spazio2 metadata values for `QUEUE_NAME` and `CORRELATION_ID`.

```curl
curl -i -X POST -v "https://myHostName:21080/2.0/files/httpapi" 
 -H "Content-Type: multipart/form-data"
 -F "file=@test.txt;type=application/octet-stream"  
 -F 'metadata={"SPFB_SP2_FILE_SYS_MD.QUEUE_NAME":"QUEUE1", "SPFB_SP2_FILE_SYS_MD.CORRELATION_ID":"invoices.xslx"}' 
 -b cookies.txt
```

### Download file

* **Endpoint**: `/files/<path>/<file>`
* **Method**: `GET`
* **Authentication:** session cookies (`sp-http-usr`, `sp-http-ses`) from `POST /login/basic`
* **Content-Type**: `multipart/form-data`

#### Description

Downloads the file `<file>` located in `<path>`.\
The response body contains the raw file content. The server sets the response `Content-Type` according to the stored file type.

#### Request parameters

**Path parameters**

| Parameter | Description                         | Data Type | Required | Note                          |
| --------- | ----------------------------------- | --------- | -------- | ----------------------------- |
| `path`    | Virtual Path where the file resides | string    | yes      | URL-encode special characters |
| `file`    | File name to download               | string    | yes      | URL-encode special characters |

#### Responses

| HTTP Status code | Description                        | Response example                                                                                                                                                                                                                              | Notes                                                                                                                           |
| ---------------- | ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| 200              | File found and content returned    | <p>Body: binary file bytes<br>Headers: <code>Content-Type: \<detected or application/octet-stream></code>; <code>Content-Length</code>; <code>Content-Disposition: attachment; filename="\<file>"</code></p>                                  |                                                                                                                                 |
| 400              | Missing filename                   | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"No filename specified",</code><br><code>"errorType":"request\_syntax"</code><br><code>}</code></p>            | Timestamp: UTC representation of the response creation using ISO-8601                                                           |
| 401              | Connection contract not configured | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Connection contract not configured",</code><br><code>"errorType":"configuration"</code><br><code>}</code></p> | Timestamp: UTC representation of the response creation using ISO-8601                                                           |
| 401              | Authentication error               | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Invalid username or password",</code><br><code>"errorType":"authentication"</code><br><code>}</code></p>      | <p>Messages depend on the authentication type.<br><br>Timestamp: UTC representation of the response creation using ISO-8601</p> |
| 403              | No download permission             | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"No read permission",</code><br><code>"errorType":"authorization"</code><br><code>}</code></p>                 | Timestamp: UTC representation of the response creation using ISO-8601                                                           |
| 404              | File not found                     | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"File '' doesn't exist",</code><br><code>"errorType":"io"</code><br><code>}</code></p>                         | Timestamp: UTC representation of the response creation using ISO-8601                                                           |
| 404              | Path not found                     | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Path '' doesn't exist",</code><br><code>"errorType":"io"</code><br><code>}</code></p>                         | Timestamp: UTC representation of the response creation using ISO-8601                                                           |

#### Example

```curl
curl -X GET https://myHostName:21080/2.0/files/http_api/HttpUploadV2Cookies_3.txt  
   -o download_file.txt 
   -b cookies.txt
```

### Delete file

* **Endpoint**: `/files/<path>/<file>`
* **Method**: `DELETE`
* **Authentication:** session cookies (`sp-http-usr`, `sp-http-ses`) from `POST /login/basic`
* **Content-Type**: `multipart/form-data`

#### Description

Deletes the specified `<file>` located in `<path>`.\
The operation permanently removes the file from the folder.

#### Request parameters

**Path parameters**

| Parameter | Description                   | Data Type | Required | Note                          |
| --------- | ----------------------------- | --------- | -------- | ----------------------------- |
| `path`    | Folder where the file resides | string    | yes      | URL-encode special characters |
| `file`    | File name to delete           | string    | yes      | URL-encode special characters |

#### Responses&#x20;

| HTTP Status code | Description                        | Response example                                                                                                                                                                                                                              | Notes                                                                 |
| ---------------- | ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| 200              | File successfully deleted          | <p><code>{</code><br><code>"result":"ok",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"File deleted",</code><br><code>"fileset":</code><br><code>}</code></p>                                            | Timestamp: UTC representation of the response creation using ISO-8601 |
| 400              | Missing parameter or syntax error  | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"missing param or syntax error",</code><br><code>"errorType":"syntax\_error"</code><br><code>}</code></p>      | Timestamp: UTC representation of the response creation using ISO-8601 |
| 401              | Connection contract not configured | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Connection contract not configured",</code><br><code>"errorType":"configuration"</code><br><code>}</code></p> | Timestamp: UTC representation of the response creation using ISO-8601 |
| 401              | Authentication error               | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Invalid username or password",</code><br><code>"errorType":"authentication"</code><br><code>}</code></p>      | Timestamp: UTC representation of the response creation using ISO-8601 |
| 403              | No delete permission               | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"No delete permission",</code><br><code>"errorType":"authorization"</code><br><code>}</code></p>               | Timestamp: UTC representation of the response creation using ISO-8601 |
| 404              | File not found                     | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"File '' doesn't exist",</code><br><code>"errorType":"io"</code><br><code>}</code></p>                         | Timestamp: UTC representation of the response creation using ISO-8601 |
| 404              | Path not found                     | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Path '' doesn't exist",</code><br><code>"errorType":"io"</code><br><code>}</code></p>                         | Timestamp: UTC representation of the response creation using ISO-8601 |

#### Examples

Deletes the file `HttpUploadV2.txt` from folder `http_api`.

```curl
curl -i -X DELETE https://myHostName:21080/2.0/files/http_api/HttpUploadV2Cookies_3.txt 
   -b cookies.txt
```

## METADATA

The Metadata APIs allow you to add, update, or read metadata associated with files.\
Metadata can belong to one or more classes:

* Generic metadata – custom user-defined attributes
* Spazio2 metadata - see the list on the [How to manage metadata in Data Mover](/data-mover-1.20/how-to.../...-manage-metadata-in-data-mover.md#spazio2-metadata-list) page.&#x20;

### Insert or update metadata

* **Endpoint**: `/metadata/<path>/<file>`
* **Method**: `POST`
* **Authentication:** session cookies (`sp-http-usr`, `sp-http-ses`) from `POST /login/basic`
* **Content-Type**: `application/json`&#x20;

#### Description

Add or updates one or more metadata entries for the specified file `<file>` in `<path>`.\
If a metadata key already exists, its value is replaced with the new one.

#### Request parameters

**Path parameters**

| Parameter | Description                      | Data Type | Required | Note                          |
| --------- | -------------------------------- | --------- | -------- | ----------------------------- |
| `path`    | Folder containing the file       | string    | yes      | URL-encode special characters |
| `file`    | File name to update metadata for | string    | yes      | URL-encode special characters |

**Request body**

A JSON object containing key values pairs of metadata entries. Each key corresponds to a metadata field.

Supported classes are: Generic and Spazio2 (keys with prefix `SPFB_SP2_FILE_SYS_MD.`  belong to Spazio2). See the [How to manage metadata in Data Mover](/data-mover-1.20/how-to.../...-manage-metadata-in-data-mover.md) page for details.&#x20;

Example of Generic metadata:

```
{
  "OFFICE": "Accounting",
  "CITY": "London"
}
```

#### Responses

| HTTP Status code | Description                        | Response example                                                                                                                                                                                                                                | Notes                                                                 |
| ---------------- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| 200              | Metadata updated successfully      | <p><code>{</code><br><code>"result":"ok",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Metadata updated",</code><br><code>"fileset":"251"</code><br><code>}</code></p>                                     | timestamp: UTC representation of the response creation using ISO-8601 |
| 400              | Missing filename                   | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"No filename specified",</code><br><code>"errorType":"request\_syntax"</code><br><code>}</code></p>              | timestamp: UTC representation of the response creation using ISO-8601 |
| 400              | Missing parameter or syntax error  | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Missing parameters or syntax error",</code><br><code>"errorType":"request\_syntax"</code><br><code>}</code></p> | timestamp: UTC representation of the response creation using ISO-8601 |
| 401              | Connection contract not configured | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Connection contract not configured",</code><br><code>"errorType":"configuration"</code><br><code>}</code></p>   | timestamp: UTC representation of the response creation using ISO-8601 |
| 401              | Authentication error               | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Invalid username or password",</code><br><code>"errorType":"authentication"</code><br><code>}</code></p>        | timestamp: UTC representation of the response creation using ISO-8601 |
| 403              | No write permission                | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"No write permission",</code><br><code>"errorType":"authorization"</code><br><code>}</code></p>                  | timestamp: UTC representation of the response creation using ISO-8601 |
| 404              | File not found                     | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"File '' doesn't exist",</code><br><code>"errorType":"io"</code><br><code>}</code></p>                           | timestamp: UTC representation of the response creation using ISO-8601 |
| 404              | Path not found                     | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Path '' doesn't exist",</code><br><code>"errorType":"io"</code><br><code>}</code></p>                           | timestamp: UTC representation of the response creation using ISO-8601 |

#### Example

The file `HttpUploadV2Cookies_3.txt` is associated with the `OFFICE` generic metadata, which has the value 'Accounting', and with `CITY` generic metadata, which has the value 'London'.

```curl
curl -i -X POST -v "https://myHostName:21080/2.0/metadata/httpapi/HttpUploadV2Cookies_3.txt" 
   -H "Content-Type: application/json" 
   -d '{"OFFICE":"Accounting", "CITY":"London"}' 
   -b cookies.txt
```

### Read metadata

* **Endpoint**: `/meadata/<path>/<file>`
* **Method**: `GET`
* **Authentication:** session cookies (`sp-http-usr`, `sp-http-ses`) from `POST /login/basic`

#### Description

Retrieves the list of metadata associated with the file `<file>` located in `<path>`.\
The response includes both user-defined and system metadata.

#### Request parameters

**Path parameters**

| `path` | Folder where the file resides              | string | yes | URL-encode special characters |
| ------ | ------------------------------------------ | ------ | --- | ----------------------------- |
| `file` | File name whose metadata will be retrieved | string | yes | URL-encode special characters |

#### Responses

| HTTP Status code | Description                        | Response example                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | Notes                                                                                                                    |
| ---------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| 200              | Metadata retrieved successfully    | <p><code>"metadata":{</code><br><code>"dstFileName":"",</code><br><code>"size":"89",</code><br><code>"correlationId":"",</code><br><code>"putDate":"2020-09-15T10:55:01.669Z",</code><br><code>"firstReadDate":"",</code><br><code>"lastModifiedTime":"2020-09-15T10:55:01.583Z",</code><br><code>"lastAccessTime":"",</code><br><code>"creationTime":"2020-09-15T10:55:01.583Z",</code><br><code>"datatype":"application/octet-stream",</code><br><code>"description":"",</code><br><code>"Partner":"Partner5"</code><br><code>}</code></p> |                                                                                                                          |
| 400              | No filename provided               | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"No filename specified",</code><br><code>"errorType":"request\_syntax"</code><br><code>}</code></p>                                                                                                                                                                                                                                                                                                           | <p>Example if specified only path of folder<br>timestamp: UTC representation of the response creation using ISO-8601</p> |
| 401              | Connection contract not configured | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Connection contract not configured",</code><br><code>"errorType":"configuration"</code><br><code>}</code></p>                                                                                                                                                                                                                                                                                                | timestamp: UTC representation of the response creation using ISO-8601                                                    |
| 401              | Authentication error               | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Invalid username or password",</code><br><code>"errorType":"authentication"</code><br><code>}</code></p>                                                                                                                                                                                                                                                                                                     | <p>Messages depends on authentication type.<br>timestamp: UTC representation of the response creation using ISO-8601</p> |
| 403              | No read permission                 | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"No read permission",</code><br><code>"errorType":"authorization"</code><br><code>}</code></p>                                                                                                                                                                                                                                                                                                                | timestamp: UTC representation of the response creation using ISO-8601                                                    |
| 404              | File not found                     | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":" doesn't exist",</code><br><code>"errorType":"io"</code><br><code>}</code></p>                                                                                                                                                                                                                                                                                                                               | timestamp: UTC representation of the response creation using ISO-8601                                                    |
| 404              | Path not found                     | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Path '' doesn't exist",</code><br><code>"errorType":"io"</code><br><code>}</code></p>                                                                                                                                                                                                                                                                                                                        | timestamp: UTC representation of the response creation using ISO-8601                                                    |

#### Example

```curl
curl -i-X GET -v "http://myHostName:21080/2.0/metadata/http_api/HttpUploadV2Cookies_3.txt 
    -H "Accept: application/json" 
    -b cookies.txt
```

**Response**

```
{
  "id": "/httpapi/testHttpUploadV2Cookies_3.txt",
  "filename": "testHttpUploadV2Cookies_3.txt",
  "fileset": 5832,
  "owner": "",
  "directory": false,
  "attributes": {
    "firstReadDate": "",
    "lastModifiedTime": "2025-05-23T14:08:40.886Z",
    "size": "6",
    "creationTime": "2025-05-23T14:08:40.886Z",
    "datatype": "application/octet-stream",
    "description": "",
    "correlationId": "",
    "putDate": "2025-05-23T14:08:40.871Z"
  }
}
```

## COUNTELEMENTS

### Count elements

* **Endpoint**: `/countelements/<path>`
* **Method**: `GET`
* **Authentication:** session cookies (`sp-http-usr`, `sp-http-ses`) from `POST /login/basic`
* **Content-Type**: `application/json`&#x20;

#### Description

Returns the number of elements (files and/or folders) that exist in the specified `<path>`.\
You can filter the count by name pattern or by element type (files or folders only).

#### Request parameters

**Path parameters**

<table data-header-hidden><thead><tr><th width="148.0909423828125">Parameter</th><th>Description</th><th>Data Type</th><th>Required</th><th>Notes</th></tr></thead><tbody><tr><td><code>path</code></td><td>Folder to count the items in</td><td>string</td><td>yes</td><td>URL-encode special characters</td></tr></tbody></table>

**Query parameters**

<table data-header-hidden><thead><tr><th width="148.0909423828125"></th><th></th><th></th><th></th><th></th></tr></thead><tbody><tr><td><code>filter</code></td><td>Pattern used to filter elements by name.<br>Use <code>*</code> as a wildcard to match any sequence of characters</td><td>string</td><td>no</td><td>Default: *</td></tr><tr><td><code>type</code></td><td>Specifies which element types to count: <code>all</code>, <code>files</code>, or <code>folders</code></td><td>string</td><td>no</td><td>Default: all</td></tr></tbody></table>

#### Response

| HTTP Status code | Description                            | Response example                                                                                                                                                                                                                              | Notes                                                                 |
| ---------------- | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| 200              | Count operation completed successfully | `2`                                                                                                                                                                                                                                           | Possible values is 0 or a positive number.                            |
| 401              | Connection contract not configured     | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Connection contract not configured",</code><br><code>"errorType":"configuration"</code><br><code>}</code></p> | timestamp: UTC representation of the response creation using ISO-8601 |
| 401              | Authentication error                   | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Invalid username or password",</code><br><code>"errorType":"authentication"</code><br><code>}</code></p>      | timestamp: UTC representation of the response creation using ISO-8601 |
| 403              | No list permission                     | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"No list permission",</code><br><code>"errorType":"authorization"</code><br><code>}</code></p>                 | timestamp: UTC representation of the response creation using ISO-8601 |
| 404              | Path not found                         | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Path doesn't exist",</code><br><code>"errorType":"io"</code><br><code>}</code></p>                            | timestamp: UTC representation of the response creation using ISO-8601 |

#### Example

Counts all elements (files and folders) in `httpapi` folder:

```curl
curl -i -u part1:partner1 -X GET -v "https://myHostName:21080/2.0/countelements/httpapi?type=all" 
   -b cookies.txt
```

## DIRECTORIES

### List elements

* **Endpoint**: `/directories/<path>`
* **Method**: `GET`
* **Authentication:** session cookies (`sp-http-usr`, `sp-http-ses`) from `POST /login/basic`
* **Content-Type**: `application/json`&#x20;

#### Description

Returns the list of folders and files contained in the given `<path>` with optional filtering, sorting, and paging.

#### Request parameters

**Path parameters**

<table data-header-hidden><thead><tr><th width="148.0909423828125">Parameter</th><th>Description</th><th>Data Type</th><th>Required</th><th>Notes</th></tr></thead><tbody><tr><td><code>path</code></td><td>Folder to list</td><td>string</td><td>yes</td><td>URL-encode special characters</td></tr></tbody></table>

**Query parameters**

<table data-header-hidden><thead><tr><th width="148.0909423828125">Paramer</th><th>Description</th><th>Data Type</th><th>Required</th><th>Notes</th></tr></thead><tbody><tr><td><code>filter</code></td><td>Pattern used to filter elements by name.<br>Use <code>*</code> as a wildcard to match any sequence of characters</td><td>string</td><td>no</td><td>Default: *</td></tr><tr><td><code>sort</code></td><td>Sort field: <code>name</code> | <code>size</code> | <code>put_date</code> | <code>read_date</code> | <code>expiry_date</code></td><td>string</td><td>no</td><td>Default: name</td></tr><tr><td><code>direction</code></td><td>Sort order</td><td>string</td><td>no</td><td></td></tr><tr><td><code>start</code></td><td>Zero-based offset of the first element to return</td><td>integer</td><td>no</td><td>Default: 0</td></tr><tr><td><code>limit</code></td><td>Max number of elements to return</td><td>integer</td><td>no</td><td>Default: 500</td></tr><tr><td><code>type</code></td><td>Specifies which element types to count: <code>all</code>, <code>files</code>, or <code>folders</code></td><td>string</td><td>no</td><td>Default: all</td></tr><tr><td><code>attributes</code></td><td>Comma-separated list of attribute names to include in each item. If an attribute is not present, its value is empty. Attributes names are:  <code>dstFileName</code>, <code>size</code>, <code>correlationId</code>, <code>putDate</code>, <code>firstReadDate</code>, <code>lastModifiedTime</code>, <code>lastAccessTime</code>, <code>creationTime</code>, <code>datatype</code>, <code>description</code></td><td>string</td><td>no</td><td>Default: all</td></tr></tbody></table>

#### Responses

| HTTP Status code | Description                        | Response example                                                                                                                                                                                                                              | Notes                                                                 |
| ---------------- | ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| 200              | Folder listed successfully         | See successful response body below                                                                                                                                                                                                            | Example of list in inbox folder with 2 folders and 4 files.           |
| 401              | Authentication error               | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Invalid username or password",</code><br><code>"errorType":"authentication"</code><br><code>}</code></p>      | timestamp: UTC representation of the response creation using ISO-8601 |
| 401              | Connection contract not configured | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Connection contract not configured",</code><br><code>"errorType":"configuration"</code><br><code>}</code></p> | timestamp: UTC representation of the response creation using ISO-8601 |
| 403              | No list permission                 | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"No list permission",</code><br><code>"errorType":"authorization"</code><br><code>}</code></p>                 | timestamp: UTC representation of the response creation using ISO-8601 |
| 404              | Path not found                     | <p><code>{</code><br><code>"result":"failed",</code><br><code>"timestamp":"2020-11-13T08:58:20.680Z"</code><br><code>"message":"Path doesn't exist",</code><br><code>"errorType":"io"</code><br><code>}</code></p>                            | timestamp: UTC representation of the response creation using ISO-8601 |

**Successful response body example**

```
{
  "uri": "https://<host>:<port>/2.0/directories/<path>",
  "totalCount": "number as string",
  "files": [
    {
      "id": "/<path>/dir1",
      "uri": "https://<host>:<port>/2.0/directories/<path>/dir1",
      "filename": "dir1",
      "owner": "",
      "directory": true,
      "attributes": {
        "dstFileName": "",
        "size": "",
        "correlationId": "",
        "putDate": "",
        "firstReadDate": "",
        "lastModifiedTime": "",
        "lastAccessTime": "",
        "creationTime": "",
        "datatype": "",
        "description": ""
      }
    },
    {
      "id": "/<path>/fileA.txt",
      "uri": "https://<host>:<port>/2.0/files/<path>/fileA.txt",
      "metaUri": "https://<host>:<port>/2.0/metadata/<path>/fileA.txt",
      "filename": "fileA.txt",
      "fileset": 54678,
      "owner": "",
      "directory": false,
      "attributes": {
        "dstFileName": "",
        "size": "206",
        "correlationId": "",
        "putDate": "2020-09-15T10:55:05.649Z",
        "firstReadDate": "",
        "lastModifiedTime": "2020-09-15T10:55:05.601Z",
        "lastAccessTime": "",
        "creationTime": "2020-09-15T10:55:05.601Z",
        "datatype": "application/octet-stream",
        "description": ""
      }
    }
  ]
}

```

#### Example

List the first 25 items in `httpapi`, sorted by size, descending:

```curl
curl -i  -X GET -v "https://myHostName:21080/2.0/directories/httpapi?sort=size&direction=DESC&start=0&limit=25" 
   -o cookies.txt
```
