Use the Identify API to set the User ID for a particular Device ID or update user properties of a particular user without sending an event. You can change Amplitude default user properties and custom user properties that you have defined.
This API uses your API key passed in the body of the request:
api-key=API_KEY
For more information, see Find your API Credentials
Region | Endpoint |
---|---|
Standard server | https://api2.amplitude.com/identify |
EU residency server | https://api.eu.amplitude.com/identify |
device_ids
or user_ids
that exceed a certain threshold of events per second. When Amplitude throttles a request, the request returns a HTTP status code 429. Pause sending events for any devices in that request for 15 seconds before retrying. Continue retrying until you no longer receive status code 429. If the same user_id
is sending events from multiple devices simultaneously, then all the devices would be throttled.YYYY-MM-DDTHH:mm:ss
). This lets you perform date comparisons in the web app. For example, '2016-01-31' > '2016-01-01'). This also applies to datetime values like '2017-08-07T10:09:08' > '2017-08-07T01:07:00'.user_id
field from an existing value, then Amplitude creates a new user. Amplitude doesn't create a new Amplitude user if the current value of user_id
is null.POST https://api2.amplitude.com/identify
1curl --location --request POST 'https://api2.amplitude.com/identify' \2--header 'Content-Type: application/x-www-form-urlencoded' \3--data-urlencode 'api_key=<API-KEY>' \4--data-urlencode 'identification=[{"user_id":"value", "user_properties":{"propertyNameToUpdate":"newValue"}}]'
You can send these parameters as query parameter in a GET request. In a POST request, send them as body parameters. The body must be form-data
or x-www-form-urlencoded
.
Name |
Description |
---|---|
api_key |
Your project API key. |
identification |
Either a single JSON identification object or an array of JSON objects, each of which represents one identification. |
Name |
Type | Description |
---|---|---|
user_id |
Required unless device_id is present. String. A UUID (unique user ID) specified by you. If you send a request with a user_id that's not in the Amplitude system yet, then the user tied to the user_id isn't marked new until their first event. |
|
device_id |
Required unless user_id is present. String. A device specific identifier, such as the Identifier for Vendor (IDFV) on iOS. |
|
user_properties |
Optional. Dictionary. A dictionary of key-value pairs that represent data tied to the user. Each distinct value appears as a user segment on the Amplitude dashboard. Object depth may not exceed 40 layers. You can store property values in an array and date values are transformed into string values. | |
groups |
Optional. Dictionary. This feature is only available to Enterprise customers who have purchased the Accounts add-on. A dictionary of key-value pairs that represent groups of users. Setting groups allows you to use account-level reporting. You can track up to 5 unique group types and 10 total groups. | |
app_version |
Optional. String. The version of the app the user is on. | |
platform |
Optional. String. The platform that's sending the data. | |
os_name |
Optional. String. The mobile operating system or browser the user is on. | |
os_version |
Optional. String. The version of the mobile operating system or browser the user is on. | |
device_brand |
Optional. String. The device brand the user is on. | |
device_manufacturer |
Optional. String. The device manufacturer of the device that the user is on. | |
device_model |
Optional. String. The device model the user is on. | |
carrier |
Optional. String. The carrier the user has. | |
country |
Optional. String. The country that the user is in. | |
region |
Optional. String. The geographical region the user is in. | |
city |
Optional. String. The city the user is in. | |
dma |
Optional. String. The Designated Market Area of the user. | |
language |
Optional. String. The language the user has set. | |
paying |
Optional. String. Whether the user is paying. | |
start_version |
Optional. String. The version of the app the user was on first. |
The user_properties
field supports these operations:
Name |
Description |
---|---|
$set |
Sets the value of a property. |
$setOnce |
Set the value only if the value hasn't already been set. |
$add |
Adds a numeric value to a numeric property. |
$append and $prepend |
Appends and prepends the value to a user property array. |
$unset |
Removes a property |
$preInsert |
Adds the specified values to the beginning of the list of properties for the user property if the values don't already exist in the list. Can give a single value or an array of values. If a list is sent, the order of the list is maintained. |
$postInsert |
Adds the specified values to the end of the list of properties for the user property if the values don't already exist in the list. Can give a single value or an array of values. If a list is sent, the order of the list is maintained. |
$remove |
Removes all instances of the values specified from the list. Can give a single value or an array of values. These should be keys in the dictionary where the values are the corresponding properties that you want to operate on. |
You can't mix user property operations with actual top-level user properties. Instead, include them inside the $set
operation. If you are using one of these operators then this dictionary can contain only user property operations and you can't combine it with the above format. For example. you can't do {"$append":{"interests":"Music"}, "subscription type":"paid"}
in the same request.
Instead, do this:
1{ 2 "$set": { 3 "cohort": "Test A" 4 }, 5 "$setOnce": { 6 "startDate": "2015-10-01" 7 }, 8 "$add": { 9 "friendCount": 310 },11 "$append": {12 "interests": "Music"13 },14 "$prepend": {15 "sports": "Tennis"16 },17 "$unset": {18 "oldProperty": "-"19 }20}
Code | Message |
---|---|
200 | Success |
400 | Bad Request. If you get a missing_event message, it means the identification parameter is missing or incorrectly formatted. |
414 | You might be using GET, which has a URL character limit. Use POST instead of GET so the data isn't passed in the URL. |
429 | Amplitude throttles requests for device_ids or user_ids that exceed a certain threshold of events per second, and returns a 429 code. |
Thanks for your feedback!
May 21st, 2024
Need help? Contact Support
Visit Amplitude.com
Have a look at the Amplitude Blog
Learn more at Amplitude Academy
© 2024 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.