It's because, as specified in the docs, the $_POST
variable holds only data sent
using application/x-www-form-urlencoded or multipart/form-data as the HTTP Content-Type in the request.
If you're sending JSON data you need to manually decode the body:
$body = json_decode(file_get_contents('php://input'), true);