GitLab Search uses Service account mode, with a self-managed project or group per source. Teammates do not connect personal GitLab accounts. Sim matches their verified identity to the source's permission strategy on each search and read.
Choose a permission strategy
The administrator path requires self-managed GitLab 17.4 or later and its administrator identity/settings APIs. A project Maintainer or group Owner is not an instance administrator. Non-admin mode does not require those administrator APIs.
The instance must be reachable from the Sim server and pass outbound-request protections. Use the self-managed host, not gitlab.com. Each source binds its host and selected project or group; a query cannot redirect the token elsewhere.
Add a project
- Create a read-only PAT with the chosen scopes and an appropriate expiry.
- Open Settings → Sources → Add source → GitLab → Add connection.
- Choose Administrator token or Non-admin token.
- Enter the token, self-managed Host, and exact Project path or numeric ID.
- Choose content and filters. Non-admin mode requires both CSV files below.
- Save, then have a permitted teammate search and read known content. Repeat with a teammate who has no grant.
Use Add connection again for another project. There is no initial sync. Organization membership and a matching verified email are required, but membership alone does not grant project access.
Resource settings
Sim checks returned content against these restrictions independently of the query. Available search APIs depend on the GitLab version and enabled search capabilities. Unsupported searches are reported explicitly.
Add a group
Choose Group in the source's Scope field and enter the numeric group ID or full group path. Enable Include subgroups only if descendant projects should be included. Sim supports up to 50,000 projects visible to the source token, subject to the CSV limits below and a 16 MiB limit for saved project IDs and paths. Projects shared from outside the group are excluded.
Discovery reads 100 projects per page and must finish within five minutes. GitLab's configured offset and rate limits still apply; choose narrower groups if the instance cannot return the complete listing within these limits. Sim also handles listings without total-count headers, which GitLab can omit above 10,000 results.
The same permission strategies apply. Group membership alone never grants access to every project: administrator mode checks each project's current permissions, and non-admin mode requires a CSV grant for each project and reader. The source token must be able to read every project you want to search.
In CSV mode, each successful upload rediscovers the group's projects and replaces all grants atomically. Newly discovered projects become searchable only for users explicitly listed in the uploaded CSV. Updating and saving source settings also refreshes discovery. A failed discovery or stale revision preserves the previous configuration and grants. If a group configured by path is renamed, save the new path and an updated project-permissions CSV together in source settings. Numeric group IDs remain valid across renames.
In CSV mode, search uses GitLab's group search API and checks each result against the saved projects and reader grants. Group code search requires Advanced Search or Exact Code Search; group wiki search requires Advanced Search. Unsupported scopes fall back to project search. A configured branch/tag, date filters, or administrator-token mode also use project search where needed. Each request visits a bounded number of pages; continuation cursors cover the remainder. Targeting a project narrows the request.
Group search stops at 10,000 candidates per content type to respect GitLab's Advanced Search window. Sim marks this as partial and asks you to narrow the query or target a project. This candidate limit applies before permission filtering. Renamed or moved projects are blocked until a successful refresh; projects outside the configured group remain excluded. See GitLab's search capabilities and pagination limits.
To expand an existing deployment, create a separate group source after the application deployment finishes. Keep the working project source and its CI variables unchanged while validating the group. Give the group job its new SIM_SOURCE_ID, then pause the old source after confirming the wider setup. Regular knowledge-base ingestion remains project-scoped.
An organization admin can add more groups without contacting Sim:
- Open Settings → Sources → GitLab → Add connection, choose Scope → Group, and enter the group ID and matching Include subgroups setting.
- Supply a token with access to that group and both permission CSVs, then save. For a large group, start with a small valid subset of grants and use CI to upload the full snapshot before expanding access to the wider team.
- Open the saved connection and copy Source ID. It is also the final segment of
/o/<organizationId>/settings/integrations/sources/<sourceId>. - Create a CI job for that group using its new
SIM_SOURCE_IDand matching--groupvalue. ReuseSIM_ORG_IDand the admin-ownedSIM_API_KEY; leave existing groups' jobs unchanged.
Non-admin CSV permissions
Use Download template beside each field, replace the examples, and upload both files.
User mapping maps numeric GitLab user IDs to verified Sim emails:
Project permissions grants mapped users access to the project:
Use the full namespace path even if Project contains a numeric ID. Include inherited members explicitly. A grant without an email mapping grants nothing; rows for other projects cannot expand this source.
- Each file has exactly two columns in the shown order and at least one data row. Template headers or headerless data are accepted.
- Use UTF-8 CSV. Manual uploads accept 8 MiB and 500,000 data rows per file. The existing single-request API also requires the complete JSON body to fit 10 MiB.
- For larger files, use the CI uploader: up to 500,000 user records, 5,000,000 project-permission records, and 1 GiB across both CSVs, uploaded in at most 4,096 parts. Counts include duplicate data records; saved mappings and grants are deduplicated.
- Identical rows are deduplicated. Conflicting user-ID/email mappings and malformed rows are rejected.
In this example, Alice can search engineering/platform because the files link GitLab user 123 to both that project and alice@example.com. Sim checks that Alice is a current organization member and that her verified Sim email uniquely matches the grant. It checks again when she opens a result. GitLab receives the request under the source's read-only service account; Alice does not sign in to GitLab or authorize Sim individually.
Saving the CSVs grants the access listed in them. Changing a membership in GitLab alone does not change these grants. Replace the CSVs to add or revoke access; the change applies to the next search or read without re-indexing.
Export both CSVs from GitLab
Download export-permissions.py and save it as ci/export-gitlab-permissions.py in your repository. It uses Python 3.10 or later with no extra packages and exports a project or group per run.
Use GitLab 17.4 or later and an internal export token with read_api and permission to see all members of each selected project, their primary emails, and confirmation status. Keep this token in a masked, protected CI variable named GITLAB_EXPORT_TOKEN. It stays in your CI job; Sim receives the CSVs. The source's separate read-only PAT continues to retrieve content.
The exporter makes only these GitLab API requests:
GitLab documents membership visibility and user profile fields. The read_api scope alone does not grant access to private emails. The export token needs that directory permission too. Profiles without a valid confirmed_at timestamp are excluded. If an eligible reader's primary email is unavailable, the script stops; it never substitutes a public email. Confirm the exported emails match your teammates' verified Sim emails.
With GITLAB_EXPORT_TOKEN set in the environment, run:
For a group, replace --project engineering/platform with --group engineering. Add --include-subgroups only when the Sim source has the same setting. Both CSVs cover the whole group: users appear once in users.csv, and project-permissions.csv contains a row for each project/user grant. Projects without eligible readers contribute no grants. If the entire export has no readers, pause the source instead of uploading empty files.
This creates gitlab-permissions/users.csv and gitlab-permissions/project-permissions.csv. Numeric project IDs are also accepted. The output directory must not already exist. Both files are published together after the export completes and passes validation.
The export includes active, unlocked human members with Reporter access or higher. It excludes Guests, Planners, bots, and memberships expiring today or earlier in UTC. It does not infer access from public/internal visibility, administrator or Auditor privileges, or custom permissions below Reporter. GitLab policies such as SSO or external authorization are not represented by these CSVs. Review the grants against your organization's access requirements before uploading them.
Requests run serially, paced at 60 per minute by default. Set --requests-per-minute to change this export-job ceiling; it does not configure live Search traffic. Each run reads each project's identity and membership pages, plus one profile request per distinct candidate reader. Group exports also read the group identity and project listing. The request ceiling applies across the entire export. API errors, hidden emails, identity conflicts, inconsistent pagination totals (when GitLab provides them), and oversized exports stop the job without publishing either file. Run exports after bulk membership updates finish; paginated API reads are not a point-in-time snapshot.
Large exports can take hours. For example, 50,000 projects require at least 100,000 project and membership requests, before listing and profile requests: over 27 hours at the default ceiling. Set the CI job timeout and schedule accordingly, or use smaller groups. Agree any higher request rate with your GitLab administrator. CSV files are written incrementally and published only when the complete export succeeds.
Access checks
The source token retrieves content. Administrator mode proves the reader's current GitLab identity from verified Sim email, then checks project/group membership and policy during the request. Unsupported restrictions fail closed.
Non-admin mode uses saved source-local CSV grants and revalidates the token's current host/project identity. Confidential issues are excluded, including issues that became confidential after search.
Reads recheck current settings, permissions, and metadata. A reference from another member, account, organization, project, or host cannot authorize a read. Sim fetches content live from GitLab. In CSV mode, Sim stores the uploaded mappings and resulting project grants.
Update permissions or rotate the token
For manually uploaded CSVs, source settings can replace either file while retaining the other. For a large snapshot uploaded through CI, use the CI uploader to replace both files together. Sim validates the resulting pair before publishing it. Invalid or stale updates preserve saved grants. Removed readers lose access on the next operation.
To rotate the PAT, supply its replacement in source settings. A blank token retains the saved token. Saving settings without replacing CSVs preserves the uploaded permissions. Changing host, scope, or permission strategy requires valid configuration for the new identity.
Automate updates with GitLab CI
After an admin configures a source in Non-admin token mode, a job can read its revision, export current permissions, and upload both CSVs. Copy Source ID from the saved connection into SIM_SOURCE_ID; copy SIM_ORG_ID from /o/<organizationId>/settings/integrations/sources/<sourceId>. Set SIM_BASE_URL to your Sim origin (for hosted Sim, https://www.sim.ai).
Store an organization admin's personal Sim API key with Full access as a masked, protected GitLab CI variable named SIM_API_KEY. A personal key inherits its owner's access; a read-only key can read the revision but not replace the CSVs. Permission uploads cannot change the GitLab PAT, host, or configured scope.
Commit the exporter above at ci/export-gitlab-permissions.py and upload-permissions.py at ci/upload-permissions.py. Both use Python 3.10 or later with no extra packages. Set GITLAB_EXPORT_TOKEN, GITLAB_PROJECT (full path or numeric ID), and the Sim variables above. This example uses CI_SERVER_URL for the GitLab host and runs on a schedule against a protected branch. Choose the schedule based on how quickly permission changes must reach Sim.
The uploader stages the files on the runner, then sends CSV parts of at most 5,000 records and 1 MiB. Allow temporary disk space for the CSV pair and another copy for staging. Sim validates each part and publishes the complete pair atomically only if the original revision still matches. Searches keep using the previous permissions during the upload.
Adjust the job timeout to the export's expected duration and ensure the runner's maximum timeout permits it. Two days is an example, not a completion guarantee. Keep the default export ceiling of 60 requests per minute unless your GitLab administrator approves a different rate.
For a group source, keep the same revision/read/upload steps and replace only the exporter command above:
Set GITLAB_GROUP to the configured group's full path or numeric ID. Add --include-subgroups if enabled in Sim. The existing --project command, CSV headers, source IDs, and revision checks are unchanged. The single-request replacement API remains available within its original limits. Grants for projects outside the configured group are rejected; a reused path with a different project ID requires a new connection.
A successful update returns the new revision. The uploader retries identical part and completion requests after transient connection errors, 429, or server errors, honoring Retry-After. It never substitutes a newer revision. On a conflict, rerun the job from the revision read and export so the files reflect current permissions. Interrupted imports expire; they do not replace the previous grants. If the connection drops after completion, the update may already have succeeded.
An invalid or header-only export leaves the previous grants in place. Alert on failed jobs so revocations aren't missed. If the source should have no readers, choose Pause search in the source settings. You can update the grants while the source is paused, then resume search when the grants are correct.
Manage sources from the CLI
Organization admins can also configure sources with the Sim CLI. Use a personal Sim API key with Full access, or an OAuth login with the required API scopes. Workspace API keys cannot administer organization sources.
The returned id is SIM_SOURCE_ID. Creating an additional group requires a separate source and CI job targeting that ID. Existing sources and CI upload commands remain unchanged.
For a new source, prepare the shared configuration once, then create the connection:
Use the same host, project/group selection, and permission strategy as Settings. source-config.json contains the complete source configuration. permission-config.json contains provider: "gitlab", mode: "csv", and both CSVs as { "filename": "...", "content": "..." } under userMapping and projectPermissions. For large exports, create the source using a valid subset of grants, then upload the full snapshot. The create API reference describes every field. Keep PAT files and permission files out of version control.
To change a group, read the source first, edit the complete configuration, and supply matching CSVs with the current permission revision. To rotate only the GitLab PAT, use sim organizations search sources update <sourceId> --organization <organizationId> --api-key @replacement-pat.txt --permission-config '{"provider":"gitlab","mode":"csv","expectedRevision":<revision>}' --yes. Omitted CSVs retain their grants; a successful rotation advances the revision. Use --status paused --yes or --status active --yes to pause or resume. Neither action changes the source ID. Integration approval remains a separate organization setting.
The CLI can replace the Python uploader in an existing CI job:
This uses the same staged-import limits, revision checks, and atomic activation as the Python uploader. A conflict requires a new export; the command never fetches a newer revision to overwrite it. Personal OAuth consent and GitLab token issuance still happen in their respective services.
Troubleshooting
Related docs
- Knowledge-base connectors — separate ingestion and permission maintenance