# Update User

PATCH https://api.webflow.com/v2/sites/{site_id}/users/{user_id}
Content-Type: application/json

Update a User by ID 

  Required scope | `users:write`

<Note class="notice">The <code>email</code> and <code>password</code>
fields cannot be updated using this endpoint</Note>


Reference: https://developers.webflow.com/data/reference/users/users/update

## OpenAPI Specification

```yaml
openapi: 3.1.1
info:
  title: Update User
  version: endpoint_users.update
paths:
  /sites/{site_id}/users/{user_id}:
    patch:
      operationId: update
      summary: Update User
      description: |
        Update a User by ID 

          Required scope | `users:write`

        <Note class="notice">The <code>email</code> and <code>password</code>
        fields cannot be updated using this endpoint</Note>
      tags:
        - - subpackage_users
      parameters:
        - name: site_id
          in: path
          description: Unique identifier for a Site
          required: true
          schema:
            type: string
            format: objectid
        - name: user_id
          in: path
          description: Unique identifier for a User
          required: true
          schema:
            type: string
            format: objectid
        - name: Authorization
          in: header
          description: >-
            Bearer authentication of the form `Bearer <token>`, where token is
            your auth token.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Request was successful
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/users_update_Response_200'
        '400':
          description: Validation failure
          content: {}
        '401':
          description: >-
            Provided access token is invalid or does not have access to
            requested resource
          content: {}
        '403':
          description: Forbidden
          content: {}
        '404':
          description: Requested resource not found
          content: {}
        '429':
          description: >-
            The rate limit of the provided access_token has been reached. Please
            have your application respect the X-RateLimit-Remaining header we
            include on API responses.
          content: {}
        '500':
          description: We had a problem with our server. Try again later.
          content: {}
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: string
                  format: objectid
                  description: Unique identifier for the User
                isEmailVerified:
                  type: boolean
                  description: Shows whether the user has verified their email address
                lastUpdated:
                  type: string
                  format: date-time
                  description: The timestamp the user was updated
                invitedOn:
                  type: string
                  format: date-time
                  description: The timestamp the user was invited
                createdOn:
                  type: string
                  format: date-time
                  description: The timestamp the user was created
                lastLogin:
                  type: string
                  format: date-time
                  description: The timestamp the user was logged in
                status:
                  $ref: >-
                    #/components/schemas/SitesSiteIdUsersUserIdPatchRequestBodyContentApplicationJsonSchemaStatus
                  description: The status of the user
                accessGroups:
                  type: array
                  items:
                    $ref: >-
                      #/components/schemas/SitesSiteIdUsersUserIdPatchRequestBodyContentApplicationJsonSchemaAccessGroupsItems
                  description: Access groups the user belongs to
                data:
                  $ref: >-
                    #/components/schemas/SitesSiteIdUsersUserIdPatchRequestBodyContentApplicationJsonSchemaData
                  description: An object containing the User's basic info and custom fields
components:
  schemas:
    SitesSiteIdUsersUserIdPatchRequestBodyContentApplicationJsonSchemaStatus:
      type: string
      enum:
        - value: invited
        - value: verified
        - value: unverified
    SitesSiteIdUsersUserIdPatchRequestBodyContentApplicationJsonSchemaAccessGroupsItemsType:
      type: string
      enum:
        - value: admin
        - value: ecommerce
    SitesSiteIdUsersUserIdPatchRequestBodyContentApplicationJsonSchemaAccessGroupsItems:
      type: object
      properties:
        slug:
          type: string
          description: Access group identifier for APIs
        type:
          $ref: >-
            #/components/schemas/SitesSiteIdUsersUserIdPatchRequestBodyContentApplicationJsonSchemaAccessGroupsItemsType
          description: |
            The type of access group based on how it was assigned to the user.
            * `admin` - Assigned to the user via API or in the designer
            * `ecommerce` - Assigned to the user via an ecommerce purchase
    SitesSiteIdUsersUserIdPatchRequestBodyContentApplicationJsonSchemaDataData:
      type: object
      properties:
        name:
          type: string
          description: |
            The name of the user
        email:
          type: string
          description: |
            The email address of the user
        accept-privacy:
          type: boolean
          description: |
            Boolean indicating if the user has accepted the privacy policy
        accept-communications:
          type: boolean
          description: >
            Boolean indicating if the user has accepted to receive
            communications
        additionalProperties:
          type: string
          description: Custom user attributes
    SitesSiteIdUsersUserIdPatchRequestBodyContentApplicationJsonSchemaData:
      type: object
      properties:
        data:
          $ref: >-
            #/components/schemas/SitesSiteIdUsersUserIdPatchRequestBodyContentApplicationJsonSchemaDataData
    SitesSiteIdUsersUserIdPatchResponsesContentApplicationJsonSchemaStatus:
      type: string
      enum:
        - value: invited
        - value: verified
        - value: unverified
    SitesSiteIdUsersUserIdPatchResponsesContentApplicationJsonSchemaAccessGroupsItemsType:
      type: string
      enum:
        - value: admin
        - value: ecommerce
    SitesSiteIdUsersUserIdPatchResponsesContentApplicationJsonSchemaAccessGroupsItems:
      type: object
      properties:
        slug:
          type: string
          description: Access group identifier for APIs
        type:
          $ref: >-
            #/components/schemas/SitesSiteIdUsersUserIdPatchResponsesContentApplicationJsonSchemaAccessGroupsItemsType
          description: |
            The type of access group based on how it was assigned to the user.
            * `admin` - Assigned to the user via API or in the designer
            * `ecommerce` - Assigned to the user via an ecommerce purchase
    SitesSiteIdUsersUserIdPatchResponsesContentApplicationJsonSchemaDataData:
      type: object
      properties:
        name:
          type: string
          description: |
            The name of the user
        email:
          type: string
          description: |
            The email address of the user
        accept-privacy:
          type: boolean
          description: |
            Boolean indicating if the user has accepted the privacy policy
        accept-communications:
          type: boolean
          description: >
            Boolean indicating if the user has accepted to receive
            communications
        additionalProperties:
          type: string
          description: Custom user attributes
    SitesSiteIdUsersUserIdPatchResponsesContentApplicationJsonSchemaData:
      type: object
      properties:
        data:
          $ref: >-
            #/components/schemas/SitesSiteIdUsersUserIdPatchResponsesContentApplicationJsonSchemaDataData
    users_update_Response_200:
      type: object
      properties:
        id:
          type: string
          format: objectid
          description: Unique identifier for the User
        isEmailVerified:
          type: boolean
          description: Shows whether the user has verified their email address
        lastUpdated:
          type: string
          format: date-time
          description: The timestamp the user was updated
        invitedOn:
          type: string
          format: date-time
          description: The timestamp the user was invited
        createdOn:
          type: string
          format: date-time
          description: The timestamp the user was created
        lastLogin:
          type: string
          format: date-time
          description: The timestamp the user was logged in
        status:
          $ref: >-
            #/components/schemas/SitesSiteIdUsersUserIdPatchResponsesContentApplicationJsonSchemaStatus
          description: The status of the user
        accessGroups:
          type: array
          items:
            $ref: >-
              #/components/schemas/SitesSiteIdUsersUserIdPatchResponsesContentApplicationJsonSchemaAccessGroupsItems
          description: Access groups the user belongs to
        data:
          $ref: >-
            #/components/schemas/SitesSiteIdUsersUserIdPatchResponsesContentApplicationJsonSchemaData
          description: An object containing the User's basic info and custom fields

```

