API Integration

i have been using pro plan of ghost. so I would like to send newsletters by email using admin apikey. let me know example code

my source node code follow that :

async function createAndSendPost() {
    try {
        // Create a new post
        const post = await api.posts.add({
            title: 'Your Email Title',
            html: '<p>This is the content of your email</p>',
            status: 'draft', // Initially save as draft
            email_only: true // Ensure it's an email-only post
        });

        // Update post to publish and send as email
        await api.posts.edit({
            id: post.id,
            status: 'published',
            updated_at: post.updated_at // Include the updated_at field
        }, { send_email: true });

        console.log('Email sent successfully!');
    } catch (err) {
        console.error('Error sending email:', err);
    }
}

createAndSendPost();

thanks for support.
but cannot add html template.
i set up html as <p>hello world</p>, but it doesn’t add in a post.

You’re missing source:html.

where might be add it?

i use this code

async function createAndSendPost() {
try {

    const member = await api.members.add({
        email: email,
        labels: ['targeted-email']
    });

    // Create a new post
    const post = await api.posts.add({
           title: 'Testing Email Sending Through API',
		html: html,
		status: 'draft',
		}, {
		source: 'html',
		newsletter: 'Cooperation', email_recipient_filter: 'label:targeted-email'});

    // Update post to publish and send as email
    await api.posts.edit({
        id: post.id,
        status: 'published',
		email_recipient_filter: 'label:targeted-email',
        updated_at: post.updated_at, // Include the updated_at field
    }, {newsletter: 'Cooperation',source: 'html',email_recipient_filter: 'label:targeted-email'});



    console.log('Email sent successfully!');
} catch (err) {
    console.error('Error sending email:', err);
}

}

email not sent specific member with label.
it sent all members