
Amplitude API Integration Profile
Information and guides about integrating with Amplitude API
Add Amplitude Integration to Your Product- iOS Attribution
Required Event Argument Keys
You must include the following keys within the event argument:
Required Key Description Example event_type
String. Prefix with brackets "[YOUR COMPANY]". "[YOUR COMPANY] Install" platform
String. Either "ios" or "android". "ios" idfa
oridfv
Required for iOS. String. The Identifier for Advertiser or the Identifier for Vendor. AEBE52E7-03EE-455A-B3C4-E57283966239 adid
Required for Android. String. The Google AdID, or Amazon Advertising ID for Amazon devices. AEBE52E7-03EE-455A-B3C4-E57283966239 Note: For iOS devices, you can send either the IDFA or the IDFV but you must send at least one.
Optional Event Argument Keys
These optional keys are available.
Additional Key Type Description Example android_id
string (Android) The Android ID AEBE52E7-03EE-455A-B3C4-E57283966239 user_properties
dictionary A dictionary of attribution properties prefixed with brackets "[YOUR COMPANY]". {"[YOUR COMPANY] media source": "Facebook"} time
long Timestamp of the event in milliseconds since epoch. 1396381378123, will be set to the upload time by default - Batch Event Upload
Batch Event Upload
Use this request to bulk upload events to Amplitude.
If you have used our HTTP API before, note that there are two minor but important differences in your POST request to
/batch
.- Content-type must be
application/json
. - The key for the
events
payload isevents
plural, notevent
singular.
Properties
Name Type Required Restrictions Description api_key
string true none Amplitude project API key events
[Event] true none Array of Events to upload options
[options] false none Object Responses
Status Meaning Description 200 OK Successful batch upload. 400 Bad Request Invalid upload request. Read the error message to fix the request. 413 Payload Too Large Payload size is too big (request size exceeds 20MB). Split your events array payload in half and try again. 429 Too Many Requests Too many requests for a user or device. Amplitude throttles requests for users and devices that exceed 1000 events per second. Code 429 Explained
When a request is rejected with a 429 status, it means that a device or user in that request was throttled. Details about which can be found in the error response data. Logging the response lets you investigate which users or devices were the cause of throttling.
Because device_id and user_id are the attributes that determine throttling, partitioning work on one of these attributes will help isolate throttling to a specific partition of work. This way partitions which are not being throttled can still make progress while the throttled partitions are blocked by throttling.
EPDS and EPUS
Amplitude measures the rate of events for each deviceid and each userid for a project, and refer to those rates as events per device second (EPDS) and events per user second (EPUS) respectively. These values are both averaged over a period of 30 seconds.
For example, to reach an EPDS limit of 1000 requires that a device sends 30,000 events in a 30-second period for the device to be throttled and receive HTTP status 429.
In general, your app shouldn't measure EPDS or EPUS itself. Send requests to Amplitude as fast as possible. When you receive a 429, wait for a short period (for example, 15 seconds) before trying to send that request again.
Daily Limit
In addition to the per-second limit, there is daily limit to prevent against spam and abuse. This limit is rarely exceeded. Events starts counting toward the daily limit after Amplitude determines that a user/device is spamming the system. After the threshold is reached, a daily limit of 500,000 events uploaded per rolling 24 hours is enforced. The 24 hour rolling period applies in one-hour intervals. The daily limit applies for each deviceid and each user_id for a project.
The daily limit is independent of the EPDS/EPUS. Once a user or device has hit the 500,000 event daily limit for a particular project, any batches uploaded containing the user or device is rejected. In those cases, the request returns a 429 response with a body indicating “exceeded_daily_quota_users” or “exceeded_daily_quota_devices” with list of deviceIds and userIds. Retry the batch when there are less than 500,000 events uploaded for a user or device in the previous 24 hour period.
- Content-type must be
- Get all Cohorts
Get all discoverable cohorts for an app. The
id
returned for each cohort is used to get a single cohort.Each COHORT_OBJECT has this schema:
{ "lastComputed": timestamp, "owners": string[], "description": string, "definition": { COHORT_DEFINITION }, "published": boolean, "archived": boolean, "name": string, "appId": string, "lastMod": timestamp, "type": string, "id": string, "size": integer }
- Get a single Cohort
Get a discoverable cohort using its
cohort_id
.This is phase one in the download a cohort operation. The
request_id
returned in the response is used to poll export status. - Get Cohort Status
Poll the request status. This is the second phase in a cohort download operation.
- Cohort Download
For small cohorts, the response body contains cohort data.
For large cohorts, the data must be downloaded. If the cohort is large, the response redirects with a 302 response code to a pre-signed Amazon S3 download URL. The download URL is valid for one minute, and should be accessed immediately.
The API request link (https://amplitude.com/api/5/cohorts/request/
/file) is valid for seven days. During the seven days, you can make the same request repeatedly to get a new S3 download link. Each S3 link is valid only for one minute.Most clients used to send API requests automatically download the data from the S3 link. If your API client doesn't automatically download the cohort from the S3 link, you have one minute access it manually.
- Upload IDs
Generate a new cohort or update an existing cohort by uploading a set of User IDs or Amplitude IDs.
Body Parameters
Parameter Description name
Required. String. A name for the cohort. app_id
Required. Integer. An identifier for the Amplitude project containing the cohort. id_type
Required. String. The type of ID being sent in the ids field. Valid options are BY_AMP_ID
orBY_USER_ID
.ids
Required. String[]. One or more user or Amplitude IDs to include in the cohort. The type of the IDs should be specified in the id_type field. owner
Required. String. The login email of the cohort's owner in Amplitude. published
Required. Boolean. Whether the cohort is discoverable or hidden. existing_cohort_id
Optional. String. The id of an existing cohort. This will replace the contents for the specified cohort with the ids being uploaded by this request. e.g. '1a2bc3d' is your cohort's id, and it can be found in your cohort's URL. https//analytics.amplitude.com/demo/cohort/1a2bc3d - Update Membership
Perform incremental update (add / remove) to existing cohort membership.
Request Body
Parameter Description cohort_id
Required. String. The ID of an existing cohort. This will update the membership for the specified cohort with the IDs being uploaded in this request. count_group
Optional. String. The count group of the given IDs. This must be the same as the cohort’s existing count group. Count_group
defaults to User.memberships
Required. List of membership json An array of JSON objects identifying IDs to add or remove. skip_invalid_ids
Optional. Boolean. Setting this parameter to false
ends the request without updating cohort membership if the request contains invalid IDs. Settingskip_invalid_ids
totrue
skips invalid IDs while applying the remaining valid ids. Default istrue
.Request Membership JSON
Parameter Description ids
Required. String[]. List of IDs to add or remove. id_type
Required. String. The type of ID being sent in the ids
field. Valid options are: - BY_ID - BY_NAME For User count_group, BY_ID is amplitude ID and BY_NAME is user ID. For any other count_group, BY_ID is group ID and BY_NAME is group name.operation
Required. String. The operation to apply on ids
field. Valid options are:ADD
andREMOVE
Success Response Fields
Parameter Description cohort_id
String. The ID of an existing cohort that the membership information was updated for. memberships_result
List of memberships_result json. An array of JSON objects identifying result of membership update (add or remove) operation. Response
memberships_result
JSONParameter Description skipped_ids
List of strings. List of IDs that were skipped (fail, invalid, etc.) in this membership operation entry. id_type
String. The type of ID that was sent for the ids
field in this membership operation entry.operation
String. The operation that was applied on ids
field in this membership operation entryError Response Body
Response body (for non 200 response):
Parameter Type Description error
error json The detail information of the error Response error json:
Parameter Description message
String. Describes the error. code
Integer. Internal error code. metadata
JSON object. For bad request error (400) with invalid id while skip_invalid_ids=false
, this field contains thecohort_id
andmemberships_result
(list of membership JSON). Thememberships_result’
sskipped_ids
can help identify which IDs were invalid in which operation. For other errors, this field is not present. - Create Data Request
Create a request for user data.
Body Parameters
Name Description userId
Required if amplitudeID
is not set. The User Id of the user to request data for.amplitudeId
Required if userID
is not set. Integer. The Amplitude ID of the user to request data for.startDate
Required. Date. The start date for the data request. endDate
Required. Date. The end date for the data request. Response
When successful, the call returns a
requestID
, which is used to poll the job status. - Get Request Status
Retrieves a request's status.
Response Body
Name Description requestId
Integer. The ID of the request. userId
String. The User Id of the user to request data for. amplitudeId
Integer. The Amplitude ID of the user to request data for. startDate
Date. The start date for the data request. endDate
The end date for the data request. status
staging: not started
submitted: in progress
done: job completed successfully and urls populated
failed: job failed, may need to retryfailReason
String. If the job failed, contains Information about the failure. urls
Array of strings. A list of dowload URLs for the data. expires
Data. The date that the output download links expire.