thanks to @Rishard i tried to custom the endpoint by add this code in WP snippet
add_filter('woocommerce_rest_prepare_product_object', function ($response, $product, $request) {
if (!empty($response->data['attributes'])) {
foreach ($response->data['attributes'] as &$attribute) {
if (!empty($attribute['options'])) {
$options_with_ids = [];
foreach ($attribute['options'] as $option) {
$term = get_term_by('name', $option, $attribute['slug']);
if ($term) {
$options_with_ids[] = [
'id' => $term->term_id,
'name' => $term->name
];
} else {
$options_with_ids[] = [
'id' => null,
'name' => $option
];
}
}
$attribute['options'] = $options_with_ids;
}
}
}
return $response;
}, 10, 3);
now to response is
{
"id": 7,
"name": "Size",
"slug": "pa_size",
"position": 4,
"visible": true,
"variation": true,
"options": [
{
"id": 123,
"name": "L"
},
{
"id": 138,
"name": "XL"
}
]
}