Hi
I am trying to subscribe a new profile to a list but I get this error:
Array ( [errors] => Array ( [0] => Array ( [id] => 8647527d-59b1-49ed-a4ea-48582741d37b [status] => 400 [code] => invalid [title] => Invalid input. [detail] => Phone number is valid but is not in a supported region for this account. Please configure a sending number for this region. [source] => Array ( [pointer] => /data/attributes/profiles/data/0/attributes/phone_number ) [links] => Array ( ) [meta] => Array ( ) ) ) )
Here is the code:
<?php
/* Using Subscribe profiles to write a new profile - Testing */
$email ='second@ecovib2d.com.au';
$firstname ='Adrian';
$lastname ='Mason';
$id = '';
$status = 'SUBSCRIBED';
$List_id = 'XXXXXXXXXXX'; // Master list
$data=array();
$data = [
"data"=> [
"type"=> "profile-subscription-bulk-create-job",
"attributes"=> [
"custom_source"=> "Purchase Event",
"profiles"=> [
"data"=> [
[
"type"=> "profile",
"id"=> $id,
"attributes"=> [
"email"=> $email,
"phone_number" => "+610423029480",
"subscriptions"=> [
"email"=> [
"marketing"=> [
"consent"=> $status,
]
],
"sms"=> [
"marketing"=> [
"consent"=> $status,
]
]
]
]
]
]
],
"historical_import"=> false
],
"relationships"=> [
"list"=> [
"data"=> [
"type"=> "list",
"id"=> $List_id,
]
]
]
]
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://a.klaviyo.com/api/profile-subscription-bulk-create-jobs/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
'Authorization: Klaviyo-API-Key pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'accept: application/json' ,
'content-type: application/json',
'revision: 2024-07-15',
),
));
$created_profile = curl_exec($curl);
print_r(json_decode($created_profile,true));
if ($created_profile === false) {
$error = curl_error($curl);
curl_close($curl);
die('Curl error: ' . $error);
}
curl_close($curl);
?>