Skip to content
  • There are no suggestions because the search field is empty.

Editing User Data Using the API

This use case covers using the WISEflow API to get, edit, and delete user data. It does not cover how to find the userId, which is described in this article.

This use case is ideal for institutions relying on the WISEflow API and has built their own middleware to control key aspects of WISEflow.

Editing user data using the API requires that a user has at least one unique ID that can be used to match up against all other WISEflow users.

Get User Data

With the userId as the parameter to identify the user, the GET /users/{userId}/user-data endpoint will return:

{
  "success": true,
  "data": [
    {
      "userDataId": 564,
      "userDataTypeId": 12,
      "description": "unicId",
      "metaTypeName": "UNIC Id",
      "value": "1"
    }
  ],
  "error": null
}

Using this data, you can identify the userDataId, the userDataTypeId and any descriptions and values that are used to tell the user data apart. If a user has more than one type of user data, this will also be displayed in the same response.

Edit User Data

With the POST /users/{userId}/user-data or the PATCH /users/{userId}/user-data you can either create user data on a user or edit existing user data. 

Creating User Data

With the POST endpoint and the userId you can create user data on users on your licence. In the body, you must enter the userDataTypeId and the value. The value must match the regex of the userDataType. The userDataType has to be unique on the user, depending on your licence settings, the userDataType might also have to be unique on the licence. The userDataTypeId and the regex are fetched from the GET /license/user-data-types endpoint.

[
  {
    "userDataTypeId": 12,
    "value": 2
  }
]

If duplicate userDataTypes are sent, all but the first are ignored. In this example, the value 1 is updated to 2.

The endpoint will return the updated user data or any errors:

{
  "success": true,
  "data": [
    {
      "userDataId": 564,
      "userDataTypeId": 12,
      "description": "unicId",
      "metaTypeName": "UNIC Id",
      "value": "2"
    }
  ],
  "error": null
}

Editing Existing User Data

With the PATCH endpoint and the userId you can update user data on users on your licence. In the body, you must enter the userDataType and the value. The value must match the regex of the userDataType. Duplicate userDataIds will result in an error. The userDataType has to be unique on the user, depending on your licence settings, the userDataType might also have to be unique on the licence. The regex is fetched from the GET /license/user-data-types endpoint and the userDataId is fetched from the GET endpoint described in the above example.
To follow the previous example, the value 2 is now updated to 3:
[
  {
    "userDataTypeId": 12,
    "value": 3
  }
]

The endpoint will return the updated user data or any errors:

{
  "success": true,
  "data": [
    {
      "userDataId": 564,
      "userDataTypeId": 12,
      "description": "unicId",
      "metaTypeName": "UNIC Id",
      "value": "3"
    }
  ],
  "error": null
}

The user data has now been updated to the value 3.

Deleting User Data

Using the DELETE /users/{userId}/user-data/{userDataId} endpoint it is possible to delete existing user data on a user. It is not possible to delete that last user data if the data is required. 

To delete user data, you need the userId of the user and the userDataId of the user data. The response will return true if the user data has been successfully deleted. Any errors will also be shown.

{
  "success": true,
  "data": null
  "error": null
}