Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Space<TType>

Type parameters

Hierarchy

Index

Properties

getSpaceUsers

getSpaceUsers: (query: QueryOptions) => Promise<Collection<User>>

Gets a collection of Users in a space

param

Object with search parameters. Check the JS SDK tutorial and the REST API reference for more details.

returns

Promise a collection of Users in a space

example
const contentful = require('contentful-management')

client.getSpace('<space_id>')
.then((space) => space.getSpaceUsers(query))
.then((data) => console.log(data))
.catch(console.error)

Type declaration

name

name: string

sys

sys: TType

Methods

createApiKey

  • Creates a Api Key

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.createApiKey({
      name: 'API Key name',
      environments:[
       {
        sys: {
         type: 'Link'
         linkType: 'Environment',
         id:'<environment_id>'
        }
       }
      ]
      }
    }))
    .then((apiKey) => console.log(apiKey))
    .catch(console.error)

    Parameters

    Returns Promise<ApiKey>

    Promise for the newly created Api Key

createApiKeyWithId

  • Creates a Api Key with a custom ID

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.createApiKeyWithId('<api-key-id>', {
      name: 'API Key name'
      environments:[
       {
        sys: {
         type: 'Link'
         linkType: 'Environment',
         id:'<environment_id>'
        }
       }
      ]
      }
    }))
    .then((apiKey) => console.log(apiKey))
    .catch(console.error)

    Parameters

    • id: string

      Api Key ID

    • data: CreateApiKeyProps

      Object representation of the Api Key to be created

    Returns Promise<ApiKey>

    Promise for the newly created Api Key

createAsset

  • Creates a Asset. After creation, call asset.processForLocale or asset.processForAllLocales to start asset processing.

    deprecated

    since version 5.0

    example
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    // Create asset
    client.getSpace('<space_id>')
    .then((space) => space.createAsset({
      fields: {
        title: {
          'en-US': 'Playsam Streamliner'
       },
       file: {
          'en-US': {
            contentType: 'image/jpeg',
           fileName: 'example.jpeg',
           upload: 'https://example.com/example.jpg'
         }
       }
      }
    }))
    .then((asset) => asset.processForLocale("en-US")) // OR asset.processForAllLocales()
    .then((asset) => console.log(asset))
    .catch(console.error)

    Parameters

    • data: AssetProps

      Object representation of the Asset to be created. Note that the field object should have an upload property on asset creation, which will be removed and replaced with an url property when processing is finished.

    Returns Promise<Asset>

    Promise for the newly created Asset

createAssetFromFiles

  • Creates a Asset based on files. After creation, call asset.processForLocale or asset.processForAllLocales to start asset processing.

    deprecated

    since version 5.0

    example
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    client.getSpace('<space_id>')
    .then((space) => space.createAssetFromFiles({
      fields: {
        file: {
          'en-US': {
             contentType: 'image/jpeg',
             fileName: 'filename_english.jpg',
             file: createReadStream('path/to/filename_english.jpg')
          },
          'de-DE': {
             contentType: 'image/svg+xml',
             fileName: 'filename_german.svg',
             file: '<svg><path fill="red" d="M50 50h150v50H50z"/></svg>'
          }
        }
      }
    }))
    .then((asset) => console.log(asset))
    .catch(console.error)

    Parameters

    • data: AssetFileProp

      Object representation of the Asset to be created. Note that the field object should have an uploadFrom property on asset creation, which will be removed and replaced with an url property when processing is finished.

    Returns Promise<Asset>

    Promise for the newly created Asset

createAssetWithId

  • Creates a Asset with a custom ID. After creation, call asset.processForLocale or asset.processForAllLocales to start asset processing.

    deprecated

    since version 5.0

    example
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    // Create asset
    client.getSpace('<space_id>')
    .then((space) => space.createAssetWithId('<asset_id>', {
      title: {
        'en-US': 'Playsam Streamliner'
      },
      file: {
        'en-US': {
          contentType: 'image/jpeg',
          fileName: 'example.jpeg',
          upload: 'https://example.com/example.jpg'
        }
      }
    }))
    .then((asset) => asset.process())
    .then((asset) => console.log(asset))
    .catch(console.error)

    Parameters

    • id: string

      Asset ID

    • data: AssetProps

      Object representation of the Asset to be created. Note that the field object should have an upload property on asset creation, which will be removed and replaced with an url property when processing is finished.

    Returns Promise<Asset>

    Promise for the newly created Asset

