{"id":12996,"library":"contentful-management","title":"Contentful Management JavaScript Client","description":"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.","status":"active","version":"12.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/contentful/contentful-management.js","tags":["javascript","typescript"],"install":[{"cmd":"npm install contentful-management","lang":"bash","label":"npm"},{"cmd":"yarn add contentful-management","lang":"bash","label":"yarn"},{"cmd":"pnpm add contentful-management","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"HTTP client, updated to address CVE-2026-40175 in v12.3.1.","package":"axios","optional":false}],"imports":[{"note":"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.","wrong":"const contentful = require('contentful-management'); const createClient = contentful.createClient;","symbol":"createClient","correct":"import { createClient } from 'contentful-management'"},{"note":"This is a TypeScript type for the client instance. Use `import type` to avoid bundling it in JavaScript outputs.","wrong":"import { ContentfulClientApi } from 'contentful-management'","symbol":"ContentfulClientApi","correct":"import type { ContentfulClientApi } from 'contentful-management'"},{"note":"Represents the `Environment` entity returned by the API, used for type declarations in TypeScript.","wrong":"import { Environment } from 'contentful-management'","symbol":"Environment","correct":"import type { Environment } from 'contentful-management'"}],"quickstart":{"code":"import { createClient } from 'contentful-management';\n\nconst SPACE_ID = process.env.CONTENTFUL_SPACE_ID ?? '';\nconst CMA_TOKEN = process.env.CONTENTFUL_MANAGEMENT_TOKEN ?? '';\n\nif (!SPACE_ID || !CMA_TOKEN) {\n  console.error('Please set CONTENTFUL_SPACE_ID and CONTENTFUL_MANAGEMENT_TOKEN environment variables.');\n  process.exit(1);\n}\n\nasync function main() {\n  try {\n    const client = createClient({\n      accessToken: CMA_TOKEN\n    });\n\n    console.log('Successfully created Contentful Management client.');\n\n    const space = await client.getSpace(SPACE_ID);\n    console.log(`Connected to Space: ${space.name} (ID: ${space.sys.id})`);\n\n    const environments = await space.getEnvironments();\n    console.log(`Found ${environments.items.length} environments.`);\n\n    for (const env of environments.items) {\n      console.log(`  - Environment: ${env.name} (ID: ${env.sys.id})`);\n    }\n  } catch (error) {\n    console.error('An error occurred:', error);\n    if (error.response && error.response.data) {\n      console.error('API Error details:', error.response.data);\n    }\n  }\n}\n\nmain();","lang":"typescript","description":"Initializes the Contentful Management client and fetches all environments within a specified space, demonstrating basic authentication and API interaction."},"warnings":[{"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.","message":"Version 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.","severity":"breaking","affected_versions":">=12.0.0"},{"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.","message":"Node.js v20+ is now the minimum supported runtime version for `contentful-management` v12.x.","severity":"breaking","affected_versions":">=12.0.0"},{"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'.","message":"Authentication 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"Version 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.","severity":"breaking","affected_versions":"<12.3.1"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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(...);`","cause":"Attempting to use CommonJS `require` syntax to directly access named exports in an ES Module context, or incorrect destructuring.","error":"TypeError: createClient is not a function"},{"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.","cause":"The provided `accessToken` is invalid, expired, or does not have sufficient permissions for the requested operation or space.","error":"Response Error: 401 Unauthorized"},{"fix":"Upgrade your Node.js installation to version 20 or higher, as required by `contentful-management` v12.x.","cause":"Running `contentful-management` version 12 or newer on an unsupported Node.js runtime version.","error":"Error: Node.js version 18.x is not supported by contentful-management@12.x"},{"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.","cause":"TypeScript cannot locate the package's type definitions, possibly due to incorrect installation or an outdated TypeScript version.","error":"TS2307: Cannot find module 'contentful-management' or its corresponding type declarations."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}