NAV Navbar
Logo
JSON Javascript Python Ruby PHP Go C# Java

Moesif API Reference

Debugging RESTful APIs Made Easier.

This API reference centers around v1 of the Moesif REST API and API Client Libs for common languages. For an overview on Moesif and higher level SDKs for common frameworks, please checkout the Developer Docs

This RESTful API is open for developers who want to build new extensions and clients. Apps can integrate with Moesif as long as it can send HTTP requests.

Moesif on Programmable Web

Overview

API Base URL

The base url for v1 of the API is:

https://api.moesif.net/v1

Prepend all endpoints below with this base url. Both HTTPS and HTTP requests are supported. Calls to our API are routed to the nearest datacenter.

Authentication

Authentication is done via HTTP Headers. The same Application Id token can be used for the cloud proxy server, the client libs, and the REST API. Add the following header to all API Calls.

X-Moesif-Application-Id: my_application_id

Request Format

For POST, PUT, and PATCH requests, the request body should be JSON. The Content-Type header should be set to application/json

Response Format

The response body format is always JSON. Successful operations are seen via 2xx status code. Successful creation of new objects will be seen via 201. 4xx status implies client error.

The REST API JSON payloads uses underscore format (i.e some_key). Many of the API libs may use camelCase, PascalCase, or other as their model entities. Please select the respective language tab.

CORS

CORS is enabled on this API. Access-Control-Allow-Origin is set to *

List of Endpoints

URL VERB Description
/events POST Create a single API Call to Moesif
/events/batch POST Create a batch of API Calls to Moesif

Errors

Error Code Meaning
400 Bad Request – Your request has an incorrect parameter
401 Unauthorized – Your X-Moesif-Application-Id header is incorrect
403 Forbidden – You accessed a resource not allowed with your key
404 Not Found – The specified resource could not be found
405 Method Not Allowed – You tried to access a resource with an invalid HTTP method
406 Not Acceptable – You requested a format that is not JSON format, Moesif’s API supports JSON
410 Gone – The resource requested has been removed from our servers
500 Internal Server Error – We had a problem with our server. Please contact us

API Libs

These open-source libs are advanced wrappers for the Moesif REST API and are the building blocks for the higher level server and mobile SDKs. These libs can be used similarly to other analytics event libs with a sendEvent() call which sends event data to api.moesif.net. These libraries support both sync and async operations.

Important

How to Install

Pick a language at the top


Source Code:

https://github.com/moesif/moesifapi-java
// Add the dependency

<dependency>
    <groupId>com.moesif.api</groupId>
    <artifactId>moesifapi</artifactId>
    <version>1.4.0</version>
</dependency>

Source Code:

https://github.com/moesif/moesifapi-nodejs


Package:

https://www.npmjs.com/package/moesifapi
// To Install Moesif Lib, run in your terminal

npm install --save moesifapi
Source Code:

https://github.com/moesif/moesifapi-python


Package:

https://pypi.python.org/pypi/moesifapi
# To Install Moesif Lib, run in your terminal

pip install moesifapi
Source Code:

https://github.com/moesif/moesifapi-ruby


Package:

https://rubygems.org/gems/moesif_api
# To Install Moesif Lib, run in your terminal

gem install moesif_api
Source Code:

https://github.com/moesif/moesifapi-csharp


Package:

https://www.nuget.org/packages/Moesif.Api/
// Install the Nuget Package via Package Manager Console:

Install-Package Moesif.Api
Source Code:

https://github.com/Moesif/moesifapi-go

go get github.com/moesif/moesifapi-go;
Source Code:

https://github.com/Moesif/moesifapi-php
// Install via Composer

composer require moesif/moesifapi

Select your language on the right:

The SDKs are open-source and available on GitHub.

Event Log API

Create an Event

POST https://api.moesif.net/v1/events

Log a single API event to Moesif. The request body itself is a single API Call object consisting of both the HTTP request and HTTP response.

POST https://api.moesif.net/v1/events

Example Request Body:
  {
    "request": {
      "time": "2017-10-22T04:45:42.914",
      "uri": "https://api.acmeinc.com/items/12345/reviews/",
      "verb": "POST",
      "api_version": "1.1.0",
      "ip_address": "61.48.220.123",
      "headers": {
        "Host": "api.acmeinc.com",
        "Accept": "*/*",
        "Connection": "Keep-Alive",
        "Content-Type": "application/json",
        "Content-Length": "126",
        "Accept-Encoding": "gzip"
      },
      "body": {
        "items": [
          {
            "direction_type": 1,
            "item_id": "fwdsfrf",
            "liked": false
          },
          {
            "direction_type": 2,
            "item_id": "d43d3f",
            "liked": true
          }
        ]
      },
      "transfer_encoding": ""
    },
    "response": {
      "time": "2017-10-22T04:45:42.914",
      "status": 500,
      "headers": {
        "Vary": "Accept-Encoding",
        "Pragma": "no-cache",
        "Expires": "-1",
        "Content-Type": "application/json; charset=utf-8",
        "Cache-Control": "no-cache"
      },
      "body": {
        "Error": "InvalidArgumentException",
        "Message": "Missing field location"
      },
      "transfer_encoding": ""
    },
    "user_id": "mndug437f43",
    "session_token": "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f",
    "metadata": {
        "some_string": "I am a string",
        "some_int": 77,
        "some_object": {
            "some_sub_field": "some_value"
        }
    }
  }
// Import the Library
MoesifAPIClient client = new MoesifAPIClient("my_application_id");
APIController api = getClient().getAPI();

// Generate the event
Map<String, String> reqHeaders = new HashMap<String, String>();
reqHeaders.put("Host", "api.acmeinc.com");
reqHeaders.put("Accept", "*/*");
reqHeaders.put("Connection", "Keep-Alive");
reqHeaders.put("User-Agent", "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)");
reqHeaders.put("Content-Type", "application/json");
reqHeaders.put("Content-Length", "126");
reqHeaders.put("Accept-Encoding", "gzip");

