Export data directly via REST endpoint

Background

In addition to the Mona python SDK, users can leverage a REST endpoint to export their data to Mona. If you are a new user, you will find all the export options on the “Getting Started” page in your dashboard. Under "REST API" will be the userId and the user's designated URL, required to access the API. Aside from the userId and URL, to access Mona's API, first an accessToken must be generated and added to the request.

curl --location --request POST 'https://incoming{YOUR-USER-ID}.monalabs.io/export' \
--header 'Authorization: Bearer YOUR-ACCESS-TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
    "userId": "YOUR-USER-ID",
    "messages": [
            {
                "arcClass": "YOUR-ARC-CLASS",
                "contextId":"CONTEXT",
                "exportTimestamp":TIMESTAMP,
                "message":{YOUR-JSON}
            }
    ]
}'
import requests
import time

url = "https://incoming{YOUR-USER-ID}.monalabs.io/export"

timeStamp = time.time()

payload={
    "userId": "{YOUR-USER-ID}",
    "messages": [
        {
            "arcClass": "YOUR-ARC-CLASS",
            "contextId": "CONTEXT",
            "exportTimestamp": timeStamp,
            "message": {YOUR-JSON}
        }
    ]
}

headers = {
  'Authorization': 'Bearer YOUR-ACCESS-TOKEN',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, json=payload)

print(response.text)

Definition

POST /export

Application JSON payload

  • (required) userId - as provided to you by us.
  • (required) messages - a json array with message object, each with:
    • (required) arcClass - string - As agreed with us to classify the messages.
    • (required) message - json object - a single json of the exported scores/values.
    • (optional) contextId - string - the key used to store the data on our end.
    • (optional) exportTimestamp - int - timestamp (in seconds since epoch) to overwrite
      exported time (e.g. backfill past calls default is current time)

Example

In this example, we assume that the Mona-supplied userId is 1234567890, and that the config expects an arc class - "arcClassName",

In this example we show how to export 3 JSONs in a single message - two of them have a contextId of "ID_123" which Mona will merge together, and one with a different contextId of "ID_124".

{
  "userId": 1234567890,
  "messages": [
    {
      "arcClass": "arcClassName",
      "contextId": "ID_123",
      "message": {
        "company-id": "79sg7723-0253438g3453",
        "browser": "chrome",
        "text_length": 50,
        "top_tagged_brand": "adidas"
      }
    },
    {
      "arcClass": "arcClassName",
      "contextId": "ID_123",
      "message": {
        "coutry": "usa"
      }
    },
    {
      "arcClass": "arcClassName",
      "contextId": "ID_124",
      "message": {
        "company-id": "2435f32-02ve3538g5232",
        "browser": "safari",
        "text_length": 30,
        "top_tagged_brand": "nike"
      }
    }
  ]
}

Did this page help you?