REST Documentation

Last updated: Oct 16th, 2016

Managing Users

Sign Up Example

curl -X POST -H "Content-Type: application/json" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-d '{"firstname":"John", "lastname":"Doe", "email":"valid@email.com", "password":"secretPassword"}' \
https://api.mesosfer.com/api/v2/users

POST https://api.mesosfer.com/api/v2/users
Headers
Name Required Type Value
Content-Type Yes String application/json
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
Contents
Name Required Type Description
firstname Yes String The first name of the user. Length must be between 3 and 64
lastname Yes String The last name of the user. Length must be between 3 and 64
email Yes String The e-mail address of the user. Maximum length is 200
password Yes String The password of the user. Length must be >=4 and <=50 characters
country Optional String Country in 2 characters. Ex: ID
phone Optional String Phone number in string format. Ex: +620000000
metadata Optional Object Additional information in JSON Object, ex: {"birthday": "1970/01/01"}
Sign In Example

curl -X POST -H "Content-Type: application/json" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-d '{"email":"valid@email.com", "password":"secretPassword"}' \
https://api.mesosfer.com/api/v2/users/signin

POST https://api.mesosfer.com/api/v2/users/signin
Headers
Name Required Type Value
Content-Type Yes String application/json
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
Contents
Name Required Type Description
email Yes String The e-mail address of the user. Maximum length is 200
password Yes String The password of the user. Length must be >=4 and <=50 characters
Sign In Body Response

{
  "accessToken": "dMEzJhRbR3exxBsMkqi95Q",
  "expiresIn": 31534510,
  "objectId": "ebC9jv8AUJ",
  "tokenType": "Bearer"
}

Response
Name Description
accessToken The code used for authentication.
expiresIn Token expiration in second.
tokenType Token type, currently only support Bearer.
objectId User unique ID.
Retrieve User Attributes

curl -X GET -H "Content-Type: application/json" \
-H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
https://api.mesosfer.com/api/v2/users/me

GET https://api.mesosfer.com/api/v2/users/me
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
User Attributes Body Response

{
   "result":{
      "accessToken":"B1w1aAGZRo6VyuRvrxZK6Q",
      "country":"ID",
      "expireAt":"2017-10-06T20:54:26.789+07:00",
      "expiresIn":31534510,
      "firstname":"John",
      "lastname":"Doe",
      "metadata":{
         "birthday":"1970/08/03",
         "nickname":"Joe"
      },
      "middlename":"Joe",
      "objectId":"ebC9jv8AUJ",
      "phone":"081232886426",
      "tokenType":"Bearer",
      "validemail":"valid@email.com"
   }
}

Retrieve All Users

curl -X GET -H "Content-Type: application/json" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
https://api.mesosfer.com/api/v2/users

GET https://api.mesosfer.com/api/v2/users
Headers
Name Required Type Value
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
Retrieve All Users Body Response

{
  "results": [
    {
      "createdAt": "2016-11-21T09:36:40.744Z",
      "firstname": "John",
      "lastname": "Doe",
      "objectId": "BD1ynKNzAt",
      "updatedAt": "2016-11-21T09:36:40.909Z",
      "validemail": "john.doe@gmail.com"
    },
    {
      "createdAt": "2016-11-10T05:36:01.286Z",
      "firstname": "mohammad",
      "lastname": "Badrullami",
      "objectId": "SFb2dG4xS5",
      "updatedAt": "2016-11-10T05:36:01.508Z",
      "validemail": "mohammad.badrullami@gmail.com"
    },
    {
      "createdAt": "2016-11-05T04:29:57.409Z",
      "firstname": "Tiyo",
      "lastname": "Avianto",
      "objectId": "hBtaNS5Bwu",
      "updatedAt": "2016-11-05T04:29:57.564Z",
      "validemail": "me@eyro.co.id"
    }
  ]
}

Managing Schema

Create Schema Example

