doc/development/access_tokens_for_gitlab_project.md
This guide helps you choose the right access token type for your needs within the GitLab project, prioritizing security best practices.
flowchart TD
A[Need GitLab API Access?] --> B{Running in CI/CD pipeline?}
B -->|Yes| C{Need only limited API access?
Git repos, packages, releases,
specific endpoints}
C -->|Yes| D[CI Job Token
Auto-rotates
No manual management
Limited API endpoints only]
C -->|No| E{Access to multiple projects?}
E -->|No| F[Project Access Token
Single project scope
Full API access
Email notifications]
E -->|Yes| G[Service Account PAT
Add to specific projects only
Precise permission control
API manageable]
B -->|No| H{Single Project Only?}
H -->|Yes| I{Need administrative actions
like creating tokens?}
I -->|No| J[Project Access Token
Scoped to one project
Email notifications
API manageable]
I -->|Yes| K[Service Account PAT
Admin permissions possible
Add to specific project
Better than Group token]
H -->|No| L{Multiple projects needed?}
L -->|Yes| M{Large group with many projects
like gitlab-org?}
M -->|Yes| N[Service Account PAT
Add to specific projects only
Avoid overpermissive group tokens
Granular control]
M -->|No| O{Small, well-defined group?}
O -->|Yes| P[Consider Group Access Token
Only for small groups
High privilege risk]
O -->|No| Q[Service Account PAT
Selective project membership
Better security boundary]
L -->|No| R{Can create Service Account?}
R -->|Yes| S[Service Account PAT
API manageable
Proper user separation
Precise permissions]
R -->|No| T[Bot User PAT
Manual rotation required
Use shared email for notifications
Last resort option]
style D fill:#d4f6d4
style F fill:#d4f6d4
style G fill:#d4f6d4
style J fill:#d4f6d4
style K fill:#d4f6d4
style N fill:#d4f6d4
style Q fill:#d4f6d4
style S fill:#d4f6d4
style P fill:#fff3cd
style T fill:#ffe6e6
| Token Type | Rotation | Scope Flexibility | Visibility | Best Use Case | Availability |
|---|---|---|---|---|---|
| CI Job Token | Automatic | Very limited (specific endpoints only) | Built-in logs | Limited pipeline API access | All tiers |
| Project Access Token | Manual/API | Single project | Email notifications | Single-project automation | Premium+ |
| Group Access Token | Manual/API | Group + subgroups/projects (HIGH RISK) | Email notifications | Rarely recommended - use Service Account instead | Free+ (Self-managed) |
| Service Account PAT | Manual/API | Selective project/group membership | Email possible | Multi-project with precise control | Premium+ |
| Bot User PAT | Manual only | User-level permissions | Manual setup required | Legacy/fallback option | All tiers |
See the CI/CD job tokens documentation for complete details.
Use when:
Limitations:
Avoid when:
See the project access tokens documentation for complete details.
Use when:
Avoid when:
See the group access tokens documentation for complete details.
Use when:
High Risk - Use Sparingly:
gitlab-org with hundreds of projectsAvoid when:
See the service accounts documentation for complete details.
Use when:
Key Advantage:
Avoid when:
See the personal access tokens documentation for complete details.
Use only when:
Required setup:
api scope unless absolutely necessary