> 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/_mcp/server. # Get a space GET https://preview.contentful.com/spaces/{space_id} Each space has a name, a set of locales, and metadata about the space. Reference: https://contentful.com/developers/docs/references/content-preview-api/spaces/get-a-space ## Request ### Path parameters - `space_id` (string, required) — Alphanumeric id of the space to retrieve. ### 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 { "locales": [ { "code": "en-US", "default": true, "fallbackCode": null, "name": "U.S. English" } ], "name": "Documentation examples", "sys": { "id": "71rop70dkqaj", "type": "Space" } } ``` **SDK Code** ```android Android // Create the Contentful client. final CDAClient client = CDAClient .builder() // Only difference to cda client creation. .preview() .setToken("") .setSpace("") .build(); client .observeSpace() // Execute result handling on the `main thread`. .observeOn(AndroidSchedulers.mainThread()) // Networking should happen on io thread. .subscribeOn(io.reactivex.schedulers.Schedulers.io()) .subscribe( new DisposableSubscriber() { CDASpace result; @Override public void onComplete() { // Do something with the result space. new AlertDialog.Builder(context) .setTitle("Contentful") .setMessage("Space: " + (result == null ? "" : result.toString())) .show(); } @Override public void onError(Throwable e) { // Handle error case. new AlertDialog.Builder(context) .setTitle("Contentful") .setMessage("An error occurred: " + e.toString()) .show(); } @Override public void onNext(CDASpace space) { // Array received, maybe more to come. result = space; } } ); ``` ```java Java // Create the Contentful client. final CDAClient client = CDAClient .builder() // Only difference to cda client creation. .preview() .setToken("") .setSpace("") .build(); final CDASpace one = client .fetchSpace(); ``` ```kotlin Kotlin // Create the Contentful client. val client = CDAClient .builder() // Only difference to cda client creation. .preview() .setToken("") .setSpace("") .build() val one = client .fetchSpace() ``` ```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: "", environmentId: "", // Defaults to "master" if omitted accessToken: "", host: Host.preview) client.fetchSpace { (result: Result) in switch result { case .success(let space): print(space) case .error(let error): print(error) } } ``` ```javascript JavaScript import { createClient } from 'contentful-management' const client = createClient({ space: '', accessToken: '', host: 'preview.contentful.com' }) client.getSpace() .then((space) => console.log(space)) .catch(console.error) ``` ```php PHP // contentful.php 3.0 $client = new Contentful\Delivery\Client( '', '', '', // Defaults to "master" if ommitted true ); $space = $client->getSpace(); ``` ```ruby Ruby require 'contentful' client = Contentful::Client.new( space: '', access_token: '', 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. ) space = client.space ``` ```python Python from contentful import Client client = Client( '', '', api_url='preview.contentful.com', # Configure the client to connect to the Content Preview API. environment='master' # Optional - it will default to 'master' ) space = client.space() ``` ```.net .NET // This client should only be created once per application. var httpClient = new HttpClient(); var client = new ContentfulClient(httpClient, "", "", "", true); var space = await client.GetSpace(); ```