createContentType

  • Creates a Content Type

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.createContentType({
      name: 'Blog Post',
      fields: [
        {
          id: 'title',
          name: 'Title',
          required: true,
          localized: false,
          type: 'Text'
        }
      ]
    }))
    .then((contentType) => console.log(contentType))
    .catch(console.error)

    Parameters

    • data: ContentTypeProps

      Object representation of the Content Type to be created

    Returns Promise<ContentType>

    Promise for the newly created Content Type

createContentTypeWithId

  • Creates a Content Type with a custom ID

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.createContentTypeWithId('<content-type-id>', {
      name: 'Blog Post',
      fields: [
        {
          id: 'title',
          name: 'Title',
          required: true,
          localized: false,
          type: 'Text'
        }
      ]
    }))
    .then((contentType) => console.log(contentType))
    .catch(console.error)

    Parameters

    • id: string

      Content Type ID

    • data: ContentTypeProps

      Object representation of the Content Type to be created

    Returns Promise<ContentType>

    Promise for the newly created Content Type

createEntry

  • Creates a Entry

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.createEntry('<content_type_id>', {
      fields: {
        title: {
          'en-US': 'Entry title'
        }
      }
    }))
    .then((entry) => console.log(entry))
    .catch(console.error)

    Parameters

    • contentTypeID: string
    • data: EntryProp

      Object representation of the Entry to be created

    Returns Promise<Entry>

    Promise for the newly created Entry

createEntryWithId

  • createEntryWithId(contentTypeID: string, id: string, data: EntryProp): Promise<Entry>
  • Creates a Entry with a custom ID

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    // Create entry
    client.getSpace('<space_id>')
    .then((space) => space.createEntryWithId('<content_type_id>', '<entry_id>', {
      fields: {
        title: {
          'en-US': 'Entry title'
        }
      }
    }))
    .then((entry) => console.log(entry))
    .catch(console.error)

    Parameters

    • contentTypeID: string
    • id: string

      Entry ID

    • data: EntryProp

      Object representation of the Entry to be created

    Returns Promise<Entry>

    Promise for the newly created Entry

createEnvironment

  • Creates an Environement

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.createEnvironment({ name: 'Staging' }))
    .then((environment) => console.log(environment))
    .catch(console.error)

    Parameters

    Returns Promise<Environment>

    Promise for the newly created Environment

createEnvironmentWithId

  • Creates an Environment with a custom ID

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.createEnvironmentWithId('<environment-id>', { name: 'Staging'}, 'master'))
    .then((environment) => console.log(environment))
    .catch(console.error)

    Parameters

    • id: string

      Environment ID

    • data: EnvironmentProps

      Object representation of the Environment to be created

    • sourceEnvironmentId: string

      ID of the source environment that will be copied to create the new environment. Default is "master"

    Returns Promise<Environment>

    Promise for the newly created Environment

createLocale

  • Creates a Locale

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    // Create locale
    client.getSpace('<space_id>')
    .then((space) => space.createLocale({
      name: 'German (Austria)',
      code: 'de-AT',
      fallbackCode: 'de-DE',
      optional: true
    }))
    .then((locale) => console.log(locale))
    .catch(console.error)

    Parameters

    • data: LocaleProps

      Object representation of the Locale to be created

    Returns Promise<Locale>

    Promise for the newly created Locale

createRole

  • Creates a Role

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    client.getSpace('<space_id>')
    .then((space) => space.createRole({
      name: 'My Role',
      description: 'foobar role',
      permissions: {
        ContentDelivery: 'all',
        ContentModel: ['read'],
        Settings: []
      },
      policies: [
        {
          effect: 'allow',
          actions: 'all',
          constraint: {
            and: [
              {
                equals: [
                  { doc: 'sys.type' },
                  'Entry'
                ]
              },
              {
                equals: [
                  { doc: 'sys.type' },
                  'Asset'
                ]
              }
            ]
          }
        }
      ]
    }))
    .then((role) => console.log(role))
    .catch(console.error)

    Parameters

    • data: RoleProps

      Object representation of the Role to be created

    Returns Promise<Role>

    Promise for the newly created Role

