Skip to main content

PUT /api/users/{userId}

The PUT /api/users/{userId} endpoint allows you to update the information of a specific user registered in the system. It is used to modify the user details, such as name, email, country, time zone, and other relevant attributes. This endpoint is useful for system administrators who need to keep user information up-to-date.

This endpoint is especially beneficial for applications that allow user management and administration, providing the capability to update specific user data.

Request Details

HTTP Method: PUT URL: /api/users/{userId}

Request Parameters

ParameterTypeRequiredDescription
userIdstringYesThe unique identifier of the user.

Request Body Parameters

The request body should be a JSON object with the following fields:

FieldTypeRequiredDescription
namestringYesThe name of the user.
emailstringYesThe email address of the user.
countrystringYesThe country of the user.
timeZonestringYesThe time zone of the user.
descriptionstringNoA description of the user.
messagestringNoA message associated with the user.
disabledbooleanNoIndicates whether the user is disabled.
disabledMessagestringNoA message describing why the user is disabled.
tagsobjectNoA set of tags associated with the user.
privilegesarrayNoA list of privileges for the user.
groupstringNoThe group to which the user belongs.
deviceIdstringNoThe identifier of the user's device.
adminDevicesintegerNoThe number of devices managed by the user.
fromstringNoThe start date and time of the user's activity.
expiresstringNoThe expiration date and time of the user.
passwordstringNoThe user's password (must be encrypted).
creationstringNoThe date and time the user was created. (This field is typically system-generated.)
modificationstringNoThe date and time of the user's last modification. (This field is typically system-generated.)
lastLoginstringNoThe date and time of the user's last login.

Authentication Required

Authentication required to use the endpoint is via a Bearer token. This authentication method implies that each request must include an authorization header with a valid access token. This Bearer token acts as a credential that verifies the identity of the user or application making the request, ensuring that only authorized entities can modify the user's information. By requiring this type of authentication, the system guarantees a high level of security and access control, protecting users' data against unauthorized access.

Example Request

PUT /api/users/12345 HTTP/1.1
Host: api.plaspy.com
Content-Type: application/json
Authorization: Bearer {your_auth_token}

{
"name": "Jane Doe",
"email": "jane.doe@example.com",
"country": "USA",
"timeZone": "America/Los_Angeles",
"description": "Updated user for the marketing department",
"tags": {
"role": "user",
"department": "marketing"
},
"privileges": ["read", "write"],
"group": "Marketing",
"deviceId": "dev-12345",
"adminDevices": 2,
"from": "2023-01-01T00:00:00Z",
"expires": "2024-01-01T00:00:00Z",
"password": "P@ssw0rd123",
"creation": "2023-01-01T00:00:00Z",
"modification": "2023-06-01T00:00:00Z",
"lastLogin": "2024-05-01T00:00:00Z"
}

Response Parameters

The response from this endpoint includes the details of the updated user or an error message if the request was not successful.

FieldTypeRequiredDescription
successbooleanNoIndicates whether the request was successful.
errorstringNoContains the error message if success is false.
apiUsageintegerNoCurrent API usage by the user.
apiDailyUsageintegerNoDaily API usage by the user.
idstringNoUnique identifier of the updated user.
namestringYesName of the updated user.
emailstringYesEmail of the updated user.
countrystringYesCountry of the updated user.
timeZonestringYesTime zone of the updated user.
descriptionstringNoDescription of the updated user.
messagestringNoMessage associated with the updated user.
disabledbooleanNoIndicates whether the updated user is disabled.
disabledMessagestringNoMessage describing why the updated user is disabled.
tagsobjectNoSet of tags associated with the updated user.
privilegesarrayNoList of privileges of the updated user.
groupstringNoGroup to which the updated user belongs.
deviceIdstringNoIdentifier of the updated user's device.
adminDevicesintegerNoNumber of devices managed by the updated user.
fromstringNoStart date and time of the updated user's activity.
expiresstringNoExpiration date and time of the updated user.
passwordstringNoPassword of the updated user (encrypted).
creationstringNoDate and time the updated user was created.
modificationstringNoDate and time of the updated user's last modification.
lastLoginstringNoDate and time of the updated user's last login.

Example Successful Response

{
"success": true,
"apiUsage": 150,
"apiDailyUsage": 15,
"id": "usr-12345",
"name": "Jane Doe",
"email": "jane.doe@example.com",
"country": "USA",
"timeZone": "America/Los_Angeles",
"description": "Updated user for the marketing department",
"tags": {
"role": "user",
"department": "marketing"
},
"privileges": ["read", "write"],
"group": "Marketing",
"deviceId": "dev-12345",
"adminDevices": 2,
"from": "2023-01-01T00:00:00Z",
"expires": "2024-01-01T00:00:00Z",
"password": null,
"creation": "2023-01-01T00:00:00Z",
"modification": "2023-06-01T00:00:00Z", "lastLogin": "2024-05-01T00:00:00Z" }

Example Error Response

{
"success": false,
"error": "User not found.",
"apiUsage": 150,
"apiDailyUsage": 15
}

Plaspy GPS Tracking Platform

Explore the Plaspy platform and compatible GPS devices

Browse technical guides, application documentation, compatible trackers, and setup resources to get more value from Plaspy.