cURL
curl --request POST \
--url https://api.onesignal.com/apps/{app_id}/users \
--header 'Content-Type: application/json' \
--data '
{
"properties": {
"tags": {},
"language": "en",
"timezone_id": "America/Los_Angeles",
"lat": 123,
"long": 123,
"country": "US",
"first_active": 123,
"last_active": 123,
"ip": "<string>",
"test_user_name": "<string>"
},
"identity": {
"external_id": "<string>"
},
"subscriptions": [
{
"token": "<string>",
"enabled": true,
"notification_types": 123,
"session_time": 123,
"session_count": 123,
"app_version": "<string>",
"device_model": "<string>",
"device_os": "<string>",
"test_type": 123,
"sdk": "<string>",
"web_auth": "<string>",
"web_p256": "<string>"
}
]
}
'import Onesignal from '@onesignal/node-onesignal';
const configuration = Onesignal.createConfiguration({
restApiKey: 'YOUR_REST_API_KEY',
});
const apiInstance = new Onesignal.DefaultApi(configuration);
// string
const appId: string = "00000000-0000-0000-0000-000000000000";
// User
const user: Onesignal.User = {
properties: {
tags: {},
language: "language_example",
timezone_id: "timezone_id_example",
lat: 3.14,
long: 3.14,
country: "country_example",
first_active: 1,
last_active: 1,
amount_spent: 3.14,
purchases: [
{
sku: "sku_example",
amount: "amount_example",
iso: "iso_example",
count: 1,
},
],
ip: "ip_example",
},
identity: {
"key": "key_example",
},
subscriptions: [
{
id: "id_example",
type: "iOSPush",
token: "token_example",
enabled: true,
notification_types: 1,
session_time: 1,
session_count: 1,
sdk: "sdk_example",
device_model: "device_model_example",
device_os: "device_os_example",
rooted: true,
test_type: 1,
app_version: "app_version_example",
net_type: 1,
carrier: "carrier_example",
web_auth: "web_auth_example",
web_p256: "web_p256_example",
},
],
};
try {
const response = await apiInstance.createUser(appId, user);
console.log(response);
} catch (e) {
if (e instanceof Onesignal.ApiException) {
// `e.errorMessages` flattens any error-envelope shape to a `string[]`;
// the raw parsed body remains on `e.body`.
console.error("createUser failed: HTTP " + e.code, e.errorMessages);
} else {
throw e;
}
}import onesignal
from onesignal.api import default_api
from onesignal.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
# Some of the OneSignal endpoints require ORGANIZATION_API_KEY token for authorization, while others require REST_API_KEY.
# We recommend adding both of them in the configuration page so that you will not need to figure it out yourself.
configuration = onesignal.Configuration(
rest_api_key = "YOUR_REST_API_KEY", # App REST API key required for most endpoints
organization_api_key = "YOUR_ORGANIZATION_API_KEY" # Organization key is only required for creating new apps and other top-level endpoints
)
# Enter a context with an instance of the API client
with onesignal.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = default_api.DefaultApi(api_client)
app_id = "00000000-0000-0000-0000-000000000000"
user = User(
properties=PropertiesObject(
tags={},
language="language_example",
timezone_id="timezone_id_example",
lat=3.14,
long=3.14,
country="country_example",
first_active=1,
last_active=1,
amount_spent=3.14,
purchases=[
Purchase(
sku="sku_example",
amount="amount_example",
iso="iso_example",
count=1,
),
],
ip="ip_example",
),
identity=IdentityObject(
key="key_example",
),
subscriptions=[
Subscription(
id="id_example",
type="iOSPush",
token="token_example",
enabled=True,
notification_types=1,
session_time=1,
session_count=1,
sdk="sdk_example",
device_model="device_model_example",
device_os="device_os_example",
rooted=True,
test_type=1,
app_version="app_version_example",
net_type=1,
carrier="carrier_example",
web_auth="web_auth_example",
web_p256="web_p256_example",
),
],
)
try:
api_response = api_instance.create_user(app_id, user)
pprint(api_response)
except onesignal.ApiException as e:
print("Exception when calling DefaultApi->create_user: %s\n" % e)
print("Status Code: %s" % e.status)
print("Response Body: %s" % e.body)<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Bearer authorization: rest_api_key
$config = onesignal\client\Configuration::getDefaultConfiguration()
->setRestApiKeyToken('YOUR_REST_API_KEY')
->setOrganizationApiKeyToken('YOUR_ORGANIZATION_API_KEY');
$apiInstance = new onesignal\client\Api\DefaultApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$app_id = '00000000-0000-0000-0000-000000000000'; // string
$user = new \onesignal\client\model\User(); // \onesignal\client\model\User
try {
$result = $apiInstance->createUser($app_id, $user);
print_r($result);
} catch (\onesignal\client\ApiException $e) {
echo 'Exception when calling DefaultApi->createUser: ', $e->getMessage(), PHP_EOL;
echo 'Status Code: ', $e->getCode(), PHP_EOL;
// getErrorMessages() flattens any error-envelope shape to a string[];
// the raw body remains on getResponseBody().
echo 'Error Messages: ', implode(', ', $e->getErrorMessages()), PHP_EOL;
echo 'Response Body: ', $e->getResponseBody(), PHP_EOL;
} catch (\Exception $e) {
echo 'Exception when calling DefaultApi->createUser: ', $e->getMessage(), PHP_EOL;
}package main
import (
"context"
"fmt"
"os"
"github.com/OneSignal/onesignal-go-api/v5"
)
func main() {
appId := "00000000-0000-0000-0000-000000000000" // string |
user := *onesignal.NewUser() // User |
configuration := onesignal.NewConfiguration()
apiClient := onesignal.NewAPIClient(configuration)
restAuth := context.WithValue(context.Background(), onesignal.RestApiKey, "YOUR_REST_API_KEY") // App REST API key required for most endpoints
resp, r, err := apiClient.DefaultApi.CreateUser(restAuth, appId).User(user).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.CreateUser``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
if apiErr, ok := err.(*onesignal.GenericOpenAPIError); ok {
// ErrorMessages() flattens any error-envelope shape to a []string;
// the raw body remains on Body().
fmt.Fprintf(os.Stderr, "Error Messages: %v\n", apiErr.ErrorMessages())
fmt.Fprintf(os.Stderr, "Response Body: %s\n", apiErr.Body())
}
}
// response from `CreateUser`: User
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.CreateUser`: %v\n", resp)
}require 'onesignal'
# setup authorization
OneSignal.configure do |config|
# Configure Bearer authorization: rest_api_key
config.rest_api_key = 'YOUR_REST_API_KEY'
end
api_instance = OneSignal::DefaultApi.new
app_id = '00000000-0000-0000-0000-000000000000' # String |
user = OneSignal::User.new # User |
begin
result = api_instance.create_user(app_id, user)
p result
rescue OneSignal::ApiError => e
puts "Error when calling DefaultApi->create_user: #{e}"
puts "Status Code: #{e.code}"
# `e.error_messages` flattens any error-envelope shape to an Array<String>;
# the raw body remains on `e.response_body`.
puts "Error Messages: #{e.error_messages}"
puts "Response Body: #{e.response_body}"
end// Import classes:
import com.onesignal.client.ApiClient;
import com.onesignal.client.ApiException;
import com.onesignal.client.Configuration;
import com.onesignal.client.auth.*;
import com.onesignal.client.model.*;
import com.onesignal.client.api.DefaultApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.onesignal.com");
// Configure HTTP bearer authorization: rest_api_key
HttpBearerAuth rest_api_key = (HttpBearerAuth) defaultClient.getAuthentication("rest_api_key");
rest_api_key.setBearerToken("YOUR_REST_API_KEY");
DefaultApi apiInstance = new DefaultApi(defaultClient);
String appId = "00000000-0000-0000-0000-000000000000"; // String |
User user = new User(); // User |
try {
User result = apiInstance.createUser(appId, user);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#createUser");
System.err.println("Status code: " + e.getCode());
// getErrorMessages() flattens any error-envelope shape to a List<String>;
// the raw body remains on getResponseBody().
System.err.println("Error messages: " + e.getErrorMessages());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}using System;
using System.Collections.Generic;
using System.Diagnostics;
using OneSignalApi.Api;
using OneSignalApi.Client;
using OneSignalApi.Model;
namespace Example
{
public class CreateUserExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.onesignal.com";
// Configure Bearer token for authorization: rest_api_key
config.AccessToken = "YOUR_REST_API_KEY";
var apiInstance = new DefaultApi(config);
var appId = "00000000-0000-0000-0000-000000000000"; // string |
var user = new User(); // User |
try
{
User result = apiInstance.CreateUser(appId, user);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling DefaultApi.CreateUser: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
// e.ErrorMessages flattens any error-envelope shape to an IReadOnlyList<string>;
// the raw body remains on e.ErrorContent.
Debug.Print("Error Messages: " + string.Join(", ", e.ErrorMessages));
Debug.Print("Response Body: " + e.ErrorContent);
Debug.Print(e.StackTrace);
}
}
}
}use onesignal_rust_api::apis::configuration::Configuration;
use onesignal_rust_api::apis::default_api;
use onesignal_rust_api::models;
#[tokio::main]
async fn main() {
let mut configuration = Configuration::new();
configuration.rest_api_key_token = Some("YOUR_REST_API_KEY".to_string());
// Realistic values are pulled from the spec's `example:` fields where present.
let app_id: &str = "00000000-0000-0000-0000-000000000000";
let user: models::User = todo!();
match default_api::create_user(&configuration, app_id, user).await {
Ok(resp) => println!("{:?}", resp),
Err(e @ onesignal_rust_api::apis::Error::ResponseError(_)) => {
// `e.error_messages()` flattens any error-envelope shape to a Vec<String>;
// the raw response remains on the ResponseError variant.
eprintln!("create_user failed: {:?}", e.error_messages());
}
Err(e) => eprintln!("create_user failed: {:?}", e),
}
}{
"identity": {
"onesignal_id": "567491ee-9105-4a87-9cbc-ed78a571645b"
},
"properties": {
"tags": {
"first_name": "John",
"last_name": "Smith"
}
}
}{
"identity": {
"onesignal_id": "567491ee-9105-4a87-9cbc-ed78a571645b",
"external_id": "test_external_id-101101"
},
"subscriptions": [
{
"id": "f67491ee-9105-4a87-9cbc-ed78a571645b",
"app_id": "a67491ee-9105-4a87-9cbc-ed78a571645b",
"token": "joe@example.com",
"type": "email"
}
],
"properties": {
"tags": {
"color": "red"
}
}
}{
"errors": [
{
"code": "internal error code",
"title": "example error title",
"meta": {}
}
]
}{
"errors": [
{
"code": "internal error code",
"title": "example error title",
"meta": {}
}
]
}{
"errors": [
{
"code": "Rate Limit Exceeded",
"title": "API rate limit exceeded"
}
]
}{
"errors": [
"Service temporarily unavailable"
]
}Create user
Create a new user or modify the subscriptions associated with an existing User.
POST
/
apps
/
{app_id}
/
users
cURL
curl --request POST \
--url https://api.onesignal.com/apps/{app_id}/users \
--header 'Content-Type: application/json' \
--data '
{
"properties": {
"tags": {},
"language": "en",
"timezone_id": "America/Los_Angeles",
"lat": 123,
"long": 123,
"country": "US",
"first_active": 123,
"last_active": 123,
"ip": "<string>",
"test_user_name": "<string>"
},
"identity": {
"external_id": "<string>"
},
"subscriptions": [
{
"token": "<string>",
"enabled": true,
"notification_types": 123,
"session_time": 123,
"session_count": 123,
"app_version": "<string>",
"device_model": "<string>",
"device_os": "<string>",
"test_type": 123,
"sdk": "<string>",
"web_auth": "<string>",
"web_p256": "<string>"
}
]
}
'import Onesignal from '@onesignal/node-onesignal';
const configuration = Onesignal.createConfiguration({
restApiKey: 'YOUR_REST_API_KEY',
});
const apiInstance = new Onesignal.DefaultApi(configuration);
// string
const appId: string = "00000000-0000-0000-0000-000000000000";
// User
const user: Onesignal.User = {
properties: {
tags: {},
language: "language_example",
timezone_id: "timezone_id_example",
lat: 3.14,
long: 3.14,
country: "country_example",
first_active: 1,
last_active: 1,
amount_spent: 3.14,
purchases: [
{
sku: "sku_example",
amount: "amount_example",
iso: "iso_example",
count: 1,
},
],
ip: "ip_example",
},
identity: {
"key": "key_example",
},
subscriptions: [
{
id: "id_example",
type: "iOSPush",
token: "token_example",
enabled: true,
notification_types: 1,
session_time: 1,
session_count: 1,
sdk: "sdk_example",
device_model: "device_model_example",
device_os: "device_os_example",
rooted: true,
test_type: 1,
app_version: "app_version_example",
net_type: 1,
carrier: "carrier_example",
web_auth: "web_auth_example",
web_p256: "web_p256_example",
},
],
};
try {
const response = await apiInstance.createUser(appId, user);
console.log(response);
} catch (e) {
if (e instanceof Onesignal.ApiException) {
// `e.errorMessages` flattens any error-envelope shape to a `string[]`;
// the raw parsed body remains on `e.body`.
console.error("createUser failed: HTTP " + e.code, e.errorMessages);
} else {
throw e;
}
}import onesignal
from onesignal.api import default_api
from onesignal.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
# Some of the OneSignal endpoints require ORGANIZATION_API_KEY token for authorization, while others require REST_API_KEY.
# We recommend adding both of them in the configuration page so that you will not need to figure it out yourself.
configuration = onesignal.Configuration(
rest_api_key = "YOUR_REST_API_KEY", # App REST API key required for most endpoints
organization_api_key = "YOUR_ORGANIZATION_API_KEY" # Organization key is only required for creating new apps and other top-level endpoints
)
# Enter a context with an instance of the API client
with onesignal.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = default_api.DefaultApi(api_client)
app_id = "00000000-0000-0000-0000-000000000000"
user = User(
properties=PropertiesObject(
tags={},
language="language_example",
timezone_id="timezone_id_example",
lat=3.14,
long=3.14,
country="country_example",
first_active=1,
last_active=1,
amount_spent=3.14,
purchases=[
Purchase(
sku="sku_example",
amount="amount_example",
iso="iso_example",
count=1,
),
],
ip="ip_example",
),
identity=IdentityObject(
key="key_example",
),
subscriptions=[
Subscription(
id="id_example",
type="iOSPush",
token="token_example",
enabled=True,
notification_types=1,
session_time=1,
session_count=1,
sdk="sdk_example",
device_model="device_model_example",
device_os="device_os_example",
rooted=True,
test_type=1,
app_version="app_version_example",
net_type=1,
carrier="carrier_example",
web_auth="web_auth_example",
web_p256="web_p256_example",
),
],
)
try:
api_response = api_instance.create_user(app_id, user)
pprint(api_response)
except onesignal.ApiException as e:
print("Exception when calling DefaultApi->create_user: %s\n" % e)
print("Status Code: %s" % e.status)
print("Response Body: %s" % e.body)<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Bearer authorization: rest_api_key
$config = onesignal\client\Configuration::getDefaultConfiguration()
->setRestApiKeyToken('YOUR_REST_API_KEY')
->setOrganizationApiKeyToken('YOUR_ORGANIZATION_API_KEY');
$apiInstance = new onesignal\client\Api\DefaultApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$app_id = '00000000-0000-0000-0000-000000000000'; // string
$user = new \onesignal\client\model\User(); // \onesignal\client\model\User
try {
$result = $apiInstance->createUser($app_id, $user);
print_r($result);
} catch (\onesignal\client\ApiException $e) {
echo 'Exception when calling DefaultApi->createUser: ', $e->getMessage(), PHP_EOL;
echo 'Status Code: ', $e->getCode(), PHP_EOL;
// getErrorMessages() flattens any error-envelope shape to a string[];
// the raw body remains on getResponseBody().
echo 'Error Messages: ', implode(', ', $e->getErrorMessages()), PHP_EOL;
echo 'Response Body: ', $e->getResponseBody(), PHP_EOL;
} catch (\Exception $e) {
echo 'Exception when calling DefaultApi->createUser: ', $e->getMessage(), PHP_EOL;
}package main
import (
"context"
"fmt"
"os"
"github.com/OneSignal/onesignal-go-api/v5"
)
func main() {
appId := "00000000-0000-0000-0000-000000000000" // string |
user := *onesignal.NewUser() // User |
configuration := onesignal.NewConfiguration()
apiClient := onesignal.NewAPIClient(configuration)
restAuth := context.WithValue(context.Background(), onesignal.RestApiKey, "YOUR_REST_API_KEY") // App REST API key required for most endpoints
resp, r, err := apiClient.DefaultApi.CreateUser(restAuth, appId).User(user).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.CreateUser``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
if apiErr, ok := err.(*onesignal.GenericOpenAPIError); ok {
// ErrorMessages() flattens any error-envelope shape to a []string;
// the raw body remains on Body().
fmt.Fprintf(os.Stderr, "Error Messages: %v\n", apiErr.ErrorMessages())
fmt.Fprintf(os.Stderr, "Response Body: %s\n", apiErr.Body())
}
}
// response from `CreateUser`: User
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.CreateUser`: %v\n", resp)
}require 'onesignal'
# setup authorization
OneSignal.configure do |config|
# Configure Bearer authorization: rest_api_key
config.rest_api_key = 'YOUR_REST_API_KEY'
end
api_instance = OneSignal::DefaultApi.new
app_id = '00000000-0000-0000-0000-000000000000' # String |
user = OneSignal::User.new # User |
begin
result = api_instance.create_user(app_id, user)
p result
rescue OneSignal::ApiError => e
puts "Error when calling DefaultApi->create_user: #{e}"
puts "Status Code: #{e.code}"
# `e.error_messages` flattens any error-envelope shape to an Array<String>;
# the raw body remains on `e.response_body`.
puts "Error Messages: #{e.error_messages}"
puts "Response Body: #{e.response_body}"
end// Import classes:
import com.onesignal.client.ApiClient;
import com.onesignal.client.ApiException;
import com.onesignal.client.Configuration;
import com.onesignal.client.auth.*;
import com.onesignal.client.model.*;
import com.onesignal.client.api.DefaultApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.onesignal.com");
// Configure HTTP bearer authorization: rest_api_key
HttpBearerAuth rest_api_key = (HttpBearerAuth) defaultClient.getAuthentication("rest_api_key");
rest_api_key.setBearerToken("YOUR_REST_API_KEY");
DefaultApi apiInstance = new DefaultApi(defaultClient);
String appId = "00000000-0000-0000-0000-000000000000"; // String |
User user = new User(); // User |
try {
User result = apiInstance.createUser(appId, user);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#createUser");
System.err.println("Status code: " + e.getCode());
// getErrorMessages() flattens any error-envelope shape to a List<String>;
// the raw body remains on getResponseBody().
System.err.println("Error messages: " + e.getErrorMessages());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}using System;
using System.Collections.Generic;
using System.Diagnostics;
using OneSignalApi.Api;
using OneSignalApi.Client;
using OneSignalApi.Model;
namespace Example
{
public class CreateUserExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.onesignal.com";
// Configure Bearer token for authorization: rest_api_key
config.AccessToken = "YOUR_REST_API_KEY";
var apiInstance = new DefaultApi(config);
var appId = "00000000-0000-0000-0000-000000000000"; // string |
var user = new User(); // User |
try
{
User result = apiInstance.CreateUser(appId, user);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling DefaultApi.CreateUser: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
// e.ErrorMessages flattens any error-envelope shape to an IReadOnlyList<string>;
// the raw body remains on e.ErrorContent.
Debug.Print("Error Messages: " + string.Join(", ", e.ErrorMessages));
Debug.Print("Response Body: " + e.ErrorContent);
Debug.Print(e.StackTrace);
}
}
}
}use onesignal_rust_api::apis::configuration::Configuration;
use onesignal_rust_api::apis::default_api;
use onesignal_rust_api::models;
#[tokio::main]
async fn main() {
let mut configuration = Configuration::new();
configuration.rest_api_key_token = Some("YOUR_REST_API_KEY".to_string());
// Realistic values are pulled from the spec's `example:` fields where present.
let app_id: &str = "00000000-0000-0000-0000-000000000000";
let user: models::User = todo!();
match default_api::create_user(&configuration, app_id, user).await {
Ok(resp) => println!("{:?}", resp),
Err(e @ onesignal_rust_api::apis::Error::ResponseError(_)) => {
// `e.error_messages()` flattens any error-envelope shape to a Vec<String>;
// the raw response remains on the ResponseError variant.
eprintln!("create_user failed: {:?}", e.error_messages());
}
Err(e) => eprintln!("create_user failed: {:?}", e),
}
}{
"identity": {
"onesignal_id": "567491ee-9105-4a87-9cbc-ed78a571645b"
},
"properties": {
"tags": {
"first_name": "John",
"last_name": "Smith"
}
}
}{
"identity": {
"onesignal_id": "567491ee-9105-4a87-9cbc-ed78a571645b",
"external_id": "test_external_id-101101"
},
"subscriptions": [
{
"id": "f67491ee-9105-4a87-9cbc-ed78a571645b",
"app_id": "a67491ee-9105-4a87-9cbc-ed78a571645b",
"token": "joe@example.com",
"type": "email"
}
],
"properties": {
"tags": {
"color": "red"
}
}
}{
"errors": [
{
"code": "internal error code",
"title": "example error title",
"meta": {}
}
]
}{
"errors": [
{
"code": "internal error code",
"title": "example error title",
"meta": {}
}
]
}{
"errors": [
{
"code": "Rate Limit Exceeded",
"title": "API rate limit exceeded"
}
]
}{
"errors": [
"Service temporarily unavailable"
]
}If you are still using pre-User Model APIs or SDKs (Mobile SDKs version 4 or
lower, Web SDKs version 15 or lower), we recommend thorough testing of this
endpoint before switching to the new User Model. Discrepancies may occur where
the External ID set through the SDK and the External ID set through the API do
not generate matching OneSignal IDs. To ensure a smooth transition, consider
the following options:
- Update to the User Model SDKs: Upgrade to the latest User Model SDKs (Mobile SDK 5+, Web SDK 16+). For more details, refer to the User Model Migration Guide.
- Continue Using Pre-User Model APIs: If you are not ready to migrate, continue using the existing APIs for Adding a Device, Editing Tags with External User ID, and Editing a Device until the SDK migration is complete.
Overview
This endpoint enables you to create and manage users outside of frontendSDK-based sessions. It’s primarily used to:- Import users from other systems.
- Programmatically define users by assigning identifiers (aliases), properties (e.g., tags), and messaging subscriptions (e.g., email, mobile, SMS).
login, addEmail, and addSms. See Users and Subscriptions for conceptual guidance.
How to use this API
To successfully create a user via the API:- You must provide at least one of
identityorsubscriptions. - To create a user without subscriptions, provide at least one unique identifier via the
identityfield (such as anexternal_id). The user is created with zero subscriptions and can be updated, targeted, and connected to subscriptions later. See User lifecycle. - You can optionally include user profile data (
properties).
Key Concepts
Aliases
Aliases uniquely identify a user and should include anexternal_id (the recommended identifier). They allow you to reference users across platforms or external systems. Up to 10 custom aliases are supported. Each alias key and value has a maximum length of 128 characters.
Properties
User properties store information such as tags, location, activity, and device data. These attributes help you personalize campaigns and optimize engagement strategies.Subscriptions
A user can have up to 20 subscriptions (across email, SMS, push, etc.). Subscriptions connect users to channels for message delivery and are transferable across users. See Subscriptions for more.Path Parameters
Your OneSignal App ID in UUID v4 format. See Keys & IDs.
Body
application/json
Represents user profile data for a given user, including tags, preferences, user activity, and other valuable properties.
Show child attributes
Show child attributes
Defines identifiers for the user. The external_id must be used and should be unique across users.
Show child attributes
Show child attributes
The subscriptions object allows for creating or transferring subscriptions to a specified user. See Subscriptions.
Show child attributes
Show child attributes
Was this page helpful?
⌘I