ManagementToken
ManagementToken
Management Tokens are tokens that provide you with read-write access to your stack's content. When used in conjunction with the stack API key, they authorize Content Management API (CMA) requests for the purpose of managing your stack's content.
update
The update method allows you to modify the existing management token within the stack.
Example:
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).managementToken('management_token_uid')
.fetch()
.then((managementToken) => {
managementToken.title = 'My New management token'
managementToken.description = 'management token description'
return managementToken.update()
})
.then((managementToken) => console.log(managementToken))delete
The delete method removes the existing management token from the stack.
Example:
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).managementToken('management_token_uid')
.delete()
.then((response) => console.log(response.notice))fetch
The fetch method retrieves the details of a specific management token from the stack.
Example:
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).managementToken('management_token_uid')
.fetch()
.then((managementToken) => console.log(managementToken))create
The create method allows you to create a new management token in the stack.
| Name | Type | Description |
|---|---|---|
| params.token | object | The details of the token, including its name, description, and scope, are specified for the token to be created |
Example:
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
const token = {
"token":{
"name":"Test Token",
"description":"This is a sample management token.",
"scope":[
{
"module":"content_type",
"acl":{
"read":true,
"write":true
}
},
{
"module":"branch",
"branches":[
"main"
],
"acl":{
"read":true
}
},
{
"module":"branch_alias",
"branch_aliases":[
"tst"
],
"acl":{
"read":true
}
}
],
"expires_on":"2024-12-10",
"is_email_notification_enabled":true
}
}
client.stack({ api_key: 'api_key'}).managementToken()
.create({ token })
.then((managementToken) => console.log(managementToken))query
The Get all managementToken request retrieves comprehensive information about all the management tokens created in a stack.
| Name | Type | Description |
|---|---|---|
| params.include_count | boolean | The include_count parameter includes the total count of management tokens in your stack, along with the details of each individual management token. |
| params.limit | int | The limit parameter retrieves a specific number of management tokens in the output. |
| params.skip | int | The skip parameter will skip a specific number of management tokens in the response. |
Example:
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).managementToken()
.query({ query: { name: 'token_name' } }))
.find()
.then((contentstackCollection) => console.log(contentstackCollection))