Source: https://leadping.ai/docs/api-reference/organizations/change-a-current-organization-user-role

# Change a current-organization user role

Changes a user’s role in the current organization, updating access to lead, automation, billing, and admin workflows.

## Endpoint

```http
PUT https://api.leadping.ai/organizations/me/members/{userId}
```

## Request examples

### cURL

```bash
curl --request PUT \
  --url https://api.leadping.ai/organizations/me/members/{userId} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "stateEligibility": {
    "allStates": true,
    "allowedStates": [
      "<string>"
    ]
  },
  "userId": "<string>",
  "email": "jsmith@example.com"
}'
```

### Python

```python
import requests

url = "https://api.leadping.ai/organizations/me/members/{userId}"

payload = {
    "stateEligibility": {
        "allStates": True,
        "allowedStates": ["<string>"]
    },
    "userId": "<string>",
    "email": "jsmith@example.com"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
```

### C# — RestSharp

```csharp
using RestSharp;


var options = new RestClientOptions("https://api.leadping.ai/organizations/me/members/{userId}");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n  \"stateEligibility\": {\n    \"allStates\": true,\n    \"allowedStates\": [\n      \"<string>\"\n    ]\n  },\n  \"userId\": \"<string>\",\n  \"email\": \"jsmith@example.com\"\n}", false);
var response = await client.PutAsync(request);

Console.WriteLine("{0}", response.Content);
```

### Java

```java
HttpResponse<String> response = Unirest.put("https://api.leadping.ai/organizations/me/members/{userId}")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"stateEligibility\": {\n    \"allStates\": true,\n    \"allowedStates\": [\n      \"<string>\"\n    ]\n  },\n  \"userId\": \"<string>\",\n  \"email\": \"jsmith@example.com\"\n}")
  .asString();
```

### JavaScript

```javascript
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    stateEligibility: {allStates: true, allowedStates: ['<string>']},
    userId: '<string>',
    email: 'jsmith@example.com'
  })
};

fetch('https://api.leadping.ai/organizations/me/members/{userId}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.leadping.ai/organizations/me/members/{userId}"

	payload := strings.NewReader("{\n  \"stateEligibility\": {\n    \"allStates\": true,\n    \"allowedStates\": [\n      \"<string>\"\n    ]\n  },\n  \"userId\": \"<string>\",\n  \"email\": \"jsmith@example.com\"\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.leadping.ai/organizations/me/members/{userId}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => json_encode([
    'stateEligibility' => [
        'allStates' => true,
        'allowedStates' => [
                '<string>'
        ]
    ],
    'userId' => '<string>',
    'email' => 'jsmith@example.com'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

## Authorizations

### Authorization

- **Type:** `string`
- **Location:** `header`
- **Required:** Yes

Authorization header using the Bearer scheme. Accepted values are Leadping user JWT access tokens and WorkOS organization API keys beginning with `sk_`.

## Path parameters

### `userId`

- **Type:** `string`
- **Required:** Yes

The ID of the user whose current-organization role is changing.

## Body

**Content types:**

- `application/json`
- `application/*+json`

The updated role assignment.

Defines the fields clients can send when working with organization user.

### `stateEligibility`

- **Type:** `object | null`

Defines the states an organization member can work; this is not verification of professional licensing.

### `userId`

- **Type:** `null | string`

User ID to add, update, or remove from the organization.

### `email`

- **Type:** `null | string<email>`

Email address for the person represented by this organization user request.

### `role`

- **Type:** `enum<string>`

Identifies an organization member's access level and permission scope within Leadping.

Available options:

- `Owner`
- `Admin`
- `Agent`

## Response

### `200` — `application/json`

Returns the organization member response.

Describes organization user data returned by Leadping.

```json
{
  "stateEligibility": {
    "allStates": true,
    "allowedStates": [
      "<string>"
    ]
  },
  "organization": {
    "id": "<string>",
    "name": "<string>"
  },
  "user": {
    "id": "<string>",
    "name": "<string>"
  },
  "userEmail": "jsmith@example.com",
  "role": "Owner",
  "createdByUserId": "<string>",
  "removedAt": "2023-11-07T05:31:56Z",
  "removedByUserId": "<string>",
  "lastUsedAt": "2023-11-07T05:31:56Z",
  "licenseBillingStatus": "<string>",
  "licenseQuantity": 123,
  "licenseRenewalDate": "2023-11-07T05:31:56Z",
  "name": "<string>",
  "id": "<string>",
  "createdAt": "2023-11-07T05:31:56Z",
  "modifiedAt": "2023-11-07T05:31:56Z"
}
```

### Response fields

#### `stateEligibility`

- **Type:** `object`

Defines the states an organization member can work; this is not verification of professional licensing.

#### `organization`

- **Type:** `object`

Provides a compact API reference to another resource using its stable identifier and human-readable display name.

#### `user`

- **Type:** `object`

Provides a compact API reference to another resource using its stable identifier and human-readable display name.

#### `userEmail`

- **Type:** `null | string<email>`

User email for this organization user.

#### `role`

- **Type:** `enum<string>`

Identifies an organization member's access level and permission scope within Leadping.

Available options:

- `Owner`
- `Admin`
- `Agent`

#### `createdByUserId`

- **Type:** `null | string`

The created by user ID associated with this organization user.

#### `removedAt`

- **Type:** `null | string<date-time>`

UTC timestamp for removed at on this organization user.

#### `removedByUserId`

- **Type:** `null | string`

The removed by user ID associated with this organization user.

#### `lastUsedAt`

- **Type:** `null | string<date-time>`

UTC timestamp for last used at on this organization user.

#### `licenseBillingStatus`

- **Type:** `null | string`

The billing status for this user's organization license.

#### `licenseQuantity`

- **Type:** `null | integer<int64>`

The quantity on the shared organization user license item after this change.

#### `licenseRenewalDate`

- **Type:** `null | string<date-time>`

The renewal date used for this user's license proration.

#### `name`

- **Type:** `string`

Human-readable display name of the resource.

#### `id`

- **Type:** `string`

Stable unique identifier of the resource.

#### `createdAt`

- **Type:** `string<date-time>`

UTC timestamp when the resource was created.

#### `modifiedAt`

- **Type:** `null | string<date-time>`

UTC timestamp when the resource was last modified, or null when it has not been updated.

## Error responses

### `400` — Bad Request

```json
{
  "type": "about:blank",
  "title": "Bad Request",
  "status": 400,
  "detail": "The request could not be completed."
}
```

### `401` — Unauthorized

```json
{
  "type": "about:blank",
  "title": "Unauthorized",
  "status": 401,
  "detail": "The request could not be completed."
}
```

### `403` — Forbidden

```json
{
  "type": "about:blank",
  "title": "Forbidden",
  "status": 403,
  "detail": "The request could not be completed."
}
```

### `429` — Too Many Requests

```json
{
  "type": "about:blank",
  "title": "Too Many Requests",
  "status": 429,
  "detail": "The request could not be completed."
}
```

## Related endpoints

- [Add a user to the current organization account](https://leadping.ai/docs/api-reference/organizations/add-a-user-to-the-current-organization-account)
- [Remove a user from the current organization](https://leadping.ai/docs/api-reference/organizations/remove-a-user-from-the-current-organization)