## SDK Code Examples

```python
import datetime

from webflow import UserAccessGroupsItem, Webflow

client = Webflow(
    access_token="YOUR_ACCESS_TOKEN",
)
client.users.update(
    site_id="580e63e98c9a982ac9b8b741",
    user_id="580e63e98c9a982ac9b8b741",
    id="6287ec36a841b25637c663df",
    is_email_verified=True,
    last_updated=datetime.datetime.fromisoformat(
        "2022-05-20 13:46:12+00:00",
    ),
    invited_on=datetime.datetime.fromisoformat(
        "2022-05-20 13:46:12+00:00",
    ),
    created_on=datetime.datetime.fromisoformat(
        "2022-05-20 13:46:12+00:00",
    ),
    last_login=datetime.datetime.fromisoformat(
        "2022-05-20 13:46:12+00:00",
    ),
    status="verified",
    access_groups=[
        UserAccessGroupsItem(
            slug="webflowers",
            type="admin",
        )
    ],
)

```

```typescript
import { WebflowClient } from "webflow-api";

const client = new WebflowClient({ accessToken: "YOUR_ACCESS_TOKEN" });
await client.users.update("580e63e98c9a982ac9b8b741", "580e63e98c9a982ac9b8b741", {
    id: "6287ec36a841b25637c663df",
    isEmailVerified: true,
    lastUpdated: new Date("2022-05-20T13:46:12.000Z"),
    invitedOn: new Date("2022-05-20T13:46:12.000Z"),
    createdOn: new Date("2022-05-20T13:46:12.000Z"),
    lastLogin: new Date("2022-05-20T13:46:12.000Z"),
    status: "verified",
    accessGroups: [{
            slug: "webflowers",
            type: "admin"
        }]
});

```