createRoleWithId

  • Creates a Role with a custom ID

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    client.getSpace('<space_id>')
    .then((space) => space.createRoleWithId('<role-id>', {
      name: 'My Role',
      description: 'foobar role',
      permissions: {
        ContentDelivery: 'all',
        ContentModel: ['read'],
        Settings: []
      },
      policies: [
        {
          effect: 'allow',
          actions: 'all',
          constraint: {
            and: [
              {
                equals: [
                  { doc: 'sys.type' },
                  'Entry'
                ]
              },
              {
                equals: [
                  { doc: 'sys.type' },
                  'Asset'
                ]
              }
            ]
          }
        }
      ]
    }))
    .then((role) => console.log(role))
    .catch(console.error)

    Parameters

    Returns Promise<Role>

    Promise for the newly created Role

createSpaceMembership

  • Creates a Space Membership Warning: the user attribute in the space membership root is deprecated. The attribute has been moved inside the sys object (i.e. sys.user).

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.createSpaceMembership({
      admin: false,
      roles: [
        {
          type: 'Link',
          linkType: 'Role',
          id: '<role_id>'
        }
      ],
      email: 'foo@example.com'
    }))
    .then((spaceMembership) => console.log(spaceMembership))
    .catch(console.error)

    Parameters

    Returns Promise<SpaceMembership>

    Promise for the newly created Space Membership

createSpaceMembershipWithId

  • Creates a Space Membership with a custom ID Warning: the user attribute in the space membership root is deprecated. The attribute has been moved inside the sys object (i.e. sys.user).

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.createSpaceMembershipWithId('<space-membership-id>', {
      admin: false,
      roles: [
        {
          type: 'Link',
          linkType: 'Role',
          id: '<role_id>'
        }
      ],
      email: 'foo@example.com'
    }))
    .then((spaceMembership) => console.log(spaceMembership))
    .catch(console.error)

    Parameters

    • id: string

      Space Membership ID

    • data: SpaceMembershipProps

      Object representation of the Space Membership to be created

    Returns Promise<SpaceMembership>

    Promise for the newly created Space Membership

createTeamSpaceMembership

  • Creates a Team Space Membership

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.createTeamSpaceMembership('team_id', {
      admin: false,
      roles: [
        {
          type: 'Link',
          linkType: 'Role',
          id: '<role_id>'
        }
      ],
    }))
    .then((teamSpaceMembership) => console.log(teamSpaceMembership))
    .catch(console.error)

    Parameters

    Returns Promise<TeamSpaceMembership>

    Promise for the newly created Team Space Membership

createUiExtension

  • Creates a UI Extension

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.createUiExtension({
      extension: {
        name: 'My awesome extension',
        src: 'https://example.com/my',
        fieldTypes: [
          {
            type: 'Symbol'
          },
          {
            type: 'Text'
          }
        ],
        sidebar: false
      }
    }))
    .then((uiExtension) => console.log(uiExtension))
    .catch(console.error)

    Parameters

    • data: UIExtensionProps

      Object representation of the UI Extension to be created

    Returns Promise<UIExtension>

    Promise for the newly created UI Extension

createUiExtensionWithId

  • Creates a UI Extension with a custom ID

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.createUiExtensionWithId('<extension_id>', {
      extension: {
        name: 'My awesome extension',
        src: 'https://example.com/my',
        fieldTypes: [
          {
            type: 'Symbol'
          },
          {
            type: 'Text'
          }
        ],
        sidebar: false
      }
    }))
    .then((uiExtension) => console.log(uiExtension))
    .catch(console.error)

    Parameters

    • id: string

      UI Extension ID

    • data: UIExtensionProps

      Object representation of the UI Extension to be created

    Returns Promise<UIExtension>

    Promise for the newly created UI Extension

