# Tracking Users (Non-shopify)

With user tracking APIs, you can create a new user or update existing users. For each customer being created/updated you will need to provide a unique identifier of this customer. The identifier can be a customer's email id or mobile number.

## /rest-api/customer

<mark style="color:green;">`POST`</mark> `https://dcqs-india.growlytics.in/rest-api/customer`&#x20;

Using /rest-api/customer API, you can create or update the customer. If the customer already exists with a given unique id, the customer will be updated, otherwise, a new customer will be created.

#### Headers

| Name                                               | Type   | Description        |
| -------------------------------------------------- | ------ | ------------------ |
| x-growlytics-key<mark style="color:red;">\*</mark> | string | Growlytics API Key |

#### Request Body

| Name                                         | Type                       | Description                                                                                                                                           |
| -------------------------------------------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| attributes<mark style="color:red;">\*</mark> | object {name, type, value} | Array Of attributes. Each array item will be an object. having: name, type, value.                                                                    |
| id<mark style="color:red;">\*</mark>         | string                     | Customer's unique id. If the customer already exists with a given unique id, the customer will be updated. Otherwise, a new customer will be created. |
|                                              |                            |                                                                                                                                                       |

{% tabs %}
{% tab title="200 ​​​When customer is successfully created or updated." %}

```
{
    success: true
}
```

{% endtab %}

{% tab title="422 When invalid input is provided. You will get reponse with details of what exactly is wrong. " %}

```
```

{% endtab %}
{% endtabs %}

## API Example

{% tabs %}
{% tab title="Node JS" %}

```javascript
// Prepare Request input data 
const requestBody = {
    "id":"your-system-uniqe-id",
    "attributes": [
        { name: 'name', type: 'string', value: `Customer Name` },
        { name: 'email', type: 'string', value: `customer_email@gmail.com` },
        { name: 'mobile', type: 'string', value: '9919211112' }
        
        // Custom Attributes (Allowed Types: number, date, boolean, string)
        { name: 'City', type: 'string', value: 'Mumbai' },
        { name: 'Total Orders', type: 'number', value: 1 },
        { name: 'Is First Time Purchaser', type: 'boolean', value: true },
        { name: 'Last Order Date', type: 'date', value: 'YYYY-MM-DD HH:MM:SS' },
    ]
};

// Call API
const request = require('request-promise');
request({
    method: 'POST',
    uri: 'https://dcqs-india.growlytics.in/rest-api/customer',
    headers: {
        Accept: 'application/json',
        'x-growlytics-key': '<GROWLYTICS-API-KEY>'
    },
    body: requestBody
});
```

{% endtab %}
{% endtabs %}

## Terms & Considerations

1. *Custom Attribute* names must be less than 50 characters.
2. *Custom Attribute* names are case-sensitive.
3. Allowed data types for event attributes:`string`, `number`, `boolean`, `date`&#x20;
4. In a Customer Profile, you can set a maximum number of 100 custom attributes.
5. Data types of each attributes are defined when they are tracked for the first time. For the second time, if the data type is not matching with the original data type, attributes will be ignored.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.growlytics.in/rest-apis/tracking-users-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
