Options
All
  • Public
  • Public/Protected
  • All
Menu

contentful-management.js - v6.1.1

Index

Enumerations

Interfaces

Type aliases

Variables

Functions

Type aliases

ActionType

ActionType: "read" | "create" | "update" | "delete" | "publish" | "unpublish" | "archive" | "unarchive"

ApiKeyProps

ApiKeyProps: { accessToken: string; description?: undefined | string; environments: { sys: MetaLinkProps }[]; name: string; policies?: { action: string; effect: string }[]; preview_api_key: { sys: MetaLinkProps }; sys: MetaSysProps }

Type declaration

AppDefinitionProps

AppDefinitionProps: { locations: LocationDefinition[]; name: string; src: string; sys: MetaSysProps }

Type declaration

  • locations: LocationDefinition[]

    Locations where the app can be installed

  • name: string

    App name

  • src: string

    URL where the root HTML document of the app can be found

  • sys: MetaSysProps

    System metadata

AppInstallationProps

AppInstallationProps: { parameters: {}; sys: MetaSysProps & { appDefinition: { sys: MetaLinkProps } } }

Type declaration

  • parameters: {}

    App Installation specific configuration variables

    • [key: string]: string
  • sys: MetaSysProps & { appDefinition: { sys: MetaLinkProps } }

AppLocation

AppLocation: "app-config" | "entry-sidebar" | "entry-editor" | "dialog" | "page"

AssetApi

AssetApi: { archive: any; delete: any; isArchived: any; isDraft: any; isPublished: any; isUpdated: any; processForAllLocales: any; processForLocale: any; publish: any; unarchive: any; unpublish: any; update: any }

