# DeleteObject

If there isn't a null version, Petabox does not remove any objects but will still respond that the command was successful.

To remove a specific version, you must use the version Id subresource. Using this subresource permanently deletes the version. If the object deleted is a delete marker, Petabox sets the response header, `x-amz-delete-marker`, to true.

You can delete objects by explicitly calling DELETE Object or configure its lifecycle (PutBucketLifecycle) to enable Petabox to remove them for you. If you want to block users or accounts from removing or deleting objects from your bucket, you must deny them the `s3:DeleteObject`, `s3:DeleteObjectVersion`, and `s3:PutLifeCycleConfiguration` actions.

## Request Syntax <a href="#api_deleteobject_requestsyntax" id="api_deleteobject_requestsyntax"></a>

```http
DELETE /Key+?versionId=VersionId HTTP/1.1
Host: Bucket.s3.petabox.io
x-amz-request-payer: RequestPayer
x-amz-bypass-governance-retention: BypassGovernanceRetention
x-amz-expected-bucket-owner: ExpectedBucketOwner
```

## URI Request Parameters <a href="#api_deleteobject_requestparameters" id="api_deleteobject_requestparameters"></a>

The request uses the following URI parameters.

#### Bucket

The bucket name of the bucket containing the object.

Required: Yes

#### Key

Key name of the object to delete.

Length Constraints: Minimum length of 1.

Required: Yes

#### versionId

VersionId used to reference a specific version of the object.

#### x-amz-bypass-governance-retention

Indicates whether S3 Object Lock should bypass Governance-mode restrictions to process this operation. To use this header, you must have the `s3:BypassGovernanceRetention` permission.

#### x-amz-expected-bucket-owner

The account ID of the expected bucket owner. If the bucket is owned by a different account, the request fails with the HTTP status code `403 Forbidden` (access denied).

#### x-amz-request-payer

Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests.&#x20;

Valid Values: `requester`

## Request Body <a href="#api_deleteobject_requestbody" id="api_deleteobject_requestbody"></a>

The request does not have a request body.

## Response Syntax <a href="#api_deleteobject_responsesyntax" id="api_deleteobject_responsesyntax"></a>

```http
HTTP/1.1 204
x-amz-delete-marker: DeleteMarker
x-amz-version-id: VersionId
x-amz-request-charged: RequestCharged
```

## Response Elements <a href="#api_deleteobject_responseelements" id="api_deleteobject_responseelements"></a>

If the action is successful, the service sends back an HTTP 204 response.

The response returns the following HTTP headers.

#### x-amz-delete-marker

Specifies whether the versioned object that was permanently deleted was (true) or was not (false) a delete marker.

#### x-amz-request-charged

If present, indicates that the requester was successfully charged for the request.

Valid Values: `requester`

#### x-amz-version-id

Returns the version ID of the delete marker created as a result of the DELETE operation.

## Examples <a href="#api_deleteobject_examples" id="api_deleteobject_examples"></a>

### Sample Request <a href="#api_deleteobject_example_1" id="api_deleteobject_example_1"></a>

The following request deletes the object `my-second-image.jpg`.

```http
DELETE /my-second-image.jpg HTTP/1.1
Host: bucket.s3.<Region>.petabox.io
Date: Wed, 12 Oct 2009 17:50:00 GMT
Authorization: authorization string
Content-Type: text/plain
```

### Sample Response <a href="#api_deleteobject_example_2" id="api_deleteobject_example_2"></a>

This example illustrates one usage of DeleteObject.

```http
HTTP/1.1 204 NoContent
x-amz-id-2: LriYPLdmOdAiIfgSm/F1YsViT1LW94/xUQxMsF7xiEb1a0wiIOIxl+zbwZ163pt7
x-amz-request-id: 0A49CE4060975EAC
Date: Wed, 12 Oct 2009 17:50:00 GMT
Content-Length: 0
Connection: close
Server: Petabox
```

### Sample Request: Deleting a specified version of an object <a href="#api_deleteobject_example_3" id="api_deleteobject_example_3"></a>

The following request deletes the specified version of the object `my-third-image.jpg`.

```http
DELETE /my-third-image.jpg?versionId=UIORUnfndfiufdisojhr398493jfdkjFJjkndnqUifhnw89493jJFJ HTTP/1.1 
Host: bucket.s3.<Region>.petabox.io
Date: Wed, 12 Oct 2009 17:50:00 GMT
Authorization: authorization string
Content-Type: text/plain
Content-Length: 0
```

### Sample Response <a href="#api_deleteobject_example_4" id="api_deleteobject_example_4"></a>

This example illustrates one usage of DeleteObject.

```http
HTTP/1.1 204 NoContent
x-amz-id-2: LriYPLdmOdAiIfgSm/F1YsViT1LW94/xUQxMsF7xiEb1a0wiIOIxl+zbwZ163pt7
x-amz-request-id: 0A49CE4060975EAC
x-amz-version-id: UIORUnfndfiufdisojhr398493jfdkjFJjkndnqUifhnw89493jJFJ
Date: Wed, 12 Oct 2009 17:50:00 GMT
Content-Length: 0
Connection: close
Server: Petabox
```

### Sample Response: If the object deleted is a delete marker <a href="#api_deleteobject_example_5" id="api_deleteobject_example_5"></a>

This example illustrates one usage of DeleteObject.

```http
HTTP/1.1 204 NoContent
x-amz-id-2: LriYPLdmOdAiIfgSm/F1YsViT1LW94/xUQxMsF7xiEb1a0wiIOIxl+zbwZ163pt7
x-amz-request-id: 0A49CE4060975EAC
x-amz-version-id: 3/L4kqtJlcpXroDTDmJ+rmSpXd3dIbrHY+MTRCxf3vjVBH40Nr8X8gdRQBpUMLUo
x-amz-delete-marker: true
Date: Wed, 12 Oct 2009 17:50:00 GMT
Content-Length: 0
Connection: close
Server: Petabox
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.petabox.io/http-api-compatible-with-amazon-s3/api-reference/deleteobject.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
