Docs

deleteUserProfileImage()

Deletes a user's profile image.

function deleteUserProfileImage(userId: string): Promise<User>

Warning

Using Backend SDK methods can contribute towards rate limiting. To remove a user's profile image, it's recommended to use the frontend user.setProfileImage({ file: null }) method instead.

const userId = 'user_123'

const response = await clerkClient.users.deleteUserProfileImage(userId, params)

console.log(response)
/*
_User {
  id: 'user_123',
  passwordEnabled: false,
  totpEnabled: false,
  backupCodeEnabled: false,
  twoFactorEnabled: false,
  banned: false,
  createdAt: 1719935072474,
  updatedAt: 1719935170538,
  imageUrl: null,
  hasImage: true,
  primaryEmailAddressId: 'idn_123',
  primaryPhoneNumberId: null,
  primaryWeb3WalletId: null,
  lastSignInAt: 1719935072492,
  externalId: null,
  username: null,
  firstName: 'Test',
  lastName: 'Clerk',
  publicMetadata: {},
  privateMetadata: {},
  unsafeMetadata: {},
  emailAddresses: [
    _EmailAddress {
      id: 'idn_123',
      emailAddress: 'test@gmail.com',
      verification: [_Verification],
      linkedTo: [Array]
    }
  ],
  phoneNumbers: [],
  web3Wallets: [],
  externalAccounts: [
    _ExternalAccount {
      id: 'idn_123',
      provider: undefined,
      identificationId: undefined,
      externalId: undefined,
      approvedScopes: 'email https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile openid profile',
      emailAddress: 'test@gmail.com',
      firstName: undefined,
      lastName: undefined,
      imageUrl: '',
      username: null,
      publicMetadata: {},
      label: null,
      verification: [_Verification]
    }
  ],
  samlAccounts: [],
  lastActiveAt: 1719935072472,
  createOrganizationEnabled: true
}
*/

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint POST/users/{user_id}/profile_image. See the BAPI reference for more information.

Feedback

What did you think of this content?

Last updated on