> ## Documentation Index
> Fetch the complete documentation index at: https://moengage.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Track User

> This API adds or updates users and user properties in MoEngage. You can create a new user, create new user property, or update existing user properties of users.

<Note>
  * For more information about trackable user attributes, reserved keys, and general data information, refer to the [Data Overview](https://www.moengage.com/docs/api/data/data-overview).
  * If you have [Portfolio](/user-guide/settings/account/portfolio/portfolio) enabled for your workspace, you must pass `project_code` in the API endpoint. This identifies which project a user or event belongs to. For more information, refer to [Portfolio: Data Ingestion and Management](/user-guide/data/key-concepts/portfolio-data-ingestion-and-management).
</Note>

#### Rate Limit

A single API request contains one or more user updates. Maintain a rate limit of 10,000 user updates per minute.


## OpenAPI

````yaml /api/data/data.yaml post /customer/{app_id}
openapi: 3.0.3
info:
  title: MoEngage Data APIs
  version: '1.0'
  description: >-
    This is a comprehensive OpenAPI specification for MoEngage's Data APIs,
    including User, Event, and Device management.

    It's designed to power an interactive API playground on your new
    documentation site.
servers:
  - url: https://api-{dc}.moengage.com/v1
    description: MoEngage Core API Server
    variables:
      dc:
        default: '01'
        description: >-
          The ‘dc’ in the API Endpoint URL refers to the MoEngage Data Center
          (DC). MoEngage hosts each customer in a different DC. You can find
          your DC number and replace the value of ‘dc’ in the URL by referring
          to the DC and API endpoint mapping
          [here](/api/introduction#data-centers). Your MoEngage Data Center (DC)
          can be 01, 02, 03, 04, 05, 06, or 101. 
security:
  - Authentication: []
tags:
  - name: User
    description: Operations for creating, updating, retrieving, and managing user profiles.
  - name: Event
    description: Operations for tracking user events.
  - name: Device
    description: Operations for managing user devices.
  - name: Tracking
    description: Endpoints for tracking attribution and installs.
  - name: Utilities
    description: Utility endpoints for testing connections.
  - name: File Imports
    description: Operations for managing asynchronous file imports.
  - name: Bulk
    description: Operations for importing users and events in bulk.
  - name: Webhooks
    description: Incoming webhook specifications from MoEngage.
paths:
  /customer/{app_id}:
    post:
      tags:
        - User
      summary: Track User
      description: >-
        This API adds or updates users and user properties in MoEngage. You can
        create a new user, create new user property, or update existing user
        properties of users.
      parameters:
        - name: app_id
          in: path
          required: true
          description: >
            This is the Workspace ID of your MoEngage account that must be
            passed with the request. You can find it in the MoEngage dashboard
            at **Settings** > **Account** > **APIs** > **Workspace ID (earlier
            app id)**.
          schema:
            type: string
            example: VJ0GSMESHMQA3L7WV1EEK3UR
        - name: X-Forwarded-For
          in: header
          required: false
          description: >
            The 'X-Forwarded-For' header is used to specify the IP address of
            the client that made the request. This header may be added by proxy
            servers or load balancers. The header value must contain the IP
            address of the original client that initiated the request. Multiple
            IP addresses may be specified in the header value, separated by
            commas.
          schema:
            type: string
            example: 203.0.113.195
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserRequest'
            examples:
              Standard Example:
                summary: Sample cURL
                value:
                  type: customer
                  customer_id: john@example.com
                  attributes:
                    name: JohnDoe
                    first_name: John
                    platforms:
                      - platform: ANDROID
                        active: 'true'
              User property as Date/Time:
                summary: Example Payload
                value:
                  type: customer
                  customer_id: john@example.com
                  update_existing_only: true
                  attributes:
                    points: 20
                    expiry_date: '2020-05-31T03:47:35Z'
                    super_user: true
                    user_persona: browsers
                    platforms:
                      - platform: ANDROID
                        active: 'true'
              User property as Array:
                summary: Array Support
                value:
                  type: customer
                  customer_id: '123'
                  attributes:
                    removeValueFromArrayField: {}
                    addValueToArrayField:
                      attribute1:
                        - abc
                        - def
                      attribute2:
                        - a
                      attribute3:
                        - '123'
                    platforms:
                      - platform: iOS
                        active: 'true'
      responses:
        '200':
          description: >-
            This response is returned when the request is processed
            successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericSuccess'
              examples:
                success_response:
                  summary: Success Response
                  value:
                    status: success
                    message: Your request has been accepted and will be processed soon.
        '400':
          description: >-
            This response is returned when the required parameters are missing
            from the request, attributes are not found, and incorrect values are
            passed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: >-
                      This field contains the status of the request and
                      specifies whether the request was a failure.
                    example: fail
                  error:
                    type: object
                    properties:
                      attribute:
                        type: string
                        description: The attribute in the payload that caused the error.
                      message:
                        type: string
                        description: >-
                          A descriptive error message explaining why the request
                          failed.
                      type:
                        type: string
                        description: >-
                          The type or category of the error
                          ("MissingAttributeError").
                      request_id:
                        type: string
                        description: >-
                          A unique identifier for the request, useful for
                          debugging.
              examples:
                missing_customer_id:
                  summary: Customer ID is missing in the payload
                  value:
                    status: fail
                    error:
                      attribute: customer_id
                      message: customer_id is not found in the payload
                      type: MissingAttributeError
                      request_id: ZbPXtKFL
                empty_customer_id:
                  summary: Customer ID is empty
                  value:
                    status: fail
                    error:
                      attribute: customer_id
                      message: customer_id can not be empty Unicode String
                      type: MissingAttributeError
                      request_id: VgjtLxTu
                array_field_error:
                  summary: Array field error
                  value:
                    status: fail
                    error:
                      attribute: addValueToArrayField
                      message: Cannot add and remove 'first_name' at the same time
                      type: ArrayFieldError
                      request_id: WPDAbugh
        '401':
          description: >-
            This response is returned when the request does not have valid
            authentication credentials.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: fail
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        description: >-
                          A descriptive error message explaining why the request
                          failed.
                      type:
                        type: string
                        description: >-
                          The type or category of the error (e.g.,
                          Authentication required).
                      request_id:
                        type: string
                        description: >-
                          A unique identifier for the request, useful for
                          debugging.
              examples:
                auth_error:
                  summary: Authorization errors
                  value:
                    status: fail
                    error:
                      message: >-
                        App Secret key mismatch. Please login to the dashboard
                        to verify key
                      type: Authentication required
                      request_id: PVUDFisO
                missing_header:
                  summary: Missing authentication header
                  value:
                    status: fail
                    error:
                      message: Authentication Header Required
                      type: Authentication required
                      request_id: PisPjGQQ
        '403':
          description: >-
            This response is returned when your MoEngage account is suspended or
            blocked.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: fail
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        description: >-
                          A descriptive error message explaining why the request
                          failed.(e.g., Your account is suspended. Please
                          contact MoEngage team.)
                      type:
                        type: string
                        description: >-
                          The type or category of the error (e.g.,
                          BlockedClient, Account Suspended, Account Temporarily
                          Suspended).
                      request_id:
                        type: string
                        description: >-
                          A unique identifier for the request, useful for
                          debugging.
              examples:
                account_blocked:
                  summary: Account is blocked
                  value:
                    status: fail
                    error:
                      message: Your account is blocked. Please contact MoEngage team.
                      type: BlockedClient
                      request_id: Block123
                account_suspended:
                  summary: Account is suspended
                  value:
                    status: fail
                    error:
                      message: Your account is suspended. Please contact MoEngage team.
                      type: Account Suspended
                      request_id: Susp123
                temp_suspended:
                  summary: Account is temporarily suspended
                  value:
                    status: fail
                    error:
                      message: >-
                        Your account is temporarily suspended due to payment
                        issues.
                      type: Account Temporarily Suspended
                      request_id: TempSusp123
        '413':
          description: This response is returned when the payload size exceeds 128 KB.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: fail
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        description: >-
                          A descriptive error message explaining why the request
                          failed.
                      type:
                        type: string
                        description: >-
                          The type or category of the error (e.g., Payload too
                          large).
                      request_id:
                        type: string
                        description: >-
                          A unique identifier for the request, useful for
                          debugging.
              examples:
                payload_exceeded:
                  summary: Payloads exceeding the size limit
                  value:
                    status: fail
                    error:
                      message: Payload size exceeds 128 KB
                      type: PayloadTooLarge
                      request_id: VFzDwhwt
        '415':
          description: This response is returned when the content type is not supported.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: fail
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        description: >-
                          A descriptive error message explaining why the request
                          failed.
                      type:
                        type: string
                        description: >-
                          The type or category of the error (e.g., Unsupported
                          media type).
                      request_id:
                        type: string
                        description: >-
                          A unique identifier for the request, useful for
                          debugging.
              examples:
                unsupported_media_type:
                  summary: Unsupported media type
                  value:
                    status: fail
                    error:
                      message: Unsupported Media Type
                      type: MediaTypeError
                      request_id: SgBQfKJh
        '429':
          description: >-
            This response is returned when the number of requests has exceeded
            the rate limit.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: fail
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        description: >-
                          A descriptive error message explaining why the request
                          failed.
                      type:
                        type: string
                        description: >-
                          The type or category of the error (e.g., Rate Limits
                          Exceeded).
                      request_id:
                        type: string
                        description: >-
                          A unique identifier for the request, useful for
                          debugging.
              examples:
                rate_limit:
                  summary: Rate limit breach
                  value:
                    status: fail
                    error:
                      message: Rate limit exceeded
                      type: RateLimitError
                      request_id: onqucLYL
        '500':
          description: >-
            This response is returned when the system runs into an unexpected
            error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: fail
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        description: >-
                          A descriptive error message explaining why the request
                          failed.
                      type:
                        type: string
                        description: >-
                          The type or category of the error (e.g., Server
                          Error).
                      request_id:
                        type: string
                        description: >-
                          A unique identifier for the request, useful for
                          debugging.
              examples:
                unknown_error:
                  summary: Unknown errors
                  value:
                    status: fail
                    error:
                      message: Internal Server Error
                      type: ServerError
                      request_id: KovrwJiF
components:
  schemas:
    CreateUserRequest:
      title: User
      type: object
      required:
        - type
        - customer_id
      properties:
        type:
          type: string
          description: >-
            This is used to identify the type of request. This field is
            case-sensitive. Follow the case as in the example when passing the
            value in the request.
          enum:
            - customer
        customer_id:
          type: string
          description: >
            The unique identifier is used to identify/create a user in MoEngage.
            Not mandatory in [Identity
            Resolution](/user-guide/data/user-data/unified-identity-identity-resolution)
            enabled workspaces. If the User Identity Resolution feature is
            enabled in your workspace, the attribute parameters in the payload
            must contain at least one of the identifiers you have activated in
            your workspace based on which users in MoEngage will be created,
            updated, or merged. In the following example, moe_mobile is one of
            the identifiers in the workspace and is passed in attributes:


            ```json
             {
                    "type": "customer",
                    "attributes": {"moe_mobile": "{{Mobile_Number}}",
                    "first_name": "John" 
                  }
            }

            ```' 
        update_existing_only:
          type: boolean
          default: false
          description: >
            This field should be passed in the request when only existing users
            in MoEngage should be updated.


            **If this value is passed as true:**

            1. Only those users for whom the customer_id from the request
            payload matches the customer identifier in MoEngage will be updated.

            2. In case of new users (customer_id in the payload does not match
            any of the existing customer ids in your MoEngage account), they
            will not be created.


            **If this value is passed as false:**

            1. The user attributes will be updated with the values present in
            the payload for existing customers.

            2. In case of new users (customer_id in the payload does not match
            any of the existing customer ids in your MoEngage account), a new
            customer will be created in the system with the details specified in
            the payload.
        attributes:
          $ref: '#/components/schemas/UserAttributes'
        platforms:
          type: array
          description: >-
            List of dictionaries with the associated platforms out of ANDROID,
            iOS, and web and their status.
          items:
            $ref: '#/components/schemas/PlatformObject'
    GenericSuccess:
      type: object
      properties:
        status:
          type: string
          description: >-
            This field contains the status of the request and specifies whether
            the request was successful.
          example: success
        message:
          type: string
          example: Your request has been accepted and will be processed soon.
    UserAttributes:
      type: object
      description: >
        A dictionary containing user attributes to add / update in the user
        profile.

        For example, to track custom attributes of different data types like
        string, numeric, boolean, and date, pass the following payload where
        points are a number, expiry_date is a date type attribute, and
        super_user is a boolean attribute.


        > **Note:**

        > * "id", "_id", and "" keywords are blocked and not to be used as user
        attribute names.

        > * You can not use "moe_" as a prefix while naming user attributes. It
        is a system prefix and using it might result in periodic blacklisting
        without prior communication.

        > For other attributes that are not listed below, use the key-value
        pairs that you intend to use.


        **Array Support**
          If you want to pass an attribute in an array, the appropriate syntax for that is: 
           ```json
           "Array_attributeName":["abc","123"]
           ```
      properties:
        u_n:
          type: string
          description: Full name of the user.
        u_fn:
          type: string
          description: First name of the user.
        u_ln:
          type: string
          description: Last name of the user.
        u_gd:
          type: string
          description: Gender of the user.
        u_em:
          type: string
          format: email
          description: Email Address of the user (Standard).
        u_mb:
          type: string
          description: Mobile Number of the user (Standard). Example `918888444411`.
        uid:
          type: string
          description: >-
            A unique ID that the app has set for a user. This is a standard
            attribute where MoEngage provides the name, and the value is
            provided by the client.
        u_bd:
          type: string
          format: date-time
          description: >-
            Birthdate of the user in ISO 8601 format (e.g.,
            2019-05-21T03:47:35Z).
        moe_wa_subscription:
          type: boolean
          description: WhatsApp subscription status of a user.
        moe_em_unsub_categories:
          type: string
          description: >-
            Email Unsubscribed Categories. The list of email categories user has
            unsubscribed.
        push_preference:
          type: boolean
          description: >-
            Push Opt In Status (iOS).The push permission status of a user on an
            iOS device.
        moe_sub_w:
          type: boolean
          description: >-
            Web Push Subscription Status. The web push subscription status of a
            user. Use this to find your aggregate subscribers and users who
            unsubscribed after subscribing once.
        moe_spam:
          type: boolean
          description: >-
            Spam. Email Spam Attribute. The emails are not sent to the user when
            the set value is true.
        moe_unsubscribe:
          type: boolean
          description: >-
            Unsubscribe. Email Unsubscribe Attribute. Emails are not sent to the
            user when the set value is true.
        moe_hard_bounce:
          type: boolean
          description: >-
            Hard Bounce. Email Hard Bounce Attribute. The emails are not sent to
            the user when the set value is true.
        moe_sms_subscription:
          type: string
          description: >-
            SMS Subscription Status. An attribute which stores the SMS
            subscription status of the user. This will be used to see if a user
            is reachable based on certain values of the attribute.
        moe_email_optin_status:
          type: string
          enum:
            - DOUBLE_OPTED_IN
            - OPTED_OUT
            - OPT_IN_PENDING
          description: >
            Email Opt-in Status. An attribute that stores the opt-in status of
            the user for the email channel. Supported values are: 

            * `DOUBLE_OPTED_IN`

            * `OPTED_OUT`

            * `OPT_IN_PENDING`
        publisher_name:
          type: string
          description: >-
            Publisher Name. The name of the campaign publisher. This standard
            attribute can only be created through the Track User API and cannot
            be updated later.
        campaign_name:
          type: string
          description: >-
            Campaign Name. The name of the campaign. This standard attribute can
            only be created through the Track User API and cannot be updated
            later.
        u_l_a:
          type: integer
          format: int64
          description: >-
            Last Seen. Time in epoch format (for example, `1767092989259`). This
            standard attribute can only be created through the Track User API
            and cannot be updated later.
        cr_t:
          type: integer
          format: int64
          description: >-
            First Seen. Time in epoch format (for example, `1767092989259`).
            This standard attribute can only be created through the Track User
            API and cannot be updated later.
        geo:
          type: string
          description: >-
            Geolocation of the user as a string of latitude and longitude (for
            example, `88.90 89.00`).
        moe_gaid:
          type: string
          description: >-
            Google Advertising ID (Android). A unique, resettable identifier
            provided by Google for ad tracking and attribution on Android
            devices. This standard attribute can only be created through the
            Track User API and cannot be updated later.
        advertising_identifier:
          type: string
          description: >-
            Advertising Identifier (iOS & Windows). A unique alphanumeric string
            used for ad tracking on iOS (IDFA) and Windows devices. This
            standard attribute can only be created through the Track User API
            and cannot be updated later.
      additionalProperties: true
      example:
        name: John
        points: 20
        expiry_date: '2020-05-31T03:47:35Z'
        super_user: true
        user_persona: browsers
    PlatformObject:
      type: object
      properties:
        platform:
          type: string
          enum:
            - ANDROID
            - iOS
            - web
        active:
          type: string
          enum:
            - 'true'
            - 'false'
  securitySchemes:
    Authentication:
      type: http
      scheme: basic
      description: >
        Authentication is done via Basic Auth. This requires a base64-encoded
        string of your credentials in the format 'username:password'.


        - **Username**: Use your MoEngage workspace ID (also known as the App
        ID). You can find it in the MoEngage dashboard at **Settings** >
        **Account** > **APIs** > **Workspace ID (earlier app id)**.

        - **Password**: Use your API Key, which you can find within the **Data**
        tile.


        **Note**: After you generate and save the Data API Key, DO NOT generate
        a new key unless there is a security breach. After you generate a
        different Data API key and save it, the authentication will start
        failing. You must update your existing data tracking. 


        For more information on authentication and getting your credentials,
        refer
        [here](https://www.moengage.com/docs/api/introduction#getting-your-credentials).

````