# Public Cloud › Storage › Object Storage › Swift Object Storage API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Public Cloud product's sections: https://developers.eu.ovhcloud.com/reference/public-cloud/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 5 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/public-cloud/storage/object-storage/swift-object-storage/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/public-cloud/storage/object-storage/swift-object-storage.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/public-cloud/storage/object-storage/swift-object-storage.json?format=openapi3

## Operations

- `GET /publicCloud/project/{projectId}/storage/swift/container` — List containers
- `POST /publicCloud/project/{projectId}/storage/swift/container` — Create a container
- `GET /publicCloud/project/{projectId}/storage/swift/container/{containerId}` — Get a container
- `PUT /publicCloud/project/{projectId}/storage/swift/container/{containerId}` — Update a container
- `DELETE /publicCloud/project/{projectId}/storage/swift/container/{containerId}` — Delete a container

## List containers

`GET /v2/publicCloud/project/{projectId}/storage/swift/container`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/storage/object-storage/swift-object-storage/#getSwiftContainers

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:storage/swift/container/get`

Returns the containers of the project across every region offering Swift object storage.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `X-Pagination-Cursor` | header | string |  | Pagination cursor |
| `X-Pagination-Size` | header | integer |  | Pagination size |
| `projectId` | path | string | yes | Project ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.storage.swift.Container[] | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Computed hash representing the current target specification value |
| `createdAt` | string (date-time) | read-only | Creation date of the container |
| `currentState` | publicCloud.storage.swift.ContainerCurrentState | read-only | Current observed state of the container, read from the Swift backend |
| `currentState.archive` | boolean | read-only | Whether the container uses the Public Cloud Archive storage policy (X-Storage-Policy: PCA). Objects in an archive container are sealed after upload and must be unsealed before download. |
| `currentState.cors` | string[] | read-only | Origins currently allowed to access the container from a browser (Access-Control-Allow-Origin container metadata). Empty when no origin is allowed. |
| `currentState.location` | publicCloud.common.Location | read-only | Region hosting the container |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.name` | string | read-only | Container name |
| `currentState.objectsCount` | integer | read-only | Number of objects stored in the container |
| `currentState.objectsSize` | integer | read-only | Total size of the objects stored in the container in bytes |
| `currentState.staticUrl` | string | read-only | Public URL of the container, only set when type is PUBLIC or STATIC. Built from the URL-encoded container name, the project's Swift account and the region's object-store endpoint. |
| `currentState.type` | publicCloud.storage.swift.ContainerTypeEnum | read-only | Access type of the container, derived from its read ACL and static website metadata: STATIC when the website metadata is set, PUBLIC when only the public read ACL is set, PRIVATE otherwise — one of `PRIVATE`, `PUBLIC`, `STATIC` |
| `currentTasks` | common.CurrentTask[] | read-only | Ongoing asynchronous tasks related to the container |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string | read-only | Container identifier, built as <REGION>_<name>, for example GRA_my-container. A container name is unique within a region of the project, so the pair identifies it. |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Container readiness in the system — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.storage.swift.ContainerTargetSpec | read-only | Last target specification of the container |
| `targetSpec.archive` | boolean |  | Create the container with the Public Cloud Archive storage policy (X-Storage-Policy: PCA) instead of the standard policy. Objects in an archive container are sealed after upload and must be unsealed (retrieval) before download. Immutable after creation. Defaults to false. |
| `targetSpec.cors` | string[] |  | Origins allowed to access the container from a browser (Access-Control-Allow-Origin container metadata), for example https://www.example.com. Duplicates are removed. Defaults to no origin, which blocks cross-origin browser requests. |
| `targetSpec.location` | publicCloud.common.Location | yes | Region hosting the container. Only region is used. availabilityZone is ignored because Swift is region-wide. The region is part of the container identifier and cannot be changed. |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Container name, unique within the region. At most 256 bytes and must not contain a slash (/). Immutable after creation. |
| `targetSpec.type` | publicCloud.storage.swift.ContainerTypeEnum |  | Access type of the container. PRIVATE requires a token or a presigned URL to read objects. PUBLIC lets anyone read and list objects. STATIC also serves the container as a static website: index.html as the index page, error.html on errors and listing.css to style listings. Default versions of these three files are pushed to the container when it is switched to STATIC. Defaults to PRIVATE. — one of `PRIVATE`, `PUBLIC`, `STATIC` |
| `updatedAt` | string (date-time) | read-only | Last update date of the container |

