Skip to main content

POST /api/groups

This endpoint allows you to create a new group within the system. It's essential for organizing devices and managing them efficiently by grouping them into logical units. Each group can have a unique name, description, and a list of associated devices.

Request Details

To create a group, you need to send a POST request with the group details in the request body. Ensure the request is authorized with a valid token.

Request Parameters

The request body must include the details of the group to be created.

Request Body Parameters

FieldTypeRequiredDescription
namestringYesThe name of the group. Must be a non-empty string.
descriptionstringNoA description of the group.
devicesarrayNoList of device IDs associated with the group.

Example Request Body

{
"name": "New Group",
"description": "Description of the new group",
"devices": ["dev-456", "dev-789"]
}

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/groups HTTP/1.1
Host: api.plaspy.com
Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXV...
Content-Type: application/json

{
"name": "New Group",
"description": "Description of the new group",
"devices": ["dev-456", "dev-789"]
}

Response Parameters

The response includes details of the newly created group.

FieldTypeRequiredDescription
successbooleanYesIndicates whether the request was successful.
errorstringNoError message if the request failed.
apiUsageintegerNoTotal API usage at the time of the request.
apiDailyUsageintegerNoDaily API usage at the time of the request.
idstringNoUnique identifier of the created group.
namestringYesName of the group.
descriptionstringNoDescription of the group.
devicesarrayNoList of IDs of devices associated with the group.
creationstringNoDate and time of group creation (in ISO 8601 format).
lastModifiedstringNoDate and time of the last modification of the group (in ISO 8601 format).

Example Successful Response

{
"success": true,
"error": null,
"apiUsage": 123,
"apiDailyUsage": 45,
"id": "grp-125",
"name": "New Group",
"description": "Description of the new group",
"devices": ["dev-456", "dev-789"],
"creation": "2023-06-01T12:00:00Z",
"lastModified": "2023-06-01T12:00:00Z"
}

Example Error Response

{
"success": false,
"error": "Invalid input",
"apiUsage": 123,
"apiDailyUsage": 45
}

This endpoint is crucial for adding new groups to the application, allowing for better organization and management of devices by grouping them into named and described units.

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.