# Project controller (/project) - Write

The project controller contains many endpoints related to projects, which is where all data is stored. The endpoints are divided in five groups:

  • General
    Get information about available projects and tables within projects, and run a basic check of access and system status.

  • Users
    Manage users that are members of a project.

  • Read
    Read user data from tables.

  • Write
    Create, update or delete user data in tables.

  • Watch
    Watch for changes of user data in tables, and for changes of project members.

# All project endpoints

Below are all endpoints in the entire project controller in alphabetical order. Endpoints in the current group are in bold.

/project/list (GET)
/project/list/all (GET)
/project/{project}/check (GET)
/project/{project}/subjects/watch/register (POST)
/project/{project}/subjects/watch/unregister/{id} (POST)
/project/{project}/subjects/watch/{id} (GET)
/project/{project}/table/{table} (GET)
/project/{project}/table/{table} (POST)
/project/{project}/table/{table} (DELETE)
/project/{project}/table/{table}/filter/delete (POST)
/project/{project}/table/{table}/filter/get (POST)
/project/{project}/table/{table}/filter/get/first (POST)
/project/{project}/table/{table}/filter/get/last (POST)
/project/{project}/table/{table}/first (GET)
/project/{project}/table/{table}/last (GET)
/project/{project}/table/{table}/purge (DELETE)
/project/{project}/table/{table}/spec (GET)
/project/{project}/table/{table}/watch/register (POST)
/project/{project}/table/{table}/watch/unregister/{id} (POST)
/project/{project}/table/{table}/watch/{id} (GET)
/project/{project}/table/{table}/{recordId} (GET)
/project/{project}/table/{table}/{recordId} (PUT)
/project/{project}/table/{table}/{recordId} (DELETE)
/project/{project}/tables (GET)
/project/{project}/user (POST)
/project/{project}/user (DELETE)
/project/{project}/users (GET)

# /{project}/table/{table} (POST)

/project/{project}/table/{table} POST
Description
Inserts records into the specified table in a project.
Authorization
Users need to have access to the specified project. Admins can access all projects.
All users can access their own data within a project that they can access, and data to which they were granted access with

/access/project/{project}

.
Patients can only access their own data.
Professionals can access the data of users to whom they were granted access.
Admins can access all data.
URL parameters
{project}
Project code (see

/project/list

)
{table}
Name of the table (see

/project/{project}/tables

)
user
(optional) User ID of the user whose data you are writing. Omit or leave empty to write your own data.
Content (application/json)
JSON array with records. Each record is a JSON object that must match the data type for the specified table. The following properties are treated specially:
id
This can be specified but will be ignored.
user
If specified, it must be the same as URL parameter ‘user’.
For tables with a local time:
localTime
Local time, formatted as 2015-09-20T00:00:00.000. This must be specified.
For tables with a UTC time:
timezone
Time zone as a location-based identifier from the tz database. For example: Europe/Amsterdam. If not specified, it defaults to the time zone from the user profile. If that is not specified either, it defaults to the time zone of the server.
utcTime
UNIX time in milliseconds. If both utcTime and localTime are specified, their values must match. If neither are specified, they default to the current time in the specified (or default) time zone.
localTime
Local time, formatted as 2015-09-20T00:00:00.000. If both utcTime and localTime are specified, their values must match. If neither are specified, they default to the current time in the specified (or default) time zone.
Any errors in the content will result in 400 Bad Request with error code INVALID_INPUT.
Response
JSON array with the IDs of the inserted records. Each ID is a UUID string.
Example
Request
POST https://www.example.com/servlets/senseeact/v6.1.0/project/default/table/steps
    ?user=b43f784d76c44e7a9ae0370b91521753
X-Auth-Token: ...
 
[
    {
        "id": "69a4588f14ba4c989e83dd67ea6e4350",
        "user": "b43f784d76c44e7a9ae0370b91521753",
        "timezone": "Europe/Amsterdam",
        "utcTime": 1442736900000,
        "localTime": "2015-09-20T10:15:00.000",
        "value": 947
    },
    {
        "timezone": "Europe/Amsterdam",
        "localTime": "2015-09-20T10:20:00.000",
        "value": 104
    },
    ...
]
Response
[
    "69a4588f14ba4c989e83dd67ea6e4350",
    "399c9c4ed74a49c0a9d0632bc51fe638",
    ...
]

# /{project}/table/{table}/{recordId} (PUT)

/project/{project}/table/{table}/{recordId} PUT
Description
Updates an existing record in the specified table in a project. If the record does not exist, the endpoint will result in 404 Not Found.
Authorization
Users need to have access to the specified project. Admins can access all projects.
All users can access their own data within a project that they can access, and data to which they were granted access with

/access/project/{project}