createUpload

  • createUpload(data: { file: string | ArrayBuffer | Stream }): Promise<Upload>
  • Creates a Upload.

    deprecated

    since version 5.0

    example
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    const uploadStream = createReadStream('path/to/filename_english.jpg')
    client.getSpace('<space_id>')
    .then((space) => space.createUpload({file: uploadStream, 'image/png'})
    .then((upload) => console.log(upload))
    .catch(console.error)

    Parameters

    • data: { file: string | ArrayBuffer | Stream }

      Object with file information.

      • file: string | ArrayBuffer | Stream

        Actual file content. Can be a string, an ArrayBuffer or a Stream.

    Returns Promise<Upload>

    Upload object containing information about the uploaded file.

createWebhook

  • Creates a Webhook

    example
    const contentful = require('contentful-management')
    
    client.getSpace('<space_id>')
    .then((space) => space.createWebhook({
      'name': 'My webhook',
      'url': 'https://www.example.com/test',
      'topics': [
        'Entry.create',
        'ContentType.create',
        '*.publish',
        'Asset.*'
      ]
    }))
    .then((webhook) => console.log(webhook))
    .catch(console.error)

    Parameters

    • data: WebhookProps

      Object representation of the Webhook to be created

    Returns Promise<WebHooks>

    Promise for the newly created Webhook

createWebhookWithId

  • Creates a Webhook with a custom ID

    example
    const contentful = require('contentful-management')
    
    client.getSpace('<space_id>')
    .then((space) => space.createWebhookWithId('<webhook_id>', {
      'name': 'My webhook',
      'url': 'https://www.example.com/test',
      'topics': [
        'Entry.create',
        'ContentType.create',
        '*.publish',
        'Asset.*'
      ]
    }))
    .then((webhook) => console.log(webhook))
    .catch(console.error)

    Parameters

    • id: string

      Webhook ID

    • data: WebhookProps

      Object representation of the Webhook to be created

    Returns Promise<WebHooks>

    Promise for the newly created Webhook

delete

  • delete(): Promise<void>
  • Deletes the space

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
      .then((space) => space.delete())
      .then(() => console.log('Space deleted.'))
      .catch(console.error)

    Returns Promise<void>

    Promise for the deletion. It contains no data, but the Promise error case should be handled.

getApiKey

  • getApiKey(id: string): Promise<ApiKey>
  • Gets a Api Key

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getApiKey('<apikey-id>'))
    .then((apikey) => console.log(apikey))
    .catch(console.error)

    Parameters

    • id: string

      API Key ID

    Returns Promise<ApiKey>

    Promise for a Api Key

getApiKeys

  • Gets a collection of Api Keys

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getApiKeys())
    .then((response) => console.log(response.items))
    .catch(console.error)

    Returns Promise<Collection<ApiKey>>

    Promise for a collection of Api Keys

getAsset

  • Gets an Asset Warning: if you are using the select operator, when saving, any field that was not selected will be removed from your entry in the backend

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getAsset('<asset_id>'))
    .then((asset) => console.log(asset))
    .catch(console.error)

    Parameters

    • id: string

      Asset ID

    • Optional query: QueryOptions

      Object with search parameters. In this method it's only useful for locale.

    Returns Promise<Asset>

    Promise for an Asset

getAssets

  • Gets a collection of Assets Warning: if you are using the select operator, when saving, any field that was not selected will be removed from your entry in the backend

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getAssets())
    .then((response) => console.log(response.items))
    .catch(console.error)

    Parameters

    Returns Promise<Collection<Asset>>

    Promise for a collection of Assets

getContentType

  • Gets a Content Type

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getContentType('<content_type_id>'))
    .then((contentType) => console.log(contentType))
    .catch(console.error)

    Parameters

    • id: string

      Content Type ID

    Returns Promise<ContentType>

    Promise for a Content Type

getContentTypeSnapshots

  • Gets all snapshots of a contentType

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getContentTypeSnapshots('<contentTypeId>'))
    .then((snapshots) => console.log(snapshots.items))
    .catch(console.error)

    Parameters

    • contentTypeId: string

      Content Type ID

    • Optional query: QueryOptions

      additional query paramaters

    Returns Promise<Collection<Snapshot<ContentTypeProps>>>

    Promise for a collection of Content Type Snapshots

getContentTypes

  • Gets a collection of Content Types

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getContentTypes())
    .then((response) => console.log(response.items))
    .catch(console.error)

    Parameters

    Returns Promise<Collection<ContentType>>

    Promise for a collection of Content Types

getEditorInterfaceForContentType

  • getEditorInterfaceForContentType(contentTypeId: string): Promise<EditorInterface>
  • Gets an EditorInterface for a ContentType

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEditorInterfaceForContentType('<content_type_id>'))
    .then((EditorInterface) => console.log(EditorInterface))
    .catch(console.error)

    Parameters

    • contentTypeId: string

      Content Type ID

    Returns Promise<EditorInterface>

    Promise for an EditorInterface