Object reqBody = APIHelper.deserialize("{" +
  "\"items\": [" +
    "{" +
      "\"type\": 1," +
      "\"id\": \"fwfrf\"" +,
    "}," +
    "{" +
      "\"type\": 2," +
       "\"id\": \"d43d3f\"" +
     "}" +
  "]" +
  "}");

Map<String, String> rspHeaders = new HashMap<String, String>();
rspHeaders.put("Vary", "Accept-Encoding");
rspHeaders.put("Pragma", "no-cache");
rspHeaders.put("Expires", "-1");
rspHeaders.put("Content-Type", "application/json; charset=utf-8");
rspHeaders.put("Cache-Control","no-cache");

Object rspBody = APIHelper.deserialize("{" +
    "\"Error\": \"InvalidArgumentException\"," +
    "\"Message\": \"Missing field field_a\"" +
  "}");


EventRequestModel eventReq = new EventRequestBuilder()
        .time(new Date())
        .uri("https://api.acmeinc.com/items/reviews/")
        .verb("PATCH")
        .apiVersion("1.1.0")
        .ipAddress("61.48.220.123")
        .headers(reqHeaders)
        .body(reqBody)
        .build();


EventResponseModel eventRsp = new EventResponseBuilder()
        .time(new Date(System.currentTimeMillis() + 1000))
        .status(500)
        .headers(rspHeaders)
        .body(rspBody)
        .build();

EventModel eventModel = new EventBuilder()
        .request(eventReq)
        .response(eventRsp)
        .userId("my_user_id")
        .sessionToken("23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f")
        .build();

// Asynchronous Call to Create Event
MoesifAPIClient client = new MoesifAPIClient("my_application_id");
APIController api = getClient().getAPI();

APICallBack<Object> callBack = new APICallBack<Object>() {
    public void onSuccess(HttpContext context, Object response) {
        // Do something
    }

    public void onFailure(HttpContext context, Throwable error) {
        // Do something else
    }
};

api.createEventsBatchAsync(eventsList, callBack);

// Synchronous Call to Create Event
api.createEventsBatch(eventsList, callBack);
// 1. Import the module
var moesifapi = require('moesifapi');
var api = moesifapi.ApiController;

// 2. Configure the ApplicationId
var config = moesifapi.configuration;
config.ApplicationId = "my_application_id";

// 3. Generate an API Event Model
var reqHeaders = JSON.parse('{' +
        '"Host": "api.acmeinc.com",' +
        '"Accept": "*/*",' +
        '"Connection": "Keep-Alive",' +
        '"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)",' +
        '"Content-Type": "application/json",' +
        '"Content-Length": "126",' +
        '"Accept-Encoding": "gzip"' +
    '}');

var reqBody = JSON.parse( '{' +
        '"items": [' +
            '{' +
                '"type": 1,' +
                '"id": "fwfrf"' +
            '},' +
            '{' +
                '"type": 2,' +
                '"id": "d43d3f"' +
            '}' +
        ']' +
    '}');

var rspHeaders = JSON.parse('{' +
        '"Vary": "Accept-Encoding",' +
        '"Pragma": "no-cache",' +
        '"Expires": "-1",' +
        '"Content-Type": "application/json; charset=utf-8",' +
        '"Cache-Control": "no-cache"' +
    '}');

var rspBody = JSON.parse('{' +
        '"Error": "InvalidArgumentException",' +
        '"Message": "Missing field field_a"' +
    '}');

var reqDate = new Date();
var eventReq = {
    time: reqDate,
    uri: "https://api.acmeinc.com/items/reviews/",
    verb: "PATCH",
    apiVersion: "1.1.0",
    ipAddress: "61.48.220.123",
    headers: reqHeaders,
    body: reqBody
};

var eventRsp = {
    time: (new Date()).setMilliseconds(reqDate.getMilliseconds() + 500),
    status: 500,
    headers: rspHeaders,
    body: rspBody
};

var eventModel = {
    request: eventReq,
    response: eventRsp,
    userId: "my_user_id",
    sessionToken: "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f"
};

var events = [new EventModel(eventModel),
  new EventModel(eventModel),
  new EventModel(eventModel),
  new EventModel(eventModel)];

// 4. Send batch of events
api.createEventsBatch(events, function(error, response, context) {
  // Do Something
});

from __future__ import print_function
from moesifapi.moesif_api_client import *
from moesifapi.models import *
from datetime import *

client = MoesifAPIClient(my_application_id)
api = client.api

# Note: we recommend sending all API Calls via MVC framework middleware.

req_headers = APIHelper.json_deserialize("""  {
  "Host": "api.acmeinc.com",
  "Accept": "*/*",
  "Connection": "Keep-Alive",
  "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)",
  "Content-Type": "application/json",
  "Content-Length": "126",
  "Accept-Encoding": "gzip"
} """)

req_body = APIHelper.json_deserialize( """{
  "items": [
    {
      "type": 1,
      "id": "fwfrf"
    },
    {
      "type": 2,
      "id": "d43d3f"
    }
  ]
}""")

rsp_headers = APIHelper.json_deserialize("""  {
    "Date": "Tue, 23 Oct 2017 23:46:49 GMT",
    "Vary": "Accept-Encoding",
    "Pragma": "no-cache",
    "Expires": "-1",
    "Content-Type": "application/json; charset=utf-8"
    "Cache-Control": "no-cache"
  } """)

rsp_body = APIHelper.json_deserialize( """{
    "Error": "InvalidArgumentException",
    "Message": "Missing field field_a"
  }""")


event_req = EventRequestModel(time = datetime.utcnow() - timedelta(seconds=-1),
    uri = "https://api.acmeinc.com/items/reviews/",
    verb = "PATCH",
    api_version = "1.1.0",
    ip_address = "61.48.220.123",
    headers = req_headers,
    body = req_body)

event_rsp = EventResponseModel(time = datetime.utcnow(),
    status = 500,
    headers = rsp_headers,
    body = rsp_body)

event_model = EventModel(request = event_req,
    response = event_rsp,
    user_id = "my_user_id",
    session_token = "my_application_id")


