# Modify an account member

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


Update a single account member. Updating a member uses a [JSON patch](https://datatracker.ietf.org/doc/html/rfc6902) representation of the desired changes. To learn more, read [Updates](https://launchdarkly.com/docs/api#updates).

To update fields in the account member object that are arrays, set the `path` to the name of the field and then append `/<array index>`. Use `/0` to add to the beginning of the array. Use `/-` to add to the end of the array. For example, to add a new custom role to a member, use the following request body:

```
  [
    {
      "op": "add",
      "path": "/customRoles/0",
      "value": "some-role-id"
    }
  ]
```

You can update only an account member's role or custom role using a JSON patch. Members can update their own names and email addresses though the LaunchDarkly UI.

When SAML SSO or SCIM is enabled for the account, account members are managed in the Identity Provider (IdP). Requests to update account members will succeed, but the IdP will override the update shortly afterwards.


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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/members/{id}:
    patch:
      operationId: patch-member
      summary: Modify an account member
      description: >

        Update a single account member. Updating a member uses a [JSON
        patch](https://datatracker.ietf.org/doc/html/rfc6902) representation of
        the desired changes. To learn more, read
        [Updates](https://launchdarkly.com/docs/api#updates).


        To update fields in the account member object that are arrays, set the
        `path` to the name of the field and then append `/<array index>`. Use
        `/0` to add to the beginning of the array. Use `/-` to add to the end of
        the array. For example, to add a new custom role to a member, use the
        following request body:


        ```
          [
            {
              "op": "add",
              "path": "/customRoles/0",
              "value": "some-role-id"
            }
          ]
        ```


        You can update only an account member's role or custom role using a JSON
        patch. Members can update their own names and email addresses though the
        LaunchDarkly UI.


        When SAML SSO or SCIM is enabled for the account, account members are
        managed in the Identity Provider (IdP). Requests to update account
        members will succeed, but the IdP will override the update shortly
        afterwards.
      tags:
        - subpackage_accountMembers
      parameters:
        - name: id
          in: path
          description: The member ID
          required: true
          schema:
            type: string
            format: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Member response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Member'
        '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'
        '404':
          description: Invalid resource identifier
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundErrorRep'
        '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/JSONPatch'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    PatchOperation:
      type: object
      properties:
        op:
          type: string
          description: The type of operation to perform
        path:
          type: string
          description: >-
            A JSON Pointer string specifying the part of the document to operate
            on
        value:
          description: A JSON value used in "add", "replace", and "test" operations
      required:
        - op
        - path
      title: PatchOperation
    JSONPatch:
      type: array
      items:
        $ref: '#/components/schemas/PatchOperation'
      title: JSONPatch
    Link:
      type: object
      properties:
        href:
          type: string
          description: The URL of the link
        type:
          type: string
          description: The type of the link
      title: Link
    UnixMillis:
      type: integer
      format: int64
      title: UnixMillis
    LastSeenMetadata:
      type: object
      properties:
        tokenId:
          type: string
          description: The ID of the token used in the member's last session
      title: LastSeenMetadata
    IntegrationStatus:
      type: object
      properties:
        display:
          type: string
        value:
          type: string
      required:
        - display
        - value
      title: IntegrationStatus
    IntegrationMetadata:
      type: object
      properties:
        externalId:
          type: string
        externalStatus:
          $ref: '#/components/schemas/IntegrationStatus'
        externalUrl:
          type: string
        lastChecked:
          $ref: '#/components/schemas/UnixMillis'
      required:
        - externalId
        - externalStatus
        - externalUrl
        - lastChecked
      title: IntegrationMetadata
    MemberTeamSummaryRep:
      type: object
      properties:
        customRoleKeys:
          type: array
          items:
            type: string
          description: A list of keys of the custom roles this team has access to
        key:
          type: string
          description: The team key
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
        name:
          type: string
          description: The team name
      required:
        - customRoleKeys
        - key
        - name
      title: MemberTeamSummaryRep
    MemberPermissionGrantSummaryRep:
      type: object
      properties:
        actionSet:
          type: string
          description: >-
            The name of the group of related actions to allow. A permission
            grant may have either an <code>actionSet</code> or a list of
            <code>actions</code> but not both at the same time.
        actions:
          type: array
          items:
            type: string
          description: >-
            A list of actions to allow. A permission grant may have either an
            <code>actionSet</code> or a list of <code>actions</code> but not
            both at the same time.
        resource:
          type: string
          description: The resource for which the actions are allowed
      required:
        - resource
      title: MemberPermissionGrantSummaryRep
    OAuthProviderKind:
      type: string
      title: OAuthProviderKind
    RoleAttributeValues:
      type: array
      items:
        type: string
      title: RoleAttributeValues
    RoleAttributeMap:
      type: object
      additionalProperties:
        $ref: '#/components/schemas/RoleAttributeValues'
      title: RoleAttributeMap
    Member:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        _id:
          type: string
          description: The member's ID
        firstName:
          type: string
          description: The member's first name
        lastName:
          type: string
          description: The member's last name
        role:
          type: string
          description: >-
            The member's base role. If the member has no additional roles, this
            role will be in effect.
        email:
          type: string
          description: The member's email address
        _pendingInvite:
          type: boolean
          description: Whether the member has a pending invitation
        _verified:
          type: boolean
          description: Whether the member's email address has been verified
        _pendingEmail:
          type: string
          description: >-
            The member's email address before it has been verified, for accounts
            where email verification is required
        customRoles:
          type: array
          items:
            type: string
          description: >-
            The set of additional roles, besides the base role, assigned to the
            member
        mfa:
          type: string
          description: Whether multi-factor authentication is enabled for this member
        excludedDashboards:
          type: array
          items:
            type: string
          description: Default dashboards that the member has chosen to ignore
        _lastSeen:
          $ref: '#/components/schemas/UnixMillis'
          description: The member's last session date (as Unix milliseconds since epoch)
        _lastSeenMetadata:
          $ref: '#/components/schemas/LastSeenMetadata'
          description: >-
            Additional metadata associated with the member's last session, for
            example, whether a token was used
        _integrationMetadata:
          $ref: '#/components/schemas/IntegrationMetadata'
          description: >-
            Details on the member account in an external source, if this member
            is provisioned externally
        teams:
          type: array
          items:
            $ref: '#/components/schemas/MemberTeamSummaryRep'
          description: Details on the teams this member is assigned to
        permissionGrants:
          type: array
          items:
            $ref: '#/components/schemas/MemberPermissionGrantSummaryRep'
          description: >-
            A list of permission grants. Permission grants allow a member to
            have access to a specific action, without having to create or update
            a custom role.
        creationDate:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the member was created
        oauthProviders:
          type: array
          items:
            $ref: '#/components/schemas/OAuthProviderKind'
          description: A list of OAuth providers
        version:
          type: integer
          description: Version of the current configuration
        roleAttributes:
          $ref: '#/components/schemas/RoleAttributeMap'
          description: The role attributes for the member
      required:
        - _links
        - _id
        - role
        - email
        - _pendingInvite
        - _verified
        - customRoles
        - mfa
        - _lastSeen
        - creationDate
      title: Member
    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
    NotFoundErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: NotFoundErrorRep
    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/id"

payload = [
    {
        "op": "add",
        "path": "/role"
    }
]
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/id';
const options = {
  method: 'PATCH',
  headers: {Authorization: '<apiKey>', 'Content-Type': 'application/json'},
  body: '[{"op":"add","path":"/role"}]'
};

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/id"

	payload := strings.NewReader("[\n  {\n    \"op\": \"add\",\n    \"path\": \"/role\"\n  }\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/id")

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  {\n    \"op\": \"add\",\n    \"path\": \"/role\"\n  }\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/id")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("[\n  {\n    \"op\": \"add\",\n    \"path\": \"/role\"\n  }\n]")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://app.launchdarkly.com/api/v2/members/id', [
  'body' => '[
  {
    "op": "add",
    "path": "/role"
  }
]',
  'headers' => [
    'Authorization' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/members/id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "[\n  {\n    \"op\": \"add\",\n    \"path\": \"/role\"\n  }\n]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  [
    "op": "add",
    "path": "/role"
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/members/id")! 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()
```