curl -X POST -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-H "Content-Type: application/json" \
-d '{"column":{"message":{"type":"String"}, "title":{"type":"String"}}}' \
https://api.mesosfer.com/api/v2/data/schema/{bucketName}


POST https://api.mesosfer.com/api/v2/data/schema/{bucketName}
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
Content-Type Yes String application/json
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
bucketName Yes String The name of the bucket. Maximum length is 30
Contents
Name Required Type Description
column Yes Array of Object using this format "fieldName" : { "type": "String" }
Currently type of Number, String, Date and Boolean is supported.
Create Schema Body Response Example

{
    "result":{
        "createdAt":"2016-10-04T03:55:51.149Z",
        "objectId":"OXjGaDMuGu"
    }
}

Retrieve a Schema

curl -X GET -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
https://api.mesosfer.com/api/v2/data/schema/{bucketName}/{objectId}

GET https://api.mesosfer.com/api/v2/data/schema/{bucketName}/{objectId}
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
bucketName Yes String The name of the bucket. Maximum length is 30
objectId Yes String Data objectId
Retrieve a Data Body Response

{
    "result":{
        "objectId":"RBvzeUDK8B",
        "metadata":{
                "message":"Hello Mesosfer",
                "title":"Greeting"
        },
        "createdAt":"2016-10-03T13:43:11.840Z",
        "updatedAt":"2016-10-03T13:43:11.840Z"
    }
}

Response
Name Description
objectId Generate automatically from system
metadata Data that send from users
createdAt Object created in ISO Format
updatedAt Object updated in ISO Format
Querying Schema

curl -X GET -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-G \
--data-urlencode 'order=-updatedAt' \
--data-urlencode 'limit=100' \
https://api.mesosfer.com/api/v2/data/schema

GET https://api.mesosfer.com/api/v2/data/schema/{bucketName}
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
bucketName Yes String The name of the bucket. Maximum length is 30
Query Params
Name Required Description
where Optional Used for constraining the value for keys, see where parameters below.
order Optional Sort by ascending or descending.
Ex: 'order=-createdAt' use to get descending query results
skip Optional Use with limit to paginate through results
limit Optional Limit the number of objects returned by the query
count Optional Counting data without getting the data, set count=1 and limit=0.
Where Parameters
Key Operation Syntax
$lt Less Than { key : { $lt : value} }
$lte Less Than Or Equal To { key : { $lte : value} }
$gt Greater Than { key : { $gt : value} }
$gte Greater Than Or Equal To { key : { $gte : value} }
$ne Not Equal To { key : { $ne : value} }
$in Contained In { key : { $in : [ array of value] } }
$nin Not Contained in { key : { $nin : [ array of value] } }
$regex Requires that a key's value match a regular expression { key : { $regex : value} }
Querying Schema Body Response

{
   "results":[
      {
         "createdAt":"2016-10-03T13:43:02.860Z",
         "metadata":{
            "message":"Hello Mesosfer",
            "title":"Greeting"
         },
         "objectId":"fchIRRNEMW",
         "updatedAt":"2016-10-03T14:36:18.833Z"
      }
   ]
}

Update a Data

curl -X PUT -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-H "Content-Type: application/json" \
https://api.mesosfer.com/api/v2/data/schema/{bucketName}/{objectId}

PUT https://api.mesosfer.com/api/v2/data/schema/{bucketName}/{objectId}
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
bucketName Yes String The name of the bucket. Maximum length is 30
objectId Yes String The object ID of the data.
Update a data Body Response

{
   "result":[
      {
         "updatedAt":"2016-10-03T14:36:18.833Z"
      }
   ]
}

Delete a Data

curl -X DELETE -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-H "Content-Type: application/json" \
https://api.mesosfer.com/api/v2/data/schema/{bucketName}/{objectId}