# Perform the API call through the SDK function
api.create_event(event_model)
require 'moesif_api'

client = MoesifApi::MoesifAPIClient.new(my_application_id)
api = client.api_controller

req_headers = JSON.parse('{'\
  '"Host": "api.acmeinc.com",'\
  '"Accept": "*/*",'\
  '"Connection": "Keep-Alive",'\
  '"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)",'\
  '"Content-Type": "application/json",'\
  '"Content-Length": "126",'\
  '"Accept-Encoding": "gzip"'\
'}')

req_body = JSON.parse( '{'\
  '"items": ['\
    '{'\
      '"type": 1,'\
      '"id": "fwfrf"'\
    '},'\
    '{'\
      '"type": 2,'\
      '"id": "d43d3f"'\
    '}'\
  ']'\
'}')

rsp_headers = JSON.parse('{'\
  '"Date": "Tue, 23 Oct 2017 23:46:49 GMT",'\
                '"Vary": "Accept-Encoding",'\
  '"Pragma": "no-cache",'\
  '"Expires": "-1",'\
  '"Content-Type": "application/json; charset=utf-8",'\
                '"Cache-Control": "no-cache"'\
'}')

rsp_body = JSON.parse('{'\
  '"Error": "InvalidArgumentException",'\
  '"Message": "Missing field field_a"'\
'}')


event_req = EventRequestModel.new()
event_req.time = "2017-10-22T04:45:42.914"
event_req.uri = "https://api.acmeinc.com/items/reviews/"
event_req.verb = "PATCH"
event_req.api_version = "1.1.0"
event_req.ip_address = "61.48.220.123"
event_req.headers = req_headers
event_req.body = req_body

event_rsp = EventResponseModel.new()
event_rsp.time = "2017-10-22T04:45:42.914"
event_rsp.status = 500
event_rsp.headers = rsp_headers
event_rsp.body = rsp_body

event_model = EventModel.new()
event_model.request = event_req
event_model.response = event_rsp
event_model.user_id ="my_user_id"
event_model.session_token = "my_application_id"

# Perform the API call through the SDK function
response = api.create_event(event_model)

using Moesif.Api;
using Moesif.Api.Helpers;

// Create client instance using your ApplicationId
var client = new MoesifAPIClient("my_application_id");
var apiClient = GetClient().Api;

