# Update User — Clerk

> Update a user's attributes. You can set the user's primary contact identifiers (email address and phone numbers) by updating the Primary Email Address Id and Primary Phone Number Id attributes respectively. Both IDs should correspond to…

- Key: `clerk-update-user`
- Type: Action (Write)
- Version: 0.0.3
- App: Clerk (`clerk`) — https://pipedream.com/apps/clerk.md
- This page (HTML): https://pipedream.com/apps/clerk/actions/update-user
- Hints: destructive · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/clerk/actions/update-user/update-user.mjs

## Description

Update a user's attributes. You can set the user's primary contact identifiers (email address and phone numbers) by updating the `Primary Email Address Id` and `Primary Phone Number Id` attributes respectively. Both IDs should correspond to verified identifications that belong to the user. [See the documentation](https://clerk.com/docs/reference/backend-api/tag/Users#operation/CreateUser)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `userId` | `string` | Yes | The Id of the user. Options are loaded from the connected account. |
| `externalId` | `string` | No | The ID of the user as used in your external systems or your previous authentication solution. Must be unique across your instance. |
| `firstName` | `string` | No | The first name to assign to the user. |
| `lastName` | `string` | No | The last name to assign to the user. |
| `primaryEmailAddressId` | `string` | No | The ID of the email address to set as primary. It must be verified, and present on the current user. Options are loaded from the connected account. |
| `notifyPrimaryEmailAddressChanged` | `boolean` | No | If set to true, the user will be notified that their primary email address has changed. By default, no notification is sent. |
| `primaryPhoneNumberId` | `string` | No | The ID of the phone number to set as primary. It must be verified, and present on the current user. Options are loaded from the connected account. |
| `primaryWeb3WalletId` | `string` | No | The ID of the web3 wallets to set as primary. It must be verified, and present on the current user. Options are loaded from the connected account. |
| `username` | `string` | No | The username to give to the user. It must be unique across your instance. |
| `profileImageId` | `string` | No | The ID of the image to set as the user's profile image |
| `password` | `string` | No | The plaintext password to give to the user. Must be at least 8 characters long, and can not be in any list of hacked passwords. |
| `skipPasswordChecks` | `boolean` | No | When set to true all password checks are skipped. It is recommended to use this method only when migrating plaintext passwords to Clerk. Upon migration the user base should be prompted to pick stronger password. |
| `signOutOfOtherSessions` | `boolean` | No | Set to true to sign out the user from all their active sessions once their password is updated. This parameter can only be used when providing a password. |
| `totpSecret` | `string` | No | In case TOTP is configured on the instance, you can provide the secret to enable it on the newly created user without the need to reset it. |
| `backupCodes` | `string[]` | No | If Backup Codes are configured on the instance, you can provide them to enable it on the newly created user without the need to reset them. You must provide the backup codes in plain format or the corresponding bcrypt digest. |
| `publicMetadata` | `object` | No | Metadata saved on the user, that is visible to both your Frontend and Backend APIs. |
| `privateMetadata` | `object` | No | Metadata saved on the user, that is only visible to your Backend API. |
| `unsafeMetadata` | `object` | No | Metadata saved on the user, that can be updated from both the Frontend and Backend APIs. Note: Since this data can be modified from the frontend, it is not guaranteed to be safe. |
| `deleteSelfEnable` | `boolean` | No | If true, the user can delete themselves with the Frontend API. |
| `createOrganizationEnabled` | `boolean` | No | If true, the user can create organizations with the Frontend API. |
| `createdAt` | `string` | No | A custom date/time denoting when the user signed up to the application, specified in RFC3339 format (e.g. 2012-10-20T07:15:20.902Z). |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "clerk",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "clerk-update-user",
  arguments: {
    userId: "User Id",
    externalId: "External Id",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "clerk-update-user",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    clerk: { authProvisionId: "apn_xxxxxxx" },
    userId: "User Id",
    externalId: "External Id",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "clerk-update-user",
    "configured_props": {
      "clerk": { "authProvisionId": "apn_xxxxxxx" },
      "userId": "User Id",
      "externalId": "External Id"
    }
  }'
```

---

- App: https://pipedream.com/apps/clerk.md · All apps: https://pipedream.com/apps
