# Allocate Licenses to a User

> As an organization admin, use this endpoint to allocate licenses to a user, based on the user ID.

As an organization admin, use this endpoint to allocate licenses to a user, based on the user ID.

## API Endpoint

`PUT` `{accessURL}/lease_/api/account/{accountId}/user-license`

Replace `{accessURL}` in all endpoint paths with the base URL for your cloud platform:

| Cloud platform | Access URL |
| --- | --- |
| Test Cloud | `https://cloud.uipath.com/` |
| Test Cloud Public Sector | `https://govcloud.uipath.us/` |
| Test Cloud Dedicated | `https://{customURL}.dedicated.uipath.com/` |

## Request Headers

```
--header 'Authorization: Bearer {access_token}'\
--header 'Content-Type: application/json'
```

:::note
To obtain the `{access_token}`, make sure to authenticate through the ROPC method described .
:::

## Path Parameters

| Path param | Data type | Description |
| --- | --- | --- |
| `accountId`  (required) | String | The ID of the organization in which your user resides. |

## Request Body

The request body contains the array of license codes for various products and their corresponding quantity.

```
{
  "userIds": ["string"],
  "userBundleCodes": ["string"],
  "useExternalLicense": true
}
```

:::note
* To see the available user bundle codes you may use in the request body, check out the [user license codes](https://docs.uipath.com/test-cloud/automation-cloud/latest/api-guide/license-codes#user-licenses).
* You may allocate as many licenses as the organization has purchased.
* Each user consumes a license unit.
:::

## Responses

### 200 OK

Returns the allocated group licenses.

### 404

No account license is allocated for the indicated organization.

### 409

The license allocation is not allowed because it exceeds the account license quantities.

## Example Request

Let's say you gathered all the information needed to build the API call.

* Your `{baseURL}` is: `https://cloud.uipath.com//{organizationName}`.
* Your `{access_token}` is: `1234` (for length considerations).
* The `{accountId}` of the tenant that needs license allocation is: `song-one`
* You have three users that need licenses:
  + User 1 with the `userId`=`singer-77`
  + User 2 with the `userId`=`singer-88`
  + User 3 with the `userId`=`singer-111`
* You want to allocate the following user licences:
  + RPA Developer - Named user (the [license code](https://docs.uipath.com/test-cloud/automation-cloud/latest/api-guide/license-codes#user-licenses) is `RPADEVNU`)
  + Attended - Named user (the [license code](https://docs.uipath.com/test-cloud/automation-cloud/latest/api-guide/license-codes#licensing-product-codes) is `ATTUNU`)
  + Tester - Named user (the [license code](https://docs.uipath.com/test-cloud/automation-cloud/latest/api-guide/license-codes#user-licenses) is `TSTNU`)

The call should resemble the following example (cURL):

```
curl --location --request POST 'https://https://cloud.uipath.com/{organizationName}/lease_/api/account/1234/user-license' \
--header 'Authorization: Bearer 1234' \
--header 'Content-Type: application/json' \
--data-raw '{
        "userIds": ["singer-77", "singer-88", "singer-111"]
    "userBundleCodes": ["RPADEVNU", "ATTUNU", "TSTNU"], 
    "useExternalLicense": true
}
```

Here's the response body for a successful license allocation:

```
[
  {
    "userId": "string",
    "organizationId": "string",
    "useExternalLicense": true,
    "userBundleCodes": [
      "string"
    ]
  }
]
```
