Skip to main content

PATCH /api/users/{userId}

The PATCH /api/users/{userId} endpoint allows for partially updating the information of a specific user. This method is useful when only a few fields need to be modified without sending all the user data. The user's identifier (userId) is included in the request URL.

Request Details

  • HTTP Method: PATCH
  • URL: /api/users/{userId}
  • Authentication: Requires a Bearer token.
  • Request Format: JSON

Request Parameters

FieldTypeRequiredDescription
userIdstringYesThe unique identifier of the user to be updated.

Request Body Parameters

The request body must contain an array of patch operations to indicate the modifications to be made.

Request Body

Each patch operation in the request body must follow the format defined in the JSON Patch specification. A patch operation includes the following fields:

FieldTypeRequiredDescription
opstringYesThe operation to be performed, can be add, remove, replace, move, copy, or test.
pathstringYesThe path to the field to be modified, following JSON Pointer syntax.
valueobjectNoThe new value for the field specified in path (required for add and replace).

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

PATCH /api/users/usr-12345 HTTP/1.1
Host: www.plaspy.com
Authorization: Bearer tu_token_de_autenticacion
Content-Type: application/json

[
{
"op": "replace",
"path": "/email",
"value": "nuevo_email@example.com"
},
{
"op": "add",
"path": "/tags",
"value": { "vip": "true" }
}
]

Response Parameters

FieldTypeRequiredDescription
successbooleanNoIndicates if the operation was successful.
errorstringNoError message if the operation was not successful.
apiUsageintegerNoAPI usage for the current request.
apiDailyUsageintegerNoDaily API usage.
idstringNoIdentifier of the updated user.
namestringNoName of the user.
emailstringNoEmail of the user.
countrystringNoCountry of the user.
timeZonestringNoTime zone of the user.
descriptionstringNoDescription of the user.
messagestringNoMessage associated with the user.
disabledbooleanNoIndicates if the user is disabled.
tagsobjectNoTags associated with the user.
privilegesarrayNoPrivileges of the user.
groupstringNoGroup to which the user belongs.
deviceIdstringNoIdentifier of the device associated with the user.
adminDevicesintegerNoNumber of devices managed by the user.
fromstringNoStart date of the user's validity.
expiresstringNoExpiration date of the user's validity.
passwordstringNoPassword of the user.
creationstringNoDate the user was created.
modificationstringNoDate the user was last modified.
lastLoginstringNoDate of the user's last login.

Example Successful Response

{
"success": true,
"id": "usr-12345",
"name": "Juan Perez",
"email": "new_email@example.com",
"country": "Colombia",
"timeZone": "America/Bogota",
"description": "VIP User",
"tags": {
"vip": "true"
},
"privileges": ["read", "write"],
"group": "administrators",
"deviceId": "dev-67890",
"adminDevices": 5,
"from": "2023-01-01T00:00:00Z",
"expires": "2024-01-01T00:00:00Z",
"creation": "2022-01-01T00:00:00Z",
"modification": "2023-06-01T00:00:00Z",
"lastLogin": "2023-06-01T00:00:00Z"
}

Example Error Response

{
"success": false,
"error": "Invalid patch operation",
"apiUsage": 25,
"apiDailyUsage": 100
}

This endpoint facilitates updating specific data of a user, ensuring flexibility and efficiency in managing users within the system.

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.