.
Patients can only access their own data.
Professionals can access the data of users to whom they were granted access.
Admins can access all data.
URL parameters
{project}
Project code (see

/project/list

)
{table}
Name of the table (see

/project/{project}/tables

)
{recordId}
The ID of the record to update
user
(optional) User ID of the user that the record belongs to. If the record belongs to yourself, you can omit this field or leave it empty.
Content (application/json)
The record as a JSON object. It must match the data type for the specified table. You should specify all data fields, not only the fields that you are changing. If you omit any fields, they will be set to their default value (for example null). The following fields are treated specially:
id
If specified, it must be the same as URL parameter ‘{recordId}’. You may omit this field.
user
If specified, it must be the same as URL parameter ‘user’. You may omit this field.
For tables with a local time:
localTime
Local time, formatted as 2015-09-20T00:00:00.000. This must be specified.
For tables with a UTC time:
timezone
Time zone as a location-based identifier from the tz database. For example: Europe/Amsterdam. If not specified, it defaults to the time zone from the user profile. If that is not specified either, it defaults to the time zone of the server.
utcTime
UNIX time in milliseconds. If both utcTime and localTime are specified, their values must match. If neither are specified, they default to the current time in the specified (or default) time zone.
localTime
Local time, formatted as 2015-09-20T00:00:00.000. If both utcTime and localTime are specified, their values must match. If neither are specified, they default to the current time in the specified (or default) time zone.
Any errors in the content will result in 400 Bad Request with error code INVALID_INPUT.
Response
Example
Request
PUT https://www.example.com/servlets/senseeact/v6.1.0/project/default/table/steps
    /69a4588f14ba4c989e83dd67ea6e4350?user=b43f784d76c44e7a9ae0370b91521753
X-Auth-Token: ...
 
{
    "id": "69a4588f14ba4c989e83dd67ea6e4350",
    "user": "b43f784d76c44e7a9ae0370b91521753",
    "timezone": "Europe/Amsterdam",
    "utcTime": 1442736900000,
    "localTime": "2015-09-20T10:15:00.000",
    "value": 947
}
Response

# /{project}/table/{table} (DELETE)

/project/{project}/table/{table} DELETE
Description
Deletes records from the specified table in a project. If the table has a field “utcTime” or “localTime”, you can delete records within a specified time range or date range. Otherwise this endpoint deletes all records for the specified subject.

You can specify a date/time as:

  • An ISO date/time with a time zone: 2015-09-20T00:00:00.000+02:00
    It will filter on “utcTime” if it exists. Otherwise it filters on “localTime” and ignores the time zone.
  • An ISO date/time without a time zone: 2015-09-20T00:00:00.000
    It will filter on “localTime”.
  • A date: 2015-09-20
    It will filter on “localTime”.
  • A UNIX time in milliseconds: 1442700000000
    It will filter on “utcTime” if it exists. Otherwise it will convert the unix time to a local time in time zone UTC, and then filter on “localTime”.

If the table does not have a time field, then the start and end parameters are ignored.

Authorization
Users need to have access to the specified project. Admins can access all projects.
All users can access their own data within a project that they can access, and data to which they were granted access with

/access/project/{project}

.
Patients can only access their own data.
Professionals can access the data of users to whom they were granted access.
Admins can access all data.
URL parameters
{project}
Project code (see

/project/list

)
{table}
Name of the table (see

/project/{project}/tables

)
user
(optional) User ID of the user whose data should be deleted. Omit or leave empty to delete your own data.
start
(optional) Start date/time of the records to delete (inclusive). Omit or leave empty to delete data from the start.
end
(optional) End date/time of the records to delete (exclusive). Omit or leave empty to delete data till the end.
Content
Response
Example
Request (filter by time on utcTime)
DELETE https://www.example.com/servlets/senseeact/v6.1.0/project/default/table/steps
    ?user=b43f784d76c44e7a9ae0370b91521753
    &start=2015-09-20T00:00:00.000+02:00
    &end=2015-09-21T00:00:00.000+02:00
X-Auth-Token: ...
Request (filter by time on localTime)
DELETE https://www.example.com/servlets/senseeact/v6.1.0/project/default/table/steps
    ?user=b43f784d76c44e7a9ae0370b91521753
    &start=2015-09-20T00:00:00.000
    &end=2015-09-21T00:00:00.000
X-Auth-Token: ...
Request (filter by date on localTime)
DELETE https://www.example.com/servlets/senseeact/v6.1.0/project/default/table/steps
    ?user=b43f784d76c44e7a9ae0370b91521753
    &start=2015-09-20
    &end=2015-09-21
X-Auth-Token: ...
Response

# /{project}/table/{table}/filter/delete

/project/{project}/table/{table}/filter/delete POST
Description
Deletes records from the specified table in a project. If the table has a field “utcTime” or “localTime”, you can delete records within a specified time range or date range. In contrast to

/project/{project}/table/{table}

, this endpoint can take a custom filter on other fields than user or time in the request content. If you do not specify a time range or filter, then this endpoint deletes all records for the specified subject.

