Facing issue while sending emails from node js

const headers = {
    "Content-Type": "application/json",
    "api-Key": <api_key>
  }

  // // construct body
  const data = {
    ...body,
  }

  // send request
  try {
    const res = await axios.post(""https://api.brevo.com/v3/smtp/email", data, { headers })
    return res
  } catch (err) {
    console.log(err)
    return err
  }

I tried doing it using sib-api-v3-sdk as well, but everytime it gives the same error:
status: 401,
text: ‹ {« message »:« Key not found »,« code »:« unauthorized »}\n ›,
method: ‹ POST ›,
path: ‹ /v3/smtp/email ›

i verified and i am using the correct key.
What are the possible reasons for this ? Am i missing something?

Hello @kaush,

Thank you for reaching out. I noticed you mentioned the sib-api-v3-sdk, which appears to be deprecated according to information on the npm website. For the most recent SDK and Node.js examples, please refer to our API documentation here.

Additionally, you can test your current API key directly on the documentation page to ensure everything is functioning as expected. If you continue to experience issues, generating a new v3 API key might help resolve them.

If you need further assistance or have any questions, don’t hesitate to reach out.

1 « J'aime »