Mark all notifications as read, for one user or for everyone
PUT
https://api.testingapis.com/api/Notifications/read-allParameters 1
| Name | Type | Description |
|---|---|---|
userId | query · integer (int32) | Only this user's notifications (default: all users). |
Responses
- 200
- Returns { message, updated } with the number of notifications changed.
- 500
- Unexpected server error.
Example
Request
curl -X PUT "https://api.testingapis.com/api/Notifications/read-all?userId=101"Response200 OK
{"message": "All notifications marked as read", "updated": 1}Code examples
JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/Notifications/read-all?userId=101", {
method: "PUT",
});
console.log(response.status, await response.text());Python (requests)
import requests
response = requests.request(
"PUT",
"https://api.testingapis.com/api/Notifications/read-all?userId=101",
allow_redirects=False,
)
print(response.status_code, response.text)Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.NEVER)
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.testingapis.com/api/Notifications/read-all?userId=101"))
.method("PUT", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}