> 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 a Preview API key

GET https://api.contentful.com/spaces/{space_id}/preview_api_keys/{preview_api_key_id}

This endpoint returns details about an existing Preview API key.

Reference: https://contentful.com/developers/docs/references/content-management-api/api-keys/get-a-preview-api-key

## 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 a form of a string
- `preview_api_key_id` (string, required) — preview_api_key_id identifier

## Response

### 200

OK - Request successful

- `map from string to any`

## Examples

**Response**

```json
{
  "accessToken": "e5e8d4c5c122cf28fc1af3ff77d28bef78a3952957f15067bbc29f2f0dde0b50",
  "description": null,
  "environments": [
    {
      "sys": {
        "id": "staging",
        "linkType": "Environment",
        "type": "Link"
      }
    }
  ],
  "name": "Example API Key",
  "sys": {
    "createdAt": "2026-01-06T07:58:55.000Z",
    "createdBy": {
      "sys": {
        "id": "7BslKh9TdKGOK41VmLDjFZ",
        "linkType": "User",
        "type": "Link"
      }
    },
    "id": "exampleapikey",
    "space": {
      "sys": {
        "id": "yadj1kx9rmg0",
        "linkType": "Space",
        "type": "Link"
      }
    },
    "type": "PreviewApiKey",
    "updatedAt": "2026-01-06T07:58:55.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();

// Fetch one api key.
client
    .previewApiKeys()
    .async()
    .fetchOne(
        "<space_id>",
        "<preview_api_key>",
        new CMACallback<CMAPreviewApiKey>() {
          @Override protected void onSuccess(CMAPreviewApiKey result) {
            new AlertDialog.Builder(context)
                .setTitle("Contentful")
                .setMessage("Successfully fetched one of the preview api keys." +
                    "\n\nResult: " + result)
                .show();
          }

          @Override protected void onFailure(RuntimeException exception) {
            // An error occurred! Inform the user.
            new AlertDialog.Builder(context)
                .setTitle("Contentful Error")
                .setMessage("Could not fetch one preview api keys." +
                    "\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 CMAPreviewApiKey previewApiKey =
    client
        .previewApiKeys()
        .fetchOne("<preview_api_key_id>");
```

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

val previewApiKey = client
        .previewApiKeys()
        .fetchOne("<preview_api_key_id>")
```

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

```js-legacy JavaScript (legacy)
SDK currently doesn't implement this endpoint.
```

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

$space = $client->getSpaceProxy('<space_id>');

$previewApiKey = $space->getPreviewApiKey('<preview_api_key_id>');

// Alternatively, if you already fetched the Delivery API key
$space->resolveLink($deliveryApiKey->getPreviewApiKey());
```

```ruby Ruby
SDK currently doesn't implement this endpoint.
```

```python Python
SDK currently doesn't implement this endpoint.
```

```.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 previewApiKey = await client.GetPreviewApiKey("<preview_api_key_id>");
```

```javascript JavaScript
No snippet for this SDK.
```