Type declaration

  • archive: function
    • archive(): Promise<Asset>
    • Archives the object

      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) => asset.archive())
      .then((asset) => console.log(`Asset ${asset.sys.id} archived.`)
      .catch(console.error)

      Returns Promise<Asset>

      Object returned from the server with updated metadata.

  • delete: function
    • delete(): Promise<void>
    • Deletes this object on the server.

      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) => asset.delete())
      .then((asset) => console.log(`Asset deleted.`)
      .catch(console.error)

      Returns Promise<void>

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

  • isArchived: function
    • isArchived(): boolean
    • Checks if asset is archived. This means it's not exposed to the Delivery/Preview APIs.

      Returns boolean

  • isDraft: function
    • isDraft(): boolean
  • isPublished: function
    • isPublished(): boolean
    • Checks if the asset is published. A published asset might have unpublished changes

      Returns boolean

  • isUpdated: function
    • isUpdated(): boolean
    • Checks if the asset is updated. This means the asset was previously published but has unpublished changes.

      Returns boolean

  • processForAllLocales: function
    • Triggers asset processing after an upload, for the files uploaded to all locales of an asset.

      prop

      options.processingCheckWait - Time in milliseconds to wait before checking again if the asset has been processed (default: 500ms)

      prop

      options.processingCheckRetries - Maximum amount of times to check if the asset has been processed (default: 5)

      throws

      {AssetProcessingTimeout} If the asset takes too long to process. If this happens, retrieve the asset again, and if the url property is available, then processing has succeeded. If not, your file might be damaged.

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

      Parameters

      Returns Promise<Asset>

      Object returned from the server with updated metadata.

  • processForLocale: function
    • Triggers asset processing after an upload, for the file uploaded to a specific locale.

      prop

      options.processingCheckWait - Time in milliseconds to wait before checking again if the asset has been processed (default: 500ms)

      prop

      options.processingCheckRetries - Maximum amount of times to check if the asset has been processed (default: 5)

      throws

      {AssetProcessingTimeout} If the asset takes too long to process. If this happens, retrieve the asset again, and if the url property is available, then processing has succeeded. If not, your file might be damaged.

      example
      const contentful = require('contentful-management')
      
      const client = contentful.createClient({
        accessToken: '<content_management_api_key>'
      })
      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.processForLocale('en-US'))
      .then((asset) => console.log(asset))
      .catch(console.error)

      Parameters

      Returns Promise<Asset>

      Object returned from the server with updated metadata.

  • publish: function
    • publish(): Promise<Asset>
    • Publishes the object

      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) => asset.publish())
      .then((asset) => console.log(`Asset ${asset.sys.id} published.`)
      .catch(console.error)

      Returns Promise<Asset>

      Object returned from the server with updated metadata.

  • unarchive: function
    • unarchive(): Promise<Asset>
    • Unarchives the object

      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) => asset.unarchive())
      .then((asset) => console.log(`Asset ${asset.sys.id} unarchived.`)
      .catch(console.error)

      Returns Promise<Asset>

      Object returned from the server with updated metadata.

  • unpublish: function
    • unpublish(): Promise<Asset>
    • Unpublishes the object

      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) => asset.unpublish())
      .then((asset) => console.log(`Asset ${asset.sys.id} unpublished.`)
      .catch(console.error)

      Returns Promise<Asset>

      Object returned from the server with updated metadata.

  • update: function
    • update(): Promise<Asset>
    • Sends an update to the server with any changes made to the object's properties

      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) => {
        asset.fields.title['en-US'] = 'New asset title'
        return asset.update()
      })
      .then((asset) => console.log(`Asset ${asset.sys.id} updated.`)
      .catch(console.error)

      Returns Promise<Asset>

      Object returned from the server with updated changes.

AssetProps

AssetProps: { fields: { description?: undefined | {}; file: {}; title: {} }; metadata?: MetadataProps; sys: { locale: string } & MetaSysProps }

Type declaration

  • fields: { description?: undefined | {}; file: {}; title: {} }
    • Optional description?: undefined | {}

      Description for this asset

    • file: {}

      File object for this asset

      • [key: string]: { contentType: string; details?: Record<string, any>; fileName: string; upload?: undefined | string; uploadFrom?: Record<string, any>; url?: undefined | string }
        • contentType: string
        • Optional details?: Record<string, any>

          Details for the file, depending on file type (example: image size in bytes, etc)

        • fileName: string
        • Optional upload?: undefined | string

          Url where the file is available to be downloaded from, into the Contentful asset system. After the asset is processed this field is gone.

        • Optional uploadFrom?: Record<string, any>
        • Optional url?: undefined | string

          Url where the file is available at the Contentful media asset system. This field won't be available until the asset is processed.

    • title: {}

      Title for this asset

      • [key: string]: string
  • Optional metadata?: MetadataProps
  • sys: { locale: string } & MetaSysProps

ClientAPI

ClientAPI: ReturnType<typeof createClientApi>

ClientParams

ClientParams: { accessToken: string; application?: undefined | string; feature?: undefined | string; headers?: undefined | {}; host?: undefined | string; hostUpload?: undefined | string; httpAgent?: httpAgent; httpsAgent?: httpsAgent; insecure?: undefined | false | true; integration?: undefined | string; logHandler?: undefined | ((level: string, data: Error | string) => void); maxContentLength?: undefined | number; proxy?: AxiosProxyConfig; requestLogger?: undefined | ((config: AxiosRequestConfig) => void); responseLogger?: undefined | ((response: AxiosResponse) => void); retryLimit?: undefined | number; retryOnError?: undefined | false | true; timeout?: undefined | number }

Type declaration

  • accessToken: string

    Contentful CMA Access Token

  • Optional application?: undefined | string

    Application name and version e.g myApp/version

  • Optional feature?: undefined | string
  • Optional headers?: undefined | {}

    Optional additional headers

  • Optional host?: undefined | string

    API host

    default

    api.contentful.com

  • Optional hostUpload?: undefined | string

    direct file upload host

    default

    upload.contentful.com

  • Optional httpAgent?: httpAgent

    Optional Node.js HTTP agent for proxying

    see

    Node.js docs and https-proxy-agent

  • Optional httpsAgent?: httpsAgent

    Optional Node.js HTTP agent for proxying

    see

    Node.js docs and https-proxy-agent

  • Optional insecure?: undefined | false | true

    Requests will be made over http instead of the default https

    default

    false

  • Optional integration?: undefined | string

    Integration name and version e.g react/version

  • Optional logHandler?: undefined | ((level: string, data: Error | string) => void)

    A log handler function to process given log messages & errors. Receives the log level (error, warning & info) and the actual log data (Error object or string).

    see

    The default can be found at: https://github.com/contentful/contentful-sdk-core/blob/master/lib/create-http-client.js

  • Optional maxContentLength?: undefined | number

    Optional maximum content length in bytes

    default

    1073741824 i.e 1GB

  • Optional proxy?: AxiosProxyConfig

    Optional Axios proxy

    see

    axios docs

  • Optional requestLogger?: undefined | ((config: AxiosRequestConfig) => void)

    Gets called on every request triggered by the SDK

  • Optional responseLogger?: undefined | ((response: AxiosResponse) => void)

    Gets called on every response

  • Optional retryLimit?: undefined | number

    Optional number of retries before failure

    default

    5

  • Optional retryOnError?: undefined | false | true

    If we should retry on errors and 429 rate limit exceptions

    default

    true

  • Optional timeout?: undefined | number

    Optional number of milliseconds before the request times out.

    default

    30000

ConditionType

ConditionType: "and" | "or" | "not" | "equals"

ConstraintType

ConstraintType: {}

Type declaration

ContentTypeApi

ContentTypeApi: { delete: any; getEditorInterface: any; getSnapshot: any; getSnapshots: any; isDraft: any; isPublished: any; isUpdated: any; omitAndDeleteField: any; publish: any; unpublish: any; update: any }

Type declaration

  • delete: function
    • delete(): Promise<void>
    • Deletes this object on the server.

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

      Returns Promise<void>

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

  • getEditorInterface: function
    • Gets the editor interface for the object
      Important note: The editor interface only represent a published contentType.
      To get the most recent representation of the contentType make sure to publish it first

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

      Returns Promise<EditorInterface>

      Object returned from the server with the current editor interface.

  • getSnapshot: function
    • Gets a snapshot of a contentType

      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((entry) => entry.getSnapshot('<snapshot-id>'))
      .then((snapshot) => console.log(snapshot))
      .catch(console.error)

      Parameters

      • id: string

      Returns Promise<SnapshotProps<ContentTypeProps>>

  • getSnapshots: function
    • Gets all snapshots of a contentType

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

      Returns Promise<Collection<Snapshot<ContentTypeProps>, SnapshotProps<ContentTypeProps>>>

  • isDraft: function
    • isDraft(): boolean
  • isPublished: function
    • isPublished(): boolean
    • Checks if the contentType is published. A published contentType might have unpublished changes (@see {ContentType.isUpdated})

      Returns boolean

  • isUpdated: function
    • isUpdated(): boolean
    • Checks if the contentType is updated. This means the contentType was previously published but has unpublished changes.

      Returns boolean

  • omitAndDeleteField: function
    • Omits and deletes a field if it exists on the contentType. This is a convenience method which does both operations at once and potentially less safe than the standard way. See note about deleting fields on the Update method.

      Parameters

      • id: string

      Returns Promise<ContentType>

      Object returned from the server with updated metadata.

  • publish: function
    • Publishes the object

      example
      const contentful = require('contentful-management')
      
      const client = contentful.createClient({
        accessToken: '<content_management_api_key>'
      })
      
      client.getSpace('<space_id>')
      .then((space) => space.getContentType('<contentType_id>'))
      .then((contentType) => contentType.publish())
      .then((contentType) => console.log(`${contentType.sys.id} is published`))
      .catch(console.error)

      Returns Promise<ContentType>

      Object returned from the server with updated metadata.

  • unpublish: function
    • Unpublishes the object

      example
      const contentful = require('contentful-management')
      
      const client = contentful.createClient({
        accessToken: '<content_management_api_key>'
      })
      
      client.getSpace('<space_id>')
      .then((space) => space.getContentType('<contentType_id>'))
      .then((contentType) => contentType.unpublish())
      .then((contentType) => console.log(`${contentType.sys.id} is unpublished`))
      .catch(console.error)

      Returns Promise<ContentType>

      Object returned from the server with updated metadata.

  • update: function
    • Sends an update to the server with any changes made to the object's properties.
      Important note about deleting fields: The standard way to delete a field is with two updates: first omit the property from your responses (set the field attribute "omitted" to true), and then delete it by setting the attribute "deleted" to true. See the "Deleting fields" section in the API reference for more reasoning. Alternatively, you may use the convenience method omitAndDeleteField to do both steps at once.

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

      Returns Promise<ContentType>

      Object returned from the server with updated changes.

ContentTypeProps

ContentTypeProps: { description: string; displayField: string; fields: ContentFields[]; name: string; sys: MetaSysProps }

Type declaration

  • description: string
  • displayField: string

    Field used as the main display field for Entries

  • fields: ContentFields[]

    All the fields contained in this Content Type

  • name: string
  • sys: MetaSysProps

ContentfulEnvironmentAPI

ContentfulEnvironmentAPI: ReturnType<typeof createEnvironmentApi>

ContentfulOrganizationAPI

ContentfulOrganizationAPI: ReturnType<typeof createOrganizationApi>

ContentfulSpaceAPI

ContentfulSpaceAPI: ReturnType<typeof createSpaceApi>

CreateApiKeyProps

CreateApiKeyProps: Pick<ApiKeyProps, "name" | "environments" | "description">

CreateContentTypeProps

CreateContentTypeProps: SetOptional<Except<ContentTypeProps, "sys">, "description" | "displayField">

CreateLocaleProps

CreateLocaleProps: SetOptional<Except<LocaleProps, "sys">, "optional" | "contentManagementApi" | "default" | "contentDeliveryApi">

CreatePersonalAccessTokenProps

CreatePersonalAccessTokenProps: Pick<PersonalAccessToken, "name" | "scopes">

EditorInterfaceProps

EditorInterfaceProps: { controls: Control[]; sys: MetaSysProps & { contentType: { sys: MetaLinkProps }; environment: { sys: MetaLinkProps }; space: { sys: MetaLinkProps } } }

Type declaration

EntryApi

EntryApi: { archive: any; delete: any; getSnapshot: any; getSnapshots: any; isArchived: any; isDraft: any; isPublished: any; isUpdated: any; publish: any; unarchive: any; unpublish: any; update: any }

Type declaration

  • archive: function
    • archive(): Promise<Entry>
    • Archives the object

      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) => entry.archive())
      .then((entry) => console.log(`Entry ${entry.sys.id} archived.`))
      .catch(console.error)

      Returns Promise<Entry>

      Object returned from the server with updated metadata.

  • delete: function
    • delete(): Promise<void>
    • Deletes this object on the server.

      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) => entry.delete())
      .then(() => console.log(`Entry deleted.`))
      .catch(console.error)

      Returns Promise<void>

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

  • getSnapshot: function
    • Gets a snapshot of an entry

      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) => entry.getSnapshot('<snapshot_id>'))
      .then((snapshot) => console.log(snapshot))
      .catch(console.error)

      Parameters

      • id: string

      Returns Promise<Snapshot<EntryProp>>

  • getSnapshots: function
    • Gets all snapshots of an entry

      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) => entry.getSnapshots())
      .then((snapshots) => console.log(snapshots.items))
      .catch(console.error)

      Returns Promise<Collection<Snapshot<EntryProp>, SnapshotProps<EntryProp>>>

  • isArchived: function
    • isArchived(): boolean
    • Checks if entry is archived. This means it's not exposed to the Delivery/Preview APIs.

      Returns boolean

  • isDraft: function
    • isDraft(): boolean
  • isPublished: function
    • isPublished(): boolean
    • Checks if the entry is published. A published entry might have unpublished changes

      Returns boolean

  • isUpdated: function
    • isUpdated(): boolean
    • Checks if the entry is updated. This means the entry was previously published but has unpublished changes.

      Returns boolean

  • publish: function
    • publish(): Promise<Entry>
    • Publishes the object

      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) => entry.publish())
      .then((entry) => console.log(`Entry ${entry.sys.id} published.`))
      .catch(console.error)

      Returns Promise<Entry>

      Object returned from the server with updated metadata.

  • unarchive: function
    • unarchive(): Promise<Entry>
    • Unarchives the object

      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) => entry.unarchive())
      .then((entry) => console.log(`Entry ${entry.sys.id} unarchived.`))
      .catch(console.error)

      Returns Promise<Entry>

      Object returned from the server with updated metadata.

  • unpublish: function
    • unpublish(): Promise<Entry>
    • Unpublishes the object

      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) => entry.unpublish())
      .then((entry) => console.log(`Entry ${entry.sys.id} unpublished.`))
      .catch(console.error)

      Returns Promise<Entry>

      Object returned from the server with updated metadata.

  • update: function
    • update(): Promise<Entry>
    • Sends an update to the server with any changes made to the object's properties

      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) => {
        entry.fields.title['en-US'] = 'New entry title'
        return entry.update()
      })
      .then((entry) => console.log(`Entry ${entry.sys.id} updated.`))
      .catch(console.error)

      Returns Promise<Entry>

      Object returned from the server with updated changes.

EntryFields

EntryFields: symbol | Text | RichText | Integer | number | Date | boolean | Record<string, any> | Location | Entry | Array

EntryProp

EntryProp: { fields: Record<string, any>; metadata?: MetadataProps; sys: EntrySys }

Type declaration

Environment

EnvironmentAliasProps

EnvironmentAliasProps: { environment: { sys: MetaLinkProps }; sys: MetaSysProps }

Type declaration

EnvironmentProps

EnvironmentProps: { name: string; sys: MetaSysProps & { space: { sys: MetaLinkProps } } }

Type declaration

Field

Field: "Symbol" | "Text" | "RichText" | "Integer" | "Number" | "Date" | "Location" | "Boolean" | "Object"

FieldType

ISO8601Timestamp

ISO8601Timestamp: string

String will be in ISO8601 datetime format e.g. 2013-06-26T13:57:24Z

LinkType

