@contentstack/management

中文文档
1.31.3发布于 2026/11/02MITTypeScriptCommonJS构建来源已验证近 30 天下载 15.5万

The Content Management API is used to manage the content of your Contentstack account

原始使用文档
文档目录11 节
  1. Contentstack Management JavaScript SDK
  2. Prerequisite
  3. Installation
  4. Authentication
  5. Authtoken
  6. Login
  7. Management Token
  8. Host and Region Configuration
  9. Contentstack Management JavaScript SDK: 5-minute Quickstart
  10. Helpful Links
  11. The MIT License (MIT)

contentstack-management-javascript-variants

Contentstack

Contentstack Management JavaScript SDK

Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. All you have to do is build your application frontend, and Contentstack will take care of the rest. Read More.

This SDK uses the Content Management API (CMA). The CMA is used to manage the content of your Contentstack account. This includes creating, updating, deleting, and fetching content of your account. To use the CMA, you will need to authenticate your users with a Management Token or an Authtoken. Read more about it in Authentication.

Note: By using CMA, you can execute GET requests for fetching content. However, we strongly recommend that you always use the Content Delivery API to deliver content to your web or mobile properties.

Prerequisite

You need Node.js version 10 or above installed on your machine to use the Contentstack JavaScript CMA SDK.

Installation

Node

Install it via npm:

npm i @contentstack/management

To import the SDK, use one of the following ways :

  1. JavaScript ES Modules

     import contentstack from '@contentstack/management';
    
    • Requires "type": "module" in package.json
  2. TypeScript with esModuleInterop

     import contentstack from '@contentstack/management';
    
    • Requires "esModuleInterop": true in tsconfig.json
  3. TypeScript Namespace Import

     import * as contentstack from '@contentstack/management';
    
    • Works regardless of esModuleInterop setting
  4. TypeScript Destructuring

     import contentstack from '@contentstack/management';
     const { client } = contentstack;
    
    • Access client function from default export

Authentication

To use this SDK, you need to authenticate your users by using the Authtoken, credentials, or Management Token (stack-level token).

Authtoken

An Authtoken is a read-write token used to make authorized CMA requests, and it is a user-specific token.

contentstackClient = contentstack.client({ authtoken: 'AUTHTOKEN' })

Login

To Login to Contentstack by using credentials, you can use the following lines of code:

contentstackClient.login({ email: 'EMAIL', password: 'PASSWORD'})
.then((response) => {
    console.log(response.notice)
    console.log(response.user)
})

Management Token

Management Tokens are stack-level tokens, with no users attached to them.

contentstackClient.stack({ api_key: 'API_KEY', management_token: 'MANAGEMENT_TOKEN' }).contentType('CONTENT_TYPE_UID')
.fetch()
.then((contenttype) => {
    console.log(contenttype)
})

Host and Region Configuration

You can configure the SDK to use a specific region or custom host for API requests.

Region

The SDK supports multiple regions. Valid region values are: NA, EU, AU, AZURE_NA, AZURE_EU, GCP_NA, GCP_EU. The default region is NA.

// Use EU region
contentstackClient = contentstack.client({ 
  authtoken: 'AUTHTOKEN',
  region: 'EU' 
})

Custom Host

You can specify a custom host for API requests. If both host and region are provided, the host parameter takes priority.

// Use custom host
contentstackClient = contentstack.client({ 
  authtoken: 'AUTHTOKEN',
  host: 'api.contentstack.io' 
})

// Custom host takes priority over region
contentstackClient = contentstack.client({ 
  authtoken: 'AUTHTOKEN',
  region: 'EU',
  host: 'custom-api.example.com' 
})

Contentstack Management JavaScript SDK: 5-minute Quickstart

Initializing Your SDK:

To use the JavaScript CMA SDK, you need to first initialize it. To do this, use the following code:

import contentstack from ‘@contentstack/management’

var contentstackClient = contentstack.client({ authtoken: 'AUTHTOKEN' })

Fetch Stack Detail

Use the following lines of code to fetch your stack detail using this SDK:

contentstackClient.stack({ api_key: 'API_KEY' })
.fetch()
.then((stack) => {
    console.log(stack)
})

Create Entry

To create an entry in a specific content type of a stack, use the following lines of code:

var  entry  = {
    title: 'Sample Entry',
    url: '/sampleEntry'
}

contentstackClient.stack({ api_key: 'API_KEY' }).contentType('CONTENT_TYPE_UID').entry().create({ entry })
.then((entry) => {
    console.log(entry)
})

Create Asset

The following lines of code can be used to upload assets to your stack:

var  asset  = {
    upload: 'path/to/file',
    title: 'Asset Title'
}

contentstackClient.stack({ api_key: 'API_KEY' }).asset().create({ asset })
.then((asset) => {
    console.log(asset)
})

The MIT License (MIT)

Copyright © 2012-2026 Contentstack. All Rights Reserved

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

版本与发布记录

@contentstack/management 共发布 87 个版本,首次发布于 2020/09/23;过去 12 个月发布了 21 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.31.3latest2026/11/028 天前
1.31.22026/10/061 个月前
1.31.12026/08/033 个月前
1.31.02026/07/293 个月前
1.30.42026/06/294 个月前
1.30.32026/05/255 个月前

关于 @contentstack/management 的常见问题

@contentstack/management 是什么?

The Content Management API is used to manage the content of your Contentstack account

如何安装 @contentstack/management?

在项目目录运行 npm install @contentstack/management,或使用 pnpm add / yarn add / bun add。

@contentstack/management 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@contentstack/management 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@contentstack/management 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=8.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@contentstack/management 可以商用吗?

@contentstack/management 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@contentstack/management 的下载量有多少?

根据 npm 官方下载统计,@contentstack/management 在 2026/10/11 – 2026/11/09 这 30 天内被下载 154,587 次,日均约 5,153 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@contentstack/management 还在维护吗?

最新版本 1.31.3 发布于 2026/11/02(8 天前);至今共发布 87 个版本,其中过去 12 个月发布了 21 个;首次发布于 2020/09/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。