// Parameters for the API call
var reqHeaders = APIHelper.JsonDeserialize<object>(@" {
        ""Host"": ""api.acmeinc.com"",
        ""Accept"": ""*/*"",
        ""Connection"": ""Keep-Alive"",
        ""User-Agent"": ""Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)"",
        ""Content-Type"": ""application/json"",
        ""Content-Length"": ""126"",
        ""Accept-Encoding"": ""gzip""
    }");

var reqBody = APIHelper.JsonDeserialize<object>(@" {
        ""items"": [
            {
                ""type"": 1,
                ""id"": ""fwfrf""
            },
            {
                ""type"": 2,
                ""id"": ""d43d3f""
            }
        ]
    }");

var rspHeaders = APIHelper.JsonDeserialize<object>(@" {
        ""Date"": ""Tue, 23 Oct 2017 23:46:49 GMT"",
        ""Vary"": ""Accept-Encoding"",
        ""Pragma"": ""no-cache"",
        ""Expires"": ""-1"",
        ""Content-Type"": ""application/json; charset=utf-8"",
        ""Cache-Control"": ""no-cache""
    } ");

var rspBody = APIHelper.JsonDeserialize<object>(@" {
        ""Error"": ""InvalidArgumentException"",
        ""Message"": ""Missing field field_a""
    }");


var eventReq = new EventRequestModel()
{
    Time = DateTime.Parse("2017-10-22T04:45:42.914"),
    Uri = "https://api.acmeinc.com/items/reviews/",
    Verb = "PATCH",
    ApiVersion = "1.1.0",
    IpAddress = "61.48.220.123",
    Headers = reqHeaders,
    Body = reqBody
};

var eventRsp = new EventResponseModel()
{
    Time = DateTime.Parse("2017-10-22T04:45:42.914"),
    Status = 500,
    Headers = rspHeaders,
    Body = rspBody
};

var eventModel = new EventModel()
{
    Request = eventReq,
    Response = eventRsp,
    UserId = "my_user_id",
    SessionToken = "my_application_id"
};

//////////////////////////////////////
// Example for making an async call //     
//////////////////////////////////////
try
{
    await controller.CreateEventAsync(eventModel);
}
catch(APIException)
{
    // Handle Error
};

///////////////////////////////////////////
// Example for making a synchronous call //
///////////////////////////////////////////
try
{
    controller.CreateEvent(eventModel);
}
catch(APIException)
{
    // Handle Error
};

import "github.com/moesif/moesifapi-go"
import "github.com/moesif/moesifapi-go/models"
import "time"

apiClient := moesifapi.NewAPI("your_moesif_application_id")

reqTime := time.Now().UTC()
apiVersion := "1.0"
ipAddress := "61.48.220.123"

req := models.EventRequestModel{
  Time:       &reqTime,
  Uri:        "https://api.acmeinc.com/widgets",
  Verb:       "GET",
  ApiVersion: &apiVersion,
  IpAddress:  &ipAddress,
  Headers: map[string]interface{}{
    "ReqHeader1": "ReqHeaderValue1",
  },
  Body: nil,
}

rspTime := time.Now().UTC().Add(time.Duration(1) * time.Second)

rsp := models.EventResponseModel{
  Time:      &rspTime,
  Status:    500,
  IpAddress: nil,
  Headers: map[string]interface{}{
    "RspHeader1":     "RspHeaderValue1",
    "Content-Type":   "application/json",
    "Content-Length": "1000",
  },
  Body: map[string]interface{}{
    "Key1": "Value1",
    "Key2": 12,
    "Key3": map[string]interface{}{
      "Key3_1": "SomeValue",
    },
  },
}

sessionToken := "end user's API or Session Token"
userId := "end user_id"

event := models.EventModel{
  Request:      req,
  Response:     rsp,
  SessionToken: &sessionToken,
  Tags:         nil,
  UserId:       &userId,
}


// Queue the event (will queue the requests into batches and flush buffers periodically.)
err := apiClient.QueueEvent(&event)

// Create the event synchronously
err := apiClient.CreateEvent(&event)

// Depending on your project setup, you might need to include composer's
// autoloader in your PHP code to enable autoloading of classes.

require_once "vendor/autoload.php";

// Import the SDK client in your project:

use MoesifApi\MoesifApiClient;

// Instantiate the client. After this, you can now access the Moesif API
// and call the respective methods:

$client = new MoesifApiClient("Your application Id");
$api = $client->getApi();

$event = APIHelper::deserialize('{ "request": { "time": "2016-09-09T04:45:42.914", "uri": "<https://api.acmeinc.com/items/reviews/>", "verb": "PATCH", "api_version": "1.1.0", "ip_address": "61.48.220.123", "headers": { "Host": "api.acmeinc.com", "Accept": "_/_", "Connection": "Keep-Alive", "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)", "Content-Type": "application/json", "Content-Length": "126", "Accept-Encoding": "gzip" }, "body": { "items": [ { "direction_type": 1, "discovery_id": "fwfrf", "liked": false }, { "direction_type": 2, "discovery_id": "d43d3f", "liked": true } ] } }, "response": { "time": "2016-09-09T04:45:42.914", "status": 500, "headers": { "Date": "Tue, 23 Aug 2016 23:46:49 GMT", "Vary": "Accept-Encoding", "Pragma": "no-cache", "Expires": "-1", "Content-Type": "application/json; charset=utf-8", "X-Powered-By": "ARR/3.0", "Cache-Control": "no-cache", "Arr-Disable-Session-Affinity": "true" }, "body": { "Error": "InvalidArgumentException", "Message": "Missing field field_a" } }, "user_id": "mndug437f43", "session_token": "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f", "metadata": { "foo": "bar" } }', new Models\EventModel());

// Note: If the request.time is in the past, it can only be backdated up to 7 days.

$reqdate = new DateTime();
$event->request->time = $reqdate->format(DateTime::ISO8601);
$rspdate = new DateTime();
$event->response->time = $rspdate->format(DateTime::ISO8601);

$api->createEvent($event);
Fields Required? Description
request Required The object that specifies the request message

request.time

Required Timestamp for the request in ISO 8601 format

request.uri

Required Full uri such as https://api.com/?query=string including host, query string, etc

request.verb

Required HTTP method used, i.e. GET, POST

request.api_version

Optional API Version you want to tag this request with such as 1.0.0

request.ip_address

Optional IP address of the requester, If not set, we use the IP address of your logging API calls.

request.headers

Required Headers of the request as a Map<string, string>.. Multiple headers with the same key name should be combined together such that the values are joined by a comma. HTTP Header Protocol on w3.org

request.body

Optional Body of the request in JSON format or Base64 encoded binary data (see transfer_encoding)

request.transfer_encoding

Optional A string that specifies the transfer encoding of Body being sent to Moesif. If field nonexistent, body assumed to be JSON or text. Only possible value is base64 for sending binary data like protobuf
response Optional The object that specifies the response message, not set implies no response received such as a timeout.

response.time

Required Timestamp for the response in ISO 8601 format

response.status

Required HTTP status code as number such as 200 or 500

request.ip_address

Optional IP address of the responding server

response.headers

Required Headers of the response as a Map<string, string>. Multiple headers with the same key name should be combined together such that the values are joined by a comma. HTTP Header Protocol on w3.org

response.body

Optional Body of the response in JSON format or Base64 encoded binary data (see transfer_encoding)

response.transfer_encoding

Optional A string that specifies the transfer encoding of Body being sent to Moesif. If field nonexistent, body assumed to be JSON or text. Only possible value is base64 for sending binary data like protobuf
session_token Recommend The end user session token such as a JWT or API key, which may or may not be temporary. Moesif will auto-detect the session token automatically if not set.
user_id Recommend Identifies this API call to a permanent user_id
metadata Optional A JSON Object consisting of any custom metadata to be stored with this event.

Create an Events Batch

POST https://api.moesif.net/v1/events/batch

Creates and logs a batch of API Calls to Moesif. The request body itself is an array API Calls object consisting of both the HTTP request and HTTP response.

This API takes a list form of the same model defined in create single event.

The maximum batch size is 12MB. Break up larger batches.

API Calls from multiple end users can be added in a single batch. Each Event in the list has independent session_token and user_id fields.

POST https://api.moesif.net/v1/events/batch

Example Request Body:
  [
    {
        "request": {
          "time": "2017-10-22T04:45:42.914",
          "uri": "https://api.acmeinc.com/items/83738/reviews/",
          "verb": "POST",
          "api_version": "1.1.0",
          "ip_address": "61.48.220.123",
          "headers": {
            "Host": "api.acmeinc.com",
            "Accept": "*/*",
            "Connection": "Keep-Alive",
            "Content-Type": "application/json",
            "Content-Length": "126",
            "Accept-Encoding": "gzip"
          },
          "body": {
            "items": [
              {
                "direction_type": 1,
                "item_id": "fwdsfrf",
                "liked": false
              },
              {
                "direction_type": 2,
                "item_id": "d43d3f",
                "liked": true
              }
            ]
          },
          "transfer_encoding": "",
        },
        "response": {
          "time": "2017-10-22T04:45:42.914",
          "status": 500,
          "headers": {
            "Vary": "Accept-Encoding",
            "Pragma": "no-cache",
            "Expires": "-1",
            "Content-Type": "application/json; charset=utf-8",
            "Cache-Control": "no-cache"
          },
          "body": {
            "Error": "InvalidArgumentException",
            "Message": "Missing field location"
          },
          "transfer_encoding": "",
        },
        "user_id": "mndug437f43",
        "session_token": "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f",
        "metadata": {
            "some_string": "I am a string",
            "some_int": 77,
            "some_object": {
                "some_sub_field": "some_value"
            }
        }
    }
  ]