DELETE https://api.mesosfer.com/api/v2/data/schema/{bucketName}/{objectId}
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
objectId Yes String The object ID of the data.
bucketName Yes String The name of the bucket. Maximum length is 30
Delete a data Body Response

{
   "result":[{}]
}

Managing Data

Informations

Before sending data to bucket, you must create bucket in cloud.mesosfer.com

Send Data to Bucket Example

curl -X POST -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-H "Content-Type: application/json" \
-d '{"metadata": {"title": "Greeting","message": "Hello Mesosfer"}}' \
https://api.mesosfer.com/api/v2/data/bucket/{bucketName}

POST https://api.mesosfer.com/api/v2/data/bucket/{bucketName}
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
Content-Type Yes String application/json
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
bucketName Yes String The name of the bucket. Maximum length is 30
Contents
Name Required Type Description
metadata Yes Object JSON Object
Push Data Body Response Example

{
    "result":{
        "createdAt":"2016-10-04T03:55:51.149Z",
        "objectId":"OXjGaDMuGu"
    }
}

Retrieve a Bucket Data

curl -X GET -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
https://api.mesosfer.com/api/v2/data/bucket/{bucketName}/{objectId}

GET https://api.mesosfer.com/api/v2/data/bucket/{bucketName}/{objectId}
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
bucketName Yes String The name of the bucket. Maximum length is 30
objectId Yes String Data objectId
Retrieve a Data Body Response

{
    "result":{
        "objectId":"RBvzeUDK8B",
        "metadata":{
                "message":"Hello Mesosfer",
                "title":"Greeting"
        },
        "createdAt":"2016-10-03T13:43:11.840Z",
        "updatedAt":"2016-10-03T13:43:11.840Z"
    }
}

Response
Name Description
objectId Generate automatically from system
metadata Data that send from users
createdAt Object created in ISO Format
updatedAt Object updated in ISO Format
Querying Data

curl -X GET -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-G \
--data-urlencode 'where={"metadata.message":"Hello Mesosfer"}' \
--data-urlencode 'order=-updatedAt' \
--data-urlencode 'limit=100' \
https://api.mesosfer.com/api/v2/data/bucket/{bucketName}


GET https://api.mesosfer.com/api/v2/data/bucket/{bucketName}
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
bucketName Yes String The name of the bucket. Maximum length is 30
Query Params
Name Required Description
where Optional Used for constraining the value for keys, see where parameters below.
order Optional Sort by ascending or descending.
Ex: 'order=-createdAt' use to get descending query results
skip Optional Use with limit to paginate through results
limit Optional Limit the number of objects returned by the query
count Optional Counting data without getting the data, set count=1 and limit=0.
Where Parameters
Key Operation Syntax
$lt Less Than { key : { $lt : value} }
$lte Less Than Or Equal To { key : { $lte : value} }
$gt Greater Than { key : { $gt : value} }
$gte Greater Than Or Equal To { key : { $gte : value} }
$ne Not Equal To { key : { $ne : value} }
$in Contained In { key : { $in : [ array of value] } }
$nin Not Contained in { key : { $nin : [ array of value] } }
$regex Requires that a key's value match a regular expression { key : { $regex : value} }
Combination $lt and $gt Parameters

Example query below to get salary from bucket that greater than 2000 and less than 8000

curl -X GET -H "Authorization: Bearer {accessToken}" \ -H "X-Mesosfer-AppId: {AppId}" \ -H "X-Mesosfer-AppKey: {AppKey}" \ -G \ --data-urlencode 'where={"salary":{"$gt":2000,"$lt":8000}}' https://api.mesosfer.com/api/v2/data/bucket/{bucketName}
Querying Data Using $in/$nin Parameter

Example query below to get salary from bucket that has 2000, 2500, 3000 in value

curl -X GET -H "Authorization: Bearer {accessToken}" \ -H "X-Mesosfer-AppId: {AppId}" \ -H "X-Mesosfer-AppKey: {AppKey}" \ -G \ --data-urlencode 'where={"salary":{"$in":[2000,2500,3000]}}' \ https://api.mesosfer.com/api/v2/data/bucket/{bucketName}

