> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://contentful.com/developers/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://contentful.com/developers/docs/_mcp/server.

# Unpublish an asset

DELETE https://api.contentful.com/spaces/{space_id}/environments/{environment_id}/assets/{asset_id}/published

Unpublishing will put the asset back into draft state.

Reference: https://contentful.com/developers/docs/references/content-management-api/assets/unpublish-an-asset

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `space_id` (string, required) — ID of the space in form of a string
- `environment_id` (string, required) — ID of the environment in form of a string
- `asset_id` (string, required) — ID of the asset in form of a string

### Headers

- `X-Contentful-Version` (string, optional) — Version of the asset to unpublish

## Response

### 200

OK - Request successful

- `map from string to any`

## Examples

**Response**

```json
{
  "fields": {
    "file": {
      "en-US": {
        "contentType": "image/jpeg",
        "fileName": "example.jpeg",
        "upload": "https://example.com/example.jpg"
      }
    },
    "title": {
      "en-US": "Playsam Streamliner"
    }
  },
  "metadata": {
    "tags": [
      {
        "sys": {
          "id": "nyCampaign",
          "linkType": "Tag",
          "type": "Link"
        }
      }
    ]
  },
  "sys": {
    "createdAt": "2025-02-17T01:54:07.000Z",
    "createdBy": {
      "sys": {
        "id": "7BslKh9TdKGOK41VmLDjFZ",
        "linkType": "User",
        "type": "Link"
      }
    },
    "environment": {
      "sys": {
        "id": "staging",
        "linkType": "Environment",
        "type": "Link"
      }
    },
    "id": "wtrHxeu3zEoEce2MokCSi",
    "space": {
      "sys": {
        "id": "yadj1kx9rmg0",
        "linkType": "Space",
        "type": "Link"
      }
    },
    "type": "Asset",
    "updatedAt": "2025-02-17T01:54:07.000Z",
    "updatedBy": {
      "sys": {
        "id": "4FLrUHftHW3v2BLi9fzfjU",
        "linkType": "User",
        "type": "Link"
      }
    },
    "version": 1
  }
}
```

**SDK Code**

```android Android
// Create the Contentful client.
final CMAClient client =
    new CMAClient
        .Builder()
        .setAccessToken("<access_token>")
        .setSpaceId("<space_id>")
        .setEnvironmentId("<environment_id>")
        .build();

client
    .assets()
    .async()
    .fetchOne(
        "<asset_id>",
        new CMACallback<CMAAsset>() {
          @Override protected void onSuccess(CMAAsset asset) {
            // Change the asset.
            asset
                .getFields()
                .setDescription("en-US", "new description");

            client
                .assets()
                .async()
                .unPublish(
                    asset,
                    new CMACallback<CMAAsset>() {
                      @Override protected void onSuccess(CMAAsset result) {
                        // Done, your unpublished asset will be the parameter of this callback.
                        new AlertDialog.Builder(context)
                            .setTitle("Contentful")
                            .setMessage("Asset unpublished." +
                                "\n\nResult: " + result)
                            .show();
                      }

                      @Override protected void onFailure(RuntimeException exception) {
                        // An error occurred! Inform the user.
                        new AlertDialog.Builder(context)
                            .setTitle("Contentful Error")
                            .setMessage("Asset could not be unbpublished." +
                                "\n\nReason: " + exception.toString())
                            .show();

                        super.onFailure(exception);
                      }
                    }
                );
          }

          @Override protected void onFailure(RuntimeException exception) {
            // An error occurred! Inform the user.
            new AlertDialog.Builder(context)
                .setTitle("Contentful Error")
                .setMessage("Could not fetch the asset." +
                    "\n\nReason: " + exception.toString())
                .show();

            super.onFailure(exception);
          }
        }
    );
```

```java Java
// Create the Contentful client.
final CMAClient client =
    new CMAClient
        .Builder()
        .setAccessToken("<access_token>")
        .setSpaceId("<space_id>")
        .setEnvironmentId("<environment_id>")
        .build();

// Fetch an existing asset.
final CMAAsset asset =
    client
        .assets()
        .fetchOne("<asset_id>");

final CMAAsset archive =
    client
        .assets()
        .unPublish(asset);
```

```kotlin Kotlin
// Create the Contentful client.
val client = CMAClient.Builder()
    .setAccessToken("<access_token>")
    .setSpaceId("<space_id>")
    .setEnvironmentId("<environment_id>")
    .build()

// Fetch an existing asset.
val asset = client
        .assets()
        .fetchOne("<asset_id>")

val archive = client
        .assets()
        .unPublish(asset)
```

```swift Swift
We currently don't provide a CMA SDK for this platform.
```

```js-legacy JavaScript (legacy)
import { createClient } from 'contentful-management'

const client = createClient({
  accessToken: '<content_management_api_key>'
}, { type: 'legacy' })

client.getSpace('<space_id>')
.then((space) => space.getEnvironment('<environment_id>'))
.then((environment) => environment.getAsset('<asset_id>'))
.then((asset) => asset.unpublish())
.then((asset) => console.log(`Asset ${asset.sys.id} unpublished.`))
.catch(console.error)
```

```javascript JavaScript
import { createClient } from 'contentful-management'

// Client init
const client = contentful.createClient({
  accessToken: '<content_management_api_key>'
})

const asset = await client.asset.unpublish({
  spaceId: '<space_id>',
  environmentId: '<environment_id>',
  assetId: '<asset_id>',
});
```

```php PHP
$client = new \Contentful\Management\Client('<content_management_api_key>');

$environment = $client->getEnvironmentProxy('<space_id>', '<environment_id>');

$asset = $environment->getAsset('<asset_id>');
$asset->unpublish();
```

```ruby Ruby
require 'contentful/management'

client = Contentful::Management::Client.new('<content_management_api_key>')

asset = client.assets('<space_id>', '<environment_id>').find('<asset_id>')
asset.unpublish
```

```python Python
from contentful_management import Client

client = Client('<content_management_api_key>')

asset = client.assets('<space_id>', '<environment_id>').find('<asset_id>')
asset.unpublish()
```

```.net .NET
// This client should only be created once per application.
var httpClient = new HttpClient();

var client = new ContentfulManagementClient(httpClient, "<content_management_api_key>", "<space_id>");

var version = 2;
var asset = await client.UnpublishAsset("<new_asset_id>", version);
```