getEntries

  • Gets a collection of Entries Warning: if you are using the select operator, when saving, any field that was not selected will be removed from your entry in the backend

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEntries({'content_type': 'foo'})) // you can add more queries as 'key': 'value'
    .then((response) => console.log(response.items))
    .catch(console.error)

    Parameters

    Returns Promise<Collection<Entry>>

    Promise for a collection of Entries

getEntry

  • getEntry(id: string): Promise<Entry>
  • Gets an Entry Warning: if you are using the select operator, when saving, any field that was not selected will be removed from your entry in the backend

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEntry('<entry-id>'))
    .then((entry) => console.log(entry))
    .catch(console.error)

    Parameters

    • id: string

      Entry ID

    Returns Promise<Entry>

    Promise for an Entry

getEntrySnapshots

  • Gets all snapshots of an entry

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEntrySnapshots('<entry_id>'))
    .then((snapshots) => console.log(snapshots.items))
    .catch(console.error)

    Parameters

    • id: string

    Returns Promise<Collection<Snapshot<EntryProp>>>

    Promise for a collection of Entry Snapshots

getEnvironment

  • Gets an environment

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEnvironment('<environement_id>'))
    .then((environment) => console.log(environment))
    .catch(console.error)

    Parameters

    • id: string

      Environment ID

    Returns Promise<Environment>

    Promise for an Environment

getEnvironmentAlias

  • Gets an Environment Alias

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEnvironmentAlias('<alias-id>'))
    .then((alias) => console.log(alias))
    .catch(console.error)

    Parameters

    • id: string

    Returns Promise<EnvironmentAlias>

    Promise for an Environment Alias

getEnvironmentAliases

  • Gets a collection of Environment Aliases

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEnvironmentAliases()
    .then((response) => console.log(response.items))
    .catch(console.error)

    Returns Promise<Collection<EnvironmentAlias>>

    Promise for a collection of Environment Aliases

getEnvironments

  • Gets a collection of Environments

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEnvironments())
    .then((response) => console.log(response.items))
    .catch(console.error)

    Returns Promise<Collection<Environment>>

    Promise for a collection of Environment

getLocale

  • getLocale(id: string): Promise<Locale>
  • Gets a Locale

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getLocale('<locale_id>'))
    .then((locale) => console.log(locale))
    .catch(console.error)

    Parameters

    • id: string

      Locale ID

    Returns Promise<Locale>

    Promise for an Locale

getLocales

  • Gets a collection of Locales

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getLocales())
    .then((response) => console.log(response.items))
    .catch(console.error)

    Returns Promise<Collection<Locale>>

    Promise for a collection of Locales

getPreviewApiKey

  • Gets a preview Api Key

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getPreviewApiKey('<preview-apikey-id>'))
    .then((previewApikey) => console.log(previewApikey))
    .catch(console.error)

    Parameters

    • id: string

      Preview API Key ID

    Returns Promise<PreviewApiKey>

    Promise for a Preview Api Key

getPreviewApiKeys

  • Gets a collection of preview Api Keys

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getPreviewApiKeys())
    .then((response) => console.log(response.items))
    .catch(console.error)

    Returns Promise<Collection<PreviewApiKey>>

    Promise for a collection of Preview Api Keys

getRole

  • getRole(id: string): Promise<Role>
  • Gets a Role

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.createRole({
      fields: {
        title: {
          'en-US': 'Role title'
        }
      }
    }))
    .then((role) => console.log(role))
    .catch(console.error)

    Parameters

    • id: string

      Role ID

    Returns Promise<Role>

    Promise for a Role

getRoles

  • Gets a collection of Roles

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getRoles())
    .then((response) => console.log(response.items))
    .catch(console.error)

    Returns Promise<Collection<Role>>

    Promise for a collection of Roles

getSpaceMember

  • Gets a Space Member

    example
    const contentful = require('contentful-management')
    
    client.getSpace('<space_id>')
    .then((space) => space.getSpaceMember(id))
    .then((spaceMember) => console.log(spaceMember))
    .catch(console.error)

    Parameters

    • id: string

      Get Space Member by user_id

    Returns Promise<SpaceMember>

    Promise for a Space Member

getSpaceMembers

  • Gets a collection of Space Members

    example
    const contentful = require('contentful-management')
    
    client.getSpace('<space_id>')
    .then((space) => space.getSpaceMembers({'limit': 100}))
    .then((spaceMemberCollection) => console.log(spaceMemberCollection))
    .catch(console.error)

    Parameters

    • Optional query: undefined | object

    Returns Promise<Collection<SpaceMember>>

    Promise for a collection of Space Members