Example query below to get salary from bucket that doesn't have 2000, 2500, 3000 in value

curl -X GET -H "Authorization: Bearer {accessToken}" \ -H "X-Mesosfer-AppId: {AppId}" \ -H "X-Mesosfer-AppKey: {AppKey}" \ -G \ --data-urlencode 'where={"salary":{"$nin":[2000,2500,3000]}}' \ https://api.mesosfer.com/api/v2/data/bucket/{bucketName}
Querying Data Using AND or OR or Both

Example query below to get salary from bucket that has 2000, 2500, 3000 in value
OR message equals to Hello Mesosfer

curl -X GET -H "Authorization: Bearer {accessToken}" \ -H "X-Mesosfer-AppId: {AppId}" \ -H "X-Mesosfer-AppKey: {AppKey}" \ -G \ --data-urlencode 'where={"$or":["salary":{"$in":[2000,2500,3000]},"message":{"Hello Mesosfer"}] }' \ --data-urlencode 'order=-updatedAt' \ --data-urlencode 'limit=100' \ https://api.mesosfer.com/api/v2/data/bucket/{bucketName}

Example query below to get title equals to 'Greeting' AND salary from bucket that has 2000, 2500, 3000 in value
OR message equals to 'Hello Mesosfer'

curl -X GET -H "Authorization: Bearer {accessToken}" \ -H "X-Mesosfer-AppId: {AppId}" \ -H "X-Mesosfer-AppKey: {AppKey}" \ -G \ --data-urlencode 'where={"title": "Greeting", "$or":["salary":{"$in":[2000,2500,3000]},"message":{"Hello Mesosfer"}] }' \ --data-urlencode 'order=-updatedAt' \ --data-urlencode 'limit=100' \ https://api.mesosfer.com/api/v2/data/bucket/{bucketName}
Counting Result

Example query below to count result that title equals to 'Greeting' AND salary from bucket that has 2000, 2500, 3000 in value
OR message equals to 'Hello Mesosfer'

curl -X GET -H "Authorization: Bearer {accessToken}" \ -H "X-Mesosfer-AppId: {AppId}" \ -H "X-Mesosfer-AppKey: {AppKey}" \ -G \ --data-urlencode 'where={"title": "Greeting", "$or":["salary":{"$in":[2000,2500,3000]},"message":{"Hello Mesosfer"}] }' \ --data-urlencode 'limit=0' \ --data-urlencode 'count=1' \ https://api.mesosfer.com/api/v2/data/bucket/{bucketName}
Querying Data Body Response

{
   "results":[
      {
         "createdAt":"2016-10-03T13:43:02.860Z",
         "metadata":{
            "message":"Hello Mesosfer",
            "title":"Greeting",
            "salary": 2000
         },
         "objectId":"fchIRRNEMW",
         "updatedAt":"2016-10-03T14:36:18.833Z"
      }
   ]
}

Update a Data

curl -X PUT -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-H "Content-Type: application/json" \
-d '{"title": "Greeting","message": "Hello Cloud Mesosfer"}' \
https://api.mesosfer.com/api/v2/data/bucket/{bucketName}/{objectId}

PUT https://api.mesosfer.com/api/v2/data/bucket/{bucketName}/{objectId}
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
bucketName Yes String The name of the bucket. Maximum length is 30
objectId Yes String The object ID of the data.
Update a data Body Response

{
   "result":[
      {
         "updatedAt":"2016-10-03T14:36:18.833Z"
      }
   ]
}

Delete a Data

curl -X DELETE -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-H "Content-Type: application/json" \
https://api.mesosfer.com/api/v2/data/bucket/{bucketName}/{objectId}

