HTTP Status 402 - Payment Required

Der HTTP-Status-Code 402 Payment Required ist für zukünftige Verwendung reserviert und ursprünglich für digitale Zahlungs-Systeme gedacht. Aktuell experimentell von einigen APIs für Monetization, Paywalls oder Quota-Limits genutzt. Keine standardisierte Semantik in RFC 9110.

Typ

Response-Status-Code

Syntax

Der Status Code wird zurückgegeben, experimentelle Verwendung variiert.

http
HTTP/1.1 402 Payment Required

Direktiven

Der 402 Payment Required Status Code hat keine standardisierte Semantik.

Reserved for Future Use
RFC 9110 reserviert 402 für zukünftige digitale Payment-Systeme, definiert aber keine konkrete Semantik. Ursprünglich für Micropayment-Schemas gedacht.
Experimental API Monetization
Einige APIs nutzen 402 experimentell, um zu signalisieren, dass Request Zahlung erfordert (Quota exceeded, Subscription expired, Premium Feature).
No Standard Headers
Keine standardisierten Response-Headers wie bei 401 (WWW-Authenticate). Implementation-specific Payment-Information im Body oder Custom Headers.

Beispiele

Nachfolgend finden Sie praktische Anwendungsbeispiele für Status 402.

Beispiel 1 API Quota Exceeded

http
GET /api/premium-data HTTP/1.1
Host: api.example.com
Authorization: Bearer token123

HTTP/1.1 402 Payment Required
Content-Type: application/json

{
  "error": "quota_exceeded",
  "message": "Free tier limit reached. Upgrade to Pro for unlimited requests.",
  "upgrade_url": "https://api.example.com/pricing"
}

Beispiel 2 Subscription Expired

http
GET /api/features/advanced HTTP/1.1
Host: api.example.com
Authorization: Bearer token456

HTTP/1.1 402 Payment Required
Content-Type: application/json

{
  "error": "subscription_expired",
  "message": "Your subscription expired on 2025-09-30",
  "renew_url": "https://billing.example.com/renew",
  "grace_period_until": "2025-10-15"
}

Beispiel 3 Premium Feature Access

http
POST /api/reports/custom HTTP/1.1
Host: api.example.com

HTTP/1.1 402 Payment Required
Content-Type: application/json

{
  "error": "premium_feature",
  "message": "Custom reports require Business tier subscription",
  "current_plan": "Starter",
  "required_plan": "Business",
  "pricing": "https://api.example.com/pricing#business"
}

API Monetization Flow

402 Payment Required bei Quota Limit für API Monetization

Vorteile für die Systemarchitektur

  • API Monetization Signal: Klare Unterscheidung zwischen Authentication Failures (401), Authorization Failures (403) und Payment-Required Scenarios. Client kann gezielt Payment-Flow triggern.
  • Quota Management: Signalisiert explizit, dass Request technisch möglich wäre, aber Business-Constraints (Quota, Subscription) verhindern Zugriff. Unterscheidet sich von Technical Errors.
  • Future-Proof: Reservierung für zukünftige standardisierte Payment-Protocols (Web Monetization API, Payment Request API). Experimental Use heute, Standard-Use morgen.

Spezifikation

RFC 9110, Section 15.5.3 – HTTP Semantics https://www.rfc-editor.org/rfc/rfc9110.html#name-402-payment-required

Weitere Spezifikationen

HTTP Status 401 - Unauthorized, HTTP Status 403 - Forbidden