202 Accepted
Fault: Neither
TL;DR
Request accepted but processing will complete asynchronously.
The request has been accepted for processing, but processing has not been completed.
What This Error Means
The request has been accepted for processing, but processing has not been completed.
Request accepted but processing will complete asynchronously.
Common Causes
- Batch operations
- Asynchronous processing
- Queued requests
How to Fix It (For Visitors)
- Check status endpoint for processing completion
How to Fix It (For Developers/Admins)
- Use for long-running async operations
- Provide status check endpoint
Code Examples
Here's how to return a 202 status code in various programming languages:
Python (Flask)
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/endpoint')
def endpoint():
return jsonify({"message": "Accepted"}), 202
Node.js (Express)
const express = require('express');
const app = express();
app.get('/endpoint', (req, res) => {
res.status(202).json({ message: 'Accepted' });
});
PHP
<?php
http_response_code(202);
header('Content-Type: application/json');
echo json_encode(['message' => 'Accepted']);
?>
Go
package main
import (
"encoding/json"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(202)
json.NewEncoder(w).Encode(map[string]string{
"message": "Accepted",
})
}
Java (Spring Boot)
@GetMapping("/endpoint")
public ResponseEntity<Map<String, String>> endpoint() {
Map<String, String> response = new HashMap<>();
response.put("message", "Accepted");
return ResponseEntity.status(202).body(response);
}
Ruby (Sinatra)
get '/endpoint' do
status 202
json message: 'Accepted'
end
Browser Compatibility
| Browser | Support | Notes |
|---|---|---|
| Chrome | ✓ Full Support | All versions |
| Firefox | ✓ Full Support | All versions |
| Safari | ✓ Full Support | All versions |
| Edge | ✓ Full Support | All versions |
Official Specification
This status code is defined in RFC 7231 Section 6.3.3.