Amplitude Logo

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 KeyDescriptionExample
    event_typeString. Prefix with brackets "[YOUR COMPANY]"."[YOUR COMPANY] Install"
    platformString. Either "ios" or "android"."ios"
    idfa or idfvRequired for iOS. String. The Identifier for Advertiser or the Identifier for Vendor.AEBE52E7-03EE-455A-B3C4-E57283966239
    adidRequired 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 KeyTypeDescriptionExample
    android_idstring(Android) The Android IDAEBE52E7-03EE-455A-B3C4-E57283966239
    user_propertiesdictionaryA dictionary of attribution properties prefixed with brackets "[YOUR COMPANY]".{"[YOUR COMPANY] media source": "Facebook"}
    timelongTimestamp 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 is events plural, not event singular.

    Properties

    NameTypeRequiredRestrictionsDescription
    api_keystringtruenoneAmplitude project API key
    events[Event]truenoneArray of Events to upload
    options[options]falsenoneObject

    Responses

    StatusMeaningDescription
    200OKSuccessful batch upload.
    400Bad RequestInvalid upload request. Read the error message to fix the request.
    413Payload Too LargePayload size is too big (request size exceeds 20MB). Split your events array payload in half and try again.
    429Too Many RequestsToo 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.

  • 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

    ParameterDescription
    nameRequired. String. A name for the cohort.
    app_idRequired. Integer. An identifier for the Amplitude project containing the cohort.
    id_typeRequired. String. The type of ID being sent in the ids field. Valid options are BY_AMP_ID or BY_USER_ID.
    idsRequired. 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.
    ownerRequired. String. The login email of the cohort's owner in Amplitude.
    publishedRequired. Boolean. Whether the cohort is discoverable or hidden.
    existing_cohort_idOptional. 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

    ParameterDescription
    cohort_idRequired. 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_groupOptional. 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.
    membershipsRequired. List of membership json An array of JSON objects identifying IDs to add or remove.
    skip_invalid_idsOptional. Boolean. Setting this parameter to false ends the request without updating cohort membership if the request contains invalid IDs. Setting skip_invalid_ids to true skips invalid IDs while applying the remaining valid ids. Default is true.

    Request Membership JSON

    ParameterDescription
    idsRequired. String[]. List of IDs to add or remove.
    id_typeRequired. 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.
    operationRequired. String. The operation to apply on ids field. Valid options are: ADD and REMOVE

    Success Response Fields

    ParameterDescription
    cohort_idString. The ID of an existing cohort that the membership information was updated for.
    memberships_resultList of memberships_result json. An array of JSON objects identifying result of membership update (add or remove) operation.

    Response memberships_result JSON

    ParameterDescription
    skipped_idsList of strings. List of IDs that were skipped (fail, invalid, etc.) in this membership operation entry.
    id_typeString. The type of ID that was sent for the ids field in this membership operation entry.
    operationString. The operation that was applied on ids field in this membership operation entry

    Error Response Body

    Response body (for non 200 response):

    ParameterTypeDescription
    errorerror jsonThe detail information of the error

    Response error json:

    ParameterDescription
    messageString. Describes the error.
    codeInteger. Internal error code.
    metadataJSON object. For bad request error (400) with invalid id while skip_invalid_ids=false, this field contains the cohort_id and memberships_result (list of membership JSON). The memberships_result’s skipped_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

    NameDescription
    userIdRequired if amplitudeID is not set. The User Id of the user to request data for.
    amplitudeIdRequired if userID is not set. Integer. The Amplitude ID of the user to request data for.
    startDateRequired. Date. The start date for the data request.
    endDateRequired. 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

    NameDescription
    requestIdInteger. The ID of the request.
    userIdString. The User Id of the user to request data for.
    amplitudeIdInteger. The Amplitude ID of the user to request data for.
    startDateDate. The start date for the data request.
    endDateThe end date for the data request.
    statusstaging: not started
    submitted: in progress
    done: job completed successfully and urls populated
    failed: job failed, may need to retry
    failReasonString. If the job failed, contains Information about the failure.
    urlsArray of strings. A list of dowload URLs for the data.
    expiresData. The date that the output download links expire.

Build every single integration your customers need with AI

Book a demo