Forum Discussion

BoruAI's avatar
BoruAI
Copper Contributor
Jul 20, 2023

API or NET client library to add users to an organization or projects under it?

the azure devops ui was like below picture, But I am wondering if I could do it through function calls?

 

1 Reply

  • Take this by using Azure DevOps REST API

    To add users to an organization or project, use the User Entitlements API:

     

    {
      "accessLevel": {
        "accountLicenseType": "express",
        "licensingSource": "account"
      },
      "user": {
        "principalName": "newuser@example.com",
        "subjectKind": "user"
      },
      "projectEntitlements": [
        {
          "group": {
            "groupType": "projectContributor"
          },
          "projectRef": {
            "id": "your-project-id"
          }
        }
      ]
    }

    You’ll need:

    • Organization name
    • Project ID
    • User email
    • Proper PAT (Personal Access Token) with admin permissions

Resources