// Import the Library
MoesifAPIClient client = new MoesifAPIClient("my_application_id");
APIController api = getClient().getAPI();

// Generate the events
Map<String, String> reqHeaders = new HashMap<String, String>();
reqHeaders.put("Host", "api.acmeinc.com");
reqHeaders.put("Accept", "*/*");
reqHeaders.put("Connection", "Keep-Alive");
reqHeaders.put("User-Agent", "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)");
reqHeaders.put("Content-Type", "application/json");
reqHeaders.put("Content-Length", "126");
reqHeaders.put("Accept-Encoding", "gzip");

Object reqBody = APIHelper.deserialize("{" +
  "\"items\": [" +
    "{" +
      "\"type\": 1," +
      "\"id\": \"fwfrf\"" +
    "}," +
    "{" +
      "\"type\": 2," +
      "\"id\": \"d43d3f\"" +
    "}" +
  "]" +
  "}");

Map<String, String> rspHeaders = new HashMap<String, String>();
rspHeaders.put("Date", "Tue, 23 Oct 2017 23:46:49 GMT");
rspHeaders.put("Vary", "Accept-Encoding");
rspHeaders.put("Pragma", "no-cache");
rspHeaders.put("Expires", "-1");
rspHeaders.put("Content-Type", "application/json; charset=utf-8");
rspHeaders.put("Cache-Control","no-cache");

Object rspBody = APIHelper.deserialize("{" +
    "\"Error\": \"InvalidArgumentException\"," +
    "\"Message\": \"Missing field field_a\"" +
  "}");


EventRequestModel eventReq = new EventRequestBuilder()
        .time(new Date())
        .uri("https://api.acmeinc.com/items/reviews/")
        .verb("PATCH")
        .apiVersion("1.1.0")
        .ipAddress("61.48.220.123")
        .headers(reqHeaders)
        .body(reqBody)
        .build();


EventResponseModel eventRsp = new EventResponseBuilder()
        .time(new Date(System.currentTimeMillis() + 1000))
        .status(500)
        .headers(rspHeaders)
        .body(rspBody)
        .build();

EventModel eventModel = new EventBuilder()
        .request(eventReq)
        .response(eventRsp)
        .userId("my_user_id")
        .sessionToken("23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f")
        .build();

List<EventModel> events = new ArrayList<EventModel>();
events.add(eventModel);
events.add(eventModel);
events.add(eventModel);
events.add(eventModel);

// Asynchronous Call to create new event
MoesifAPIClient client = new MoesifAPIClient("my_application_id");
APIController api = getClient().getAPI();

APICallBack<Object> callBack = new APICallBack<Object>() {
    public void onSuccess(HttpContext context, Object response) {
      // Do something
    }

    public void onFailure(HttpContext context, Throwable error) {
      // Do something else
    }
};

api.createEventsBatchAsync(events, callBack);

// Synchronous Call to create new event
api.createEventsBatch(events, callBack);
// Import the module:
var moesifapi = require('moesifapi');

// Set your application id
var config = moesifapi.configuration;
config.ApplicationId = 'my_application_id';

// Create API Event Models and set fields
var reqHeaders = JSON.parse('{' +
        '"Host": "api.acmeinc.com",' +
        '"Accept": "*/*",' +
        '"Connection": "Keep-Alive",' +
        '"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)",' +
        '"Content-Type": "application/json",' +
        '"Content-Length": "126",' +
        '"Accept-Encoding": "gzip"' +
    '}');

var reqBody = JSON.parse( '{' +
        '"items": [' +
            '{' +
                '"type": 1,' +
                '"id": "fwfrf"' +
            '},' +
            '{' +
                '"type": 2,' +
                '"id": "d43d3f"' +
            '}' +
        ']' +
    '}');

var rspHeaders = JSON.parse('{' +
        '"Vary": "Accept-Encoding",' +
        '"Pragma": "no-cache",' +
        '"Expires": "-1",' +
        '"Content-Type": "application/json; charset=utf-8",' +
        '"Cache-Control": "no-cache"' +
    '}');

var rspBody = JSON.parse('{' +
        '"Error": "InvalidArgumentException",' +
        '"Message": "Missing field field_a"' +
    '}');

var reqDate = new Date();
var eventReq = {
    time: reqDate,
    uri: "https://api.acmeinc.com/items/reviews/",
    verb: "PATCH",
    apiVersion: "1.1.0",
    ipAddress: "61.48.220.123",
    headers: reqHeaders,
    body: reqBody
};

var eventRsp = {
    time: (new Date()).setMilliseconds(reqDate.getMilliseconds() + 500),
    status: 500,
    headers: rspHeaders,
    body: rspBody
};

var eventA = {
    request: eventReq,
    response: eventRsp,
    userId: "my_user_id",
    sessionToken: "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f"
};

var myEventModels = [ eventA ]

//Access various controllers by:
var controller = moesifapi.ApiController;

// Send the actual events
controller.createEventsBatch(myEventModels, function(error, response, context) {
  //  Handle Errors
});

from __future__ import print_function
from moesifapi.moesif_api_client import *
from moesifapi.models import *
from datetime import *

# Setup API Client
client = MoesifAPIClient(my_application_id)
api = client.api_controller


# Create API Event Models and set fields
req_headers = APIHelper.json_deserialize("""  {
  "Host": "api.acmeinc.com",
  "Accept": "*/*",
  "Connection": "Keep-Alive",
  "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)",
  "Content-Type": "application/json",
  "Content-Length": "126",
  "Accept-Encoding": "gzip"
} """)

req_body = APIHelper.json_deserialize( """{
  "items": [
    {
      "type": 1,
      "id": "fwfrf"
    },
    {
      "type": 2,
      "id": "d43d3f"
    }
  ]
}""")

rsp_headers = APIHelper.json_deserialize("""  {
    "Date": "Tue, 23 Oct 2017 23:46:49 GMT",
    "Vary": "Accept-Encoding",
    "Pragma": "no-cache",
    "Expires": "-1",
    "Content-Type": "application/json; charset=utf-8"
    "Cache-Control": "no-cache"
  } """)