LinkType: "Asset" | "Entry"

LocaleProps

LocaleProps: { code: string; contentDeliveryApi: boolean; contentManagementApi: boolean; default: boolean; fallbackCode: string; name: string; optional: boolean; sys: MetaSysProps }

Type declaration

  • code: string

    Locale code (example: en-us)

  • contentDeliveryApi: boolean

    If the content under this locale should be available on the CDA (for public reading)

  • contentManagementApi: boolean

    If the content under this locale should be available on the CMA (for editing)

  • default: boolean

    If this is the default locale

  • fallbackCode: string

    Locale code to fallback to when there is not content for the current locale

  • name: string

    Locale name

  • optional: boolean

    If the locale needs to be filled in on entries or not

  • sys: MetaSysProps

LocationDefinition

Organization

OrganizationInvitationProps

OrganizationInvitationProps: { email: string; firstName: string; lastName: string; role: string; sys: MetaSysProps & { invitationUrl: string; organizationMembership: { sys: MetaLinkProps }; status: string; user: Record<string, any> | null } }

Type declaration

  • email: string
  • firstName: string
  • lastName: string
  • role: string
  • sys: MetaSysProps & { invitationUrl: string; organizationMembership: { sys: MetaLinkProps }; status: string; user: Record<string, any> | null }

OrganizationMembershipProps

OrganizationMembershipProps: { role: string; status: boolean; sys: MetaSysProps }

Type declaration

  • role: string

    Role

  • status: boolean

    status

  • sys: MetaSysProps

    System metadata

OrganizationProp

OrganizationProp: { name: string; sys: MetaSysProps }

Type declaration

PersonalAccessTokenProp

PersonalAccessTokenProp: { name: string; revokedAt: null | string; scopes: "content_management_manage"[]; sys: MetaSysProps; token?: undefined | string }

Type declaration

  • name: string
  • revokedAt: null | string
  • scopes: "content_management_manage"[]
  • sys: MetaSysProps
  • Optional token?: undefined | string

PreviewApiKeyProps

PreviewApiKeyProps: { description: string; name: string; sys: MetaSysProps }

Type declaration

RoleProps

RoleProps: { name: string; permissions: { ContentDelivery: string[] | string; ContentModel: string[]; EnvironmentAliases: string[] | string; Environments: string[] | string; Settings: string[] | string }; policies: { actions: ActionType[] | "all"; constraint: ConstraintType; effect: string }[]; sys: MetaSysProps }

Type declaration

  • name: string
  • permissions: { ContentDelivery: string[] | string; ContentModel: string[]; EnvironmentAliases: string[] | string; Environments: string[] | string; Settings: string[] | string }

    Permissions for application sections

    • ContentDelivery: string[] | string
    • ContentModel: string[]
    • EnvironmentAliases: string[] | string
    • Environments: string[] | string
    • Settings: string[] | string
  • policies: { actions: ActionType[] | "all"; constraint: ConstraintType; effect: string }[]
  • sys: MetaSysProps

SchedulableActionType

SchedulableActionType: "publish" | "unpublish"

SchedulableEntityType

SchedulableEntityType: "Entry"

ScheduledActionApi

ScheduledActionApi: { delete: any }

Type declaration

ScheduledActionProps

ScheduledActionProps: { action: SchedulableActionType; entity: Link<SchedulableEntityType>; environment?: undefined | { sys: MetaLinkProps }; scheduledFor: { datetime: ISO8601Timestamp }; sys: ScheduledActionSysProps }

Type declaration

ScheduledActionSysProps

ScheduledActionSysProps: { canceledAt?: ISO8601Timestamp; canceledBy?: undefined | { sys: MetaLinkProps }; createdAt: ISO8601Timestamp; createdBy: { sys: MetaLinkProps }; id: string; space: { sys: MetaLinkProps }; status: ScheduledActionStatus; type: "ScheduledAction" }

Type declaration

SdkHttpClient

SdkHttpClient: AxiosInstance & { cloneWithNewParams: (newParams: Record<string, any>) => SdkHttpClient; httpClientParams: Record<string, any> }

SnapshotProps

SnapshotProps<T>: { snapshot: T; sys: MetaSysProps & { snapshotEntityType: string; snapshotType: string } }

Type parameters

  • T

Type declaration

  • snapshot: T
  • sys: MetaSysProps & { snapshotEntityType: string; snapshotType: string }

Space

SpaceMemberProps

SpaceMemberProps: { admin: boolean; roles: { sys: MetaLinkProps }[]; sys: MetaSysProps }

Type declaration

SpaceMembershipProps

SpaceMembershipProps: { admin: boolean; name: string; roles: { sys: MetaLinkProps }[]; sys: MetaSysProps }

Type declaration

SpaceProps

SpaceProps: { name: string; sys: MetaSysProps }

Type declaration

TagApi

TagApi: { delete: any; update: any }

Type declaration

TagCollectionProps

TagCollectionProps: { items: TagProps[]; sys: { type: "Array" }; total: number }

Type declaration

  • items: TagProps[]
  • sys: { type: "Array" }
    • type: "Array"
  • total: number

TagProps

TagProps: { name: string; sys: TagSysProps }

Type declaration

TagSysProps

TagSysProps: Pick<MetaSysProps, "id" | "space" | "version" | "createdAt" | "createdBy" | "updatedAt" | "updatedBy"> & { environment: { sys: { id: string; linkType: "Environment"; type: "Link" } }; type: "Tag" }

TeamMembershipProps

TeamMembershipProps: { admin: boolean; organizationMembershipId: string; sys: MetaSysProps & { team: { sys: MetaLinkProps } } }

Type declaration

  • admin: boolean

    Is admin

  • organizationMembershipId: string

    Organization membership id

  • sys: MetaSysProps & { team: { sys: MetaLinkProps } }

    System metadata

TeamProps

TeamProps: { description: string; name: string; sys: MetaSysProps }

Type declaration

  • description: string

    Description of the team

  • name: string

    Name of the team

  • sys: MetaSysProps

    System metadata

TeamSpaceMembershipProps

TeamSpaceMembershipProps: { admin: boolean; roles: { sys: MetaLinkProps }[]; sys: MetaSysProps }

Type declaration

ThisContext

UIExtensionProps

UIExtensionProps: { extension: { fieldTypes: EntryFields[]; name: string; sidebar: boolean; src?: undefined | string; srcdoc?: undefined | string }; sys: MetaSysProps }

Type declaration

  • extension: { fieldTypes: EntryFields[]; name: string; sidebar: boolean; src?: undefined | string; srcdoc?: undefined | string }
    • fieldTypes: EntryFields[]

      Field types where an extension can be used

    • name: string

      Extension name

    • sidebar: boolean

      Controls the location of the extension. If true it will be rendered on the sidebar instead of replacing the field's editing control

    • Optional src?: undefined | string

      URL where the root HTML document of the extension can be found

    • Optional srcdoc?: undefined | string

      String representation of the extension (e.g. inline HTML code)

  • sys: MetaSysProps

UploadProps

UploadProps: { sys: MetaSysProps }

Type declaration

UsageMetricEnum

UsageMetricEnum: "cda" | "cma" | "cpa" | "gql"

UsageProps

UsageProps: { dateRange: { endAt: string; startAt: string }; metric: UsageMetricEnum; sys: MetaSysProps & { organization?: undefined | { sys: MetaLinkProps } }; unitOfMeasure: string; usage: number; usagePerDay: {} }

Type declaration

  • dateRange: { endAt: string; startAt: string }

    Range of usage

    • endAt: string
    • startAt: string
  • metric: UsageMetricEnum

    Type of usage

  • sys: MetaSysProps & { organization?: undefined | { sys: MetaLinkProps } }

    System metadata

  • unitOfMeasure: string

    Unit of usage metric

  • usage: number

    Value of the usage

  • usagePerDay: {}

    Usage per day

    • [key: string]: number

UserProps

UserProps: { activated: boolean; avatarUrl: string; confirmed: boolean; email: string; firstName: string; lastName: string; signInCount: number; sys: MetaSysProps }

Type declaration

  • activated: boolean

    Activation flag

  • avatarUrl: string

    Url to the users avatar

  • confirmed: boolean

    User confirmation flag

  • email: string

    Email address of the user

  • firstName: string

    First name of the user

  • lastName: string

    Last name of the user

  • signInCount: number

    Number of sign ins

  • sys: MetaSysProps

    System metadata

WebhookFilter

WebhookHeader

WebhookHeader: { key: string; secret?: undefined | false | true; value: string }

Type declaration

  • key: string
  • Optional secret?: undefined | false | true
  • value: string

WebhookProps

WebhookProps: { filters?: WebhookFilter[]; headers: Array<WebhookHeader>; httpBasicPassword?: undefined | string; httpBasicUsername?: undefined | string; name: string; sys: MetaSysProps; topics: string[]; transformation?: WebhookTransformation; url: string }

