---
title: "Swift (old)"
description: "Methods of the old Swift API version for working with S3"
---

import { CustomTable } from '@selectel/docux/components'

:::warning

The URL and methods of this Swift API version will be supported until 15.09.2026. After 15.09.2026, they will be disabled. Some features [will no longer be supported](/s3/manage/configure-storage-update/#unavailable-features).

We recommend using [S3 API](/api/object-storage-s3/), more details in the guide [Configuring S3 after an update](/s3/manage/configure-storage-update/).

:::

The Swift API is designed for applications that work with user files hosted in storage or send their own data to storage. Interaction with the Swift API is performed using standard HTTP requests. The documentation describes the currently available API calls and the formats of requests and responses. At this time, the following operations can be performed using the Swift API:

* get information about the account, containers, and folders;
* create and delete containers;
* upload files to storage and download them;
* copy, move, and delete files;
* set the file retention period, etc.

## URL format \{#url-format}

The host for all API requests is `https://api.selcdn.ru`

After authorization, access to the storage is performed via a URL of the type: `https://api.selcdn.ru/v1/SEL_ * * * **`, where ` * ****` is the user account number. The API version (v1) is also specified in the URL.

`https://api.selcdn.ru/v1/SEL_ * * ***/container_name` is usually used for an authorized client. For example, when working with private containers, deleting/adding objects, or working with metadata. This is the URL format in the OpenStack Object API. More details in the [OpenStack documentation](https://developer.openstack.org/api-ref/object-store/).

The domain ` * *****.selcdn.ru` is a personal account domain, which can be found via the X-Storage-Url header command:

```bash
curl -i \
-H 'X-Auth-User: *****' \
-H 'X-Auth-Key: *****' \
https://api.selcdn.ru/auth/v1.0
```

This domain is used to distribute static content from public containers. A CNAME record is created for this domain when using custom domains linked to a container, and data distributed through this domain is cached, which speeds up content delivery.

Both options will work, but `api.selcdn.ru` will not be cached.

You can also find your personal account domain in the [Control Panel](https://my.selectel.ru/storage/) in the container settings under the **Domains**.

You can get a domain using the API with the following request:

```bash
curl -i \
-H 'X-Auth-User: *' \
-H 'X-Auth-Key: *' \
https://auth.selcdn.ru/
```

In the future, we plan to discontinue numbered domains, so we recommend using links of the type `https://api.selcdn.ru/v1/SEL_ *****.`.

## API access \{#access-to-api}

To successfully execute API requests, you must:

* be a registered Selectel user;
* have a sufficient account balance;
* have a login and password for storage access;
* obtain a unique access key (token) that will be passed in all requests.

## Authorization and token acquisition \{#authorization-and-getting-token}

This section describes authorization methods and how to obtain a token for working with the API. Pool — ru-1, for software that requires specifying a pool (e.g., `--storage-openstack-region`).

When using all three methods, please note the following:

* the token lifetime is 24 hours;
* after 24 hours from the moment the token was last obtained, the API will return responses with code 401; in this case, the token must be obtained again;
* if you request a token 12 hours after the last authorization, it will be updated, and the previously obtained token will become invalid.

### Authorization via v1 protocol \{#authorization-by-protocol-v1}

#### Request example \{#authorization-by-protocol-v1-request-example}

```bash
curl -i -XGET https://api.selcdn.ru/auth/v1.0 -H "X-Auth-User: *****" -H "X-Auth-Key: $password"
```

Upon successful execution of the request, a response with code 204 (No Content) will be returned.

#### Response example \{#authorization-by-protocol-v1-response-example}

```
HTTP/1.1 204 No Content
Content-Type: text/plain; charset=utf-8
X-Storage-Token: $token
X-Content-Type-Options: nosniff
X-Expire-Auth-Token: *****
X-Auth-Token: $token
X-Storage-Url: https://api.selcdn.ru/v1/SEL_*****
```

#### Request parameters \{#authorization-by-protocol-v1-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>GET</td><td>`https://api.selcdn.ru/auth/v1.0`</td><td>X-Auth-User — account number; X-Auth-Key — password for storage access</td><td>Returns an authorization key (token) for working with storage via API, which must be passed in all subsequent requests</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

The password to access the storage is specified in the [Control Panel](https://my.selectel.ru/storage/users).

#### Response parameters \{#authorization-by-protocol-v1-response-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Parameter</th><th>Value</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>X-Expire-Auth-Token</td><td>authorization key lifetime (in seconds)</td>
      </tr>

      <tr>
        <td>X-Storage-URL</td><td>URL for storage access</td>
      </tr>

      <tr>
        <td>X-Auth-Token</td><td>authorization key</td>
      </tr>

      <tr>
        <td>X-Storage-Token</td><td>authorization key (same as the previous parameter)</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

### Authorization via v2 protocol \{#authorization-by-protocol-v2}

#### Request example \{#authorization-by-protocol-v2-request-example}

```
curl -i -XPOST https://api.selcdn.ru/v2.0/tokens -H "Content-type: application/json" -d '{"auth": {"passwordCredentials": {"username":"*****", "password":"pA$sW0rD"}}}'
```

#### Response example \{#authorization-by-protocol-v2-response-example}

```
HTTP/1.1 200 OK
Content-Length: 423
Content-Type: application/json
```

```
{"access":{"token":{"id":"49a049462d6943d55b2ccc85abd5fdae","expires":"2016-05-20T13:12:45\n","tenant":{"id":"00000","name":"00000"}},"user":{"id":"00000","name":"00000","roles":[]},"serviceCatalog":[{"endpoints":[{"region":"common","adminURL":"https://api.selcdn.ru/v1/SEL_00000","internalURL":"https://api.selcdn.ru/v1/SEL_0000","publicURL":"https://api.selcdn.ru/v1/SEL_00000"}],"type":"object-store","name":"swift"}]}}
```

### Authorization via v3 protocol \{#authorization-by-protocol-v3}

#### Request example \{#authorization-by-protocol-v3-request-example}

```bash
curl -i -XPOST https://api.selcdn.ru/v3/auth/tokens -d '{"auth": { "identity": { "methods": ["password"], "password": { "user": { "id": "*****", "password": "pA$sW0rD"}}}}}'
```

#### Response example \{#authorization-by-protocol-v3-response-example}

```
HTTP/1.1 200 OK
Content-Length: 807
Content-Type: application/json
X-Subject-Token: $token
```

```
{"token":{"expires_at":"2016-05-21T09:27:53.8459900Z","issued_at":"2016-05-20T15:56:36.8459900Z","methods":["password"],"project":{"domain":{}},"Catalog":[{"endpoints":[{"id":"614ed749fba45aa218d1ba68c7c83411","region_id":"RegionOne","url":"https://api.selcdn.ru/v1/SEL_*****","region":"RegionOne","interface":"public"},{"id":"614ed749fba45aa218d1ba68c7c83411","region_id":"RegionOne","url":"https://api.selcdn.ru/v1/SEL_*****","region":"RegionOne","interface":"admin"},{"id":"614ed749fba45aa218d1ba68c7c83411","region_id":"RegionOne","url":"https://api.selcdn.ru/v1/SEL_*****","region":"RegionOne","interface":"internal"}],"type":"object-store","name":"swift","id":""}],"user":{"id":"614ed749fba45aa218d1ba68c7c83411","name":"*****","domain":{"id":"default","name":"Default","links":{}}},"audit_ids":[""]}}
```

## Account operations \{#account-operations}

### Getting account information \{#get-info-about-account}

#### Request example \{#get-info-about-account-request-example}

```bash
curl -i -XGET https://api.selcdn.ru/v1/SEL_*****  -H "X-Auth-Token: $token"
```

In case of successful execution of the request, the API returns a response with code 204.

#### Response example \{#get-info-about-account-response-example}

```
HTTP/1.1 204 No Content
Content-Length: 0
X-Account-Object-Count: 6
X-Timestamp: 1374058535.42927
X-Account-Meta-Temp-Url-Key: 00000
X-Account-Bytes-Used: 484474
X-Account-Container-Count: 3
```

#### Response parameters \{#get-info-about-account-response-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Parameter</th><th>Value</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>X-Account-Bytes-Used</td><td>total volume of stored data, bytes</td>
      </tr>

      <tr>
        <td>X-Account-Container-Count</td><td>number of containers</td>
      </tr>

      <tr>
        <td>X-Account-Object-Count</td><td>total number of stored objects</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

### Getting storage information \{#get-info-about-storage}

Request type: GET

#### Request parameters \{#get-info-about-storage-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Parameter</th><th>Value</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>X-Auth-Token</td><td>authorization key</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#get-info-about-storage-request-example}

```bash
curl -i -XGET https://*****.selcdn.ru/ -H "X-Auth-Token: $token"
```

#### Response example \{#get-info-about-storage-response-example}

```
HTTP/1.1 204 No Content
Date: Tue, 28 Oct 2014 09:34:31 GMT
Server: Selectel_Storage/1.0
Content-Length: 0
X-Account-Object-Count: 6
X-Timestamp: 1374058535.42927
X-Account-Meta-Temp-Url-Key: *****
X-Account-Bytes-Used: 484474
X-Account-Container-Count: 3
Content-Type: text/plain; charset=utf-8
Accept-Ranges: bytes
X-Received-Bytes: 345102605
X-Transfered-Bytes: 54907061
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Account-Object-Count, X-Timestamp,
X-Account-Meta-Temp-Url-Key, X-Account-Bytes-Used, X-Account-Container-Count, X-Received-Bytes, X-Transfered-Bytes
Expires: 0
Pragma: no-cache
Cache-Control: no-cache, no-store, must-revalidate
```

#### Response parameters \{#get-info-about-storage-response-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Parameter</th><th>Value</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>X-Account-Bytes-Used</td><td>total volume of stored data, bytes</td>
      </tr>

      <tr>
        <td>X-Account-Container-Count</td><td>number of containers</td>
      </tr>

      <tr>
        <td>X-Account-Object-Count</td><td>total number of stored objects</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

## Container operations \{#container-operations}

### Getting a list of containers \{#get-list-of-containers}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>GET</td><td>`https://api.selcdn.ru/v1/SEL_ *****`</td><td>X-Auth-Token — authorization token</td><td>Returns a list of containers currently available in storage</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#get-list-of-containers-request-example-1}

```bash
curl https://api.selcdn.ru/v1/SEL_*****  -H "X-Auth-Token: $token"
```

#### Response example \{#get-list-of-containers-response-example-1}

```
container1
container2
container3
container4
```

#### Request example \{#get-list-of-containers-request-example-2}

```bash
curl -i -XGET https://*****.selcdn.ru/?format=json  -X GET -H "X-Auth-Token: $token"
```

#### Response example \{#get-list-of-containers-response-example-2}

```
HTTP/1.1 200 OK

Server: Selectel_Storage/1.0
X-Account-Object-Count: 6
X-Timestamp: 1374058535.42927
X-Account-Meta-Temp-Url-Key: ******
X-Account-Bytes-Used: 484474
X-Account-Container-Count: 3
Content-Type: application/json; charset=utf-8
Accept-Ranges: bytes
Content-Length: 300
X-Received-Bytes: 345102605
X-Transfered-Bytes: 54907061
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Account-Object-Count, X-Timestamp,
X-Account-Meta-Temp-Url-Key, X-Account-Bytes-Used, X-Account-Container-Count, X-Received-Bytes, X-Transfered-Bytes
Expires: 0
Pragma: no-cache
Cache-Control: no-cache, no-store, must-revalidate
[{"count": 1, "name": "test2", "rx_bytes": 363, "tx_bytes": 1006, "type": "public", "bytes": 363},
{"count": 1, "name": "upload", "rx_bytes": 0, "tx_bytes": 0, "type": "private", "bytes": 363},
{"count": 4, "name": "yellow", "rx_bytes": 484666, "tx_bytes": 264846, "type": "public", "bytes": 483748}]
```

#### Response parameters \{#get-list-of-containers-response-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Parameter</th><th>Value</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>X-Account-Container-Count</td><td>total number of containers in storage</td>
      </tr>

      <tr>
        <td>X-Account-Object-Count</td><td>total number of objects stored in containers</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

A single request can retrieve information about 10,000 containers. If there are more containers, additional requests with the marker parameter are required.

### Creating a new container \{#create-new-container}

#### Request parameters \{#create-new-container-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>PUT</td><td>`https://api.selcdn.ru/v1/SEL_******/container`</td><td>X-Auth-Token — authorization token; X-Container-Meta-Type — container type: public (public) or private (private); X-Container-Meta-Some — container metadata; X-Storage-Policy — storage policy: hot (Policy-0) by default, cold (cold)<p /><p /><p /><p /><p /></td><td>Creates a container with the parameters specified in the request</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#create-new-container=request-example}

```bash
curl -i -XPUT https://api.selcdn.ru/v1/SEL_*****/new_container -H "X-Auth-Token: $token" \
-H "X-Container-Meta-Type: public" -H "X-Container-Meta-Some: my test container"
```

In case of a successful request, a response with code 201 will be returned.

#### Response example \{#create-new-container-response-example}

```
HTTP/1.1 201 Created
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Length: 0
Content-Type: text/html
```

### Getting information about a container \{#get-info-about-container}

#### Request parameters \{#get-info-about-container-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>GET</td><td>`https://api.selcdn.ru/v1/SEL_******/container`</td><td>X-Auth-Token — authorization token</td><td>Returns information about the specified container</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Response parameters \{#get-info-about-container-reponse-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Parameter</th><th>Value</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>X-Container-Object-Count</td><td>number of objects in the container</td>
      </tr>

      <tr>
        <td>X-Container-Bytes-Used</td><td>total volume of all stored objects in bytes</td>
      </tr>

      <tr>
        <td>X-Container-Meta-Type</td><td>container type (public or private)</td>
      </tr>

      <tr>
        <td>X-Container-Meta-Some</td><td>container metadata</td>
      </tr>

      <tr>
        <td>X-Container-Domains</td><td>domains linked to the container</td>
      </tr>

      <tr>
        <td>X-Transfered-Bytes</td><td>total volume of information downloaded from the container, bytes</td>
      </tr>

      <tr>
        <td>X-Received-Bytes</td><td>total volume of information uploaded to the container, bytes</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#get-info-about-container-request-example}

```bash
curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/t-rex -H "X-Auth-Token: $token"
```

Upon successful execution of the request, the API returns a response with code 204.

#### Response example \{#get-info-about-container-response-example}

```
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Length,Date,X-Container-Domains,X-Backend-Delete-Timestamp,X-Timestamp,X-Container-Meta-Type,X-Backend-Status-Changed-At,X-Backend-Storage-Policy-Index,X-Container-Object-Count,X-Backend-Put-Timestamp,X-Container-Bytes-Used,Content-Type,X-Backend-Timestamp,X-Put-Timestamp
Content-Type: text/plain; charset=utf-8
Date: Wed, 14 Mar 2018 08:43:43 GMT
X-Backend-Delete-Timestamp: 0000000000.00000
X-Backend-Put-Timestamp: 1445521637.35495
X-Backend-Status-Changed-At: 1445521364.56786
X-Backend-Storage-Policy-Index: 0
X-Backend-Timestamp: 1445521364.51371
X-Container-Bytes-Used: 2455570
X-Container-Domains:
X-Container-Meta-Type: gallery
X-Container-Object-Count: 9
X-Put-Timestamp: 1445521637.35495
X-Timestamp: 1445521364.51371
```

### Setting, changing, and deleting container metadata \{#set-edit-delete-container-metadata}

#### Request parameters \{#set-edit-delete-container-metadata-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>POST</td><td>`https://api.selcdn.ru/v1/SEL_******/container`</td><td>X-Auth-Token — authorization token; X-Container-Meta-Type; X-Container-Meta-Some — container metadata</td><td>Sets the metadata for the specified container passed in the X-Container-Meta-Some header</td>
      </tr>

      <tr>
        <td>POST</td><td>`https://api.selcdn.ru/v1/SEL_******/container`</td><td>X-Auth-Token — authorization token; X-Container-Meta-Some — container metadata</td><td>Replaces metadata with new metadata passed in the X-Container-Meta-Some header</td>
      </tr>

      <tr>
        <td>POST</td><td>`https://api.selcdn.ru/v1/SEL_******/container`</td><td>X-Auth-Token — authorization token; X-Remove-Container-Meta-Some — container metadata to be deleted</td><td>Deletes metadata passed in the X-Remove-Container-Meta-Some header</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#set-edit-delete-container-metadata-request-example}

```bash
curl -i -XPOST {storage_url}/{container_name} -H "X-Auth-Token: $token" -H "X-Container-Meta-Type: gallery"
```

### Getting a list of files in a container \{#get-list-of-files}

#### Request parameters \{#get-list-of-files-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>GET</td><td>`https://api.selcdn.ru/v1/SEL_******/container_name`</td><td>X-Auth-Token — authorization token</td><td>Returns a list of files located in the specified container. The list of objects is limited to 10,000. Use the marker and limit query parameters for flexible retrieval of object lists in a container.</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#get-list-of-files-request-example}

```bash
curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container_name  -H "X-Auth-Token: $token"
```

#### Response example \{#get-list-of-files-response-example}

```
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Storage-Policy-Index,X-Backend-Status-Changed-At,X-Put-Timestamp,
X-Container-Meta-Type,X-Timestamp,X-Backend-Delete-Timestamp,X-Backend-Timestamp,X-Backend-Put-Timestamp,
X-Container-Bytes-Used,Content-Length,X-Container-Object-Count,Content-Type,Date
Content-Length: 120
Content-Type: text/plain; charset=utf-8
Date: Wed, 14 Mar 2018 09:11:28 GMT
X-Backend-Delete-Timestamp: 0000000000.00000
X-Backend-Put-Timestamp: 1445521637.35495
X-Backend-Status-Changed-At: 1445521364.56786
X-Backend-Storage-Policy-Index: 0
X-Backend-Timestamp: 1445521364.51371
X-Container-Bytes-Used: 2455570
X-Container-Meta-Type: gallery
X-Container-Object-Count: 9
X-Put-Timestamp: 1445521637.35495
X-Timestamp: 1445521364.51371
```

```
File1
File2
File3
File4
```

### Additional query parameters \{#additional-query-parameters}

In the request to get a list of files, you can also use additional query parameters, for example:

```bash
curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container/?format=json -H "X-Auth-Token: $token"
```

As a result of executing this command, a list of files will be returned in json format. You can also specify another output format — xml:

```bash
curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container/?format=xml -H "X-Auth-Token: $token"
```

Using the limit parameter, you can set the exact number of files that will be included in the list. This opportunity is useful when working with containers that store many objects (for example, thousands or even tens of thousands):

```bash
curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container/?limit=20 -H "X-Auth-Token: $token"
```

As a result of executing this command, only the first 20 files will be included in the list. Information about all other files will not be in the list.

The marker parameter allows you to specify the name of the file from which the list will begin:

```bash
curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container/?marker=file3 -H "X-Auth-Token: $token"
```

As a result of executing this request, the list will display files that follow the file named file3. Previous files, as well as file3 itself, will not be included in the list.

Using the prefix parameter, you can include files in the list whose names start with the specified character sequence:

```bash
curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container/?prefix=my_ -H "X-Auth-Token: $token"
```

Using the delimiter parameter, you can display only the part of the file name that precedes a specific character, for example:

```bash
curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container/?delimiter=.
```

As a result of executing this command, only the part of the file names that precedes the dot (only names without extensions) will be output.

### Deleting a container \{#delete-container}

Before deleting a container, you must delete all files from it. If there is at least one file in the container, deletion is impossible.

#### Request parameters \{#delete-container-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>DELETE</td><td>`https://api.selcdn.ru/v1/SEL_******/container`</td><td>X-Auth-Token — authorization token</td><td>Deletes the specified container</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#delete-container-request-example}

```bash
curl -i https://api.selcdn.ru/v1/SEL_*****/container/ -X DELETE -H "X-Auth-Token: $token"
```

In case of success, the API returns a response with code 204.

#### Response example \{#delete-container-response-example}

```
HTTP/1.1 204 No Content
content-length: 0
content-type: text/html; charset=UTF-8
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers:
```

## Working with files \{#files}

### Downloading a file from a container \{#download-file}

#### Request parameters \{#download-file-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>GET</td><td>`https://api.selcdn.ru/v1/SEL_******/container/file`</td><td>X-Auth-Token — authorization token (required only when downloading from a private container; files from public containers can be downloaded without a token). You can also use standard HTTP headers described in RFC2616 in the request: If-Match, If-None-Match, If-Modified-Since, If-Unmodified-Since</td><td>Downloads the specified file</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#download-file-request-example}

```bash
curl -O https://api.selcdn.ru/v1/SEL_*****/images/image1.png
```

To open a file in a browser, enter the command:

```
https://*****.selcdn.ru/container/1111_Union.patch.xml
```

The response will look as follows:

```
HTTP/2 200
accept-language: bytes
access-control-allow-origin: *
access-control-expose-headers: Content-Type,Etag,X-Client,X-Timestamp,X-Trans-Id,Content-Length,Last-Modified,Accept-Ranges
content-length: 5782
content-type: application/xml
etag: "61808ed864f4c3453d329071986b04ba"
```

To download a file without opening it in a browser, add the get parameter **?filename=some\_name.ext** to the link:

```
https://*****.selcdn.ru/container/1111_Union.patch.xml?filename=Union.patch.xml
```

The browser will prompt you to download the file named Union.patch.xml. The response will look as follows:

```
HTTP/2 200
accept-language: bytes
access-control-allow-origin: *
access-control-expose-headers: Etag,X-Client,X-Timestamp,X-Trans-Id,Last-Modified,Accept-Ranges,Content-Length,Content-Type
content-disposition: attachment; filename="1111_Union.patch.xml" <- this response adds this header, which tells the browser to download the file
content-length: 5782
content-type: application/xml
etag: "61808ed864f4c3453d329071986b04ba"
```

### Uploading a file to a container \{#upload-file}

#### Request parameters \{#upload-file-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>PUT</td><td>`https://api.selcdn.ru/v1/SEL_******/container/file`</td><td>X-Auth-Token — authorization token; X-Delete-At — file deletion time in Unix Timestamp format; X-Delete-After — file retention period (in seconds); Etag — Etag identifier; X-Object-Meta — metadata of the uploaded object</td><td>Uploads an object to the specified container</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#upload-file-request-example}

```bash
curl -i -XPUT https://api.selcdn.ru/v1/SEL_*****/new_container/file  -H "X-Auth-Token: $token" -H "X-Delete-After: 180"  -T "file"
```

Upon successful request, a response with code 201 will be returned.

#### Response example \{#upload-file-response-example}

```
HTTP/1.1 100 Continue
HTTP/1.1 201 Created
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Length: 0
Content-Type: text/html
Etag: b65ad34618e410d9d8bf624d61f8a980
Date: Thu, 15 Mar 2018 07:31:32 GMT
```

### Deleting a file \{#delete-file}

#### Request parameters \{#delete-file-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>DELETE</td><td>https://api.selcdn.ru/v1/SEL\_\*\*\*\*\*\*/container/file</td><td>X-Auth-Token — authorization token</td><td>Deletes the specified file</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#delete-file-request-example}

```bash
curl -i -XDELETE https://api.selcdn.ru/v1/SEL_*****/container/file -H "X-Auth-Token: $token"
```

In case of success, the API returns a response with code 204.

#### Response example \{#delete-file-response-example}

```
HTTP/1.1 204 No Content
content-length: 0
content-type: text/html; charset=UTF-8
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers:
```

### Deleting multiple objects from storage \{#delete-multiple-objects}

The bulk-delete command, unlike the delete command:

* allows you to delete several files simultaneously;
* allows you to delete objects from different containers simultaneously;
* works sequentially.

Only the main user token is suitable for this command.

#### Request parameters \{#delete-multiple-objects-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>POST</td><td>`https://api.selcdn.ru/v1/SEL_******?bulk-delete=true`</td><td>X-Auth-Token — authorization token; X-Delete-After — file retention period (in seconds)</td><td>Deletes several specified files simultaneously</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#delete-multiple-objects-request-example}

```bash
curl -i -XPOST "https://api.selcdn.ru/v1/SEL_******?bulk-delete=true" -H "X-Auth-Token: $token" -H "Content-Type: text/plain" --data $"container/file1\ncontainer/file2\n"
```

Upon successful execution of the request, a response with code 200 is returned.

#### Response example \{#delete-multiple-objects-response-example}

```
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Type: application/json; charset=utf-8
Date: Fri, 08 Jun 2018 13:37:53 GMT
Content-Length: 101
{"Number Not Found":0,"Response Status":"200 OK","Response Body":"","Errors":null,"Number Deleted":2}
```

### Delayed deletion using X-Delete \{#x-delete}

There are two possible header options:

* X-Delete-At;
* X-Delete-After.

Both options allow setting a time interval for automatic deletion of an object from storage. Headers are sent using PUT and POST requests.

#### X-Delete-At \{#x-delete-at}

The header value passed is a timestamp in Unix Epoch format. This value tells the server until what time the object should be stored. To convert to a human-readable format, it is convenient to use an [online converter ](https://www.epochconverter.com/)(.

<CustomTable>
  <table>
    <tbody>
      <tr>
        <td>Unix Epoch</td><td>Human View</td>
      </tr>

      <tr>
        <td>1317070737</td><td>Mon Sep 26 20:58:57 2011 UTC</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### X-Delete-After \{#x-delete-after}

The header value passed is an integer number of seconds after which the object will be scheduled for deletion. Upon receiving this value, the server converts it to an X-Delete-At header and stops storing the object when that time value is reached.

*Access to objects for which the X-Delete-\* header was passed ceases after the time value has elapsed. The server, in response to a request for such an object, will return a 404 response. The objects themselves are automatically deleted after some time.*

#### Double header \{#double-header}

If both headers are passed to an object simultaneously, the system will prioritize the X-Delete-After header.

#### Internal operations \{#internal-operations}

The current implementation has the following features:

* if an object having X-Delete-At is placed via PUT into a container with a modified header, the object's header will be overwritten by the container's header;
* if an object having X-Delete-At is placed via PUT with the X-Copy-From header set into a container that already has a modified header, the object's header will be preserved from the previous source and will not be overwritten;
* when copying an object with the X-Delete-At header set using COPY and the Destination header — the header is not preserved;
* when placing an object into a container for versioned objects via the control panel S3, the X-Delete-At / X-Delete-After header will be kept unchanged and the object will be deleted according to the specified value;
* when placing an object into a container for versioned objects via API (COPY command with Destination header), the header is not preserved.

### Managing HTTP headers for files \{#manage-https-headers-for-files}

You can set HTTP headers for all files placed in storage. Headers are used for controlling caching on the client side (and on intermediate proxy servers), as well as for processing cross-domain requests (CORS).

The following headers are supported:

* Cache-Control
* Access-Control-Allow-Origin
* Access-Control-Max-Age
* Access-Control-Allow-Methods
* Access-Control-Allow-Credentials
* Access-Control-Expose-Headers
* Access-Control-Allow-Headers
* Link
* Content-Type
* Content-Disposition (final file only)
* Strict-Transport-Security (container only)

#### Request parameters \{#manage-https-headers-for-files-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>POST</td><td>`https://api.selcdn.ru/v1/SEL_******/container`</td><td>X-Auth-Token — authorization token; X-Container-Meta-…. — header whose parameters need to be set (the header itself is specified after -Meta-, for example: X-Container-Meta-Cache-Control</td><td>Sets values for the headers specified in the request</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#manage-https-headers-for-files-request-example}

```bash
curl -i -XPOST  https://api.selcdn.ru/v1/SEL_*****/container -H "X-Auth-Token: $token" \
-H "X-Container-Meta-Access-Control-Allow-Methods: HEAD, GET" \
-H "X-Container-Meta-Cache-Control: public" \
-H "X-Container-Meta-Strict-Transport-Security: max-age=31536000; includeSubDomains"
```

In case of success, the API returns a response with code 202.

To add the `Link` header to the file1 object, enter:

```bash
curl -i -XPOST https://api.selcdn.ru/v1/SEL_*****/container/file1 -H "X-Auth-Token: $token" -H "Link: rel=canonical"
```

To add this header to all objects in a container at once, use the following request:

```bash
curl -i -XPOST https://api.selcdn.ru/v1/SEL_*****/container -H "X-Auth-Token: $token" -H "X-Container-Meta-Link: rel=canonical"
```

#### Response example \{#manage-https-headers-for-files-response-example}

```
HTTP/1.1 202 Accepted
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Length: 76
Content-Type: text/html
```

### Viewing headers of a specific object \{#view-object-headers}

To view the headers of a specific object, enter:

```bash
curl --head https://api.selcdn.ru/v1/SEL_*****/images/file.png
```

### Support for large objects \{#supporting-big-objects}

There are no size restrictions for uploaded files in storage, but it is not recommended to place files larger than 100 MB into storage as a whole — you should use segmented uploading.

There are two options for segmented uploading: dynamic and static.

#### Dynamic uploading \{#dynamic-upload}

In dynamic uploading, an object is split into segments, after which a manifest is created — an empty file containing a pointer to the container where all segments are uploaded. In the request to upload a large object, the path to the container is specified in the X-Object-Manifest header.

It is advisable to upload segments first and then create or update the manifest: the object will not be available for downloading until the upload of all segments is completed.

##### Example \{#dynamic-upload-example}

```bash
curl -X PUT -H "X-Auth-Token: $token"  https://api.selcdn.ru/v1/SEL_*****/new_container/big_object/00000001 --data-binary "1" \
curl -X PUT -H "X-Auth-Token: $token"  https://api.selcdn.ru/v1/SEL_*****/new_container/big_object/00000002 --data-binary "2" \
curl -X PUT -H "X-Auth-Token: $token"  https://api.selcdn.ru/v1/SEL_*****/new_container/big_object/00000003 --data-binary "3"
```

##### Manifest example \{#dynamic-upload-manifest-example}

```bash
curl -X PUT -H "X-Auth-Token: $token" -H "X-Object-Manifest: new_container/big_object/" https://api.selcdn.ru/v1/SEL_*****/new_container/big_object --data-binary ""
```

#### Static uploading \{#static-upload}

During static uploading, you need to create a static manifest specifying paths to segments, their checksum (Etag), and size. The manifest is saved in a special file.

##### Manifest example \{#static-upload-manifest-example}

```
[{"path": "/cont/object",  "etag": "etagoftheobjectsegment",  "size_bytes": 10485760, }, ...]
```

The manifest file must be uploaded to storage using a PUT request with the query parameter **?multipart-manifest=put** and the header **X-Static-Large-Object: True**.

To get the manifest file, you need to execute a GET request with the query parameter **?multipart-manifest=get**.

You can delete all segments and then the manifest file using a DELETE request with the query parameter **?multipart-manifest=delete**.

### Setting a retention period for files \{#set-storage-period-for-files}

#### Request parameters \{#set-storage-period-for-files-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>PUT</td><td>https://api.selcdn.ru/v1/SEL\_\*\*\*\*\*\*/container</td><td>X-Auth-Token — authorization token; X-Container-Meta-Default-Delete-After — retention period for all files in the container (in seconds)</td><td>Sets the retention period for all files placed in the container. Upon expiry of this period, all files will be automatically deleted</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#set-storage-period-for-files-request-example}

```bash
curl -i -XPUT https://api.selcdn.ru/v1/SEL_*****/container  -H "X-Auth-Token: $token" \
-H "X-Container-Meta-Default-Delete-After: 300"
```

Upon successful request, a response with code 202 will be returned.

#### Response example \{#set-storage-period-for-files-response-example}

```
HTTP/1.1 202 Accepted
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Length: 76
Content-Type: text/html
```

### Setting file metadata \{#set-file-metadata}

#### Request parameters \{#set-file-metadata-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>POST</td><td>`https://api.selcdn.ru/v1/SEL_******/container/file`</td><td>X-Auth-Token — authorization token; X-Object-Meta-Some — any additional information about the file</td><td>Adds metadata passed in the X-Object-Meta-Some header to the file</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#set-file-metadata-request-example}

```bash
curl -i -XPOST  https://api.selcdn.ru/v1/SEL_***/new_container/file -H "X-Auth-Token: $token" -H "X-Object-Meta-Some: metadata"
```

In case of success, the API returns a response with code 201.

#### Response example \{#set-file-metadata-response-example}

```
HTTP/1.1 201 Created
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Length: 0
Content-Type: text/html
Etag: d41d8cd98f00b204e9800998ecf8427e
```

### Copying files within storage \{#copy-files}

#### Method 1 \{#copy-files-1}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>PUT</td><td>`https://api.selcdn.ru/v1/SEL_******/new_location/path to container and destination folder/file name`</td><td>X-Auth-Token — authorization token; X-Copy-From — path to the file to be copied</td><td>Copies a file from one location to another</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

During this operation, the value of the x-delete-at header is also copied, regardless of where this header was set — on the source object or the source container.

##### Request example \{#copy-files-1-request-example}

```bash
curl -i -X PUT https://api.selcdn.ru/v1/SEL_*****/container2/file -H "X-Auth-Token: $token" -H "X-Copy-From: /container1/file"
```

##### Response example \{#copy-files-1-response-example}

```
HTTP/1.1 201
Created etag: 0f343b0931126a20f133d67c2b018a3b
X-Copied-From: new_container/new_object
X-Copied-From-Last-Modified: Mon, 27 May 2013 13:16:49 GMT
Last-Modified: Tue, 28 May 2018 06:30:51 GMT
```

#### Method 2 \{#copy-files-2}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>COPY</td><td>`https://api.selcdn.ru/v1/SEL_******/container/file/path to file/`</td><td>X-Auth-Token — authorization token; Destination — path to the container and folder where you need to copy the file</td><td>Copies a file from one location to another</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

If you set the header -H "X-Fresh-Metadata: true" when using this method, the new object will be created with new headers upon copying, including without X-Delete-At.

##### Request example \{#copy-files-2-request-example}

```bash
curl -i -X COPY https://api.selcdn.ru/v1/SEL_*****/container1/file -H "X-Auth-Token: $token" -H "Destination: /container2/file"
```

##### Response example \{#copy-files-2-response-example}

```
HTTP/1.1 201
Created etag: 0f343b0931126a20f133d67c2b018a3b
X-Copied-From: container1/file
X-Copied-From-Last-Modified: Mon, 27 May 2013 13:16:49 GMT
Last-Modified: Tue, 28 May 2013 06:30:51 GMT
```

## Setting limits \{#set-limits}

### Setting limits for a container \{#set-container-limits}

#### Request parameters \{#set-container-limits-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>POST</td><td>`https://api.selcdn.ru/v1/SEL_******/container/`</td><td>X-Auth-Token — authorization token; X-Container-Meta-Quota-Bytes — maximum storage data volume (in bytes); X-Container-Meta-Quota-Count — maximum number of files and folders in a container</td><td>Sets limits for the specified container passed in the X-Container-Meta-Quota-Bytes and X-Container-Meta-Quota-Count headers</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#set-container-limits-request-example}

```bash
curl -i -XPOST https://api.selcdn.ru/v1/SEL_*****/container/  -H "X-Auth-Token: $token" \
-H "X-Container-Meta-Quota-Bytes: 52428800" -H "X-Container-Meta-Quota-Count: 1000"
```

In case of success, a response with code 202 will be returned.

#### Response example \{#set-container-limits-response-example}

```
HTTP/1.1 202 Accepted
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Length: 76
Content-Type: text/html
```

### Setting limits for an account \{#set-account-limits}

#### Request parameters \{#set-account-limits-request-parameters}

<CustomTable>
  <table>
    <thead>
      <tr>
        <th>Request type</th><th>URI</th><th>Headers</th><th>Description</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>POST</td><td>`https://api.selcdn.ru/v1/SEL_*****/`</td><td>X-Auth-Token — authorization token; X-Account-Meta-Quota-Bytes — maximum storage data volume (in bytes)</td><td>Sets the limit for the specified account passed in the X-Account-Meta-Quota-Bytes header</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

#### Request example \{#set-account-limits-request-example}

```bash
curl -i -XPOST https://api.selcdn.ru/v1/SEL_***** -H "X-Auth-Token: $token" \
-H "X-Account-Meta-Quota-Bytes: 52428800"
```

#### Response example \{#set-account-limits-response-example}

```
HTTP/1.1 202 Accepted
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Length: 76
Content-Type: text/html
```