getSpaceMembership

  • Gets a Space Membership Warning: the user attribute in the space membership root is deprecated. The attribute has been moved inside the sys object (i.e. sys.user).

    example
    const contentful = require('contentful-management')
    
    client.getSpace('<space_id>')
    .then((space) => space.getSpaceMembership('id'))
    .then((spaceMembership) => console.log(spaceMembership))
    .catch(console.error)

    Parameters

    • id: string

      Space Membership ID

    Returns Promise<SpaceMembership>

    Promise for a Space Membership

getSpaceMemberships

  • Gets a collection of Space Memberships Warning: the user attribute in the space membership root is deprecated. The attribute has been moved inside the sys object (i.e. sys.user).

    example
    const contentful = require('contentful-management')
    
    client.getSpace('<space_id>')
    .then((space) => space.getSpaceMemberships({'limit': 100})) // you can add more queries as 'key': 'value'
    .then((response) => console.log(response.items))
    .catch(console.error)

    Parameters

    Returns Promise<Collection<SpaceMembership>>

    Promise for a collection of Space Memberships

getSpaceUser

  • getSpaceUser(id: string): Promise<User>
  • Gets a User

    example
    const contentful = require('contentful-management')
    
    client.getSpace('<space_id>')
    .then((space) => space.getSpaceUser('id'))
    .then((user) => console.log(user))
    .catch(console.error)

    Parameters

    • id: string

      User ID

    Returns Promise<User>

    Promise for a User

getTeamSpaceMembership

  • Gets a Team Space Membership

    example
    const contentful = require('contentful-management')
    
    client.getSpace('<space_id>')
    .then((space) => space.getTeamSpaceMembership('team_space_membership_id'))
    .then((teamSpaceMembership) => console.log(teamSpaceMembership))
    .catch(console.error)

    Parameters

    • id: string

      Team Space Membership ID

    Returns Promise<TeamSpaceMembership>

    Promise for a Team Space Membership

getTeamSpaceMemberships

  • Gets a collection of Team Space Memberships

    example
    const contentful = require('contentful-management')
    
    client.getSpace('<space_id>')
    .then((space) => space.getTeamSpaceMemberships())
    .then((response) => console.log(response.items))
    .catch(console.error)

    Returns Promise<Collection<TeamSpaceMembership>>

    Promise for a collection of Team Space Memberships

getUiExtension

  • Gets an UI Extension

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getUiExtension('<extension-id>'))
    .then((uiExtension) => console.log(uiExtension))
    .catch(console.error)

    Parameters

    • id: string

      UI Extension ID

    Returns Promise<UIExtension>

    Promise for an UI Extension

getUiExtensions

  • Gets a collection of UI Extension

    deprecated

    since version 5.0

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getUiExtensions()
    .then((response) => console.log(response.items))
    .catch(console.error)

    Returns Promise<Collection<UIExtension>>

    Promise for a collection of UI Extensions

getUpload

  • getUpload(id: string): Promise<Upload>
  • Gets an Upload

    deprecated

    since version 5.0

    example
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    const uploadStream = createReadStream('path/to/filename_english.jpg')
    client.getSpace('<space_id>')
    .then((space) => space.getUpload('<upload-id>')
    .then((upload) => console.log(upload))
    .catch(console.error)

    Parameters

    • id: string

      Upload ID

    Returns Promise<Upload>

    Promise for an Upload

getWebhook

  • getWebhook(id: string): Promise<WebHooks>
  • Gets a Webhook

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getWebhook('<webhook_id>'))
    .then((webhook) => console.log(webhook))
    .catch(console.error)

    Parameters

    • id: string

      Webhook ID

    Returns Promise<WebHooks>

    Promise for a Webhook

getWebhooks

  • Gets a collection of Webhooks

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getWebhooks())
    .then((response) => console.log(response.items))
    .catch(console.error)

    Returns Promise<Collection<WebHooks>>

    Promise for a collection of Webhooks

toPlainObject

update

  • update(): Promise<void>
  • Updates the space

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => {
      space.name = 'New name'
      return space.update()
    })
    .then((space) => console.log(`Space ${space.sys.id} renamed.`)
    .catch(console.error)

    Returns Promise<void>

    Promise for the updated space.