```json
[
  {
    "checksum": "string",
    "createdAt": "2024-01-01T12:00:00Z",
    "currentState": {
      "archive": true,
      "cors": [
        "string"
      ],
      "location": {
        "availabilityZone": "string",
        "region": "string"
      },
      "name": "string",
      "objectsCount": 0,
      "objectsSize": 0,
      "staticUrl": "string",
      "type": "PRIVATE"
    },
    "currentTasks": [
      {
        "errors": [
          {
            "message": "string"
          }
        ],
        "id": "00000000-0000-0000-0000-000000000000",
        "link": "string",
        "status": "ERROR",
        "type": "string"
      }
    ],
    "id": "string",
    "resourceStatus": "CREATING",
    "targetSpec": {
      "archive": true,
      "cors": [
        "string"
      ],
      "location": {
        "availabilityZone": "string",
        "region": "string"
      },
      "name": "string",
      "type": "PRIVATE"
    },
    "updatedAt": "2024-01-01T12:00:00Z"
  }
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/swift/container" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/v2/publicCloud/project/{projectId}/storage/swift/container")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/v2/publicCloud/project/{projectId}/storage/swift/container");

print_r($result);
?>
```

## Create a container

`POST /v2/publicCloud/project/{projectId}/storage/swift/container`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/storage/object-storage/swift-object-storage/#createSwiftContainer

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:storage/swift/container/create`

Creates a container in a region. The archive policy, the access type and the CORS origins can be set at creation. Name, region and archive policy cannot be changed afterward.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |

### Request body (required)

Type: `publicCloud.storage.swift.ContainerCreation`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `targetSpec` | publicCloud.storage.swift.ContainerTargetSpec | yes | Desired target specification for the container to create |
| `targetSpec.archive` | boolean |  | Create the container with the Public Cloud Archive storage policy (X-Storage-Policy: PCA) instead of the standard policy. Objects in an archive container are sealed after upload and must be unsealed (retrieval) before download. Immutable after creation. Defaults to false. |
| `targetSpec.cors` | string[] |  | Origins allowed to access the container from a browser (Access-Control-Allow-Origin container metadata), for example https://www.example.com. Duplicates are removed. Defaults to no origin, which blocks cross-origin browser requests. |
| `targetSpec.location` | publicCloud.common.Location | yes | Region hosting the container. Only region is used. availabilityZone is ignored because Swift is region-wide. The region is part of the container identifier and cannot be changed. |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Container name, unique within the region. At most 256 bytes and must not contain a slash (/). Immutable after creation. |
| `targetSpec.type` | publicCloud.storage.swift.ContainerTypeEnum |  | Access type of the container. PRIVATE requires a token or a presigned URL to read objects. PUBLIC lets anyone read and list objects. STATIC also serves the container as a static website: index.html as the index page, error.html on errors and listing.css to style listings. Default versions of these three files are pushed to the container when it is switched to STATIC. Defaults to PRIVATE. — one of `PRIVATE`, `PUBLIC`, `STATIC` |

```json
{
  "targetSpec": {
    "archive": true,
    "cors": [
      "string"
    ],
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "type": "PRIVATE"
  }
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.storage.swift.Container | successful operation |
| 400 | object | Error 400 response |
| 409 | object | Error 409 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Computed hash representing the current target specification value |
| `createdAt` | string (date-time) | read-only | Creation date of the container |
| `currentState` | publicCloud.storage.swift.ContainerCurrentState | read-only | Current observed state of the container, read from the Swift backend |
| `currentState.archive` | boolean | read-only | Whether the container uses the Public Cloud Archive storage policy (X-Storage-Policy: PCA). Objects in an archive container are sealed after upload and must be unsealed before download. |
| `currentState.cors` | string[] | read-only | Origins currently allowed to access the container from a browser (Access-Control-Allow-Origin container metadata). Empty when no origin is allowed. |
| `currentState.location` | publicCloud.common.Location | read-only | Region hosting the container |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.name` | string | read-only | Container name |
| `currentState.objectsCount` | integer | read-only | Number of objects stored in the container |
| `currentState.objectsSize` | integer | read-only | Total size of the objects stored in the container in bytes |
| `currentState.staticUrl` | string | read-only | Public URL of the container, only set when type is PUBLIC or STATIC. Built from the URL-encoded container name, the project's Swift account and the region's object-store endpoint. |
| `currentState.type` | publicCloud.storage.swift.ContainerTypeEnum | read-only | Access type of the container, derived from its read ACL and static website metadata: STATIC when the website metadata is set, PUBLIC when only the public read ACL is set, PRIVATE otherwise — one of `PRIVATE`, `PUBLIC`, `STATIC` |
| `currentTasks` | common.CurrentTask[] | read-only | Ongoing asynchronous tasks related to the container |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string | read-only | Container identifier, built as <REGION>_<name>, for example GRA_my-container. A container name is unique within a region of the project, so the pair identifies it. |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Container readiness in the system — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.storage.swift.ContainerTargetSpec | read-only | Last target specification of the container |
| `targetSpec.archive` | boolean |  | Create the container with the Public Cloud Archive storage policy (X-Storage-Policy: PCA) instead of the standard policy. Objects in an archive container are sealed after upload and must be unsealed (retrieval) before download. Immutable after creation. Defaults to false. |
| `targetSpec.cors` | string[] |  | Origins allowed to access the container from a browser (Access-Control-Allow-Origin container metadata), for example https://www.example.com. Duplicates are removed. Defaults to no origin, which blocks cross-origin browser requests. |
| `targetSpec.location` | publicCloud.common.Location | yes | Region hosting the container. Only region is used. availabilityZone is ignored because Swift is region-wide. The region is part of the container identifier and cannot be changed. |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Container name, unique within the region. At most 256 bytes and must not contain a slash (/). Immutable after creation. |
| `targetSpec.type` | publicCloud.storage.swift.ContainerTypeEnum |  | Access type of the container. PRIVATE requires a token or a presigned URL to read objects. PUBLIC lets anyone read and list objects. STATIC also serves the container as a static website: index.html as the index page, error.html on errors and listing.css to style listings. Default versions of these three files are pushed to the container when it is switched to STATIC. Defaults to PRIVATE. — one of `PRIVATE`, `PUBLIC`, `STATIC` |
| `updatedAt` | string (date-time) | read-only | Last update date of the container |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "currentState": {
    "archive": true,
    "cors": [
      "string"
    ],
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "objectsCount": 0,
    "objectsSize": 0,
    "staticUrl": "string",
    "type": "PRIVATE"
  },
  "currentTasks": [
    {
      "errors": [
        {
          "message": "string"
        }
      ],
      "id": "00000000-0000-0000-0000-000000000000",
      "link": "string",
      "status": "ERROR",
      "type": "string"
    }
  ],
  "id": "string",
  "resourceStatus": "CREATING",
  "targetSpec": {
    "archive": true,
    "cors": [
      "string"
    ],
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "type": "PRIVATE"
  },
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/swift/container" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: publicCloud.storage.swift.ContainerCreation
result = client.post("/v2/publicCloud/project/{projectId}/storage/swift/container",
	targetSpec = None, # Desired target specification for the container to create (type: publicCloud.storage.swift.ContainerTargetSpec)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: publicCloud.storage.swift.ContainerCreation
$result = $ovh->post("/v2/publicCloud/project/{projectId}/storage/swift/container", array(
	targetSpec => null, // Desired target specification for the container to create (type: publicCloud.storage.swift.ContainerTargetSpec)
));

print_r($result);
?>
```

## Get a container

`GET /v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/storage/object-storage/swift-object-storage/#getSwiftContainer

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:storage/swift/container/get`

Returns the container configuration and its current state, including its object count and stored size.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `containerId` | path | string | yes | Container ID |
| `projectId` | path | string | yes | Project ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.storage.swift.Container | successful operation |
| 404 | object | Error 404 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Computed hash representing the current target specification value |
| `createdAt` | string (date-time) | read-only | Creation date of the container |
| `currentState` | publicCloud.storage.swift.ContainerCurrentState | read-only | Current observed state of the container, read from the Swift backend |
| `currentState.archive` | boolean | read-only | Whether the container uses the Public Cloud Archive storage policy (X-Storage-Policy: PCA). Objects in an archive container are sealed after upload and must be unsealed before download. |
| `currentState.cors` | string[] | read-only | Origins currently allowed to access the container from a browser (Access-Control-Allow-Origin container metadata). Empty when no origin is allowed. |
| `currentState.location` | publicCloud.common.Location | read-only | Region hosting the container |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.name` | string | read-only | Container name |
| `currentState.objectsCount` | integer | read-only | Number of objects stored in the container |
| `currentState.objectsSize` | integer | read-only | Total size of the objects stored in the container in bytes |
| `currentState.staticUrl` | string | read-only | Public URL of the container, only set when type is PUBLIC or STATIC. Built from the URL-encoded container name, the project's Swift account and the region's object-store endpoint. |
| `currentState.type` | publicCloud.storage.swift.ContainerTypeEnum | read-only | Access type of the container, derived from its read ACL and static website metadata: STATIC when the website metadata is set, PUBLIC when only the public read ACL is set, PRIVATE otherwise — one of `PRIVATE`, `PUBLIC`, `STATIC` |
| `currentTasks` | common.CurrentTask[] | read-only | Ongoing asynchronous tasks related to the container |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string | read-only | Container identifier, built as <REGION>_<name>, for example GRA_my-container. A container name is unique within a region of the project, so the pair identifies it. |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Container readiness in the system — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.storage.swift.ContainerTargetSpec | read-only | Last target specification of the container |
| `targetSpec.archive` | boolean |  | Create the container with the Public Cloud Archive storage policy (X-Storage-Policy: PCA) instead of the standard policy. Objects in an archive container are sealed after upload and must be unsealed (retrieval) before download. Immutable after creation. Defaults to false. |
| `targetSpec.cors` | string[] |  | Origins allowed to access the container from a browser (Access-Control-Allow-Origin container metadata), for example https://www.example.com. Duplicates are removed. Defaults to no origin, which blocks cross-origin browser requests. |
| `targetSpec.location` | publicCloud.common.Location | yes | Region hosting the container. Only region is used. availabilityZone is ignored because Swift is region-wide. The region is part of the container identifier and cannot be changed. |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Container name, unique within the region. At most 256 bytes and must not contain a slash (/). Immutable after creation. |
| `targetSpec.type` | publicCloud.storage.swift.ContainerTypeEnum |  | Access type of the container. PRIVATE requires a token or a presigned URL to read objects. PUBLIC lets anyone read and list objects. STATIC also serves the container as a static website: index.html as the index page, error.html on errors and listing.css to style listings. Default versions of these three files are pushed to the container when it is switched to STATIC. Defaults to PRIVATE. — one of `PRIVATE`, `PUBLIC`, `STATIC` |
| `updatedAt` | string (date-time) | read-only | Last update date of the container |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "currentState": {
    "archive": true,
    "cors": [
      "string"
    ],
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "objectsCount": 0,
    "objectsSize": 0,
    "staticUrl": "string",
    "type": "PRIVATE"
  },
  "currentTasks": [
    {
      "errors": [
        {
          "message": "string"
        }
      ],
      "id": "00000000-0000-0000-0000-000000000000",
      "link": "string",
      "status": "ERROR",
      "type": "string"
    }
  ],
  "id": "string",
  "resourceStatus": "CREATING",
  "targetSpec": {
    "archive": true,
    "cors": [
      "string"
    ],
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "type": "PRIVATE"
  },
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}");

print_r($result);
?>
```

## Update a container

`PUT /v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/storage/object-storage/swift-object-storage/#editSwiftContainer

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:storage/swift/container/edit`

Updates the access type and the CORS origins of the container. Send the current checksum to prevent overwriting a concurrent change. Without it, the last write wins.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `containerId` | path | string | yes | Container ID |
| `projectId` | path | string | yes | Project ID |

### Request body (required)

Type: `publicCloud.storage.swift.ContainerUpdate`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string |  | Optional concurrency-control checksum. When supplied, it must match the resource's current checksum or the request is rejected with a 409 checksum-mismatch conflict. When omitted or empty, the concurrency check is skipped and the write is forced (last-write-wins). |
| `targetSpec` | publicCloud.storage.swift.ContainerUpdateTargetSpec | yes | Desired target specification for the container |
| `targetSpec.cors` | string[] |  | Origins allowed to access the container from a browser (Access-Control-Allow-Origin container metadata), for example https://www.example.com. The list replaces the current origins. Duplicates are removed. An empty list or null removes every origin. |
| `targetSpec.type` | publicCloud.storage.swift.ContainerTypeEnum |  | Access type of the container. A null or missing type resets the container to PRIVATE. PRIVATE requires a token or a presigned URL to read objects. PUBLIC lets anyone read and list objects. STATIC also serves the container as a static website: index.html as the index page, error.html on errors and listing.css to style listings. Default versions of these three files are pushed to the container when it is switched to STATIC. Switching back to PRIVATE removes the public read ACL and the static website settings but keeps the objects. — one of `PRIVATE`, `PUBLIC`, `STATIC` |

```json
{
  "checksum": "string",
  "targetSpec": {
    "cors": [
      "string"
    ],
    "type": "PRIVATE"
  }
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.storage.swift.Container | successful operation |
| 400 | object | Error 400 response |
| 404 | object | Error 404 response |
| 409 | object | Error 409 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Computed hash representing the current target specification value |
| `createdAt` | string (date-time) | read-only | Creation date of the container |
| `currentState` | publicCloud.storage.swift.ContainerCurrentState | read-only | Current observed state of the container, read from the Swift backend |
| `currentState.archive` | boolean | read-only | Whether the container uses the Public Cloud Archive storage policy (X-Storage-Policy: PCA). Objects in an archive container are sealed after upload and must be unsealed before download. |
| `currentState.cors` | string[] | read-only | Origins currently allowed to access the container from a browser (Access-Control-Allow-Origin container metadata). Empty when no origin is allowed. |
| `currentState.location` | publicCloud.common.Location | read-only | Region hosting the container |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.name` | string | read-only | Container name |
| `currentState.objectsCount` | integer | read-only | Number of objects stored in the container |
| `currentState.objectsSize` | integer | read-only | Total size of the objects stored in the container in bytes |
| `currentState.staticUrl` | string | read-only | Public URL of the container, only set when type is PUBLIC or STATIC. Built from the URL-encoded container name, the project's Swift account and the region's object-store endpoint. |
| `currentState.type` | publicCloud.storage.swift.ContainerTypeEnum | read-only | Access type of the container, derived from its read ACL and static website metadata: STATIC when the website metadata is set, PUBLIC when only the public read ACL is set, PRIVATE otherwise — one of `PRIVATE`, `PUBLIC`, `STATIC` |
| `currentTasks` | common.CurrentTask[] | read-only | Ongoing asynchronous tasks related to the container |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string | read-only | Container identifier, built as <REGION>_<name>, for example GRA_my-container. A container name is unique within a region of the project, so the pair identifies it. |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Container readiness in the system — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.storage.swift.ContainerTargetSpec | read-only | Last target specification of the container |
| `targetSpec.archive` | boolean |  | Create the container with the Public Cloud Archive storage policy (X-Storage-Policy: PCA) instead of the standard policy. Objects in an archive container are sealed after upload and must be unsealed (retrieval) before download. Immutable after creation. Defaults to false. |
| `targetSpec.cors` | string[] |  | Origins allowed to access the container from a browser (Access-Control-Allow-Origin container metadata), for example https://www.example.com. Duplicates are removed. Defaults to no origin, which blocks cross-origin browser requests. |
| `targetSpec.location` | publicCloud.common.Location | yes | Region hosting the container. Only region is used. availabilityZone is ignored because Swift is region-wide. The region is part of the container identifier and cannot be changed. |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Container name, unique within the region. At most 256 bytes and must not contain a slash (/). Immutable after creation. |
| `targetSpec.type` | publicCloud.storage.swift.ContainerTypeEnum |  | Access type of the container. PRIVATE requires a token or a presigned URL to read objects. PUBLIC lets anyone read and list objects. STATIC also serves the container as a static website: index.html as the index page, error.html on errors and listing.css to style listings. Default versions of these three files are pushed to the container when it is switched to STATIC. Defaults to PRIVATE. — one of `PRIVATE`, `PUBLIC`, `STATIC` |
| `updatedAt` | string (date-time) | read-only | Last update date of the container |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "currentState": {
    "archive": true,
    "cors": [
      "string"
    ],
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "objectsCount": 0,
    "objectsSize": 0,
    "staticUrl": "string",
    "type": "PRIVATE"
  },
  "currentTasks": [
    {
      "errors": [
        {
          "message": "string"
        }
      ],
      "id": "00000000-0000-0000-0000-000000000000",
      "link": "string",
      "status": "ERROR",
      "type": "string"
    }
  ],
  "id": "string",
  "resourceStatus": "CREATING",
  "targetSpec": {
    "archive": true,
    "cors": [
      "string"
    ],
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "type": "PRIVATE"
  },
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X PUT \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: publicCloud.storage.swift.ContainerUpdate
result = client.put("/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}",
	checksum = None, # Optional concurrency-control checksum. When supplied, it must match the resource's current checksum or the request is rejected with a 409 checksum-mismatch conflict. When omitted or empty, the concurrency check is skipped and the write is forced (last-write-wins). (type: string, nullable)
	targetSpec = None, # Desired target specification for the container (type: publicCloud.storage.swift.ContainerUpdateTargetSpec)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: publicCloud.storage.swift.ContainerUpdate
$result = $ovh->put("/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}", array(
	checksum => null, // Optional concurrency-control checksum. When supplied, it must match the resource's current checksum or the request is rejected with a 409 checksum-mismatch conflict. When omitted or empty, the concurrency check is skipped and the write is forced (last-write-wins). (type: string, nullable)
	targetSpec => null, // Desired target specification for the container (type: publicCloud.storage.swift.ContainerUpdateTargetSpec)
));

print_r($result);
?>
```

## Delete a container

`DELETE /v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/storage/object-storage/swift-object-storage/#deleteSwiftContainer

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:storage/swift/container/delete`

Deletes the container and every object it holds. The deletion is asynchronous: the container stays in DELETING status until it is emptied and removed.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `containerId` | path | string | yes | Container ID |
| `projectId` | path | string | yes | Project ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.storage.swift.Container | successful operation |
| 404 | object | Error 404 response |
| 409 | object | Error 409 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Computed hash representing the current target specification value |
| `createdAt` | string (date-time) | read-only | Creation date of the container |
| `currentState` | publicCloud.storage.swift.ContainerCurrentState | read-only | Current observed state of the container, read from the Swift backend |
| `currentState.archive` | boolean | read-only | Whether the container uses the Public Cloud Archive storage policy (X-Storage-Policy: PCA). Objects in an archive container are sealed after upload and must be unsealed before download. |
| `currentState.cors` | string[] | read-only | Origins currently allowed to access the container from a browser (Access-Control-Allow-Origin container metadata). Empty when no origin is allowed. |
| `currentState.location` | publicCloud.common.Location | read-only | Region hosting the container |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.name` | string | read-only | Container name |
| `currentState.objectsCount` | integer | read-only | Number of objects stored in the container |
| `currentState.objectsSize` | integer | read-only | Total size of the objects stored in the container in bytes |
| `currentState.staticUrl` | string | read-only | Public URL of the container, only set when type is PUBLIC or STATIC. Built from the URL-encoded container name, the project's Swift account and the region's object-store endpoint. |
| `currentState.type` | publicCloud.storage.swift.ContainerTypeEnum | read-only | Access type of the container, derived from its read ACL and static website metadata: STATIC when the website metadata is set, PUBLIC when only the public read ACL is set, PRIVATE otherwise — one of `PRIVATE`, `PUBLIC`, `STATIC` |
| `currentTasks` | common.CurrentTask[] | read-only | Ongoing asynchronous tasks related to the container |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string | read-only | Container identifier, built as <REGION>_<name>, for example GRA_my-container. A container name is unique within a region of the project, so the pair identifies it. |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Container readiness in the system — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.storage.swift.ContainerTargetSpec | read-only | Last target specification of the container |
| `targetSpec.archive` | boolean |  | Create the container with the Public Cloud Archive storage policy (X-Storage-Policy: PCA) instead of the standard policy. Objects in an archive container are sealed after upload and must be unsealed (retrieval) before download. Immutable after creation. Defaults to false. |
| `targetSpec.cors` | string[] |  | Origins allowed to access the container from a browser (Access-Control-Allow-Origin container metadata), for example https://www.example.com. Duplicates are removed. Defaults to no origin, which blocks cross-origin browser requests. |
| `targetSpec.location` | publicCloud.common.Location | yes | Region hosting the container. Only region is used. availabilityZone is ignored because Swift is region-wide. The region is part of the container identifier and cannot be changed. |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Container name, unique within the region. At most 256 bytes and must not contain a slash (/). Immutable after creation. |
| `targetSpec.type` | publicCloud.storage.swift.ContainerTypeEnum |  | Access type of the container. PRIVATE requires a token or a presigned URL to read objects. PUBLIC lets anyone read and list objects. STATIC also serves the container as a static website: index.html as the index page, error.html on errors and listing.css to style listings. Default versions of these three files are pushed to the container when it is switched to STATIC. Defaults to PRIVATE. — one of `PRIVATE`, `PUBLIC`, `STATIC` |
| `updatedAt` | string (date-time) | read-only | Last update date of the container |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "currentState": {
    "archive": true,
    "cors": [
      "string"
    ],
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "objectsCount": 0,
    "objectsSize": 0,
    "staticUrl": "string",
    "type": "PRIVATE"
  },
  "currentTasks": [
    {
      "errors": [
        {
          "message": "string"
        }
      ],
      "id": "00000000-0000-0000-0000-000000000000",
      "link": "string",
      "status": "ERROR",
      "type": "string"
    }
  ],
  "id": "string",
  "resourceStatus": "CREATING",
  "targetSpec": {
    "archive": true,
    "cors": [
      "string"
    ],
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "type": "PRIVATE"
  },
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.delete("/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->delete("/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}");

print_r($result);
?>
```