```go
package main

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

func main() {

	url := "https://api.webflow.com/v2/sites/580e63e98c9a982ac9b8b741/users/580e63e98c9a982ac9b8b741"

	payload := strings.NewReader("{\n  \"id\": \"6287ec36a841b25637c663df\",\n  \"isEmailVerified\": true,\n  \"lastUpdated\": \"2022-05-20T13:46:12.093Z\",\n  \"invitedOn\": \"2022-05-20T13:46:12.093Z\",\n  \"createdOn\": \"2022-05-20T13:46:12.093Z\",\n  \"lastLogin\": \"2022-05-20T13:46:12.093Z\",\n  \"status\": \"verified\",\n  \"accessGroups\": [\n    {\n      \"slug\": \"webflowers\",\n      \"type\": \"admin\"\n    }\n  ],\n  \"data\": {\n    \"name\": \"Arthur Dent\",\n    \"email\": \"arthur.dent@mostlyharmless.com\",\n    \"accept-privacy\": true,\n    \"accept-communications\": true,\n    \"favoriteDrink\": \"Tea\",\n    \"currentPlanet\": \"Somewhere in the vicinity of Betelgeuse\"\n  }\n}")

	req, _ := http.NewRequest("PATCH", 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(res)
	fmt.Println(string(body))

}
```

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

url = URI("https://api.webflow.com/v2/sites/580e63e98c9a982ac9b8b741/users/580e63e98c9a982ac9b8b741")

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"id\": \"6287ec36a841b25637c663df\",\n  \"isEmailVerified\": true,\n  \"lastUpdated\": \"2022-05-20T13:46:12.093Z\",\n  \"invitedOn\": \"2022-05-20T13:46:12.093Z\",\n  \"createdOn\": \"2022-05-20T13:46:12.093Z\",\n  \"lastLogin\": \"2022-05-20T13:46:12.093Z\",\n  \"status\": \"verified\",\n  \"accessGroups\": [\n    {\n      \"slug\": \"webflowers\",\n      \"type\": \"admin\"\n    }\n  ],\n  \"data\": {\n    \"name\": \"Arthur Dent\",\n    \"email\": \"arthur.dent@mostlyharmless.com\",\n    \"accept-privacy\": true,\n    \"accept-communications\": true,\n    \"favoriteDrink\": \"Tea\",\n    \"currentPlanet\": \"Somewhere in the vicinity of Betelgeuse\"\n  }\n}"

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