DELETE https://api.mesosfer.com/api/v2/data/bucket/{bucketName}/{objectId}
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
bucketName Yes String The name of the bucket. Maximum length is 30
objectId Yes String The object ID of the data.
Delete a data Body Response

{
   "result":[{}]
}

Push Notification

Push notifications is a great way to keep your users engaged and informed about your app. You can reach your entire user base quickly and effectively. This guide will help you through the setup process and the general usage of Mesosfer to send push notifications. There are two method to send push notification : Everyone and Custom Audience. When you choose custom audience you can filter user that you want by using filter query field on class Installation.

Send to Everyone

curl -X POST -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-H "Content-Type: application/json" \
-d '{"data":{"title": "Hi", "alert": "Thanks for coming."}}' \
https://api.mesosfer.com/api/v2/push/notification

POST https://api.mesosfer.com/api/v2/push/notification
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
Send Push Body Response

{
  "result": {
    "result": true
  }
}

Send to Custom Audience

curl -X POST -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-H "Content-Type: application/json" \
-d '{"where":{"objectId":"0e7iVHGhza"},"data":{"title": "Hi", "alert": "Thanks for coming."}}' \
https://api.mesosfer.com/api/v2/push/notification

POST https://api.mesosfer.com/api/v2/push/notification
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
Send Push Body Response

{
  "result": {
    "result": true
  }
}

Managing Devices

Register a device

curl -v -X POST -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-H "Content-Type: application/json" \
-d '{"deviceName": "DeviceOne","manufacture": "DeviceManufacture", "topic": "channel1"}' \
https://api.mesosfer.com/api/v2/device

POST https://api.mesosfer.com/api/v2/device
Headers
Name Required Type Value
Content-Type Yes String application/json
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
Contents
Name Required Type Description
deviceName Yes String The name of the device. Length must be between 3 and 64
manufacture Yes String The name of the device manufacture. Length must be between 3 and 64
topic Yes String The name of published topic. Length must be between 3 and 64
Retrieve a device

curl -X GET -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
https://api.mesosfer.com/api/v2/device/{objectId}

GET https://api.mesosfer.com/api/v2/device/{objectId}
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
objectId Yes String Data objectId
Retrieve a device body response

{
    "result":{
        "objectId":"RBvzeUDK8B",
        "createdAt":"2016-10-03T13:43:11.840Z",
        "updatedAt":"2016-10-03T13:43:11.840Z"
    }
}

Response
Name Description
objectId Generate automatically from system
createdAt Object created in ISO Format
updatedAt Object updated in ISO Format
Querying Device

curl -X GET -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-G \
--data-urlencode 'order=-updatedAt' \
--data-urlencode 'limit=100' \
https://api.mesosfer.com/api/v2/device

GET https://api.mesosfer.com/api/v2/device
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
Query Params
Name Required Description
where Optional Used for constraining the value for keys, see where parameters below.
order Optional Sort by ascending or descending.
Ex: 'order=-createdAt' use to get descending query results
skip Optional Use with limit to paginate through results
limit Optional Limit the number of objects returned by the query
count Optional Counting data without getting the data, set count=1 and limit=0.
Where Parameters
Key Operation Syntax
$lt Less Than { key : { $lt : value} }
$lte Less Than Or Equal To { key : { $lte : value} }
$gt Greater Than { key : { $gt : value} }
$gte Greater Than Or Equal To { key : { $gte : value} }
$ne Not Equal To { key : { $ne : value} }
$in Contained In { key : { $in : [ array of value] } }
$nin Not Contained in { key : { $nin : [ array of value] } }
$regex Requires that a key's value match a regular expression { key : { $regex : value} }
Querying Device Body Response

{
   "results":[
      {
         "createdAt":"2016-10-03T13:43:02.860Z",
         "objectId":"fchIRRNEMW",
         "updatedAt":"2016-10-03T14:36:18.833Z"
      }
   ]
}

Update a device

