API Response and Status Codes in CodeIgniter — a practical guide to API status codes CodeIgniter with clear examples you can reuse in real projects.
CodeIgniter Tutorial Series (62/74). Prefer one article? Read the complete CodeIgniter tutorial.
Short description
Use 200/201 for success, 400 for validation errors, 401/403 for auth, 404 for missing, 500 for server errors.
JSON response helper style
return $this->response->setStatusCode(201)->setJSON([
'status' => 'success',
'data' => $post,
]);