Registry / crm-productivity / contentful-management

contentful-management

JSON →
library2.15.2jsnpmunverified

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-management
INSTALL
IMPORT
SIG · CONTENTFUL-MANAGEM
C
contentful-management
crm-productivityjavascriptv2.15.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createClient
import { createClient } from 'contentful-management'
const contentful = require('contentful-management'); const createClient = contentful.createClient;
Since v12.0.0, the package primarily supports ES Modules. While CommonJS is still available, direct named imports are the recommended pattern. For CommonJS, you may need to access it via the default export or specific CJS paths.
ContentfulClientApi
import type { ContentfulClientApi } from 'contentful-management'
import { ContentfulClientApi } from 'contentful-management'
This is a TypeScript type for the client instance. Use `import type` to avoid bundling it in JavaScript outputs.
Environment
import type { Environment } from 'contentful-management'
import { Environment } from 'contentful-management'
Represents the `Environment` entity returned by the API, used for type declarations in TypeScript.

Initializes the Contentful Management client and fetches all environments within a specified space, demonstrating basic authentication and API interaction.

import { createClient } from 'contentful-management'; const SPACE_ID = process.env.CONTENTFUL_SPACE_ID ?? ''; const CMA_TOKEN = process.env.CONTENTFUL_MANAGEMENT_TOKEN ?? ''; if (!SPACE_ID || !CMA_TOKEN) { console.error('Please set CONTENTFUL_SPACE_ID and CONTENTFUL_MANAGEMENT_TOKEN environment variables.'); process.exit(1); } async function main() { try { const client = createClient({ accessToken: CMA_TOKEN }); console.log('Successfully created Contentful Management client.'); const space = await client.getSpace(SPACE_ID); console.log(`Connected to Space: ${space.name} (ID: ${space.sys.id})`); const environments = await space.getEnvironments(); console.log(`Found ${environments.items.length} environments.`); for (const env of environments.items) { console.log(` - Environment: ${env.name} (ID: ${env.sys.id})`); } } catch (error) { console.error('An error occurred:', error); if (error.response && error.response.data) { console.error('API Error details:', error.response.data); } } } main();
Debug
Known issues
breakingVersion 12.0.0 introduced full ES Module (ESM) support and made it the primary distribution. CommonJS (CJS) is still available but using ESM imports is recommended. The package structure and import paths have changed.
fix
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.
affects: >=12.0.0
breakingNode.js v20+ is now the minimum supported runtime version for `contentful-management` v12.x.
fix
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.
affects: >=12.0.0
gotchaAuthentication requires a Contentful Management API key, not a Content Delivery API key. Management API keys have broader permissions and are typically long-lived personal access tokens or dedicated service account tokens.
fix
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'.
affects: >=1.0.0
breakingVersion 12.3.1 includes a fix for CVE-2026-40175 by bumping the `axios` dependency to `^1.15.0`. If you are on an older version of `contentful-management` or have a dependency tree that pulls an older `axios` version, you may be vulnerable.
fix
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.
affects: <12.3.1
Errors
Common errors & fixes
TypeError: createClient is not a function
Attempting to use CommonJS `require` syntax to directly access named exports in an ES Module context, or incorrect destructuring.
fix
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(...);`
Response Error: 401 Unauthorized
The provided `accessToken` is invalid, expired, or does not have sufficient permissions for the requested operation or space.
fix
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.
Error: Node.js version 18.x is not supported by contentful-management@12.x
Running `contentful-management` version 12 or newer on an unsupported Node.js runtime version.
fix
Upgrade your Node.js installation to version 20 or higher, as required by `contentful-management` v12.x.
TS2307: Cannot find module 'contentful-management' or its corresponding type declarations.
TypeScript cannot locate the package's type definitions, possibly due to incorrect installation or an outdated TypeScript version.
fix
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.
Upgrade
Version history
2.15.2latest on npm
Audit
Dependencies
axiosrequiredHTTP client, updated to address CVE-2026-40175 in v12.3.1.
Agent activity
43 hits · last 30 days
node
40
OpenAI (training)
1
Resources