SIP

Simuler une réponse 403 Forbidden

The server understood the request but is refusing to fulfill it. Authorization will not help. The request should not be repeated.

Voir la référence complète →

1 Réponse HTTP

Réponse HTTP
HTTP/1.1 403 Forbidden
Content-Type: application/json
Date: Tue, 25 Feb 2026 12:00:00 GMT
Content-Length: 50

{
  "error": "forbidden",
  "message": "Access denied"
}

2 Tester avec curl

terminal
curl -i https://httpbin.org/status/403

3 Retourner 403 Forbidden dans votre framework

django
from django.http import JsonResponse


def my_view(request):
    return JsonResponse(
        {"error": "forbidden", "message": "Access denied"},
        status=403,
    )
flask
from flask import Flask, jsonify

app = Flask(__name__)


@app.route("/endpoint")
def my_endpoint():
    return jsonify({"error": "forbidden", "message": "Access denied"}), 403
fastapi
from fastapi import FastAPI
from fastapi.responses import JSONResponse

app = FastAPI()


@app.get("/endpoint")
def my_endpoint():
    return JSONResponse(
        content={"error": "forbidden", "message": "Access denied"},
        status_code=403,
    )
express.js
// Express.js
app.get('/endpoint', (req, res) => {
  res.status(403).json({"error": "forbidden", "message": "Access denied"});
});
spring boot
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

@RestController
public class MyController {

    @GetMapping("/endpoint")
    public ResponseEntity<Map<String, Object>> myEndpoint() {
        return ResponseEntity
            .status(403)
            .body(Map.of("error", "forbidden",
                         "message", "Forbidden"));
    }
}
go net/http
package main

import (
    "encoding/json"
    "net/http"
)

func myHandler(w http.ResponseWriter, r *http.Request) {
    w.Header().Set("Content-Type", "application/json")
    w.WriteHeader(403)
    json.NewEncoder(w).Encode(map[string]string{
        "error":   "forbidden",
        "message": "Forbidden",
    })
}
ruby on rails
class MyController < ApplicationController
  def my_action
    render json: {"error": "forbidden", "message": "Access denied"},
           status: :forbidden
  end
end
asp.net core
// ASP.NET Core Minimal API
app.MapGet("/endpoint", () =>
    Results.Json(
        new { error = "forbidden", message = "Forbidden" },
        statusCode: 403
    )
);

Plus de pages Mock SIP