Creates a new comment for an entry
Promise for the newly created Comment
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)
Object representation of the Comment to be created
Creates a new task for an entry
Promise for the newly created Task
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)
Object representation of the Task to be created
Deletes this object on the server.
Promise for the deletion. It contains no data, but the Promise error case should be handled.
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)
Gets a comment of an entry
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '
client.getSpace('<comment-id>
))
.then((comment) => console.log(comment))
.catch(console.error)
```
Gets all comments of an entry
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '
client.getSpace('
Gets a snapshot of an entry
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)
Id of the snapshot
Gets all snapshots of an entry
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.getSnapshots())
.then((snapshots) => console.log(snapshots.items))
.catch(console.error)
Gets a task of an entry
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '
client.getSpace('<task-id>
))
.then((task) => console.log(task))
.catch(console.error)
```
Gets all tasks of an entry
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '
client.getSpace('
Checks if entry is archived. This means it's not exposed to the Delivery/Preview APIs.
Checks if the entry is in draft mode. This means it is not published.
Checks if the entry is published. A published entry might have unpublished changes
Checks if the entry is updated. This means the entry was previously published but has unpublished changes.
Optional
metadataSends an JSON patch to the server with any changes made to the object's properties
Object returned from the server with updated changes.
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)
Publishes the object
Object returned from the server with updated metadata.
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)
Recursively collects references of an entry and their descendants
Optional
options: EntryReferenceOptionsPropsUnarchives the object
Object returned from the server with updated metadata.
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)
Unpublishes the object
Object returned from the server with updated metadata.
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)
Sends an update to the server with any changes made to the object's properties
Object returned from the server with updated changes.
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)
Archives the object
Returns
Object returned from the server with updated metadata.
Example