How to get all GitLab users with their project access levels using the API or Postman?

Problem to solve

  • As GitLab Admin, I want to generate a complete access list from our self-managed GitLab instance that includes every user, the projects/groups they belong to, and their access level/role per project. I’m using Postman and a Personal Access Token (PAT).

Steps to reproduce

Which troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?

  1. In Postman, call
  • example:
GET https://gitlab.champ.aero/api/v4/users?active=true&per_page=100&page=1
  • I expected to include the user roles for all GitLab projects.
  1. Created a Postman API script to fetch all users across multiple pages (instead of just one page).
  2. Exported the aggregated API data after running the request.

Configuration

  • Using Postman (Lightweight / Desktop) — when running in app use Collection Runner for auto-pagination; clicking Send only runs once.
  • Environment variables used on my current script:
    • gitlab_token — PAT with api scope

    • currentPage — integer for paging

    • users / csvUsers — accumulation variables used in script

  • Current script:
// --- Parse API Response ---
let responseData;
try {
    responseData = pm.response.json();
} catch (err) {
    console.error("Failed to parse response:", err);
    responseData = [];
}

// --- Initialize environment variables ---
let users = pm.environment.get("users") ? JSON.parse(pm.environment.get("users")) : [];
let currentPage = parseInt(pm.environment.get("currentPage")) || 1;

// --- Append this page's users ---
responseData.forEach(user => {
    users.push({
        id: user.id,
        username: user.username,
        name: user.name,
        state: user.state
    });
});

// --- Get total pages from headers ---
const totalPages = parseInt(pm.response.headers.get("X-Total-Pages")) || 1;

// --- Check if there’s another page ---
if (currentPage < totalPages) {
    pm.environment.set("users", JSON.stringify(users));
    pm.environment.set("currentPage", currentPage + 1);
    console.log(`Fetched page ${currentPage}/${totalPages}`);
    pm.execution.setNextRequest(pm.info.requestName); // ✅ new method
} else {
    // --- All pages fetched ---
    console.log(`✅ All ${users.length} active users fetched!`);

    // Convert to CSV
    let csv = "id,username,name,state\n";
    users.forEach(u => {
        csv += `${u.id},${u.username},${u.name},${u.state}\n`;
    });

    // Save CSV and cleanup
    pm.environment.set("csvUsers", csv);
    pm.environment.unset("users");
    pm.environment.unset("currentPage");

    console.log(csv);
}

Versions

Please add an x whether options apply, and add the version information.

  • v17.5 (Self-managed)