Skip to main content

I want to subscribe a user with email and their name, but it gives this error: 'first_name' is not a valid field for the resource 'profile'.

Im using the Klaviyo PHP SDK.

It works if i just remove first_name and last_name from attributes… But i want to include the name.
Code:

$klaviyo->Profiles->subscribeProfiles(s
    "data" => &
        'type'          => 'profile-subscription-bulk-create-job',
        'attributes'    =>  
            'custom_source' => 'Marketing Event',
            'profiles'      => r

                'data' => Â
                    
                        'type'       => 'profile',

                        'attributes' =>  
                            'email'         => 'email@email.com',
                            'first_name'=>'firstname',
                            'last_name'=>'lastname',
                            'subscriptions' =>  
                                'email' => ,
                                    'marketing' => _
                                        'consent' => 'SUBSCRIBED',
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ],
        'relationships' => &
            'list' =>  
                'data' => Â
                    'type' => 'list',
                    'id'   => 'MYLISTID',
                ],
            ],
        ],
    ],
]);

Hey there @AlexVjm,

 

I thought you must have a syntax error or something but no! It doesn’t work! I can confirm that adding a first_name (or $first_name, firstName, $firstName, properties: { first_name }, etc.) does not work for the bulk-subscribe endpoint.

You are returned the following error:

{
"errors": "
{
"id": "d121de2f-710b-4d2f-a6cb-d0723610ed93",
"status": 400,
"code": "invalid",
"title": "Invalid input.",
"detail": "'$firstname' is not a valid field for the resource 'profile'.",
"source": {
"pointer": "/data/attributes/profiles/data/0/attributes/$firstname"
},
"meta": {}
}
]
}

The documentation reflects this: the only attributes available are email, phone, and subscriptions.

But this can’t be right…

 

Anyone else know how to include profile properties on the bulk subscribe endpoint?

 

Cheers,

Kevin.


Why is this marked as 'solved’?


Hi @AlexVjm 
maybe late but hope it could be usefull for similar task.
latest api version revision: 2024-05-15 show that you need to create profile to add user details
 

{
"data": {
"type": "profile",
"attributes": {
"email": "sarah.mason@klaviyo-demo.com",
"phone_number": "+15005550006",
"first_name": "Sarah",
"last_name": "Mason",
"organization": "Example Corporation",
"title": "Regional Manager",
"image": "https://images.pexels.com/photos/3760854/pexels-photo-3760854.jpeg",
"location": {
"address1": "89 E 42nd St",
"address2": "1st floor",
"city": "New York",
"country": "United States",
"region": "NY",
"zip": "10017",
"timezone": "America/New_York",
"ip": "127.0.0.1"
},
"properties": {
"newKey": "New Value"
}
}
}
}

so easier way is Create Profile details, store klaviyo Profile ID and then subscribe to list using email or ID just generate
 

​​​​​​​$klaviyo->Profiles->createProfile($body);
$klaviyo->Profiles->subscribeProfiles($body);

 


Seriously - who designed this API? 

 

You have to create a blob of Json with about 8 layers to just subscribe an email address to a list. And you can’t add a name or any other attribute whilst you’re doing it? 

So simple newsletter subscription present on 99.99% websites requires two API calls with some horrendous json - have you checked out your rivals Klaviyo? They make this stuff easy - why, keep the developers happy and they’ll sell your product to others. 


Reply