> For the complete documentation index, see [llms.txt](https://rudderlabs.gitbook.io/rudderlabs-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rudderlabs.gitbook.io/rudderlabs-1/docs/rudderstack-api/api-specification/rudderstack-spec/alias.md).

# Alias

The `alias` call lets you merge different identities of a known user.

`alias` is an advanced method that lets you change the tracked user's ID explicitly. This method is useful when managing identities for some of the downstream destinations.

The following destinations support the `alias` call:

* [MoEngage](https://rudderstack.com/docs/destinations/marketing/moengage/)
* [Kissmetrics](https://rudderstack.com/docs/destinations/analytics/kissmetrics/)
* [Amplitude](https://rudderstack.com/docs/destinations/analytics/amplitude/) (only supported by the [JavaScript SDK ](https://rudderstack.com/docs/stream-sources/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk/)via [Cloud Mode ](https://rudderstack.com/docs/rudderstack-cloud/rudderstack-connection-modes/#cloud-mode))
* [Mixpanel](https://rudderstack.com/docs/destinations/analytics/mixpanel/)

## Sample payload

A sample payload of an `alias` call with most of the [**Common Fields**](https://rudderstack.com/docs/rudderstack-api/api-specification/rudderstack-spec/common-fields/) removed is shown below:

```javascript
{
  "type": "alias",
  "previousId": "name@surname.com",
  "userId": "12345"
}
```

The corresponding event that generates the above payload via the [**JavaScript SDK**](https://rudderstack.com/docs/stream-sources/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk/) is as shown:

```javascript
rudderanalytics.alias("12345")
```

The RudderStack SDK automatically passes the user's `anonymousId` as `previousId` in the payload, as seen above.

When instrumenting a website with the JavaScript SDK, making the `alias` call via the client-side is important as the `anonymousId` is generated via the browser. Similarly, if you're using a server-side SDK, the `alias` call must be made from the server-side as the session ID is set as the `anonymousId`.

## Alias fields

In addition to the [**Common Fields**](https://rudderstack.com/docs/rudderstack-api/api-specification/rudderstack-spec/common-fields/), the `alias` call accepts the following fields:

| **Field**    | **Type** | **Presence**                               | **Description**                                                                             |
| ------------ | -------- | ------------------------------------------ | ------------------------------------------------------------------------------------------- |
| `userId`     | Object   | Optional (if `anonymousId` is already set) | The user's identifier in your database. Either `userId` or `anonymousId` should be present. |
| `previousId` | String   | Required                                   | The user's previous identifier.                                                             |

## `userId` vs `previousId`

* The `previousId` attribute refers to the previous user identifier. It could be either:
  * An `anonymousId` assigned to the user (by the browser if the user is a new visitor or has not logged in yet, or the session ID if you're using a server-side SDK).
  * A previously set `userId` to identify the user via the `identify` call.
* The `userId` is the user's new identity or an existing identity that you want to merge with `previousId`.

## Contact us

For more information on any section covered in this doc, you can [**contact us**](mailto:%20docs@rudderstack.com) or start a conversation in our [**Slack**](https://rudderstack.com/join-rudderstack-slack-community) community.
