Hey Klaviyo team,
I am wondering where I can find the return types for specific API queries? For instance I have the following “Create Client Subscription” operation, but I am manually typing out the return types:
interface CreateClientSubscription {
email?: string | null;
phone?: string | null;
status: number;
message: string;
error: string | null;
submittedAt: string;
}
/**
* Subscribes a user to a specified email list.
* @param email - The user's email address
* @param listId - The email list ID (newsletter)
* @returns A Promise resolving to the subscription data
* @see https://developers.klaviyo.com/en/reference/create_client_subscription
*/
const newsletter = async (
email: string,
listId: string
): Promise<CreateClientSubscription> => {
return await $fetch('/api/klaviyo', {
method: 'POST',
body: {
data: {
type: 'subscription',
attributes: {
profile: {
data: {
type: 'profile',
attributes: { email }
}
}
},
relationships: {
list: {
data: {
type: 'list',
id: listId
}
}
}
}
}
});
};
Ideally, it would be best to just import the pre-defined types into my Klaviyo operations. I am using codegen, but I dont think this can be done. Perhaps there is another repo/library I am missing?
Thanks!:)