# Modify account members

PATCH https://app.launchdarkly.com/api/v2/members
Content-Type: application/json

> ### Full use of this API resource is an Enterprise feature
>
> The ability to perform a partial update to multiple members is available to customers on an Enterprise plan. If you are on another plan, you can update members individually. To learn more, [read about our pricing](https://launchdarkly.com/pricing/). To upgrade your plan, [contact Sales](https://launchdarkly.com/contact-sales/).

Perform a partial update to multiple members. Updating members uses the semantic patch format.

To make a semantic patch request, you must append `domain-model=launchdarkly.semanticpatch` to your `Content-Type` header. To learn more, read [Updates using semantic patch](https://launchdarkly.com/docs/api#updates-using-semantic-patch).

### Instructions

Semantic patch requests support the following `kind` instructions for updating members.

<details>
<summary>Click to expand instructions for <strong>updating members</strong></summary>

#### replaceMembersRoles

Replaces the roles of the specified members. This also removes all custom roles assigned to the specified members.

##### Parameters

- `value`: The new role. Must be a valid [base role](https://launchdarkly.com/docs/home/getting-started/vocabulary#base-role). To learn more, read [Roles](https://launchdarkly.com/docs/home/account/roles).
- `memberIDs`: List of member IDs.

Here's an example:

```json
{
  "instructions": [{
    "kind": "replaceMembersRoles",
    "value": "reader",
    "memberIDs": [
      "1234a56b7c89d012345e678f",
      "507f1f77bcf86cd799439011"
    ]
  }]
}
```

#### replaceAllMembersRoles

Replaces the roles of all members. This also removes all custom roles assigned to the specified members.

Members that match any of the filters are **excluded** from the update.

##### Parameters

- `value`: The new role. Must be a valid [base role](https://launchdarkly.com/docs/home/getting-started/vocabulary#base-role). To learn more, read [Roles](https://launchdarkly.com/docs/home/account/roles).
- `filterLastSeen`: (Optional) A JSON object with one of the following formats:
  - `{"never": true}` - Members that have never been active, such as those who have not accepted their invitation to LaunchDarkly, or have not logged in after being provisioned via SCIM.
  - `{"noData": true}` - Members that have not been active since LaunchDarkly began recording last seen timestamps.
  - `{"before": 1608672063611}` - Members that have not been active since the provided value, which should be a timestamp in Unix epoch milliseconds.
- `filterQuery`: (Optional) A string that matches against the members' emails and names. It is not case sensitive.
- `filterRoles`: (Optional) A `|` separated list of roles and custom roles. For the purposes of this filtering, `Owner` counts as `Admin`.
- `filterTeamKey`: (Optional) A string that matches against the key of the team the members belong to. It is not case sensitive.
- `ignoredMemberIDs`: (Optional) A list of member IDs.

Here's an example:

```json
{
  "instructions": [{
    "kind": "replaceAllMembersRoles",
    "value": "reader",
    "filterLastSeen": { "never": true }
  }]
}
```

#### replaceMembersCustomRoles

Replaces the custom roles of the specified members.

##### Parameters

- `values`: List of new custom roles. Must be a valid custom role key or ID.
- `memberIDs`: List of member IDs.

Here's an example:

```json
{
  "instructions": [{
    "kind": "replaceMembersCustomRoles",
    "values": [ "example-custom-role" ],
    "memberIDs": [
      "1234a56b7c89d012345e678f",
      "507f1f77bcf86cd799439011"
    ]
  }]
}
```

#### replaceAllMembersCustomRoles

Replaces the custom roles of all members. Members that match any of the filters are **excluded** from the update.

##### Parameters

- `values`: List of new roles. Must be a valid custom role key or ID.
- `filterLastSeen`: (Optional) A JSON object with one of the following formats:
  - `{"never": true}` - Members that have never been active, such as those who have not accepted their invitation to LaunchDarkly, or have not logged in after being provisioned via SCIM.
  - `{"noData": true}` - Members that have not been active since LaunchDarkly began recording last seen timestamps.
  - `{"before": 1608672063611}` - Members that have not been active since the provided value, which should be a timestamp in Unix epoch milliseconds.
- `filterQuery`: (Optional) A string that matches against the members' emails and names. It is not case sensitive.
- `filterRoles`: (Optional) A `|` separated list of roles and custom roles. For the purposes of this filtering, `Owner` counts as `Admin`.
- `filterTeamKey`: (Optional) A string that matches against the key of the team the members belong to. It is not case sensitive.
- `ignoredMemberIDs`: (Optional) A list of member IDs.

Here's an example:

```json
{
  "instructions": [{
    "kind": "replaceAllMembersCustomRoles",
    "values": [ "example-custom-role" ],
    "filterLastSeen": { "never": true }
  }]
}
```

#### replaceMembersRoleAttributes

Replaces the role attributes of the specified members.

##### Parameters

- `value`: Map of role attribute keys to lists of values.
- `memberIDs`: List of member IDs.

Here's an example:

```json
{
  "instructions": [{
    "kind": "replaceMembersRoleAttributes",
    "value": {
      "myRoleProjectKey": ["mobile", "web"],
      "myRoleEnvironmentKey": ["production"]
    },
    "memberIDs": [
      "1234a56b7c89d012345e678f",
      "507f1f77bcf86cd799439011"
    ]
  }]
}
```

</details>


Reference: https://launchdarkly.com/docs/api/account-members/patch-members

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/members:
    patch:
      operationId: patch-members
      summary: Modify account members
      description: >
        > ### Full use of this API resource is an Enterprise feature

        >

        > The ability to perform a partial update to multiple members is
        available to customers on an Enterprise plan. If you are on another
        plan, you can update members individually. To learn more, [read about
        our pricing](https://launchdarkly.com/pricing/). To upgrade your plan,
        [contact Sales](https://launchdarkly.com/contact-sales/).


        Perform a partial update to multiple members. Updating members uses the
        semantic patch format.


        To make a semantic patch request, you must append
        `domain-model=launchdarkly.semanticpatch` to your `Content-Type` header.
        To learn more, read [Updates using semantic
        patch](https://launchdarkly.com/docs/api#updates-using-semantic-patch).


        ### Instructions


        Semantic patch requests support the following `kind` instructions for
        updating members.


        <details>

        <summary>Click to expand instructions for <strong>updating
        members</strong></summary>


        #### replaceMembersRoles


        Replaces the roles of the specified members. This also removes all
        custom roles assigned to the specified members.


        ##### Parameters


        - `value`: The new role. Must be a valid [base
        role](https://launchdarkly.com/docs/home/getting-started/vocabulary#base-role).
        To learn more, read
        [Roles](https://launchdarkly.com/docs/home/account/roles).

        - `memberIDs`: List of member IDs.


        Here's an example:


        ```json

        {
          "instructions": [{
            "kind": "replaceMembersRoles",
            "value": "reader",
            "memberIDs": [
              "1234a56b7c89d012345e678f",
              "507f1f77bcf86cd799439011"
            ]
          }]
        }

        ```


        #### replaceAllMembersRoles


        Replaces the roles of all members. This also removes all custom roles
        assigned to the specified members.


        Members that match any of the filters are **excluded** from the update.


        ##### Parameters


        - `value`: The new role. Must be a valid [base
        role](https://launchdarkly.com/docs/home/getting-started/vocabulary#base-role).
        To learn more, read
        [Roles](https://launchdarkly.com/docs/home/account/roles).

        - `filterLastSeen`: (Optional) A JSON object with one of the following
        formats:
          - `{"never": true}` - Members that have never been active, such as those who have not accepted their invitation to LaunchDarkly, or have not logged in after being provisioned via SCIM.
          - `{"noData": true}` - Members that have not been active since LaunchDarkly began recording last seen timestamps.
          - `{"before": 1608672063611}` - Members that have not been active since the provided value, which should be a timestamp in Unix epoch milliseconds.
        - `filterQuery`: (Optional) A string that matches against the members'
        emails and names. It is not case sensitive.

        - `filterRoles`: (Optional) A `|` separated list of roles and custom
        roles. For the purposes of this filtering, `Owner` counts as `Admin`.

        - `filterTeamKey`: (Optional) A string that matches against the key of
        the team the members belong to. It is not case sensitive.

        - `ignoredMemberIDs`: (Optional) A list of member IDs.


        Here's an example:


        ```json

        {
          "instructions": [{
            "kind": "replaceAllMembersRoles",
            "value": "reader",
            "filterLastSeen": { "never": true }
          }]
        }

        ```


        #### replaceMembersCustomRoles


        Replaces the custom roles of the specified members.


        ##### Parameters


        - `values`: List of new custom roles. Must be a valid custom role key or
        ID.

        - `memberIDs`: List of member IDs.


        Here's an example:


        ```json

        {
          "instructions": [{
            "kind": "replaceMembersCustomRoles",
            "values": [ "example-custom-role" ],
            "memberIDs": [
              "1234a56b7c89d012345e678f",
              "507f1f77bcf86cd799439011"
            ]
          }]
        }

        ```


        #### replaceAllMembersCustomRoles


        Replaces the custom roles of all members. Members that match any of the
        filters are **excluded** from the update.


        ##### Parameters


        - `values`: List of new roles. Must be a valid custom role key or ID.

        - `filterLastSeen`: (Optional) A JSON object with one of the following
        formats:
          - `{"never": true}` - Members that have never been active, such as those who have not accepted their invitation to LaunchDarkly, or have not logged in after being provisioned via SCIM.
          - `{"noData": true}` - Members that have not been active since LaunchDarkly began recording last seen timestamps.
          - `{"before": 1608672063611}` - Members that have not been active since the provided value, which should be a timestamp in Unix epoch milliseconds.
        - `filterQuery`: (Optional) A string that matches against the members'
        emails and names. It is not case sensitive.

        - `filterRoles`: (Optional) A `|` separated list of roles and custom
        roles. For the purposes of this filtering, `Owner` counts as `Admin`.

        - `filterTeamKey`: (Optional) A string that matches against the key of
        the team the members belong to. It is not case sensitive.

        - `ignoredMemberIDs`: (Optional) A list of member IDs.


        Here's an example:


        ```json

        {
          "instructions": [{
            "kind": "replaceAllMembersCustomRoles",
            "values": [ "example-custom-role" ],
            "filterLastSeen": { "never": true }
          }]
        }

        ```


        #### replaceMembersRoleAttributes


        Replaces the role attributes of the specified members.


        ##### Parameters


        - `value`: Map of role attribute keys to lists of values.

        - `memberIDs`: List of member IDs.


        Here's an example:


        ```json

        {
          "instructions": [{
            "kind": "replaceMembersRoleAttributes",
            "value": {
              "myRoleProjectKey": ["mobile", "web"],
              "myRoleEnvironmentKey": ["production"]
            },
            "memberIDs": [
              "1234a56b7c89d012345e678f",
              "507f1f77bcf86cd799439011"
            ]
          }]
        }

        ```


        </details>
      tags:
        - subpackage_accountMembers
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Members response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkEditMembersRep'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidRequestErrorRep'
        '401':
          description: Invalid access token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorRep'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenErrorRep'
        '409':
          description: Status conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatusConflictErrorRep'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitedErrorRep'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/membersPatchInput'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    Instruction:
      type: object
      additionalProperties:
        description: Any type
      title: Instruction
    Instructions:
      type: array
      items:
        $ref: '#/components/schemas/Instruction'
      title: Instructions
    membersPatchInput:
      type: object
      properties:
        comment:
          type: string
          description: Optional comment describing the update
        instructions:
          $ref: '#/components/schemas/Instructions'
          description: >-
            The instructions to perform when updating. This should be an array
            with objects that look like <code>{"kind": "update_action"}</code>.
            Some instructions also require additional parameters as part of this
            object.
      required:
        - instructions
      title: membersPatchInput
    BulkEditMembersRep:
      type: object
      properties:
        members:
          type: array
          items:
            type: string
          description: A list of members IDs of the members who were successfully updated.
        errors:
          type: array
          items:
            type: object
            additionalProperties:
              type: string
          description: >-
            A list of member IDs and errors for the members whose updates
            failed.
      title: BulkEditMembersRep
    InvalidRequestErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: InvalidRequestErrorRep
    UnauthorizedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: UnauthorizedErrorRep
    ForbiddenErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: ForbiddenErrorRep
    StatusConflictErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: StatusConflictErrorRep
    RateLimitedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: RateLimitedErrorRep
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

```

## SDK Code Examples

```python
import requests

url = "https://app.launchdarkly.com/api/v2/members"

payload = {
    "instructions": [
        {
            "kind": "replaceMembersRoles",
            "memberIDs": ["1234a56b7c89d012345e678f", "507f1f77bcf86cd799439011"],
            "value": "reader"
        }
    ],
    "comment": "Optional comment about the update"
}
headers = {
    "Authorization": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/members';
const options = {
  method: 'PATCH',
  headers: {Authorization: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"instructions":[{"kind":"replaceMembersRoles","memberIDs":["1234a56b7c89d012345e678f","507f1f77bcf86cd799439011"],"value":"reader"}],"comment":"Optional comment about the update"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://app.launchdarkly.com/api/v2/members"

	payload := strings.NewReader("{\n  \"instructions\": [\n    {\n      \"kind\": \"replaceMembersRoles\",\n      \"memberIDs\": [\n        \"1234a56b7c89d012345e678f\",\n        \"507f1f77bcf86cd799439011\"\n      ],\n      \"value\": \"reader\"\n    }\n  ],\n  \"comment\": \"Optional comment about the update\"\n}")

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

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

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

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

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.launchdarkly.com/api/v2/members")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"instructions\": [\n    {\n      \"kind\": \"replaceMembersRoles\",\n      \"memberIDs\": [\n        \"1234a56b7c89d012345e678f\",\n        \"507f1f77bcf86cd799439011\"\n      ],\n      \"value\": \"reader\"\n    }\n  ],\n  \"comment\": \"Optional comment about the update\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://app.launchdarkly.com/api/v2/members")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"instructions\": [\n    {\n      \"kind\": \"replaceMembersRoles\",\n      \"memberIDs\": [\n        \"1234a56b7c89d012345e678f\",\n        \"507f1f77bcf86cd799439011\"\n      ],\n      \"value\": \"reader\"\n    }\n  ],\n  \"comment\": \"Optional comment about the update\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://app.launchdarkly.com/api/v2/members', [
  'body' => '{
  "instructions": [
    {
      "kind": "replaceMembersRoles",
      "memberIDs": [
        "1234a56b7c89d012345e678f",
        "507f1f77bcf86cd799439011"
      ],
      "value": "reader"
    }
  ],
  "comment": "Optional comment about the update"
}',
  'headers' => [
    'Authorization' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/members");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"instructions\": [\n    {\n      \"kind\": \"replaceMembersRoles\",\n      \"memberIDs\": [\n        \"1234a56b7c89d012345e678f\",\n        \"507f1f77bcf86cd799439011\"\n      ],\n      \"value\": \"reader\"\n    }\n  ],\n  \"comment\": \"Optional comment about the update\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "instructions": [
    [
      "kind": "replaceMembersRoles",
      "memberIDs": ["1234a56b7c89d012345e678f", "507f1f77bcf86cd799439011"],
      "value": "reader"
    ]
  ],
  "comment": "Optional comment about the update"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/members")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```