Hierarchy

Properties

archive: (() => Promise<Entry>) = ...

Type declaration

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

      Returns

      Object returned from the server with updated metadata.

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

      Returns Promise<Entry>

createComment: ((data: CreateCommentProps) => Promise<Comment>) = ...

Type declaration

    • (data: CreateCommentProps): Promise<Comment>
    • Creates a new comment for an entry

      Returns

      Promise for the newly created Comment

      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) => entry.createComment({
      body: 'Something left to do'
      }))
      .then((comment) => console.log(comment))
      .catch(console.error)

      Parameters

      Returns Promise<Comment>

createTask: ((data: CreateTaskProps) => Promise<Task>) = ...

Type declaration

    • (data: CreateTaskProps): Promise<Task>
    • Creates a new task for an entry

      Returns

      Promise for the newly created Task

      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) => entry.createTask({
      body: 'Something left to do',
      assignedTo: '<user-id>',
      status: 'active'
      }))
      .then((task) => console.log(task))
      .catch(console.error)

      Parameters

      Returns Promise<Task>

delete: (() => Promise<any>) = ...

Type declaration

    • (): Promise<any>
    • Deletes this object on the server.

      Returns

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

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

      Returns Promise<any>

fields: KeyValueMap
getComment: ((id: string) => Promise<Comment>) = ...

Type declaration

    • (id: string): Promise<Comment>
    • Gets a comment of an entry

      Returns

      const contentful = require('contentful-management')

      const client = contentful.createClient({ accessToken: '' })

      client.getSpace('') .then((space) => space.getEnvironment('')) .then((environment) => environment.getEntry('')) .then((entry) => entry.getComment(<comment-id>)) .then((comment) => console.log(comment)) .catch(console.error) ```

      Parameters

      • id: string

      Returns Promise<Comment>

getComments: (() => Promise<Collection<Comment, CommentProps>>) = ...

Type declaration

    • (): Promise<Collection<Comment, CommentProps>>
    • Gets all comments of an entry

      Returns

      const contentful = require('contentful-management')

      const client = contentful.createClient({ accessToken: '' })

      client.getSpace('') .then((space) => space.getEnvironment('')) .then((environment) => environment.getEntry('')) .then((entry) => entry.getComments()) .then((comments) => console.log(comments)) .catch(console.error) ```

      Returns Promise<Collection<Comment, CommentProps>>

getSnapshot: ((snapshotId: string) => Promise<Snapshot<EntryProps<KeyValueMap>>>) = ...

Type declaration

    • (snapshotId: string): Promise<Snapshot<EntryProps<KeyValueMap>>>
    • 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.getEnvironment('<environment_id>'))
      .then((environment) => environment.getEntry('<entry_id>'))
      .then((entry) => entry.getSnapshot('<snapshot_id>'))
      .then((snapshot) => console.log(snapshot))
      .catch(console.error)

      Parameters

      • snapshotId: string

        Id of the snapshot

      Returns Promise<Snapshot<EntryProps<KeyValueMap>>>

getSnapshots: ((query?: {}) => Promise<Collection<Snapshot<EntryProps<KeyValueMap>>, SnapshotProps<EntryProps<KeyValueMap>>>>) = ...

Type declaration

getTask: ((id: string) => Promise<Task>) = ...

Type declaration

    • (id: string): Promise<Task>
    • Gets a task of an entry

      Returns

      const contentful = require('contentful-management')

      const client = contentful.createClient({ accessToken: '' })

      client.getSpace('') .then((space) => space.getEnvironment('')) .then((environment) => environment.getEntry('')) .then((entry) => entry.getTask(<task-id>)) .then((task) => console.log(task)) .catch(console.error) ```

      Parameters

      • id: string

      Returns Promise<Task>

getTasks: ((query?: {}) => Promise<Collection<Task, TaskProps>>) = ...

Type declaration

    • (query?: {}): Promise<Collection<Task, TaskProps>>
    • Gets all tasks of an entry

      Returns

      const contentful = require('contentful-management')

      const client = contentful.createClient({ accessToken: '' })

      client.getSpace('') .then((space) => space.getEnvironment('')) .then((environment) => environment.getEntry('')) .then((entry) => entry.getTasks()) .then((tasks) => console.log(tasks)) .catch(console.error) ```

      Parameters

      • query: {} = {}

        Returns Promise<Collection<Task, TaskProps>>

    isArchived: (() => boolean) = ...

    Type declaration

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

        Returns boolean

    isDraft: (() => boolean) = ...

    Type declaration

      • (): boolean
      • Checks if the entry is in draft mode. This means it is not published.

        Returns boolean

    isPublished: (() => boolean) = ...

    Type declaration

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

        Returns boolean

    isUpdated: (() => boolean) = ...

    Type declaration

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

        Returns boolean

    metadata?: MetadataProps
    patch: ((ops: OpPatch[]) => Promise<Entry>) = ...

    Type declaration

      • (ops: OpPatch[]): Promise<Entry>
      • Sends an JSON patch to the server with any changes made to the object's properties

        Returns

        Object returned from the server with updated changes.

        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) => entry.patch([
        {
        op: 'replace',
        path: '/fields/title/en-US',
        value: 'New entry title'
        }
        ]))
        .then((entry) => console.log(`Entry ${entry.sys.id} updated.`))
        .catch(console.error)

        Parameters

        • ops: OpPatch[]

        Returns Promise<Entry>

    publish: (() => Promise<Entry>) = ...

    Type declaration

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

        Returns

        Object returned from the server with updated metadata.

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

        Returns Promise<Entry>

    references: ((options?: EntryReferenceOptionsProps) => Promise<Collection<Entry, EntryProps<KeyValueMap>>>) = ...

    Type declaration

    unarchive: (() => Promise<Entry>) = ...

    Type declaration

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

        Returns

        Object returned from the server with updated metadata.

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

        Returns Promise<Entry>

    unpublish: (() => Promise<Entry>) = ...

    Type declaration

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

        Returns

        Object returned from the server with updated metadata.

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

        Returns Promise<Entry>

    update: (() => Promise<Entry>) = ...

    Type declaration

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

        Returns

        Object returned from the server with updated changes.

        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) => {
        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>

    Methods