This Node.js script fetches all users in your Contentful organization, along with their organization roles, space roles, and any teams they belong to, then outputs everything to a CSV file.
- Node.js installed (v14+ recommended).
- A Contentful Management API token with permissions to read:
- Organization memberships
- Space memberships
- Team memberships
-
Clone or download this repository.
-
Install dependencies:
npm install
-
Create and configure a .env file:
- Copy the sample:
cp .env.sample .env
- Open .env and add your actual Contentful Management API token and organization ID:
CONTENTFUL_MANAGEMENT_API_TOKEN=YOUR_REAL_TOKEN CONTENTFUL_ORGANIZATION_ID=YOUR_ORGANIZATION_ID
Run the script:
node fetch-contentful-users.js
It will generate a contentful_users.csv file containing columns:
userId, email, name, orgRoles, spaceRoles, teams
- userId: The Contentful user’s ID
- email: The user’s email address
- name: The user’s first and last name
- orgRoles: A semicolon-delimited list of organization roles (e.g., "Organization Owner; Editor")
- spaceRoles: A semicolon-delimited list of space roles (e.g., "Admin; Editor")
- teams: A semicolon-delimited list of teams this user belongs to
Sample output file here: example_output.csv
This project is open source and available under the MIT License. See the LICENSE file for more details.
This script is not officially supported by Contentful. It is a personal project and provided as-is without any warranties or guarantees.