Type declaration

  • Optional filters?: WebhookFilter[]

    Webhook filters

  • headers: Array<WebhookHeader>

    Headers that should be appended to the webhook request

  • Optional httpBasicPassword?: undefined | string

    Password for basic http auth

  • Optional httpBasicUsername?: undefined | string

    Username for basic http auth

  • name: string

    Webhook name

  • sys: MetaSysProps

    System metadata

  • topics: string[]

    Topics the webhook wants to subscribe to

  • Optional transformation?: WebhookTransformation

    Transformation to apply

  • url: string

    Webhook url

WebhookTransformation

WebhookTransformation: { body?: JsonValue; contentType?: null | "application/vnd.contentful.management.v1+json" | "application/vnd.contentful.management.v1+json; charset=utf-8" | "application/json" | "application/json; charset=utf-8" | "application/x-www-form-urlencoded" | "application/x-www-form-urlencoded; charset=utf-8"; includeContentLength?: boolean | null; method?: null | "POST" | "GET" | "PUT" | "PATCH" | "DELETE" }

Type declaration

  • Optional body?: JsonValue
  • Optional contentType?: null | "application/vnd.contentful.management.v1+json" | "application/vnd.contentful.management.v1+json; charset=utf-8" | "application/json" | "application/json; charset=utf-8" | "application/x-www-form-urlencoded" | "application/x-www-form-urlencoded; charset=utf-8"
  • Optional includeContentLength?: boolean | null
  • Optional method?: null | "POST" | "GET" | "PUT" | "PATCH" | "DELETE"

WrapperMethod

WrapperMethod<E, A>: (http: A, data: any) => E

Type parameters

  • E

  • A: AxiosInstance

Type declaration

    • (http: A, data: any): E
    • Parameters

      • http: A
      • data: any

      Returns E

Variables

Const ASSET_PROCESSING_CHECK_RETRIES

ASSET_PROCESSING_CHECK_RETRIES: 10 = 10

Const ASSET_PROCESSING_CHECK_WAIT

ASSET_PROCESSING_CHECK_WAIT: 3000 = 3000

Const entityPath

entityPath: "webhook_definitions" = "webhook_definitions"

Const wrapScheduledActionCollection

wrapScheduledActionCollection: (Anonymous function) = wrapCollection(wrapScheduledAction)

Const wrapTagCollection

wrapTagCollection: (Anonymous function) = wrapCollection(wrapTag)

Functions

Const VersionHeader

  • VersionHeader(version?: undefined | number): { headers: object }
  • Parameters

    • Optional version: undefined | number

    Returns { headers: object }

    • headers: object
      • X-Contentful-Version: undefined | number

createApiKeyApi

  • createApiKeyApi(http: AxiosInstance): { delete: (Anonymous function); update: any }

createAppDefinitionApi

  • createAppDefinitionApi(http: AxiosInstance): { delete: (Anonymous function); update: () => Promise<T> }
  • Parameters

    • http: AxiosInstance

    Returns { delete: (Anonymous function); update: () => Promise<T> }

    • delete: (Anonymous function)
    • update: () => Promise<T>
        • (): Promise<T>
        • Returns Promise<T>

createAppInstallationApi

  • createAppInstallationApi(http: AxiosInstance): { delete: (Anonymous function); update: any }

createAssetApi

  • createAssetApi(http: AxiosInstance): AssetApi

createClient

createClientApi

  • createClientApi(__namedParameters: { http: AxiosInstance }): { createPersonalAccessToken: any; createSpace: any; getCurrentUser: any; getOrganization: any; getOrganizationUsage: any; getOrganizations: any; getPersonalAccessToken: any; getPersonalAccessTokens: any; getSpace: any; getSpaceUsage: any; getSpaces: any; rawRequest: any }
  • Parameters

    • __namedParameters: { http: AxiosInstance }
      • http: AxiosInstance

    Returns { createPersonalAccessToken: any; createSpace: any; getCurrentUser: any; getOrganization: any; getOrganizationUsage: any; getOrganizations: any; getPersonalAccessToken: any; getPersonalAccessTokens: any; getSpace: any; getSpaceUsage: any; getSpaces: any; rawRequest: any }

    • createPersonalAccessToken: function
      • Creates a personal access token

        example
        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.createPersonalAccessToken(
         {
           "name": "My Token",
           "scope": [
             "content_management_manage"
           ]
         }
        )
        .then(personalAccessToken => console.log(personalAccessToken.token))
        .catch(console.error)

        Parameters

        Returns Promise<PersonalAccessToken>

        Promise for a Token

    • createSpace: function
      • createSpace(data: Omit<SpaceProps, "sys">, organizationId: string): Promise<Space>
      • Creates a space

        example
        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.createSpace({
          name: 'Name of new space'
        })
        .then((space) => console.log(space))
        .catch(console.error)

        Parameters

        • data: Omit<SpaceProps, "sys">

          Object representation of the Space to be created

        • organizationId: string

          Organization ID, if the associated token can manage more than one organization.

        Returns Promise<Space>

        Promise for the newly created Space

    • getCurrentUser: function
      • getCurrentUser(): Promise<User>
      • Gets the authenticated user

        example
        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getCurrentUser()
        .then(user => console.log(user.firstName))
        .catch(console.error)

        Returns Promise<User>

        Promise for a User

    • getOrganization: function
      • Gets an organization

        example
        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('<org_id>')
        .then((org) => console.log(org))
        .catch(console.error)

        Parameters

        • id: string

          Organization ID

        Returns Promise<Organization>

        Promise for a Organization

    • getOrganizationUsage: function
      • Get organization usage grouped by metric

        example
        
        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganizationUsage('<organizationId>', {
           'metric[in]': 'cma,gql',
           'dateRange.startAt': '2019-10-22',
           'dateRange.endAt': '2019-11-10'
           }
        })
        .then(result => console.log(result.items))
        .catch(console.error)

        Parameters

        • organizationId: string

          Id of an organization

        • Default value query: QueryOptions = {}

          Query parameters

        Returns Promise<Collection<Usage, UsageProps>>

        Promise of a collection of usages

    • getOrganizations: function
      • Gets a collection of Organizations

        example
        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganizations()
        .then(result => console.log(result.items))
        .catch(console.error)

        Returns Promise<Collection<Organization, OrganizationProp>>

        Promise for a collection of Organizations

    • getPersonalAccessToken: function
      • Gets a personal access token

        example
        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getPersonalAccessToken(tokenId)
        .then(token => console.log(token.token))
        .catch(console.error)

        Parameters

        • tokenId: string

        Returns Promise<PersonalAccessToken>

        Promise for a Token

    • getPersonalAccessTokens: function
      • Gets all personal access tokens

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

        Returns Promise<Collection<PersonalAccessToken, PersonalAccessTokenProp>>

        Promise for a Token

    • getSpace: function
      • getSpace(id: string): Promise<Space>
      • Gets a space

        Parameters

        • id: string

          Space ID

        Returns Promise<Space>

        Promise for a Space

        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getSpace('<space_id>')
        .then((space) => console.log(space))
        .catch(console.error)
    • getSpaceUsage: function
      • Get organization usage grouped by space and metric

        Parameters

        • organizationId: string

          Id of an organization

        • Default value query: UsageQuery = {}

          Query parameters

        Returns Promise<Collection<Usage, UsageProps>>

        Promise of a collection of usages

        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getSpaceUsage('<organizationId>', {
           skip: 0,
           limit: 10,
           'metric[in]': 'cda,cpa,gql',
           'dateRange.startAt': '2019-10-22',
           'dateRange.endAt': '2020-11-30'
           }
        })
        .then(result => console.log(result.items))
        .catch(console.error)
    • getSpaces: function
      • Gets all spaces

        Parameters

        Returns Promise<Collection<Space, SpaceProps>>

        Promise for a collection of Spaces

        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getSpaces()
        .then((response) => console.log(response.items))
        .catch(console.error)
    • rawRequest: function
      • rawRequest(opts: AxiosRequestConfig): Promise<any>
      • Make a custom request to the Contentful management API's /spaces endpoint

        Parameters

        Returns Promise<any>

        Promise for the response data

        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.rawRequest({
          method: 'GET',
          url: '/custom/path'
        })
        .then((responseData) => console.log(responseData))
        .catch(console.error)

createContentTypeApi

createDeleteScheduledAction

  • createDeleteScheduledAction(http: AxiosInstance): () => Promise<ScheduledAction>

createDeleteTag

  • createDeleteTag(http: AxiosInstance): () => Promise<void>
  • Parameters

    • http: AxiosInstance

    Returns () => Promise<void>

      • (): Promise<void>
      • Returns Promise<void>

createEditorInterfaceApi

  • createEditorInterfaceApi(http: AxiosInstance): { getControlForField: any; update: any }

createEntryApi

  • createEntryApi(http: AxiosInstance): EntryApi

createEnvironmentAliasApi

  • createEnvironmentAliasApi(http: AxiosInstance): { delete: (Anonymous function); update: () => Promise<T> }
  • Parameters

    • http: AxiosInstance

    Returns { delete: (Anonymous function); update: () => Promise<T> }

    • delete: (Anonymous function)
    • update: () => Promise<T>
        • (): Promise<T>
        • Returns Promise<T>

