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 is events
plural, not event
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.