API Tokens
This routes provides an overview of the API tokens associated with the user’s IoT Wonderland account. An API token is a unique credential used to authenticate and authorize access to an API. It functions as a digital key, enabling approved users or applications to securely access specific API resources and features. API tokens help protect against unauthorized access and play a critical role in maintaining data security.
GET /user/token
Retrieve all API tokens associated with the authenticated user.
Description:
Returns a list of active API tokens available for the current user account.
Authentication:
Requires a valid authenticated session or API token.
- Example response:
{
"errors": [],
"debug": [],
"meta": [],
"data": [
{
"uid": 15,
"hash": "4f9a8b32c1d5e6f7a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2",
"user_ref": 55,
"created": "2024-01-29 18:25:42",
"until": null,
"enabled": 1,
"type": "app",
"name": null,
"meta": null
},
{
"uid": 19,
"hash": "b4f6c9812d3e5a7f8901b2d4c6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5",
"user_ref": 55,
"created": "2024-02-07 14:03:23",
"until": null,
"enabled": 1,
"type": "master",
"name": null,
"meta": null
}
],
"success": true
}
POST /user/token
This route creates a new API token for the authenticated user.
Description:
Generates a new API token that can be used to authenticate future API requests.
A valid authenticated session or an existing API token is required to access this endpoint.
When creating a new token:
- Specify the token type in the request body:
{
"type": "API"
}
```
- In your API client, set the authentication method to **API Key**.
- Under **Key**, select the token field.
- Enter the generated API token as the **Value**.
- Ensure the token is sent in the **Authorization** request header for all subsequent API requests.
- ***Example response:***
```json
{
"errors": [],
"messages": [
"API token created"
],
"debug": [],
"meta": [],
"data": 89,
"success": true
}
DELETE /user/token
Deletes the specified API token associated with the authenticated user.
Description:
This endpoint permanently removes an existing API token. The request must be authenticated using the same method as described for the creation of the API Token.
Authentication:
A valid authenticated session or API token is required to access this endpoint. Configure authentication in the same manner as for the POST request by providing the API token in the Authorization header.
Request Body:
The request body must include the unique identifier (uid) of the API token to be deleted.
{
"uid": 81
}
```
- **Example response:**
```json
{
"errors": [],
"messages": [
"API token deleted"
],
"debug": [],
"meta": [],
"data": 81,
"success": true
}