Search code examples
node.jsemailsendinblue

SendInBlue - sib-api-v3-sdk sendTransacEmail() returns 403 Forbidden


I'm trying to send a transactional email with my new SendInBlue account and I keep receiving an error that simply says "Forbidden". I followed the example on SendInBlue's Nodejs docs to write this code:

const SibApiV3Sdk = require('sib-api-v3-sdk');

const defaultClient = SibApiV3Sdk.ApiClient.instance;

// Configure API key authorization: api-key
const apiKey = defaultClient.authentications['api-key'];
apiKey.apiKey = 'xxx';
// Uncomment the following line to set a prefix for the API key, e.g. 'Token' (defaults to null)
//apiKey.apiKeyPrefix = 'Token'

// Configure API key authorization: partner-key
//const partnerKey = defaultClient.authentications['partner-key'];
//partnerKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. 'Token' (defaults to null)
//partnerKey.apiKeyPrefix['partner-key'] = 'Token'

const apiInstance = new SibApiV3Sdk.TransactionalEmailsApi();

const sendSmtpEmail = new SibApiV3Sdk.SendSmtpEmail(); // SendSmtpEmail | Values to send a transactional email

const sendEmail = async (to, subject, htmlBody, textBody) => {

    sendSmtpEmail.to = [{ email: to }];
    sendSmtpEmail.sender = { email: '*', name: '*' };
    sendSmtpEmail.htmlContent = `*`;
    sendSmtpEmail.textContent = `*`;
    sendSmtpEmail.subject = `*`;
    sendSmtpEmail.replyTo = { email: '*' };

    const result = await apiInstance.sendTransacEmail(sendSmtpEmail);
    console.log(result);
    return result;
};


export { sendEmail };

The apiInstance.sendTransacEmail(sendSmtpEmail) line throws a 403 error that simply says "Forbidden". How do I fix this?


Solution

  • Your transactional account is not activated. Create a ticket on SendinBlue support. They will activate it and your issue will be resolved.