```java
HttpResponse<String> response = Unirest.patch("https://api.webflow.com/v2/sites/580e63e98c9a982ac9b8b741/users/580e63e98c9a982ac9b8b741")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"id\": \"6287ec36a841b25637c663df\",\n  \"isEmailVerified\": true,\n  \"lastUpdated\": \"2022-05-20T13:46:12.093Z\",\n  \"invitedOn\": \"2022-05-20T13:46:12.093Z\",\n  \"createdOn\": \"2022-05-20T13:46:12.093Z\",\n  \"lastLogin\": \"2022-05-20T13:46:12.093Z\",\n  \"status\": \"verified\",\n  \"accessGroups\": [\n    {\n      \"slug\": \"webflowers\",\n      \"type\": \"admin\"\n    }\n  ],\n  \"data\": {\n    \"name\": \"Arthur Dent\",\n    \"email\": \"arthur.dent@mostlyharmless.com\",\n    \"accept-privacy\": true,\n    \"accept-communications\": true,\n    \"favoriteDrink\": \"Tea\",\n    \"currentPlanet\": \"Somewhere in the vicinity of Betelgeuse\"\n  }\n}")
  .asString();
```

```php
<?php

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.webflow.com/v2/sites/580e63e98c9a982ac9b8b741/users/580e63e98c9a982ac9b8b741', [
  'body' => '{
  "id": "6287ec36a841b25637c663df",
  "isEmailVerified": true,
  "lastUpdated": "2022-05-20T13:46:12.093Z",
  "invitedOn": "2022-05-20T13:46:12.093Z",
  "createdOn": "2022-05-20T13:46:12.093Z",
  "lastLogin": "2022-05-20T13:46:12.093Z",
  "status": "verified",
  "accessGroups": [
    {
      "slug": "webflowers",
      "type": "admin"
    }
  ],
  "data": {
    "name": "Arthur Dent",
    "email": "arthur.dent@mostlyharmless.com",
    "accept-privacy": true,
    "accept-communications": true,
    "favoriteDrink": "Tea",
    "currentPlanet": "Somewhere in the vicinity of Betelgeuse"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
var client = new RestClient("https://api.webflow.com/v2/sites/580e63e98c9a982ac9b8b741/users/580e63e98c9a982ac9b8b741");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"id\": \"6287ec36a841b25637c663df\",\n  \"isEmailVerified\": true,\n  \"lastUpdated\": \"2022-05-20T13:46:12.093Z\",\n  \"invitedOn\": \"2022-05-20T13:46:12.093Z\",\n  \"createdOn\": \"2022-05-20T13:46:12.093Z\",\n  \"lastLogin\": \"2022-05-20T13:46:12.093Z\",\n  \"status\": \"verified\",\n  \"accessGroups\": [\n    {\n      \"slug\": \"webflowers\",\n      \"type\": \"admin\"\n    }\n  ],\n  \"data\": {\n    \"name\": \"Arthur Dent\",\n    \"email\": \"arthur.dent@mostlyharmless.com\",\n    \"accept-privacy\": true,\n    \"accept-communications\": true,\n    \"favoriteDrink\": \"Tea\",\n    \"currentPlanet\": \"Somewhere in the vicinity of Betelgeuse\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "id": "6287ec36a841b25637c663df",
  "isEmailVerified": true,
  "lastUpdated": "2022-05-20T13:46:12.093Z",
  "invitedOn": "2022-05-20T13:46:12.093Z",
  "createdOn": "2022-05-20T13:46:12.093Z",
  "lastLogin": "2022-05-20T13:46:12.093Z",
  "status": "verified",
  "accessGroups": [
    [
      "slug": "webflowers",
      "type": "admin"
    ]
  ],
  "data": [
    "name": "Arthur Dent",
    "email": "arthur.dent@mostlyharmless.com",
    "accept-privacy": true,
    "accept-communications": true,
    "favoriteDrink": "Tea",
    "currentPlanet": "Somewhere in the vicinity of Betelgeuse"
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.webflow.com/v2/sites/580e63e98c9a982ac9b8b741/users/580e63e98c9a982ac9b8b741")! 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()
```