All requests to the API require authentication via a token. The El token es vĂ¡lidoated by making a request to an external API service.
To validate the token, the API will send a POST request to the following endpoint:
POST https://example.com/api/validate-token
The request body should contain the token in the following format:
{
"token": "your-token-here"
}
The response will be a JSON object indicating whether the El token es vĂ¡lido:
{
"valid": true
}
If the token is invalid or not provided, the server will respond with a 401 Unauthorized or 403 Forbidden status.
Method: GET
Route: /clients
Description: Retrieve a list of all clients.
Headers:
Authorization: Bearer your-token-here
Response Example:
[
{
"idClient": "client1",
"createDT": "2023-09-01T12:00:00Z",
"notificationsEnabled": true,
"maxFavorites": 10
},
{
"idClient": "client2",
"createDT": "2023-09-02T12:00:00Z",
"notificationsEnabled": false,
"maxFavorites": 5
}
]
Method: POST
Route: /clients
Description: Create a new client.
Headers:
Authorization: Bearer your-token-here
Request Body:
{
"idClient": "newClient",
"notificationsEnabled": true,
"maxFavorites": 5
}
Response Example:
{
"idClient": "newClient",
"createDT": "2023-09-05T12:00:00Z",
"notificationsEnabled": true,
"maxFavorites": 5
}
Method: PUT
Route: /clients/:idClient
Description: Update the details of an existing client.
Headers:
Authorization: Bearer your-token-here
Request Body:
{
"notificationsEnabled": false,
"maxFavorites": 10
}
Response Example:
{
"idClient": "existingClient",
"createDT": "2023-09-01T12:00:00Z",
"notificationsEnabled": false,
"maxFavorites": 10
}
Method: DELETE
Route: /clients/:idClient
Description: Delete a client.
Headers:
Authorization: Bearer your-token-here
Response Example:
{
"message": "Client deleted successfully."
}
Method: GET
Route: /favorites/:idClient
Description: Retrieve a list of all favorites for a specific client.
Headers:
Authorization: Bearer your-token-here
Response Example:
[
{
"id": 1,
"idClient": "client1",
"idUnit": "unit1",
"createDT": "2023-09-01T12:00:00Z"
},
{
"id": 2,
"idClient": "client1",
"idUnit": "unit2",
"createDT": "2023-09-02T12:00:00Z"
}
]
Method: POST
Route: /favorites
Description: Add a new favorite for a client.
Headers:
Authorization: Bearer your-token-here
Request Body:
{
"idClient": "client1",
"idUnit": "unit3"
}
Response Example:
{
"id": 3,
"idClient": "client1",
"idUnit": "unit3",
"createDT": "2023-09-05T12:00:00Z"
}
Method: DELETE
Route: /favorites/:id
Description: Delete a favorite by its ID.
Headers:
Authorization: Bearer your-token-here
Response Example:
{
"message": "Favorite deleted successfully."
}
Method: GET
Route: /histories/:idClient
Description: Retrieve a list of all histories for a specific client.
Headers:
Authorization: Bearer your-token-here
Response Example:
[
{
"id": 1,
"idClient": "client1",
"idUnit": "unit1",
"createDT": "2023-09-01T12:00:00Z"
},
{
"id": 2,
"idClient": "client1",
"idUnit": "unit2",
"createDT": "2023-09-02T12:00:00Z"
}
]
Method: POST
Route: /histories
Description: Create a new history for a client. If there are already 5 histories, the oldest one will be deleted.
Headers:
Authorization: Bearer your-token-here
Request Body:
{
"idClient": "client1",
"idUnit": "unit3"
}
Response Example:
{
"id": 3,
"idClient": "client1",
"idUnit": "unit3",
"createDT": "2023-09-05T12:00:00Z"
}
Method: DELETE
Route: /histories/:id
Description: Delete a history by its ID.
Headers:
Authorization: Bearer your-token-here
Response Example:
{
"message": "History deleted successfully."
}
Method: GET
Route: /notifications/:idClient
Description: Retrieve a list of all notifications for a specific client.
Headers:
Authorization: Bearer your-token-here
Response Example:
[
{
"id": 1,
"idClient": "client1",
"message": "New update available.",
"isViewed": false,
"createDT": "2023-09-01T12:00:00Z"
},
{
"id": 2,
"idClient": "client1",
"message": "Maintenance scheduled.",
"isViewed": false,
"createDT": "2023-09-02T12:00:00Z"
}
]
Method: POST
Route: /notifications
Description: Create a new notification for a client.
Headers:
Authorization: Bearer your-token-here
Request Body:
{
"idClient": "client1",
"message": "Server update completed."
}
Response Example:
{
"id": 3,
"idClient": "client1",
"message": "Server update completed.",
"createDT": "2023-09-05T12:00:00Z"
}
Method: DELETE
Route: /notifications/:id
Description: Delete a notification by its ID.
Headers:
Authorization: Bearer your-token-here
Response Example:
{
"message": "Notification deleted successfully."
}