Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Properties

archive

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

Type declaration

    • 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.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>

      Object returned from the server with updated metadata.

createComment

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

Type declaration

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

      Parameters

      Returns Promise<Comment>

      Promise for the newly created Comment

createTask

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

Type declaration

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

      Parameters

      Returns Promise<Task>

      Promise for the newly created Task

delete

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

Type declaration

    • (): Promise<any>
    • 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.getEnvironment('<environment_id>'))
      .then((environment) => environment.getEntry('<entry_id>'))
      .then((entry) => entry.delete())
      .then(() => console.log(`Entry deleted.`))
      .catch(console.error)

      Returns Promise<any>

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

fields

fields: KeyValueMap

getComment

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

Type declaration

    • Gets a comment of an entry

      Parameters

      • id: string

      Returns Promise<Comment>

      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)

      
      

getComments

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

Type declaration

    • Gets all comments of an entry

      Returns Promise<Collection<Comment, CommentProps>>

      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)

      
      

getSnapshot

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

Type declaration

    • 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

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

Type declaration

getTask

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

Type declaration

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

      Parameters

      • id: string

      Returns Promise<Task>

      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)

      
      

getTasks

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

Type declaration

    • Gets all tasks of an entry

      Parameters

      • query: {} = {}

        Returns Promise<Collection<Task, TaskProps>>

        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)

        
        

    isArchived

    isArchived: () => boolean = ...

    Type declaration

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

        Returns boolean

    isDraft

    isDraft: () => boolean = ...

    Type declaration

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

        Returns boolean

    isPublished

    isPublished: () => boolean = ...

    Type declaration

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

        Returns boolean

    isUpdated

    isUpdated: () => boolean = ...

    Type declaration

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

        Returns boolean

    Optional metadata

    metadata?: MetadataProps

    patch

    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

        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>

        Object returned from the server with updated changes.

    publish

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

    Type declaration

      • 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.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>

        Object returned from the server with updated metadata.

    references

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

    Type declaration

    sys

    unarchive

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

    Type declaration

      • 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.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>

        Object returned from the server with updated metadata.

    unpublish

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

    Type declaration

      • 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.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>

        Object returned from the server with updated metadata.

    update

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

    Type declaration

      • 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.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>

        Object returned from the server with updated changes.

    Methods

    toPlainObject