cURL
Create or update alias
Add or update aliases on an existing user when you already know one of that user’s aliases, such as an external_id, onesignal_id, or custom alias. Updates the identity object only.
PATCH
cURL
Overview
Add or update aliases on a user by providing one alias that already exists within OneSignal. An alias is akey : 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 exampleexternal_id,onesignal_id, or a custom alias label.alias_id: the value of that alias.
identity object, each key is an alias label and each value is that user’s ID for the label:
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 anexternal_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_idfrom111to222on that user succeeds. - A different user already holds that label and value. The request fails with
409 Conflictand nothing on either user changes. Sendingcrm_user_id: 222fails when another user already hascrm_user_id: 222.
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:
Limits
Each user supports oneexternal_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 anexternal_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 with409 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 returns409 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. Theonesignal_id cannot be removed.
Related pages
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
Your App API key with prefix Key. See Keys & IDs.
Path Parameters
Your OneSignal App ID in UUID v4 format. See Keys & IDs.
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.
The specific identifier for the given alias to identify the user.
Body
application/json
One or more aliases to be created for this user.
Response
200