metodo eliminar crup api fetch

<?php
$data = json_decode(file_get_contents("php://input"));
$id = $data->id;
    require "conexion.php";
    $eliminar = $pdo->prepare("DELETE FROM productos WHERE id = $id");
    $eliminar->execute();
    if ($eliminar) {
        echo "ok";
    }
?>