Skip to main content
REST API

403 Forbidden

ErrorAuthValidateEasy

What you will learn

  • 403 means authenticated but not authorised โ€” different from 401 (unauthenticated)
  • Avoid leaking resource existence โ€” 403 for a hidden resource tells an attacker it exists
  • Test role-based access: per-role ร— per-endpoint matrix catches permission holes

Description

Handle insufficient permissions for authenticated user.

Test Scenario

const response = await request.delete('/api/v1/admin/settings', {
  headers: { 'Authorization': 'Bearer ' + userToken }
});
expect(response.status()).toBe(403);
Endpoint/api/v1/errors/403

Testing Tips

  • โ€ขValid auth but no permission
  • โ€ขDifferent from 401 (authenticated but forbidden)
  • โ€ขCheck error explains restriction
// Playwright API Testing - REST
import { test, expect } from '@playwright/test';
test('REST API request', async ({ request }) => {
const response = await request.get('/api/v1/resource');
expect(response.ok()).toBeTruthy();
expect(response.status()).toBe(200);
const data = await response.json();
expect(data).toBeDefined();
});

Challenge ID: rest-error-403

2 frameworks available

API Playground

Send requests and inspect responses

Endpoint: /api/v1/errors/403

Press Enter to send