rsp_body = APIHelper.json_deserialize( """{
    "Error": "InvalidArgumentException",
    "Message": "Missing field field_a"
  }""")


event_req = EventRequestModel(time = datetime.utcnow() - timedelta(seconds=-1),
    uri = "https://api.acmeinc.com/items/reviews/",
    verb = "PATCH",
    api_version = "1.1.0",
    ip_address = "61.48.220.123",
    headers = req_headers,
    body = req_body)

event_rsp = EventResponseModel(time = datetime.utcnow(),
    status = 500,
    headers = rsp_headers,
    body = rsp_body)

event_a = EventModel(request = event_req,
    response = event_rsp,
    user_id = "my_user_id",
    session_token = "my_application_id")

my_events = [ event_a ]

# Send the actual events
api.create_events_batch(my_events)

require 'moesif_api'

# Setup API Client
client = MoesifApi::MoesifAPIClient.new(my_application_id)
api = client.api_controller

# Create API Event Models and set fields
event_a = EventModel.new()
event_a.user_id = "my user id" #  ...
my_event_models = [ event_a ]

# Send the actual events
api.create_events_batch(my_event_models)

using Moesif.Api;
using Moesif.Api.Helpers;

// Create client instance using your ApplicationId
var client = new MoesifAPIClient("my_application_id");
var apiClient = GetClient().Api;

