> 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 spaces an account has access to

GET https://api.contentful.com/spaces

Reference: https://contentful.com/developers/docs/references/content-management-api/spaces/get-all-spaces-an-account-has-access-to

## Authentication

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

## Request

### Query parameters

- `skip` (integer, optional) — Number of resources to skip (offset pagination).
- `limit` (integer, optional) — Maximum number of resources to return.
- `order` (string, optional) — Sort order, e.g. `sys.createdAt` or `-sys.createdAt`.
- `cursor` (boolean, optional) — When `true`, switches the response to cursor-based pagination. The response includes a `pages` object with `next` and `prev` URLs instead of `skip`/`limit`.
- `pageNext` (string, optional) — Cursor token for the next page. Use the value from `pages.next` in a previous cursor-paginated response.
- `pagePrev` (string, optional) — Cursor token for the previous page. Use the value from `pages.prev` in a previous cursor-paginated response.
- `query` (string, optional) — Search spaces by exact space ID match or partial name match.
- `type` (string, optional) — Filter by space type.

### Headers

- `X-Contentful-Organization` (string, optional) — Scope the listing to a specific organization. When omitted, spaces from all organizations the account has access to are returned.

## Response

### 200

OK - Request successful

- `map from string to any`

## Examples

### Offset pagination (default)

**Response**

```json
{
  "items": [
    {
      "name": "Contentful Example API",
      "sys": {
        "createdAt": "2025-06-04T11:58:18.000Z",
        "createdBy": {
          "sys": {
            "id": "7BslKh9TdKGOK41VmLDjFZ",
            "linkType": "User",
            "type": "Link"
          }
        },
        "id": "yadj1kx9rmg0",
        "organization": {
          "sys": {
            "id": "0D9ZC8rLWiw6x5qizZGiRs",
            "linkType": "Organization",
            "type": "Link"
          }
        },
        "type": "Space",
        "updatedAt": "2026-01-05T11:02:17.000Z",
        "updatedBy": {
          "sys": {
            "id": "4FLrUHftHW3v2BLi9fzfjU",
            "linkType": "User",
            "type": "Link"
          }
        },
        "version": 3
      }
    }
  ],
  "limit": 100,
  "skip": 0,
  "sys": {
    "type": "Array"
  },
  "total": 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
    .spaces()
    .async()
    .fetchAll(
        new CMACallback<CMAArray<CMASpace>>() {
          @Override protected void onSuccess(CMAArray<CMASpace> result) {
            // Done.
            new AlertDialog.Builder(context)
                .setTitle("Contentful")
                .setMessage("List of all spaces was successful." +
                    "\n\nResult: " + result.getItems())
                .show();
          }

          @Override protected void onFailure(RuntimeException exception) {
            // An error occurred! Inform the user.
            new AlertDialog.Builder(context)
                .setTitle("Contentful Error")
                .setMessage("Could not list all spaces." +
                    "\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();

final CMAArray<CMASpace> array =
    client
        .spaces()
        .fetchAll();
```

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

val array = client
        .spaces()
        .fetchAll()
```

```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.getSpaces()
.then((response) => console.log(response.items))
.catch(console.error)
```

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

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

const spaces = await client.space.getMany({
  query: {
    limit: 10,
  },
});
```

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

$spaces = $client->getSpaces();
```

```ruby Ruby
require 'contentful/management'

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

spaces = client.spaces.all
```

```python Python
from contentful_management import Client

client = Client('<content_management_api_key>')

spaces = client.spaces().all()
```

```.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 spaces = await client.GetSpaces();
```

### Cursor pagination (?cursor=true)

**Response**

```json
{
  "items": [
    {
      "name": "Contentful Example API",
      "sys": {
        "createdAt": "2025-06-04T11:58:18.000Z",
        "createdBy": {
          "sys": {
            "id": "7BslKh9TdKGOK41VmLDjFZ",
            "linkType": "User",
            "type": "Link"
          }
        },
        "id": "yadj1kx9rmg0",
        "organization": {
          "sys": {
            "id": "0D9ZC8rLWiw6x5qizZGiRs",
            "linkType": "Organization",
            "type": "Link"
          }
        },
        "type": "Space",
        "updatedAt": "2026-01-05T11:02:17.000Z",
        "updatedBy": {
          "sys": {
            "id": "4FLrUHftHW3v2BLi9fzfjU",
            "linkType": "User",
            "type": "Link"
          }
        },
        "version": 3
      }
    }
  ],
  "pages": {
    "next": "https://api.contentful.com/spaces?cursor=true&pageNext=<cursor_token>",
    "prev": null
  },
  "sys": {
    "type": "Array"
  },
  "total": 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
    .spaces()
    .async()
    .fetchAll(
        new CMACallback<CMAArray<CMASpace>>() {
          @Override protected void onSuccess(CMAArray<CMASpace> result) {
            // Done.
            new AlertDialog.Builder(context)
                .setTitle("Contentful")
                .setMessage("List of all spaces was successful." +
                    "\n\nResult: " + result.getItems())
                .show();
          }

          @Override protected void onFailure(RuntimeException exception) {
            // An error occurred! Inform the user.
            new AlertDialog.Builder(context)
                .setTitle("Contentful Error")
                .setMessage("Could not list all spaces." +
                    "\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();

final CMAArray<CMASpace> array =
    client
        .spaces()
        .fetchAll();
```

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

val array = client
        .spaces()
        .fetchAll()
```

```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.getSpaces()
.then((response) => console.log(response.items))
.catch(console.error)
```

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

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

const spaces = await client.space.getMany({
  query: {
    limit: 10,
  },
});
```

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

$spaces = $client->getSpaces();
```

```ruby Ruby
require 'contentful/management'

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

spaces = client.spaces.all
```

```python Python
from contentful_management import Client

client = Client('<content_management_api_key>')

spaces = client.spaces().all()
```

```.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 spaces = await client.GetSpaces();
```