Skip to main content
PATCH
/
users
/
{user_id}
Update user
curl --request PATCH \
  --url https://api.wacht.dev/users/{user_id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form 'first_name=<string>' \
  --form 'last_name=<string>' \
  --form 'username=<string>' \
  --form 'public_metadata={"plan": "premium"}' \
  --form 'private_metadata={"internal_id": "12345"}' \
  --form disabled=true \
  --form remove_profile_image=false \
  --form profile_image='@example-file'
{
  "id": "1234567890",
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-20T15:45:00Z",
  "first_name": "John",
  "last_name": "Doe",
  "profile_picture_url": "https://cdn.wacht.dev/deployments/123/users/456/profile.jpg",
  "disabled": false,
  "has_password": true,
  "has_backup_codes": false,
  "username": "johndoe",
  "schema_version": "v2",
  "second_factor_policy": "disabled",
  "availability": "available",
  "last_password_reset_at": "2024-01-15T10:30:00Z",
  "deployment_id": "1234567890",
  "public_metadata": {},
  "private_metadata": {},
  "primary_email_address_id": "9876543210",
  "primary_email_address": "[email protected]",
  "primary_phone_number_id": "1111111111",
  "primary_phone_number": "+1234567890",
  "active_organization_membership_id": "5555555555",
  "active_workspace_membership_id": "6666666666",
  "email_addresses": [
    {
      "id": "9876543210",
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T10:30:00Z",
      "deployment_id": "1234567890",
      "user_id": "1234567890",
      "email": "[email protected]",
      "is_primary": true,
      "verified": true,
      "verified_at": "2024-01-15T10:35:00Z",
      "verification_strategy": "otp"
    }
  ],
  "phone_numbers": [
    {
      "id": "1111111111",
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T10:30:00Z",
      "user_id": "1234567890",
      "phone_number": "1234567890",
      "country_code": "+1",
      "verified": true,
      "verified_at": "2024-01-15T10:36:00Z"
    }
  ],
  "social_connections": [
    {
      "id": "2222222222",
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T10:30:00Z",
      "user_id": "1234567890",
      "user_email_address_id": "9876543210",
      "provider": "google_oauth",
      "email_address": "[email protected]"
    }
  ],
  "segments": [
    {
      "id": "4444444444",
      "deployment_id": "1234567890",
      "name": "Premium Users",
      "type": "user",
      "created_at": "2024-01-10T10:00:00Z",
      "updated_at": "2024-01-10T10:00:00Z",
      "deleted_at": null
    }
  ]
}

Authorizations

Authorization
string
header
required

API key authentication (Bearer token)

Path Parameters

user_id
string
required

User ID (integer as string)

Body

multipart/form-data
first_name
string

User's first name

last_name
string

User's last name

username
string

User's username

public_metadata
string

JSON string of public metadata

Example:

"{\"plan\": \"premium\"}"

private_metadata
string

JSON string of private metadata

Example:

"{\"internal_id\": \"12345\"}"

disabled
boolean

Whether the user account is disabled

remove_profile_image
boolean
default:false

Set to true to remove the profile image

profile_image
file

Profile image file (JPEG, PNG, GIF, WEBP, or ICO)

Response

User updated successfully

id
string
required

User ID (integer serialized as string)

Example:

"1234567890"

created_at
string<date-time>
required
Example:

"2024-01-15T10:30:00Z"

updated_at
string<date-time>
required
Example:

"2024-01-20T15:45:00Z"

first_name
string
required

User's first name

Example:

"John"

last_name
string
required

User's last name

Example:

"Doe"

profile_picture_url
string
required

URL to profile picture

Example:

"https://cdn.wacht.dev/deployments/123/users/456/profile.jpg"

disabled
boolean
required

Whether the user account is disabled

Example:

false

has_password
boolean
required

Whether the user has a password set

Example:

true

has_backup_codes
boolean
required

Whether the user has backup codes generated

Example:

false

username
string | null

User's username (nullable)

Example:

"johndoe"

schema_version
enum<string>

Schema version

Available options:
v1,
v2
Example:

"v2"

second_factor_policy
enum<string>

Second factor authentication policy

Available options:
disabled,
optional,
required
Example:

"disabled"

availability
string

User availability status

Example:

"available"

last_password_reset_at
string<date-time> | null

Last password reset timestamp

Example:

"2024-01-15T10:30:00Z"

deployment_id
string

Deployment ID (integer serialized as string)

Example:

"1234567890"

public_metadata
object

Public metadata (custom fields)

Example:
{}
private_metadata
object

Private metadata (custom fields, only accessible via backend API)

Example:
{}
primary_email_address_id
string | null

Primary email ID

Example:

"9876543210"

primary_email_address
string<email> | null

Primary email address

primary_phone_number_id
string | null

Primary phone ID

Example:

"1111111111"

primary_phone_number
string | null

Primary phone number with country code

Example:

"+1234567890"

active_organization_membership_id
string | null

Active organization membership ID

Example:

"5555555555"

active_workspace_membership_id
string | null

Active workspace membership ID

Example:

"6666666666"

email_addresses
object[]

All email addresses associated with the user

phone_numbers
object[]

All phone numbers associated with the user

social_connections
object[]

All social connections associated with the user

segments
object[]

All segments the user belongs to