// Parameters for the API call
var reqHeaders = APIHelper.JsonDeserialize<object>(@" {
        ""Host"": ""api.acmeinc.com"",
        ""Accept"": ""*/*"",
        ""Connection"": ""Keep-Alive"",
        ""User-Agent"": ""Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)"",
        ""Content-Type"": ""application/json"",
        ""Content-Length"": ""126"",
        ""Accept-Encoding"": ""gzip""
    }");

var reqBody = APIHelper.JsonDeserialize<object>(@" {
        ""items"": [
            {
                ""type"": 1,
                ""id"": ""fwfrf""
            },
            {
                ""type"": 2,
                ""id"": ""d43d3f""
            }
        ]
    }");

var rspHeaders = APIHelper.JsonDeserialize<object>(@" {
        ""Date"": ""Tue, 23 Oct 2017 23:46:49 GMT"",
        ""Vary"": ""Accept-Encoding"",
        ""Pragma"": ""no-cache"",
        ""Expires"": ""-1"",
        ""Content-Type"": ""application/json; charset=utf-8"",
        ""Cache-Control"": ""no-cache""
    } ");

var rspBody = APIHelper.JsonDeserialize<object>(@" {
        ""Error"": ""InvalidArgumentException"",
        ""Message"": ""Missing field field_a""
    }");

var reqDate = new Date();
var eventReq = new EventRequestModel()
{
    Time = DateTime.Parse("2017-10-22T04:45:42.914"),
    Uri = "https://api.acmeinc.com/items/reviews/",
    Verb = "PATCH",
    ApiVersion = "1.1.0",
    IpAddress = "61.48.220.123",
    Headers = reqHeaders,
    Body = reqBody
};

var eventRsp = new EventResponseModel()
{
    Time = DateTime.Parse("2017-10-22T04:45:42.914"),
    Status = 500,
    Headers = rspHeaders,
    Body = rspBody
};

var eventModel = new EventModel()
{
    Request = eventReq,
    Response = eventRsp,
    UserId = "my_user_id",
    SessionToken = "my_application_id"
};

// Create a List
var events = new List<EventModel>();
events.Add(eventModel);
events.Add(eventModel);
events.Add(eventModel);

//////////////////////////////////////
// Example for making an async call //  
//////////////////////////////////////
try
{
    await controller.CreateEventsBatchAsync(events);
}
catch(APIException)
{
    // Handle Error
};

///////////////////////////////////////////
// Example for making a synchronous call //
///////////////////////////////////////////
try
{
    controller.CreateEventsBatch(events);
}
catch(APIException)
{
    // Handle Error
};

import "github.com/moesif/moesifapi-go"
import "github.com/moesif/moesifapi-go/models"
import "time"

apiClient := moesifapi.NewAPI("my_application_id")

reqTime := time.Now().UTC()
apiVersion := "1.0"
ipAddress := "61.48.220.123"

req := models.EventRequestModel{
  Time:       &reqTime,
  Uri:        "https://api.acmeinc.com/widgets",
  Verb:       "GET",
  ApiVersion: &apiVersion,
  IpAddress:  &ipAddress,
  Headers: map[string]interface{}{
    "ReqHeader1": "ReqHeaderValue1",
  },
  Body: nil,
}

rspTime := time.Now().UTC().Add(time.Duration(1) * time.Second)

rsp := models.EventResponseModel{
  Time:      &rspTime,
  Status:    500,
  IpAddress: nil,
  Headers: map[string]interface{}{
    "RspHeader1": "RspHeaderValue1",
  },
  Body: map[string]interface{}{
    "Key1": "Value1",
    "Key2": 12,
    "Key3": map[string]interface{}{
      "Key3_1": "SomeValue",
    },
  },
}

sessionToken := "end user API or session token"
userId := "end user_id"

event := models.EventModel{
  Request:      req,
  Response:     rsp,
  SessionToken: &sessionToken,
  Tags:         nil,
  UserId:       &userId,
}

events := make([]*models.EventModel, 20)
for i := 0; i < 20; i++ {
  events[i] = &event
}

// Queue the events
err := apiClient.QueueEvents(events)

// Create the events batch synchronously
err := apiClient.CreateEventsBatch(event)

// Depending on your project setup, you might need to include composer's
// autoloader in your PHP code to enable autoloading of classes.

require_once "vendor/autoload.php";

// Import the SDK client in your project:

use MoesifApi\MoesifApiClient;

// Instantiate the client. After this, you can now access the Moesif API
// and call the respective methods:

$client = new MoesifApiClient("Your application Id");
$api = $client->getApi();
Fields Required? Description
request Required The object that specifies the request message

request.time

Required Timestamp for the request in ISO 8601 format

request.uri

Required Full uri such as https://api.com/?query=string including host, query string, etc

request.verb

Required HTTP method used, i.e. GET, POST

request.api_version

Optional API Version you want to tag this request with such as 1.0.0

request.ip_address

Optional IP address of the requester, If not set, we use the IP address of your logging API calls.

request.headers

Required Headers of the request as a Map<string, string>. Multiple headers with the same key name should be combined together such that the values are joined by a comma. HTTP Header Protocol on w3.org

request.body

Optional Body of the request in JSON format or Base64 encoded binary data (see transfer_encoding)

request.transfer_encoding

Optional A string that specifies the transfer encoding of Body being sent to Moesif. If field nonexistent, body assumed to be JSON or text. Only possible value is base64 for sending binary data like protobuf
response Optional The object that specifies the response message, not set implies no response received such as a timeout.

response.time

Required Timestamp for the response in ISO 8601 format

response.status

Required HTTP status code as number such as 200 or 500

request.ip_address

Optional IP address of the responding server

response.headers

Required Headers of the response as a Map<string, string>. Multiple headers with the same key name should be combined together such that the values are joined by a comma. HTTP Header Protocol on w3.org

response.body

Optional Body of the response in JSON format or Base64 encoded binary data (see transfer_encoding)

response.transfer_encoding

Optional A string that specifies the transfer encoding of Body being sent to Moesif. If field nonexistent, body assumed to be JSON or text. Only possible value is base64 for sending binary data like protobuf
session_token Recommend The end user session token such as a JWT or API key, which may or may not be temporary. Moesif will auto-detect the session token automatically if not set.
user_id Recommend Identifies this API call to a permanent user_id
metadata Optional A JSON Object consisting of any custom metadata to be stored with this event.

Users API

Update a User

POST https://api.moesif.net/v1/users

Updates an end user profile in Moesif.

A custom JSON object can be placed in the metadata object which will be stored as part of the user profile.

If present, Moesif will detect special metadata fields like:

Updating an end user will create one if it does not exist, also know as upsert If a user exists, it will be merged on top of existing fields. Any new field set will override the existing fields. This is done via recursive merge which merges inner objects.

POST https://api.moesif.net/v1/users

Example Request Body:
  {
    "modified_time": "2017-02-22T04:45:42.914",
    "ip_address": "61.48.220.123",
    "session_token": "df32dkj32opxzfdmji4hf4fs98y18cx98q3yhwmnhcfx43f",
    "user_id": "123456",
    "user_agent_string": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
    "metadata": {
      "first_name": "John Doe",
      "last_name": "John Doe",
      "email": "john@gmail.com",
      "phone": "123-456-7890",
      "custom_string_field": "some_value"
      "custom_int_field": 55,
      "custom_obj_field": {
          "sub_a": "value_a",
          "sub_b": "value_b"
      }
    }
  }

// 1. Import the module
var moesifapi = require('moesifapi');
var api = moesifapi.ApiController;

// 2. Configure the ApplicationId
var config = moesifapi.configuration;
config.ApplicationId = "my_application_id";

// 3. Generate a User Model
var user = {
    userId: "my_user_id",
    sessionToken: "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f",
    metadata: {
      email: "johndoe@acmeinc.com",
      string_field: "value_1",
      number_field: 0,
      object_field: {
        field_a: "value_a",
        field_b: "value_b"
      }
    }
};

// 4. Create a single user
api.updateUser(new UserModel(user), function(error, response, context) {
  // Do Something
});
from __future__ import print_function
from moesifapi.moesif_api_client import *
from moesifapi.models import *
from datetime import *

client = MoesifAPIClient(my_application_id)
api = client.api

metadata = APIHelper.json_deserialize("""  {
        "email": "pythonapiuser@email.com",
        "name": "pythonapiuser",
        "custom": "testdata"
    } """)

user_model = EventRequestModel(
    user_id = 'pythonapiuser1',
    modified_time = datetime.utcnow(),
    metadata = metadata)

# Perform the API call through the SDK function
api.update_user(user_model)
client = MoesifApi::MoesifAPIClient.new(my_application_id)
api = client.api

metadata = JSON.parse('{'\
  '"email": "testrubyapi@user.com",'\
  '"name": "ruby api user",'\
  '"custom": "testdata"'\
'}')

user_model = UserModel.new()
user_model.modified_time = Time.now.utc.iso8601  # option, default now.
user_model.user_id = "testrubyapiuser"  #only required field.
user_model.metadata = metadata

response = api.update_user(user_model)
// Depending on your project setup, you might need to include composer's
// autoloader in your PHP code to enable autoloading of classes.

require_once "vendor/autoload.php";

// Import the SDK client in your project:

use MoesifApi\MoesifApiClient;

// Instantiate the client. After this, you can now access the Moesif API
// and call the respective methods:

$client = new MoesifApiClient("Your application Id");
$api = $client->getApi();

$user = new Models\UserModel();

$user->userId = "moesifphpuser";
$user->metadata = [
  "email" => "moesifphp@email.com",
  "name" => "moesif php",
  "custom" => "randomdata"
];

$api->updateUser($user);
MoesifAPIClient client = new MoesifAPIClient("my_application_id");
APIController api = getClient().getAPI();

UserModel user = new UserBuilder()
    .userId("12345")
    .modifiedTime(new Date())
    .ipAddress("29.80.250.240")
    .sessionToken("di3hd982h3fubv3yfd94egf")
    .userAgentString("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36")
    .metadata(APIHelper.deserialize("{" +
        "\"email\": \"johndoe@acmeinc.com\"," +
        "\"string_field\": \"value_1\"," +
        "\"number_field\": 0," +
        "\"object_field\": {" +
          "\"field_1\": \"value_1\"," +
          "\"field_2\": \"value_2\"" +
        "}" +
      "}"))
     .build();

// Asynchronous Call to update user
APICallBack<Object> callBack = new APICallBack<Object>() {
    public void onSuccess(HttpContext context, Object response) {
      // Do something
    }

    public void onFailure(HttpContext context, Throwable error) {
      // Do something else
    }
};

api.updateUserAsync(user, callBack);

// Synchronous Call to update user
api.updateUser(user, callBack);

user_id vs. session_token

Users in Moesif are identified by two attributes: user_id and session_token.

Fields Required? Description
user_id Required Your application’s user_id to identify this user.
modified_time Optional Last Modified Timestamp for the user in ISO 8601 format (Set automatically if not provided).
ip_address Optional Current IP address of the user, If not set, we use the IP address of the POST request.
session_token Optional Current end user session or API token such as a JWT. Setting this field does not remove old session tokens previously stored. Instead, Moesif will append the new value to an alias table for this user_id.
user_agent_string Optional If you want Moesif to parse a user agent string, you can do so via user_agent_string.
metadata Optional A JSON Object consisting of any custom metadata to be stored with this user.

Update Users in Batch

POST https://api.moesif.net/v1/users/batch

Updates a list of end user profile in Moesif.

A custom JSON object can be placed in the metadata object of each user which will be stored as part of the user profile.

If present, Moesif will detect special metadata fields like:

If user does not exist, a new one will be created. If a user exists, it will be merged on top of existing fields. Any new field set will override the existing fields. This is done via recursive merge which merges inner objects.

POST https://api.moesif.net/v1/users/batch

Example Request Body:
  [
    {
      "modified_time": "2017-02-22T04:45:42.914",
      "ip_address": "61.48.220.123",
      "session_token": "df32dkj32opxzfdmji4hf4fs98y18cx98q3yhwmnhcfx43f",
      "user_id": "12345",
      "user_agent_string": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
      "metadata": {
        "first_name": "John Doe",
        "last_name": "John Doe",
        "email": "john@gmail.com",
        "phone": "123-456-7890",
        "custom_string_field": "some_value"
        "custom_int_field": 55,
        "custom_obj_field": {
            "sub_a": "value_a",
            "sub_b": "value_b"
        }
      }
    },
    {
      "modified_time": "2017-02-22T04:45:42.914",
      "ip_address": "61.48.220.129",
      "session_token": "d2ewzcazchurvcqdevnhcuiyrgvru",
      "user_id": "7890",
      "user_agent_string": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
      "metadata": {
        "first_name": "Mary Doe",
        "last_name": "Mary Doe",
        "email": "mary@gmail.com",
        "phone": "123-456-7890",
        "custom_string_field": "some_value"
        "custom_int_field": 55,
        "custom_obj_field": {
            "sub_a": "value_a",
            "sub_b": "value_b"
        }
      }
    }
  ]

var moesifapi = require('moesifapi');
var api = moesifapi.ApiController;

// 2. Configure the ApplicationId
var config = moesifapi.configuration;
config.ApplicationId = "my_application_id";

// 3. Generate an API Event Model
var userA = {
    userId: "12345",
    sessionToken: "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f",
    metadata: {
      email: "johndoe@acmeinc.com",
      string_field: "value_1",
      number_field: 0,
      object_field: {
        field_a: "value_a",
        field_b: "value_b"
      }
    }
};

var userB = {
    userId: "6789",
    sessionToken: "23jdf0oszfexfqe[lwjfiefovprewv4d8ayrcdx8nu2ng]zfeeadedefx43f",
    metadata: {
      email: "maryjane@acmeinc.com",
      string_field: "value_1",
      number_field: 1,
      object_field: {
        field_a: "value_a",
        field_b: "value_b"
      }
    }
};

var users = [new UserModel(userA), new UserModel(userB)];

// 4. Send batch of events
api.updateUsersBatch(users, function(error, response, context) {
  // Do Something
});
MoesifAPIClient client = new MoesifAPIClient("my_application_id");
APIController api = getClient().getAPI();

List<UserModel> users = new ArrayList<UserModel>();

UserModel userA = new UserBuilder()
    .userId("12345")
    .modifiedTime(new Date())
    .ipAddress("29.80.250.240")
    .sessionToken("di3hd982h3fubv3yfd94egf")
    .userAgentString("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36")
    .metadata(APIHelper.deserialize("{" +
        "\"email\": \"johndoe@acmeinc.com\"," +
        "\"string_field\": \"value_1\"," +
        "\"number_field\": 0," +
        "\"object_field\": {" +
          "\"field_1\": \"value_1\"," +
          "\"field_2\": \"value_2\"" +
        "}" +
      "}"))
    .build();
users.add(userA);

UserModel userB = new UserBuilder()
    .userId("56789")
    .modifiedTime(new Date())
    .ipAddress("21.80.11.242")
    .sessionToken("zceadckekvsfgfpsakvnbfouavsdvds")
    .userAgentString("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36")
    .metadata(APIHelper.deserialize("{" +
        "\"email\": \"maryjane@acmeinc.com\"," +
        "\"string_field\": \"value_1\"," +
        "\"number_field\": 1," +
        "\"object_field\": {" +
          "\"field_1\": \"value_1\"," +
          "\"field_2\": \"value_2\"" +
        "}" +
      "}"))
    .build();
users.add(userB);

// Asynchronous call to update users
APICallBack<Object> callBack = new APICallBack<Object>() {
    public void onSuccess(HttpContext context, Object response) {
      // Do something
    }

    public void onFailure(HttpContext context, Throwable error) {
      // Do something else
    }
};

api.updateUsersBatchAsync(users, callBack);


//Synchronous call to update users
api.updateUsersBatch(users, callBack);

user_id vs. session_token

Users in Moesif are identified by two attributes: user_id and session_token.

Fields Required? Description
user_id Required Your application’s user_id to identify this user.
modified_time Optional Last Modified Timestamp for the user in ISO 8601 format (Set automatically if not provided).
ip_address Optional Current IP address of the user, If not set, we use the IP address of the POST request.
session_token Optional Current end user session or API token such as a JWT. Setting this field does not remove old session tokens previously stored. Instead, Moesif will append the new value to an alias table for this user_id.
user_agent_string Optional If you want Moesif to parse a user agent string, you can do so via user_agent_string.
metadata Optional A JSON Object consisting of any custom metadata to be stored with this user.