You can specify a date/time as:

  • An ISO date/time with a time zone: 2015-09-20T00:00:00.000+02:00
    It will filter on “utcTime” if it exists. Otherwise it filters on “localTime” and ignores the time zone.
  • An ISO date/time without a time zone: 2015-09-20T00:00:00.000
    It will filter on “localTime”.
  • A date: 2015-09-20
    It will filter on “localTime”.
  • A UNIX time in milliseconds: 1442700000000
    It will filter on “utcTime” if it exists. Otherwise it will convert the unix time to a local time in time zone UTC, and then filter on “localTime”.

If the table does not have a time field, then the start and end parameters are ignored.

Authorization
Users need to have access to the specified project. Admins can access all projects.
All users can access their own data within a project that they can access, and data to which they were granted access with

/access/project/{project}

.
Patients can only access their own data.
Professionals can access the data of users to whom they were granted access.
Admins can access all data.
URL parameters
{project}
Project code (see

/project/list

)
{table}
Name of the table (see

/project/{project}/tables

)
user
(optional) User ID of the user whose data should be deleted. Omit or leave empty to delete your own data.
start
(optional) Start date/time of the records to delete (inclusive). Omit or leave empty to delete data from the start.
end
(optional) End date/time of the records to delete (exclusive). Omit or leave empty to delete data till the end.
Content
The content can be empty or a JSON object with property ‘filter’. Its value is a filter object (see below). It can also be omitted or set to null.

A filter is a JSON object with one key/value pair. Possible keys:

$and
JSON list with filters
$or
JSON list with filters
<field name>
a value filter (see below)
A value filter for equality is a simple string or numeric value (matching the field type).
A value filter for other comparisons is a JSON object with one key/value pair. The value is again a simple string or numeric value. The key is one of:
$ne
not equal
$lt
less than
$gt
greater than
$le
less or equal
$ge
greater or equal
Response (application/json)
Example
Request (filter by time on utcTime)
POST https://www.example.com/servlets/senseeact/v6.1.0/project/default/table/steps/filter/delete
    ?user=b43f784d76c44e7a9ae0370b91521753
    &start=2015-09-20T00:00:00.000+02:00
    &end=2015-09-21T00:00:00.000+02:00
X-Auth-Token: ...
 
{
    "filter": {
        "$and": [
            { "field1": "value1" },
            { "field2": { "$ne": 2 } },
            { "$or": [
                { "field3": "value3" },
                { "field4": { "$lt": 4 } }
            ] }
        ]
    }
}
Request (filter by time on localTime)
POST https://www.example.com/servlets/senseeact/v6.1.0/project/default/table/steps/filter/delete
    ?user=b43f784d76c44e7a9ae0370b91521753
    &start=2015-09-20T00:00:00.000
    &end=2015-09-21T00:00:00.000
X-Auth-Token: ...
 
...
Request (filter by date on localTime)
POST https://www.example.com/servlets/senseeact/v6.1.0/project/default/table/steps/filter/delete
    ?user=b43f784d76c44e7a9ae0370b91521753
    &start=2015-09-20
    &end=2015-09-21
X-Auth-Token: ...
 
...
Response

# /{project}/table/{table}/{recordId} (DELETE)

/project/{project}/table/{table}/{recordId} DELETE
Description
Deletes a record from the specified table in a project. If the record does not exist, this endpoint has no effect.
Authorization
Users need to have access to the specified project. Admins can access all projects.
All users can access their own data within a project that they can access, and data to which they were granted access with

/access/project/{project}

.
Patients can only access their own data.
Professionals can access the data of users to whom they were granted access.
Admins can access all data.
URL parameters
{project}
Project code (see

/project/list

)
{table}
Name of the table (see

/project/{project}/tables

)
{recordId}
The ID of the record to delete
user
(optional) User ID of the user that the record belongs to. If the record belongs to yourself, you can omit this field or leave it empty.
Content
Response
Example
Request
DELETE https://www.example.com/servlets/senseeact/v6.1.0/project/default/table/steps
    /69a4588f14ba4c989e83dd67ea6e4350
    ?user=b43f784d76c44e7a9ae0370b91521753
X-Auth-Token: ...
Response

# /{project}/table/{table}/purge

/project/{project}/table/{table}/purge DELETE
Description
Purges all records for a user from the specified table in a project. This function also deletes database actions and synchronization progress. It should only be used for maintenance. Normally you can delete records with

/project/{project}/table/{table}

, which creates delete actions in the action table.
Authorization
Users need to have access to the specified project. Admins can access all projects.
All users can access their own data within a project that they can access.
Patients can only access their own data.
Professionals can access the data of users to whom they were granted access.
Admins can access all data.
URL parameters
{project}
Project code (see

/project/list

)
{table}
Name of the table (see

/project/{project}/tables

)
user
(optional) User ID of the user whose data should be deleted. Omit or leave empty to delete your own data.
Content
Response (application/json)
Example
Request
DELETE https://www.example.com/servlets/senseeact/v6.1.0/project/default/table/steps/purge
    ?user=b43f784d76c44e7a9ae0370b91521753
X-Auth-Token: ...
Response