# Public Cloud › Storage › Object Storage › Swift Object Storage › Object Management 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

> 4 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/object-management/

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

## Operations

- `GET /publicCloud/project/{projectId}/storage/swift/container/{containerId}/object` — List objects
- `GET /publicCloud/project/{projectId}/storage/swift/container/{containerId}/object/{key}` — Get object metadata
- `DELETE /publicCloud/project/{projectId}/storage/swift/container/{containerId}/object/{key}` — Delete an object
- `POST /publicCloud/project/{projectId}/storage/swift/container/{containerId}/presign` — Create a presigned URL

## List objects

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

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

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

Returns the objects of the container, at most 500 per page. Filter by key prefix, and page with the marker: the key of the last object of the previous page.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `X-Pagination-Cursor` | header | string |  | Pagination cursor |
| `X-Pagination-Size` | header | integer |  | Pagination size |
| `containerId` | path | string | yes | Container ID |
| `limit` | query | integer |  | Maximum number of objects to return. Defaults to 500. At most 500. |
| `marker` | query | string |  | Only return objects whose keys sort after this one. Pass the key of the last object of the previous page to get the next page. |
| `prefix` | query | string |  | Only return objects whose keys begin with this prefix |
| `projectId` | path | string | yes | Project ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.storage.swift.ContainerObject[] | successful operation |
| 400 | object | Error 400 response |
| 404 | object | Error 404 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `contentType` | string | read-only | MIME type of the object content (Content-Type header), for example image/png |
| `etag` | string | read-only | Entity tag of the object: the MD5 hash of its content, or a hash of the segment hashes for a large object |
| `key` | string | read-only | Object key, which is its full path within the container, for example documents/report.pdf |
| `lastModifiedAt` | string (date-time) | read-only | Last modification timestamp of the object |
| `retrievalDelay` | integer | read-only | Seconds to wait before the object becomes readable, only set while retrievalState is UNSEALING |
| `retrievalState` | publicCloud.storage.swift.ObjectRetrievalStateEnum | read-only | Retrieval state of the object, only meaningful in an archive container: SEALED objects must be unsealed before download, UNSEALING objects are being retrieved, UNSEALED objects can be downloaded. Absent in a standard container. — one of `SEALED`, `UNSEALED`, `UNSEALING` |
| `size` | integer | read-only | Object size in bytes |

```json
[
  {
    "contentType": "string",
    "etag": "string",
    "key": "string",
    "lastModifiedAt": "2024-01-01T12:00:00Z",
    "retrievalDelay": 0,
    "retrievalState": "SEALED",
    "size": 0
  }
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}/object" \
  -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}/object")

# 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}/object");

print_r($result);
?>
```

## Get object metadata

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

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

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

Returns the object metadata, without its content.

### Parameters

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

### Responses

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `contentType` | string | read-only | MIME type of the object content (Content-Type header), for example image/png |
| `etag` | string | read-only | Entity tag of the object: the MD5 hash of its content, or a hash of the segment hashes for a large object |
| `key` | string | read-only | Object key, which is its full path within the container, for example documents/report.pdf |
| `lastModifiedAt` | string (date-time) | read-only | Last modification timestamp of the object |
| `retrievalDelay` | integer | read-only | Seconds to wait before the object becomes readable, only set while retrievalState is UNSEALING |
| `retrievalState` | publicCloud.storage.swift.ObjectRetrievalStateEnum | read-only | Retrieval state of the object, only meaningful in an archive container: SEALED objects must be unsealed before download, UNSEALING objects are being retrieved, UNSEALED objects can be downloaded. Absent in a standard container. — one of `SEALED`, `UNSEALED`, `UNSEALING` |
| `size` | integer | read-only | Object size in bytes |

```json
{
  "contentType": "string",
  "etag": "string",
  "key": "string",
  "lastModifiedAt": "2024-01-01T12:00:00Z",
  "retrievalDelay": 0,
  "retrievalState": "SEALED",
  "size": 0
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}/object/{key}" \
  -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}/object/{key}")

# 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}/object/{key}");

print_r($result);
?>
```

## Delete an object

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

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

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

Deletes the object from the container.

### Parameters

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

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | — | successful operation |

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}/object/{key}" \
  -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}/object/{key}")

# 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}/object/{key}");

print_r($result);
?>
```

## Create a presigned URL

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

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

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

Creates a temporary URL to download one object without credentials. The URL expires after the given time, one hour by default and seven days at most.

### 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.ContainerPresignedURLCreation`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `expiresIn` | integer |  | Lifetime of the URL in seconds. Defaults to 3600 (one hour). At most 604800 (seven days). |
| `key` | string | yes | Key of the object to grant access to, as its full path within the container, for example documents/report.pdf. The object does not need to exist yet. |

```json
{
  "expiresIn": 0,
  "key": "string"
}
```

### Responses

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `expiresAt` | string (date-time) | read-only | Timestamp after which the URL is refused |
| `key` | string | read-only | Key of the object the URL gives access to, as its full path within the container |
| `method` | publicCloud.storage.swift.ContainerPresignedURLMethodEnum | read-only | HTTP method the URL is valid for. Always GET. — one of `GET` |
| `url` | string | read-only | Temporary URL that downloads the object with a GET request, without credentials, until expiresAt |

```json
{
  "expiresAt": "2024-01-01T12:00:00Z",
  "key": "string",
  "method": "GET",
  "url": "string"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}/presign" \
  -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.ContainerPresignedURLCreation
result = client.post("/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}/presign",
	expiresIn = None, # Lifetime of the URL in seconds. Defaults to 3600 (one hour). At most 604800 (seven days). (type: integer, nullable)
	key = None, # Key of the object to grant access to, as its full path within the container, for example documents/report.pdf. The object does not need to exist yet. (type: string)
)

# 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.ContainerPresignedURLCreation
$result = $ovh->post("/v2/publicCloud/project/{projectId}/storage/swift/container/{containerId}/presign", array(
	expiresIn => null, // Lifetime of the URL in seconds. Defaults to 3600 (one hour). At most 604800 (seven days). (type: integer, nullable)
	key => null, // Key of the object to grant access to, as its full path within the container, for example documents/report.pdf. The object does not need to exist yet. (type: string)
));

print_r($result);
?>
```
