The `contentful-management.js` library is the official JavaScript client for interacting with Contentful's Content Management API (CMA). It empowers developers to programmatically manage all aspects of their Contentful spaces, including creating and updating content types, entries, assets, and handling users and webhooks. The current stable version is 12.3.1, with the project maintaining a regular release cadence, delivering frequent patch and minor updates that often include new features, bug fixes, and security improvements. Major versions, such as the recent v12.0.0, introduce significant platform enhancements, like full ESM support and updated Node.js runtime requirements, ensuring the library remains modern and secure. Its key differentiators include robust built-in rate limiting with recovery mechanisms, convenient asset processing helpers, and deep integration designed specifically for the Contentful ecosystem. This makes it an essential tool for automation, custom content workflows, and sophisticated content infrastructure management, offering capabilities far beyond what the Contentful web app alone provides.
npm install contentful-managementVerified import paths — ran on the pinned version, not inferred.
Initializes the Contentful Management client and fetches all environments within a specified space, demonstrating basic authentication and API interaction.
Migrate your import statements to use ES Modules (e.g., `import { createClient } from 'contentful-management'`). Consult the MIGRATION.md guide for specific changes. For CommonJS, ensure you're using the correct `require` syntax for the CJS bundle.Upgrade your Node.js runtime to version 20 or newer. Using older Node.js versions with v12.x may lead to unexpected errors or unsupported syntax issues.
Ensure you are using a valid Management API key with appropriate permissions for the operations you intend to perform. You can generate these in the Contentful web app under 'Settings' -> 'API keys' -> 'Content Management Tokens'.
Upgrade `contentful-management` to version 12.3.1 or higher to ensure you receive the updated `axios` dependency with the security fix. Regularly check for dependency updates.
For ES Modules, use `import { createClient } from 'contentful-management';`. If you must use CommonJS, ensure your environment is configured for CJS, and try `const { createClient } = require('contentful-management');` or access through the default export depending on your build setup: `const contentful = require('contentful-management'); const client = contentful.createClient(...);`Verify that your Contentful Management API `accessToken` is correct, active, and has the necessary permissions for the space and resources you are trying to access. Ensure it's a Management API token, not a Delivery API token.
Upgrade your Node.js installation to version 20 or higher, as required by `contentful-management` v12.x.
Ensure `contentful-management` is correctly installed (`npm install contentful-management` or `yarn add contentful-management`). If the issue persists, check your `tsconfig.json` for `moduleResolution` settings and ensure your TypeScript version is compatible. Sometimes, restarting your IDE helps.