curl -X PUT -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-H "Content-Type: application/json" \
https://api.mesosfer.com/api/v2/device/{objectId}

PUT https://api.mesosfer.com/api/v2/device/{objectId}
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
objectId Yes String The object ID of the data.
Update a device Body Response

{
   "result":[
      {
         "updatedAt":"2016-10-03T14:36:18.833Z"
      }
   ]
}

Delete a device

curl -X DELETE -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-H "Content-Type: application/json" \
https://api.mesosfer.com/api/v2/device/{objectId}

DELETE https://api.mesosfer.com/api/v2/device/{objectId}
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
objectId Yes String The object ID of the data.
Delete a data Body Response

{
   "result":[{}]
}

Managing Files

Upload File

curl -v -X POST -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-H "Content-Type: {mimetype of file}" \
--data-binary '@fullpath of file' \
https://api.mesosfer.com/api/v2/files/{filename}

Example

curl -v -X POST -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-H "Content-Type: image/jpg" \
--data-binary '@/Users/Eyro/Desktop/abcdef.png' \
https://api.mesosfer.com/api/v2/files/abcdef.png


POST https://api.mesosfer.com/api/v2/files/{filename}
Headers
Name Required Type Value
Content-Type Yes String Mime type of file
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
filename Yes String The name file with extension.
Contents
Name Required Type Description
data binary Yes File data binary of file
Upload File body response

{
    "objectId":"e5oJsNqFSI",
    "name":"42V69Gh5LYGAFRpX_abcdef.png",
    "url":"https://mesosfer-files.s3.amazonaws.com/oOl9hdn1Wd/LkMzGGHjl1/42V69Gh5LYGAFRpX_abcdef.png"
}

Delete File

curl -X DELETE -H "Authorization: Bearer {accessToken}" \
-H "X-Mesosfer-AppId: {AppId}" \
-H "X-Mesosfer-AppKey: {AppKey}" \
-H "Content-Type: application/json" \
https://api.mesosfer.com/api/v2/files/{objectId}

DELETE https://api.mesosfer.com/api/v2/files/{objectId}
Headers
Name Required Type Value
Authorization Yes String Bearer {accessToken}
X-Mesosfer-AppId Yes String Get Application ID from cloud.mesosfer.com
X-Mesosfer-AppKey Yes String Get Application Key from cloud.mesosfer.com
URL Params
Name Required Type Description
objectId Yes String The object ID of the data.
Delete a data Body Response

{
   "result":[{}]
}

Error Codes

Related to Apps
Name HTTP Status Code Error Code Description
CredentialsMissing 400 902 The AppId or AppKey is required.
InvalidCredentials 404 903 The request is using an invalid AppId or AppKey.
APICallLimit 429 904 API Call
Related to Users
Name HTTP Status Code Error Code Description
UserInvalidLoginParams 404 101 Invalid login parameters.
ObjectNotFound 404 101 The specified object doesn’t exist or could not be found.
UsernameMissing 400 200 The username is missing or empty.
PasswordMissing 400 201 The password is missing or empty.
UsernameTaken 400 202 The username has already been taken.
UserEmailTaken 400 203 Email has already been used.
UserEmailMissing 400 204 The email is missing, and must be specified.
InvalidSessionToken 403 209 The access token is no longer valid.
InvalidFirstName 400 210 The firstname is missing, and must be specified.
InvalidLastName 400 211 The lastname is missing, and must be specified.
InvalidMiddleName 400 212 The middlename must be specified.
InvalidCountry 400 213 The country must be specified.
InvalidPhone 400 214 The phone must be specified.
Related to Schema
Name HTTP Status Code Error Code Description
InvalidBucketName 400 301 The bucketName must be specified.
Related to Bucket
Name HTTP Status Code Error Code Description
InvalidSchema 400 302 The schema must be specified.
Related to Bucket
Name HTTP Status Code Error Code Description
deviceName 400 302 The schema must be specified.