createEnvironmentApi

  • createEnvironmentApi(__namedParameters: { http: AxiosInstance; httpUpload: AxiosInstance }): { createAsset: createAsset; createUpload: createUpload; createAppInstallation: any; createAssetFromFiles: any; createAssetWithId: any; createContentType: any; createContentTypeWithId: any; createEntry: any; createEntryWithId: any; createLocale: any; createTag: any; createUiExtension: any; createUiExtensionWithId: any; delete: any; getAppInstallation: any; getAppInstallations: any; getAsset: any; getAssetFromData: any; getAssets: any; getContentType: any; getContentTypeSnapshots: any; getContentTypes: any; getEditorInterfaceForContentType: any; getEntries: any; getEntry: any; getEntryFromData: any; getEntrySnapshots: any; getLocale: any; getLocales: any; getTag: any; getTags: any; getUiExtension: any; getUiExtensions: any; getUpload: any; update: any }
  • Creates API object with methods to access the Environment API

    Parameters

    • __namedParameters: { http: AxiosInstance; httpUpload: AxiosInstance }
      • http: AxiosInstance
      • httpUpload: AxiosInstance

    Returns { createAsset: createAsset; createUpload: createUpload; createAppInstallation: any; createAssetFromFiles: any; createAssetWithId: any; createContentType: any; createContentTypeWithId: any; createEntry: any; createEntryWithId: any; createLocale: any; createTag: any; createUiExtension: any; createUiExtensionWithId: any; delete: any; getAppInstallation: any; getAppInstallations: any; getAsset: any; getAssetFromData: any; getAssets: any; getContentType: any; getContentTypeSnapshots: any; getContentTypes: any; getEditorInterfaceForContentType: any; getEntries: any; getEntry: any; getEntryFromData: any; getEntrySnapshots: any; getLocale: any; getLocales: any; getTag: any; getTags: any; getUiExtension: any; getUiExtensions: any; getUpload: any; update: any }

    • createAsset: createAsset

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

      param

      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 for the newly created Asset

      example
      const client = contentful.createClient({
        accessToken: '<content_management_api_key>'
      })
      
      // Create asset
      client.getSpace('<space_id>')
      .then((space) => space.getEnvironment('<environment-id>'))
      .then((environment) => environment.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)
    • createUpload: createUpload

      Creates a Upload.

      param

      Object with file information.

      param

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

      returns

      Upload object containing information about the uploaded file.

      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.getEnvironment('<environment-id>'))
      .then((environment) => environment.createUpload({file: uploadStream})
      .then((upload) => console.log(upload))
      .catch(console.error)
    • createAppInstallation: function
      • Gets an App Installation

        example
        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getSpace('<space_id>')
         .then((space) => space.getEnvironment('<environment-id>'))
         .then((environment) => environment.createAppInstallation('<app_definition_id>', {
           parameters: {
             someParameter: someValue
           }
          })
         .then((appInstallation) => console.log(appInstallation))
         .catch(console.error)

        Parameters

        • appDefinitionId: string

          AppDefinition ID

        • data: Omit<AppInstallationProps, "sys">

          AppInstallation data

        Returns Promise<AppInstallation>

        Promise for an App Installation

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

        example
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getSpace('<space_id>')
        .then((space) => space.getEnvironment('<environment-id>'))
        .then((environment) => environment.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: Omit<AssetFileProp, "sys">

          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: function
      • createAssetWithId(id: string, data: Omit<AssetProps, "sys">): Promise<Asset>
      • Creates a Asset with a custom ID. After creation, call asset.processForLocale or asset.processForAllLocales to start asset processing.

        example
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        // Create asset
        client.getSpace('<space_id>')
        .then((space) => space.getEnvironment('<environment-id>'))
        .then((environment) => environment.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: Omit<AssetProps, "sys">

          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: function
      • Creates a Content Type

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

        Parameters

        Returns Promise<ContentType>

        Promise for the newly created Content Type

    • createContentTypeWithId: function
      • Creates a Content Type 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.getEnvironment('<environment-id>'))
        .then((environment) => environment.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: CreateContentTypeProps

          Object representation of the Content Type to be created

        Returns Promise<ContentType>

        Promise for the newly created Content Type

    • createEntry: function
      • createEntry(contentTypeId: string, data: Omit<EntryProp, "sys">): Promise<Entry>
      • Creates a Entry

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

        Parameters

        • contentTypeId: string

          The Content Type ID of the newly created Entry

        • data: Omit<EntryProp, "sys">

          Object representation of the Entry to be created

        Returns Promise<Entry>

        Promise for the newly created Entry

    • createEntryWithId: function
      • createEntryWithId(contentTypeId: string, id: string, data: Omit<EntryProp, "sys">): Promise<Entry>
      • Creates a Entry with a custom ID

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

        Parameters

        • contentTypeId: string

          The Content Type of the newly created Entry

        • id: string

          Entry ID

        • data: Omit<EntryProp, "sys">

          Object representation of the Entry to be created

        Returns Promise<Entry>

        Promise for the newly created Entry

    • createLocale: function
      • Creates a Locale

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

        Parameters

        Returns Promise<Locale>

        Promise for the newly created Locale

    • createTag: function
      • createTag(id: string, name: string): Promise<Tag>
    • createUiExtension: function
      • Creates a UI Extension

        example
        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getSpace('<space_id>')
        .then((space) => space.getEnvironment('<environment-id>'))
        .then((environment) => environment.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: Omit<UIExtensionProps, "sys">

          Object representation of the UI Extension to be created

        Returns Promise<UIExtension>

        Promise for the newly created UI Extension

    • createUiExtensionWithId: function
      • Creates a UI Extension 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.getEnvironment('<environment-id>'))
        .then((environment) => environment.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

          Extension ID

        • data: Omit<UIExtensionProps, "sys">

          Object representation of the UI Extension to be created

        Returns Promise<UIExtension>

        Promise for the newly created UI Extension

    • delete: function
      • delete(): Promise<void>
      • Deletes the environment

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

        Returns Promise<void>

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

    • getAppInstallation: function
      • Gets an App Installation

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

        Parameters

        • id: string

          AppDefintion ID

        Returns Promise<AppInstallation>

        Promise for an App Installation

    • getAppInstallations: function
      • Gets a collection of App Installation

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

        Returns Promise<Collection<AppInstallation, AppInstallationProps>>

        Promise for a collection of App Installations

    • getAsset: function
      • 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

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

        Parameters

        • id: string

          Asset ID

        • Default value query: QueryOptions = {}

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

        Returns Promise<Asset>

        Promise for an Asset

    • getAssetFromData: function
      • Creates SDK Asset object (locally) from entry data

        example
        environment.getAsset('asset_id').then(asset => {
        
          // Build a plainObject in order to make it usable for React (saving in state or redux)
          const plainObject = asset.toPlainObject();
        
          // The asset is being updated in some way as plainObject:
          const updatedPlainObject = {
            ...plainObject,
            fields: {
              ...plainObject.fields,
              title: {
                'en-US': 'updatedTitle'
              }
            }
          };
        
          // Rebuild an sdk object out of the updated plainObject:
          const assetWithMethodsAgain = environment.getAssetFromData(updatedPlainObject);
        
          // Update with help of the sdk method:
          assetWithMethodsAgain.update();
        
        });

        Parameters

        Returns Asset

        Asset

    • getAssets: function
      • 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

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

        Parameters

        Returns Promise<Collection<Asset, AssetProps>>

        Promise for a collection of Assets

    • getContentType: function
      • Gets a Content Type

        example
        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getSpace('<space_id>')
        .then((space) => space.getEnvironment('<environment-id>'))
        .then((environment) => environment.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: function
      • Gets all snapshots of a contentType

        func

        getContentTypeSnapshots

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

        Parameters

        • contentTypeId: string

          Content Type ID

        • Default value query: QueryOptions = {}

          query additional query paramaters

        Returns Promise<Collection<Snapshot<ContentType>, SnapshotProps<ContentType>>>

        Promise for a collection of Content Type Snapshots

    • getContentTypes: function
      • Gets a collection of Content Types

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

        Parameters

        Returns Promise<Collection<ContentType, ContentTypeProps>>

        Promise for a collection of Content Types

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

        example
        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getSpace('<space_id>')
        .then((space) => space.getEnvironment('<environment-id>'))
        .then((environment) => environment.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: function
      • 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

        example
        const contentful = require('contentful-management')
        
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getSpace('<space_id>')
        .then((space) => space.getEnvironment('<environment-id>'))
        .then((environment) => environment.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, EntryProp>>

        Promise for a collection of Entries

    • getEntry: function
      • 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

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

        Parameters

        • id: string

          Entry ID

        • Default value query: QueryOptions = {}

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

        Returns Promise<Entry>

        Promise for an Entry

    • getEntryFromData: function
      • Creates SDK Entry object (locally) from entry data

        example
        environment.getEntry('entryId').then(entry => {
        
          // Build a plainObject in order to make it usable for React (saving in state or redux)
          const plainObject = entry.toPlainObject();
        
          // The entry is being updated in some way as plainObject:
          const updatedPlainObject = {
            ...plainObject,
            fields: {
              ...plainObject.fields,
              title: {
                'en-US': 'updatedTitle'
              }
            }
          };
        
          // Rebuild an sdk object out of the updated plainObject:
          const entryWithMethodsAgain = environment.getEntryFromData(updatedPlainObject);
        
          // Update with help of the sdk method:
          entryWithMethodsAgain.update();
        
        });

        Parameters

        Returns Entry

        Entry

    • getEntrySnapshots: function
      • Gets all snapshots of an entry

        func

        getEntrySnapshots

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

        Parameters

        • entryId: string

          Entry ID

        • Default value query: QueryOptions = {}

          query additional query paramaters

        Returns Promise<Collection<Snapshot<Entry>, SnapshotProps<Entry>>>

        Promise for a collection of Entry Snapshots

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

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

        Parameters

        • id: string

          Locale ID

        Returns Promise<Locale>

        Promise for an Locale

    • getLocales: function
      • Gets a collection of Locales

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

        Returns Promise<Collection<Locale, LocaleProps>>

        Promise for a collection of Locales

    • getTag: function
      • getTag(id: string): Promise<Tag>
    • getTags: function
    • getUiExtension: function
      • Gets an UI Extension

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

        Parameters

        • id: string

          Extension ID

        Returns Promise<UIExtension>

        Promise for an UI Extension

    • getUiExtensions: function
      • Gets a collection of UI Extension

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

        Returns Promise<Collection<UIExtension, UIExtensionProps>>

        Promise for a collection of UI Extensions

    • getUpload: function
      • getUpload(id: string): Promise<{ delete: (Anonymous function) } & UploadProps & { toPlainObject: any }>
      • Gets an Upload

        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.getEnvironment('<environment-id>'))
        .then((environment) => environment.getUpload('<upload-id>')
        .then((upload) => console.log(upload))
        .catch(console.error)

        Parameters

        • id: string

          Upload ID

        Returns Promise<{ delete: (Anonymous function) } & UploadProps & { toPlainObject: any }>

        Promise for an Upload

    • update: function
      • Updates the environment

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

        Returns Promise<Environment>

        Promise for the updated environment.

createLocaleApi

  • createLocaleApi(http: AxiosInstance): { delete: (Anonymous function); update: any }

createOrganizationApi

  • createOrganizationApi(__namedParameters: { http: AxiosInstance }): { createAppDefinition: any; createOrganizationInvitation: any; createTeam: any; createTeamMembership: any; getAppDefinition: any; getAppDefinitions: any; getOrganizationInvitation: any; getOrganizationMembership: any; getOrganizationMemberships: any; getOrganizationSpaceMembership: any; getOrganizationSpaceMemberships: any; getTeam: any; getTeamMembership: any; getTeamMemberships: any; getTeamSpaceMembership: any; getTeamSpaceMemberships: any; getTeams: any; getUser: any; getUsers: any }
  • Creates API object with methods to access the Organization API

    Parameters

    • __namedParameters: { http: AxiosInstance }
      • http: AxiosInstance

    Returns { createAppDefinition: any; createOrganizationInvitation: any; createTeam: any; createTeamMembership: any; getAppDefinition: any; getAppDefinitions: any; getOrganizationInvitation: any; getOrganizationMembership: any; getOrganizationMemberships: any; getOrganizationSpaceMembership: any; getOrganizationSpaceMemberships: any; getTeam: any; getTeamMembership: any; getTeamMemberships: any; getTeamSpaceMembership: any; getTeamSpaceMemberships: any; getTeams: any; getUser: any; getUsers: any }

    • createAppDefinition: function
      • Creates an app definition

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('<org_id>')
        .then((org) => org.createAppDefinition({
           name: 'Example app',
           locations: [{ location: 'app-config' }],
           src: "http://my-app-host.com/my-app"
         }))
        .then((appDefinition) => console.log(appDefinition))
        .catch(console.error)

        Parameters

        Returns Promise<AppDefinition>

        Promise for the newly created AppDefinition

    • createOrganizationInvitation: function
      • Create an Invitation in Organization

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('<org_id>')
         .then((organization) => organization.createOrganizationInvitation({
           email: 'user.email@example.com'
           firstName: 'User First Name'
           lastName: 'User Last Name'
           role: 'developer'
         })
        .catch(console.error)

        Parameters

        Returns Promise<OrganizationInvitation>

        Promise for a OrganizationInvitation in an organization

    • createTeam: function
      • Creates a Team

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('<org_id>')
        .then((org) => org.createTeam({
           name: 'new team',
           description: 'new team description'
         }))
        .then((team) => console.log(team))
        .catch(console.error)

        Parameters

        Returns Promise<Team>

    • createTeamMembership: function
      • Creates a Team membership

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('organizationId')
        .then((org) => org.createTeamMembership('teamId', {
           admin: true,
           organizationMembershipId: 'organizationMembershipId'
         }))
        .then((teamMembership) => console.log(teamMembership))
        .catch(console.error)

        Parameters

        • teamId: string
        • data: Omit<TeamMembershipProps, "sys">

          Object representation of the Team Membership to be created

        Returns Promise<TeamMembership>

        Promise for the newly created TeamMembership

    • getAppDefinition: function
      • Gets an app definition

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('<org_id>')
        .then((org) => org.getAppDefinition('<app_definition_id>'))
        .then((appDefinition) => console.log(appDefinition))
        .catch(console.error)

        Parameters

        • id: string

        Returns Promise<AppDefinition>

        Promise for an App Definition

    • getAppDefinitions: function
      • Gets all app definitions

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('<org_id>')
        .then((org) => org.getAppDefinitions())
        .then((response) => console.log(response.items))
        .catch(console.error)

        Parameters

        Returns Promise<Collection<AppDefinition, AppDefinitionProps>>

        Promise for a collection of App Definitions

    • getOrganizationInvitation: function
      • Gets an Invitation in Organization

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('<org_id>')
        .then((organization) => organization.getOrganizationInvitation('invitation_id'))
        .then((invitation) => console.log(invitation))
        .catch(console.error)

        Parameters

        • invitationId: string

        Returns Promise<OrganizationInvitation>

        Promise for a OrganizationInvitation in an organization

    • getOrganizationMembership: function
      • Gets an Organization Membership

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('organization_id')
        .then((organization) => organization.getOrganizationMembership('organizationMembership_id'))
        .then((organizationMembership) => console.log(organizationMembership))
        .catch(console.error)

        Parameters

        • id: string

          Organization Membership ID

        Returns Promise<OrganizationMembership>

        Promise for an Organization Membership

    • getOrganizationMemberships: function
      • Gets a collection of Organization Memberships

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('organization_id')
        .then((organization) => organization.getOrganizationMemberships({'limit': 100})) // you can add more queries as 'key': 'value'
        .then((response) => console.log(response.items))
        .catch(console.error)

        Parameters

        Returns Promise<Collection<OrganizationMembership, OrganizationMembershipProps>>

        Promise for a collection of Organization Memberships

    • getOrganizationSpaceMembership: function
      • Gets an Space Membership in Organization

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('organization_id')
        .then((organization) => organization.getOrganizationSpaceMembership('organizationSpaceMembership_id'))
        .then((organizationMembership) => console.log(organizationMembership))
        .catch(console.error)

        Parameters

        • id: string

          Organiztion Space Membership ID

        Returns Promise<SpaceMembership>

        Promise for a Space Membership in an organization

    • getOrganizationSpaceMemberships: function
      • Gets a collection Space Memberships in organization

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('organization_id')
        .then((organization) => organization.getOrganizationSpaceMemberships()) // you can add queries like 'limit': 100
        .then((response) => console.log(response.items))
        .catch(console.error)

        Parameters

        Returns Promise<Collection<SpaceMembership, SpaceMembershipProps>>

        Promise for a Space Membership collection across all spaces in the organization

    • getTeam: function
      • getTeam(teamId: string): Promise<Team>
      • Gets an Team

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('orgId')
        .then((organization) => organization.getTeam('teamId'))
        .then((team) => console.log(team))
        .catch(console.error)

        Parameters

        • teamId: string

        Returns Promise<Team>

    • getTeamMembership: function
      • getTeamMembership(teamId: string, teamMembershipId: string): Promise<TeamMembership>
      • Gets an Team Membership from the team with given teamId

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('organizationId')
        .then((organization) => organization.getTeamMembership('teamId', 'teamMembership_id'))
        .then((teamMembership) => console.log(teamMembership))
        .catch(console.error)

        Parameters

        • teamId: string
        • teamMembershipId: string

        Returns Promise<TeamMembership>

        Promise for an Team Membership

    • getTeamMemberships: function
      • Get all Team Memberships. If teamID is provided in the optional config object, it will return all Team Memberships in that team. By default, returns all team memberships for the organization.

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('organizationId')
        .then((organization) => organization.getTeamMemberships('teamId'))
        .then((teamMemberships) => console.log(teamMemberships))
        .catch(console.error)

        Parameters

        • Default value opts: { query?: QueryOptions; teamId?: undefined | string } = {}
          • Optional query?: QueryOptions
          • Optional teamId?: undefined | string

        Returns Promise<Collection<TeamMembership, TeamMembershipProps>>

        Promise for a Team Membership Collection

    • getTeamSpaceMembership: function
      • Get a Team Space Membership with given teamSpaceMembershipId

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('organizationId')
        .then((organization) => organization.getTeamSpaceMembership('teamSpaceMembershipId'))
        .then((teamSpaceMembership) => console.log(teamSpaceMembership))
        .catch(console.error)]

        Parameters

        • teamSpaceMembershipId: string

        Returns Promise<TeamSpaceMembership>

        Promise for a Team Space Membership

    • getTeamSpaceMemberships: function
      • Get all Team Space Memberships. If teamID is provided in the optional config object, it will return all Team Space Memberships in that team. By default, returns all team space memberships across all teams in the organization.

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('organizationId')
        .then((organization) => organization.getTeamSpaceMemberships('teamId'))
        .then((teamSpaceMemberships) => console.log(teamSpaceMemberships))
        .catch(console.error)

        Parameters

        • Default value opts: { query?: QueryOptions; teamId?: undefined | string } = {}
          • Optional query?: QueryOptions
          • Optional teamId?: undefined | string

        Returns Promise<Collection<TeamSpaceMembership, TeamSpaceMembershipProps>>

        Promise for a Team Space Membership Collection

    • getTeams: function
      • Gets all Teams in an organization

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('orgId')
        .then((organization) => organization.getTeams())
        .then((teams) => console.log(teams))
        .catch(console.error)

        Parameters

        Returns Promise<Collection<Team, TeamProps>>

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

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('<organization_id>')
        .then((organization) => organization.getUser('id'))
        .then((user) => console.log(user))
        .catch(console.error)

        Parameters

        • id: string

        Returns Promise<User>

        Promise for a User

    • getUsers: function
      • Gets a collection of Users in organization

        example
        const contentful = require('contentful-management')
        const client = contentful.createClient({
          accessToken: '<content_management_api_key>'
        })
        
        client.getOrganization('<organization_id>')
        .then((organization) => organization.getUsers())
        .then((user) => console.log(user))
        .catch(console.error)

        Parameters

        Returns Promise<Collection<User, UserProps>>

        Promise a collection of Users in organization

createOrganizationMembershipApi

  • createOrganizationMembershipApi(http: AxiosInstance): { delete: (Anonymous function); update: any }

createPersonalAccessToken

  • createPersonalAccessToken(http: AxiosInstance): { revoke: any }

createPreviewApiKeyApi

  • createPreviewApiKeyApi(): {}

createRoleApi

  • createRoleApi(http: AxiosInstance): { delete: (Anonymous function); update: () => Promise<T> }
  • Parameters

    • http: AxiosInstance

    Returns { delete: (Anonymous function); update: () => Promise<T> }

    • delete: (Anonymous function)
    • update: () => Promise<T>
        • (): Promise<T>
        • Returns Promise<T>

createScheduledActionApi

createSnapshotApi

  • createSnapshotApi(): {}

createSpaceApi

  • createSpaceApi(__namedParameters: { http: AxiosInstance; httpUpload: AxiosInstance }): { createAsset: createAsset; createUpload: createUpload; createApiKey: any; createApiKeyWithId: any; createAssetFromFiles: any; createAssetWithId: any; createContentType: any; createContentTypeWithId: any; createEntry: any; createEntryWithId: any; createEnvironment: any; createEnvironmentAliasWithId: any; createEnvironmentWithId: any; createLocale: any; createRole: any; createRoleWithId: any; createScheduledAction: any; createSpaceMembership: any; createSpaceMembershipWithId: any; createTeamSpaceMembership: any; createUiExtension: any; createUiExtensionWithId: any; createWebhook: any; createWebhookWithId: any; delete: any; getApiKey: any; getApiKeys: any; getAsset: any; getAssets: any; getContentType: any; getContentTypeSnapshots: any; getContentTypes: any; getEditorInterfaceForContentType: any; getEntries: any; getEntry: any; getEntrySnapshots: any; getEnvironment: any; getEnvironmentAlias: any; getEnvironmentAliases: any; getEnvironments: any; getLocale: any; getLocales: any; getPreviewApiKey: any; getPreviewApiKeys: any; getRole: any; getRoles: any; getScheduledActions: any; getSpaceMember: any; getSpaceMembers: any; getSpaceMembership: any; getSpaceMemberships: any; getSpaceUser: any; getSpaceUsers: any; getTeamSpaceMembership: any; getTeamSpaceMemberships: any; getUiExtension: any; getUiExtensions: any; getUpload: any; getWebhook: any; getWebhooks: any; update: any }
  • Creates API object with methods to access the Space API

    prop

    {object} http - HTTP client instance

    prop

    {object} entities - Object with wrapper methods for each kind of entity

    Parameters

    • __namedParameters: { http: AxiosInstance; httpUpload: AxiosInstance }
      • http: AxiosInstance
      • httpUpload: AxiosInstance

    Returns { createAsset: createAsset; createUpload: createUpload; createApiKey: any; createApiKeyWithId: any; createAssetFromFiles: any; createAssetWithId: any; createContentType: any; createContentTypeWithId: any; createEntry: any; createEntryWithId: any; createEnvironment: any; createEnvironmentAliasWithId: any; createEnvironmentWithId: any; createLocale: any; createRole: any; createRoleWithId: any; createScheduledAction: any; createSpaceMembership: any; createSpaceMembershipWithId: any; createTeamSpaceMembership: any; createUiExtension: any; createUiExtensionWithId: any; createWebhook: any; createWebhookWithId: any; delete: any; getApiKey: any; getApiKeys: any; getAsset: any; getAssets: any; getContentType: any; getContentTypeSnapshots: any; getContentTypes: any; getEditorInterfaceForContentType: any; getEntries: any; getEntry: any; getEntrySnapshots: any; getEnvironment: any; getEnvironmentAlias: any; getEnvironmentAliases: any; getEnvironments: any; getLocale: any; getLocales: any; getPreviewApiKey: any; getPreviewApiKeys: any; getRole: any; getRoles: any; getScheduledActions: any; getSpaceMember: any; getSpaceMembers: any; getSpaceMembership: any; getSpaceMemberships: any; getSpaceUser: any; getSpaceUsers: any; getTeamSpaceMembership: any; getTeamSpaceMemberships: any; getUiExtension: any; getUiExtensions: any; getUpload: any; getWebhook: any; getWebhooks: any; update: any }

    • createAsset: createAsset

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

      deprecated

      since version 5.0

      param

      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 for the newly created Asset

      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)
    • createUpload: createUpload

      Creates a Upload.

      deprecated

      since version 5.0

      param

      Object with file information.

      param

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

      returns

      Upload object containing information about the uploaded file.

      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)
    • createApiKey: function
      • 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: function
      • 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

    • createAssetFromFiles: function
      • 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: Omit<AssetFileProp, "sys">

          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: function
      • createAssetWithId(id: string, data: Omit<AssetProps, "sys">): Promise<Asset>
      • 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: Omit<AssetProps, "sys">

          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: function
      • 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

        Returns Promise<ContentType>

        Promise for the newly created Content Type

    • createContentTypeWithId: function
      • 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: CreateContentTypeProps

          Object representation of the Content Type to be created

        Returns Promise<ContentType>

        Promise for the newly created Content Type

    • createEntry: function
      • createEntry(contentTypeId: string, data: Omit<EntryProp, "sys">): Promise<Entry>
      • 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

          The Content Type which this Entry is based on

        • data: Omit<EntryProp, "sys">

          Object representation of the Entry to be created

        Returns Promise<Entry>

        Promise for the newly created Entry

    • createEntryWithId: function
      • createEntryWithId(contentTypeId: string, id: string, data: Omit<EntryProp, "sys">): 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

          The Content Type which this Entry is based on

        • id: string

          Entry ID

        • data: Omit<EntryProp, "sys">

          Object representation of the Entry to be created

        Returns Promise<Entry>

        Promise for the newly created Entry

    • createEnvironment: function
      • 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

        • Default value data: {} = {}

          Object representation of the Environment to be created

        Returns Promise<Environment>

        Promise for the newly created Environment

    • createEnvironmentAliasWithId: function
      • Creates an EnvironmentAlias 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.createEnvironmentAliasWithId('<environment-alias-id>', {
          environment: {
            sys: { type: 'Link', linkType: 'Environment', id: 'targetEnvironment' }
          }
        }))
        .then((environmentAlias) => console.log(environmentAlias))
        .catch(console.error)

        Parameters

        • id: string

          EnvironmentAlias ID

        • data: Omit<EnvironmentAliasProps, "sys">

          Object representation of the EnvironmentAlias to be created

        Returns Promise<EnvironmentAlias>

        Promise for the newly created EnvironmentAlias

    • createEnvironmentWithId: function
      • createEnvironmentWithId(id: string, data: Omit<EnvironmentProps, "sys">, sourceEnvironmentId?: undefined | string): Promise<Environment>
      • 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: Omit<EnvironmentProps, "sys">

          Object representation of the Environment to be created

        • Optional sourceEnvironmentId: undefined | 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: function
      • 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

        Returns Promise<Locale>

        Promise for the newly created Locale

    • createRole: function
      • 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: Omit<RoleProps, "sys">

          Object representation of the Role to be created

        Returns Promise<Role>

        Promise for the newly created Role

    • createRoleWithId: function
      • createRoleWithId(id: string, data: Omit<RoleProps, "sys">): Promise<Role>
      • 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

        • id: string

          Role ID

        • data: Omit<RoleProps, "sys">

          Object representation of the Role to be created

        Returns Promise<Role>

        Promise for the newly created Role

    • createScheduledAction: function
    • createSpaceMembership: function
      • 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

        • data: Omit<SpaceMembershipProps, "sys">

          Object representation of the Space Membership to be created

        Returns Promise<SpaceMembership>

        Promise for the newly created Space Membership

    • createSpaceMembershipWithId: function
      • 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: Omit<SpaceMembershipProps, "sys">

          Object representation of the Space Membership to be created

        Returns Promise<SpaceMembership>

        Promise for the newly created Space Membership

    • createTeamSpaceMembership: function
      • 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: [
           {
        sys: {
              type: 'Link',
              linkType: 'Role',
              id: '<role_id>'
             }
           }
          ],
        }))
        .then((teamSpaceMembership) => console.log(teamSpaceMembership))
        .catch(console.error)

        Parameters

        • teamId: string
        • data: Omit<TeamSpaceMembershipProps, "sys">

          Object representation of the Team Space Membership to be created

        Returns Promise<TeamSpaceMembership>

        Promise for the newly created Team Space Membership

    • createUiExtension: function
      • 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: Omit<UIExtensionProps, "sys">

          Object representation of the UI Extension to be created

        Returns Promise<UIExtension>

        Promise for the newly created UI Extension

    • createUiExtensionWithId: function
      • 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: Omit<UIExtensionProps, "sys">

          Object representation of the UI Extension to be created

        Returns Promise<UIExtension>

        Promise for the newly created UI Extension

    • createWebhook: function
      • 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: Omit<WebhookProps, "sys">

          Object representation of the Webhook to be created

        Returns Promise<WebHooks>

        Promise for the newly created Webhook

    • createWebhookWithId: function
      • 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: Omit<WebhookProps, "sys">

          Object representation of the Webhook to be created

        Returns Promise<WebHooks>

        Promise for the newly created Webhook

    • delete: function
      • 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: function
      • 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: function
      • 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, ApiKeyProps>>

        Promise for a collection of Api Keys

    • getAsset: function
      • 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

        • Default value query: QueryOptions = {}

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

        Returns Promise<Asset>

        Promise for an Asset

    • getAssets: function
      • 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, AssetProps>>

        Promise for a collection of Assets

    • getContentType: function
      • 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: function
      • 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

        • Default value query: QueryOptions = {}

          additional query paramaters

        Returns Promise<Collection<Snapshot<unknown>, SnapshotProps<unknown>>>

        Promise for a collection of Content Type Snapshots

    • getContentTypes: function
      • 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, ContentTypeProps>>

        Promise for a collection of Content Types

    • getEditorInterfaceForContentType: function
      • 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: function
      • 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, EntryProp>>

        Promise for a collection of Entries

    • getEntry: function
      • 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

        • Default value query: QueryOptions = {}

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

        Returns Promise<Entry>

        Promise for an Entry

    • getEntrySnapshots: function
      • 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

        • entryId: string

          Entry ID

        • Default value query: QueryOptions = {}

          additional query paramaters

        Returns Promise<Collection<Snapshot<unknown>, SnapshotProps<unknown>>>

        Promise for a collection of Entry Snapshots

    • getEnvironment: function
      • 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: function
      • 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: function
      • 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, EnvironmentAliasProps>>

        Promise for a collection of Environment Aliases

    • getEnvironments: function
      • 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, EnvironmentProps>>

        Promise for a collection of Environment

    • getLocale: function
      • 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: function
      • 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, LocaleProps>>

        Promise for a collection of Locales

    • getPreviewApiKey: function
      • 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: function
      • 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, PreviewApiKeyProps>>

        Promise for a collection of Preview Api Keys

    • getRole: function
      • 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: function
      • 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, RoleProps>>

        Promise for a collection of Roles

    • getScheduledActions: function
    • getSpaceMember: function
      • getSpaceMember(id: string): Promise<SpaceMemberProps & { toPlainObject: any }>
      • 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<SpaceMemberProps & { toPlainObject: any }>

        Promise for a Space Member

    • getSpaceMembers: function
      • 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

        Returns Promise<Collection<SpaceMemberProps & { toPlainObject: any }, SpaceMemberProps>>

        Promise for a collection of Space Members

    • getSpaceMembership: function
      • 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: function
      • 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, SpaceMembershipProps>>

        Promise for a collection of Space Memberships

    • getSpaceUser: function
      • 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

    • getSpaceUsers: function
      • Gets 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)

        Parameters

        Returns Promise<Collection<User, UserProps>>

        Promise a collection of Users in a space

    • getTeamSpaceMembership: function
      • 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

        • teamSpaceMembershipId: string

        Returns Promise<TeamSpaceMembership>

        Promise for a Team Space Membership

    • getTeamSpaceMemberships: function
    • getUiExtension: function
      • 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: function
      • 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, UIExtensionProps>>

        Promise for a collection of UI Extensions

    • getUpload: function
      • getUpload(id: string): Promise<{ delete: (Anonymous function) } & UploadProps & { toPlainObject: any }>
      • 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<{ delete: (Anonymous function) } & UploadProps & { toPlainObject: any }>

        Promise for an Upload

    • getWebhook: function
      • 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: function
      • 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, WebhookProps>>

        Promise for a collection of Webhooks

    • update: function
      • update(): Promise<Space>
      • 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<Space>

        Promise for the updated space.

createSpaceMembershipApi

  • createSpaceMembershipApi(http: AxiosInstance): { delete: (Anonymous function); update: () => Promise<T> }
  • Parameters

    • http: AxiosInstance

    Returns { delete: (Anonymous function); update: () => Promise<T> }

    • delete: (Anonymous function)
    • update: () => Promise<T>
        • (): Promise<T>
        • Returns Promise<T>

createTagApi

  • createTagApi(http: AxiosInstance): TagApi

createTeamMembershipApi

  • createTeamMembershipApi(http: AxiosInstance): { delete: any; update: any }

createTeamSpaceMembershipApi

  • createTeamSpaceMembershipApi(http: AxiosInstance): { delete: (Anonymous function); update: any }

createUiExtensionApi

  • createUiExtensionApi(http: AxiosInstance): { delete: (Anonymous function); update: () => Promise<T> }
  • Parameters

    • http: AxiosInstance

    Returns { delete: (Anonymous function); update: () => Promise<T> }

    • delete: (Anonymous function)
    • update: () => Promise<T>
        • (): Promise<T>
        • Returns Promise<T>

createUpdateTag

  • createUpdateTag(http: AxiosInstance): () => Promise<Tag>

createUploadApi

  • createUploadApi(http: AxiosInstance): { delete: (Anonymous function) }
  • Parameters

    • http: AxiosInstance

    Returns { delete: (Anonymous function) }

    • delete: (Anonymous function)

createWebhookApi

  • createWebhookApi(http: AxiosInstance): { delete: (Anonymous function); update: () => Promise<T>; getCall: any; getCalls: any; getHealth: any }
  • Parameters

    • http: AxiosInstance

    Returns { delete: (Anonymous function); update: () => Promise<T>; getCall: any; getCalls: any; getHealth: any }

    • delete: (Anonymous function)
    • update: () => Promise<T>
        • (): Promise<T>
        • Returns Promise<T>

    • getCall: function
      • getCall(id: string): Promise<Record<string, unknown>>
    • getCalls: function
      • getCalls(): Promise<Record<string, unknown>>
    • getHealth: function
      • getHealth(): Promise<Record<string, unknown>>

raiseDeprecationWarning

  • raiseDeprecationWarning(method: string): void

spaceMembershipDeprecationWarning

  • spaceMembershipDeprecationWarning(): void

Const wrapCollection

  • wrapCollection<R, T>(fn: (http: AxiosInstance, entity: T) => R): (Anonymous function)
  • Type parameters

    • R

    • T

    Parameters

    • fn: (http: AxiosInstance, entity: T) => R
        • (http: AxiosInstance, entity: T): R
        • Parameters

          • http: AxiosInstance
          • entity: T

          Returns R

    Returns (Anonymous function)

wrapScheduledAction

wrapTag