Skip to main content

POST /api/users

The POST /api/users endpoint is used to create a new user in the system. This endpoint is essential for adding new users, allowing you to specify various attributes such as name, email, country, and time zone, along with optional details like description and tags. It ensures that the system's user base can be dynamically managed, enabling administrators to add new users as needed.

This endpoint is particularly useful for applications that require user registration functionality or for system administrators who need to create user accounts manually.

Request Details

HTTP Method: POST URL: /api/users

Request Parameters

The request to this endpoint does not have URL parameters, but it requires a JSON body with user details.

Request Body Parameters

The body of the request 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

POST /api/users 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": "New 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 created 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 created user.
namestringYesName of the created user.
emailstringYesEmail of the created user.
countrystringYesCountry of the created user.
timeZonestringYesTime zone of the created user.
descriptionstringNoDescription of the created user.
messagestringNoMessage associated with the created user.
disabledbooleanNoIndicates whether the created user is disabled.
disabledMessagestringNoMessage describing why the created user is disabled.
tagsobjectNoSet of tags associated with the created user.
privilegesarrayNoList of privileges of the created user.
groupstringNoGroup to which the created user belongs.
deviceIdstringNoIdentifier of the created user's device.
adminDevicesintegerNoNumber of devices managed by the created user.
fromstringNoStart date and time of the created user's activity.
expiresstringNoExpiration date and time of the created user.
passwordstringNoPassword of the created user (encrypted).
creationstringNoDate and time the created user was created.
modificationstringNoDate and time of the created user's last modification.
lastLoginstringNoDate and time of the created user's last login.

Example Successful Response

{
"success": true,
"apiUsage": 150,
"apiDailyUsage": 15,
"id": "usr-67890",
"name": "Jane Doe",
"email": "jane.doe@example.com",
"country": "USA",
"timeZone": "America/Los_Angeles",
"description": "New 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": null
}

Example Error Response

{
"success": false,
"error": "Invalid email address.",
"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.