How to automatically accept project join requests in GitLab using the GitLab API

If you are managing a public GitLab project where users can request access, constantly accepting new requests can be time-consuming. I would like to show you how to automate this process using Postman and the GitLab API.

Valentin Despa
DevOps with Valentine

--

Access requests in GitLab

How to use the GitLab REST API

The GitLab API allows you to perform many of the actions you typically performed through the user interface. If you have never used the GitLab API, here is a quick introduction to it.

The workflow (manual)

We need to use a few endpoints to accomplish this action. To make sure everything works properly, we will use Postman to test the workflow.

Get new access requests

Here we are using the GET /api/v4/projects/:id/access_requests endpoint to get a list of the latest users who have requested access.

{{projectId}} is a Postman variable holding the project id. You can hardcode the value if you wish.

Approve access request

--

--

Valentin Despa
DevOps with Valentine

Software developer, educator & overlander • GitLab Hero • AWS Community Builder • Postman Supernova • Imprint: http://vdespa.com/imprint