This api call creates a new session in the database.

If a UUID is supplied, any existing session with that UUID is deleted first. Otherwise, if no UUID is supplied One is created.

This api call accepts the following content-types:

  • application/json : The request body is interpreted as a JSON document. File attachments are not supported.
  • multipart/form-data : The request is interpreted as a standard web form post. File attachments are supported.
  • application/x-www-form-urlencoded: The request is interpretted as a form post. File attachments are supported.

For the form request types, attachments can be uploaded to the database at the same time as uploaded the session. The attachments must be in the correct field names to be recognised, as detailed below.

The request is expected to contain a structured document as follows:

JSON example:

{
  "session":{
    "uuid" : "12341234-12341234-1234-1234-123412341234",
    "unit_id" : "mydevice",
    "created" : 1234567890,
    "saved" : 1234567890,
    "data" : {
      "point1" : "value1",
      "point2" : "value2",
      "sketch1" : { "rawData" : "base-64-data-goes-here" }
    }
  }
}

For a form post the fields would be named:

session[uuid]=12341234-12341234-1234-1234-123412341234
session[unit_id]=mydevice
session[created]=1234567890
session[saved]=1234567890
session[data][point1]=value1
session[data][point2]=value2
session[data][sketch1][rawData]=base-64-data-goes-here==
session[data][__timezone__]=36000

A successful call will return a JSON response with the session data in the result.

Params

Param name Description
project_id
required

The project ID number

Validations:

  • Must be a Integer

session[uuid]
optional

The UUID for the session. A random UUID will be created if none is supplied.

Validations:

  • Must be a String

session[unit_id]
required

The UnitID for the device that created the session.

Validations:

  • Must be a String

session[created]
optional

The unix timestamp for when the session was created. Defaults to the current time if not supplied

Validations:

  • Must be a Integer

session[saved]
optional

The unix timestamp for when the session was saved. Defaults to the current time if not supplied

Validations:

  • Must be a Integer

session[data][<point_name>]
optional

The value for the point given by point_name. This can be a scalar value (string) or a hash with a rawData key for any small amount of embedded binary data. For attachments, this field will be an file uploaded in a mutipart form post.

Validations:

  • Must be a String