--- stage: Software Supply Chain Security group: Authentication info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments title: User follow and unfollow API --- {{< details >}} - Tier: Free, Premium, Ultimate - Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated {{< /details >}} Use this API to perform follower actions for user accounts. For more information, see [Follow users](../user/profile/_index.md#follow-users). ## Follow a user Follow a given user account. ```plaintext POST /users/:id/follow ``` Supported attributes: | Attribute | Type | Required | Description | |:----------|:--------|:---------|:------------| | `id` | integer | yes | ID of user account | Example request: ```shell curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/users/3/follow" ``` Example response: ```json { "id": 1, "username": "john_smith", "name": "John Smith", "state": "active", "locked": false, "avatar_url": "http://localhost:3000/uploads/user/avatar/1/cd8.jpeg", "web_url": "http://localhost:3000/john_smith" } ``` ## Unfollow a user Unfollow a given user account. ```plaintext POST /users/:id/unfollow ``` Supported attributes: | Attribute | Type | Required | Description | |:----------|:--------|:---------|:------------| | `id` | integer | yes | ID of user account | Example request: ```shell curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/users/3/unfollow" ``` ## List all accounts that follow a user Lists all users accounts that follow a given user. ```plaintext GET /users/:id/followers ``` Supported attributes: | Attribute | Type | Required | Description | |:----------|:--------|:---------|:------------| | `id` | integer | yes | ID of user account | Example request: ```shell curl --request GET --header "PRIVATE-TOKEN: " "https://gitlab.example.com/users/3/followers" ``` Example response: ```json [ { "id": 2, "name": "Lennie Donnelly", "username": "evette.kilback", "state": "active", "locked": false, "avatar_url": "https://www.gravatar.com/avatar/7955171a55ac4997ed81e5976287890a?s=80&d=identicon", "web_url": "http://127.0.0.1:3000/evette.kilback" }, { "id": 4, "name": "Serena Bradtke", "username": "cammy", "state": "active", "locked": false, "avatar_url": "https://www.gravatar.com/avatar/a2daad869a7b60d3090b7b9bef4baf57?s=80&d=identicon", "web_url": "http://127.0.0.1:3000/cammy" } ] ``` ## List all accounts followed by a user Lists all users accounts being followed by a given user. ```plaintext GET /users/:id/following ``` Supported attributes: | Attribute | Type | Required | Description | |:----------|:--------|:---------|:------------| | `id` | integer | yes | ID of user account | Example request: ```shell curl --request GET --header "PRIVATE-TOKEN: " "https://gitlab.example.com/users/3/following" ```