> 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.

# Get all assets

GET https://preview.contentful.com/spaces/{space_id}/environments/{environment_id}/assets

Reference: https://contentful.com/developers/docs/references/content-preview-api/assets/get-all-assets

## Request

### Path parameters

- `space_id` (string, required) — Alphanumeric id of the space to retrieve.
- `environment_id` (string, required) — ID of the environment in form of a string.

### Query parameters

- `access_token` (string, required) — A *preview* Content Preview API key.

## Response

### 200

OK - Request successful

- `map from string to any`

## Examples

**Response**

```json
{
  "items": [],
  "limit": 100,
  "skip": 0,
  "sys": {
    "type": "Array"
  },
  "total": 0
}
```

**SDK Code**

```android Android
// Create the Contentful client.
final CDAClient client =
    CDAClient
        .builder()
        // Only difference to cda client creation.
        .preview()
        .setToken("<access_token>")
        .setSpace("<space_id>")
        .build();

client
    .observe(CDAAsset.class)
    .all()
    .observeOn(AndroidSchedulers.mainThread())
    .subscribeOn(io.reactivex.schedulers.Schedulers.io())
    .subscribe(
        new DisposableSubscriber<CDAArray>() {
          CDAArray result;

          @Override public void onComplete() {
            // Do something with the result.
            new AlertDialog.Builder(context)
                .setTitle("Contentful")
                .setMessage("Found assets: " + result.items().toString())
                .show();
          }

          @Override public void onError(Throwable e) {
            // Handle error case.
            new AlertDialog.Builder(context)
                .setTitle("Contentful")
                .setMessage("Something went wrong: " + e.toString())
                .show();
          }

          @Override public void onNext(CDAArray asset) {
            // Array received, maybe more to come.
            result = asset;
          }
        }
    );
```

```java Java
// Create the Contentful client.
final CDAClient client =
    CDAClient
        .builder()
        // Only difference to cda client creation.
        .preview()
        .setToken("<access_token>")
        .setSpace("<space_id>")
        .build();

final CDAArray all =
    client
        .fetch(CDAAsset.class)
        .all();
```

```kotlin Kotlin
// Create the Contentful client.
val client = CDAClient
        .builder()
        // Only difference to cda client creation.
        .preview()
        .setToken("<access_token>")
        .setSpace("<space_id>")
        .build()

val all = client
        .fetch(CDAAsset::class.java)
        .all()
```

```swift Swift
import Contentful

// Retain the client as a property on a type you define so that
// the client's asynchronous network callbacks are executed.
let client = Client(spaceId: "<space_id>",
                    environmentId: "<environment_id>", // Defaults to "master" if omitted
                    accessToken: "<access_token>",
                    host: Host.preview)


client.fetchAssets() { (result: Result<ArrayResponse<Asset>>) in
  switch result {
  case .success(let arrayResponse):
    let assets = arrayResponse.items
    print(assets)
  case .error(let error):
    print(error)
  }
}
```

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

const client = createClient({
  space: '<space_id>',
  accessToken: '<content_preview_api_key>',
  host: 'preview.contentful.com'
})

client.getAssets()
.then((response) => console.log(response.items))
.catch(console.error)
```

```php PHP
// contentful.php 3.0

$client = new Contentful\Delivery\Client(
  '<content_preview_api_key>',
  '<space_id>',
  '<environment_id>', // Defaults to "master" if ommitted
  true
);

$assets = $client->getAssets();
```

```ruby Ruby
require 'contentful'

client = Contentful::Client.new(
  space: '<space_id>',
  access_token: '<content_preview_api_key>',
  api_url: 'preview.contentful.com',  # Configure the client to connect to the Content Preview API.
  environment: 'master',  # Optional - defaults to 'master'.
  dynamic_entries: :auto  # Enable Content Type caching.
)

assets = client.assets
```

```python Python
from contentful import Client

client = Client(
    '<space_id>',
    '<content_preview_api_key>',
    api_url='preview.contentful.com',  # Configure the client to connect to the Content Preview API.
    environment='master'  # Optional - it will default to 'master'
)

assets = client.assets()
```

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

var client = new ContentfulClient(httpClient, "<content_delivery_api_key>", "<content_preview_api_key>", "<space_id>", true);

var assets = await client.GetAssets();
```