Skip to main content
PATCH
cURL

Overview

Add or update aliases on a user by providing one alias that already exists within OneSignal. An alias is a key : value pair: the key is the alias_label such as external_id or a custom label like crm_user_id, and the value is that user’s ID in your own system. This endpoint updates the identity object only. It does not create users, and it does not modify Subscriptions, Tags, or other user properties. The onesignal_id is read-only. To create a user with Subscriptions and properties, use the Create user API instead.
Sending an alias_label the user already has replaces that label’s value. Sending an alias_label the user does not have adds a new alias, and aliases you leave out of the request stay unchanged. A label and value pair can belong to only one user in the app, so claiming a pair that another user already holds fails with 409 Conflict.

How to use this API

Identify the user with two path parameters:
  • alias_label: the type of alias you know, for example external_id, onesignal_id, or a custom alias label.
  • alias_id: the value of that alias.
The path identifies the user that exists within OneSignal. The request body sets the new aliases you want to add or update. Inside the identity object, each key is an alias label and each value is that user’s ID for the label:
That request sets two aliases on the user you named in the path. Changes take effect immediately.
Set the external_id before you add custom aliases. The external_id is what links a user’s push, email, and SMS Subscriptions into one user record. Your frontend SDK sets it through the login method when a user signs in.
If you only know a Subscription ID and no alias, use the Create alias (by subscription) API instead.

Alias conflicts

A conflict depends on who owns an alias, not on whether the alias already exists. Labels themselves are shared: every user in the app can have an external_id. What must be unique is the label and value pair, and that pair identifies exactly one user:
  • The user in the path already has the label. OneSignal updates the value. Changing crm_user_id from 111 to 222 on that user succeeds.
  • A different user already holds that label and value. The request fails with 409 Conflict and nothing on either user changes. Sending crm_user_id: 222 fails when another user already has crm_user_id: 222.
This endpoint never moves an alias between users and never merges the two records. A conflict returns error code user-2 with the title One or more Aliases claimed by another User. Each conflicting label appears in errors[].meta, mapped to the alias ID another user already holds:
A 409 usually means the target user already exists. To attach the current Subscription to that existing user, use the Transfer Subscription API rather than retrying this endpoint.

Limits

Each user supports one external_id plus up to 10 custom aliases. Alias keys (alias_label) and values (alias_id) are each limited to 128 characters.

FAQ

What happens if I add a custom alias to a user with no External ID?

The alias attaches to a single user record instead of to the person, and you cannot fix it afterward by repeating the call. Without an external_id, OneSignal treats each Subscription as its own user with its own onesignal_id, so one person’s web, mobile, email, and SMS Subscriptions are four separate records. Adding a custom alias to one record does not reach the other three, and adding the same alias value to a second record returns 409 Conflict because that value already identifies the first. Set the external_id through your SDK’s login method before you add custom aliases. See Users and Aliases for details.

What happens if the alias label already exists?

It depends on which user owns it, not on the fact that it exists. If the user you identified in the path already has that label, OneSignal updates its value, and aliases you do not include in the request are left unchanged. If the alias value belongs to a different user, the request fails with 409 Conflict and nothing changes. See Alias conflicts.

How do I attach a Subscription to a user that already owns the alias?

Use the Transfer Subscription API, which reassigns a Subscription to a different user in the same app. This endpoint cannot do it, because claiming an alias that another user already owns returns 409 Conflict. Transfer Subscription needs the subscription_id and exactly one alias identifying the target user.

Can I set the onesignal_id with this API?

No. OneSignal generates the onesignal_id when the user record is created, and it is read-only. You can use it as the alias_label to identify the user, but you cannot assign or change its value.

How do I remove an alias?

Use the Delete alias API. The onesignal_id cannot be removed.

Users

How OneSignal ID and External ID identify a user across devices.

Aliases

Set and manage custom aliases with the SDK or the REST API.

Create user

Create a user with Subscriptions and properties, not just aliases.

Delete alias

Remove a single alias without deleting the user.

Transfer Subscription

Move a Subscription to a user that already owns the alias.

Headers

Authorization
string
default:Key YOUR_APP_API_KEY
required

Your App API key with prefix Key. See Keys & IDs.

Path Parameters

app_id
string
required

Your OneSignal App ID in UUID v4 format. See Keys & IDs.

alias_label
string
required

The alias name or key to locate the user. Most commonly set as external_id but can be the onesignal_id or a custom alias.

alias_id
string
required

The specific identifier for the given alias to identify the user.

Body

application/json
identity
object

One or more aliases to be created for this user.

Response

200

identity
object