New in 2.4: Test runs you can trust See what's new →

Allow only tokens with the delete scope

DELETEhttps://api.testingapis.com/api/auth/roles/resource

Header: Authorization: Bearer <token>. Only admin-token has the delete scope; user-token and readonly-token get 403.

Bearer token — admin-token

Responses

200
Token has the delete scope.
401
Token missing or not one of the test tokens.
403
Valid token without the delete scope.

Example

Request
curl -X DELETE "https://api.testingapis.com/api/auth/roles/resource" \
  -H "Authorization: Bearer admin-token"
Run in Studio
Response200 OK
{
  "authorized": true,
  "user": "Alice Admin",
  "roles": ["admin", "user"],
  "scopes": ["read", "write", "delete"]
}

Code examples

JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/auth/roles/resource", {
  method: "DELETE",
  headers: {
    "Authorization": "Bearer admin-token",
  },
});
console.log(response.status, await response.text());
Python (requests)
import requests

response = requests.request(
    "DELETE",
    "https://api.testingapis.com/api/auth/roles/resource",
    headers={
        "Authorization": "Bearer admin-token",
    },
    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/auth/roles/resource"))
            .header("Authorization", "Bearer admin-token")
            .method("DELETE", HttpRequest.BodyPublishers.noBody())
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}