title: Javascript REST API - You must specify an API key to make request
body: <p>I get a 403 "You must specify an API key to make request" when trying to get data from a 3rd party API (<a href="https://www.klaviyo.com/docs/api/lists" rel="nofollow noreferrer">Klaviyo</a>).</p>
  
  <pre><code>const { id } = req.body
  
  request.get({
      url: `https://a.klaviyo.com/api/v1/person/${id}`,
      headers: {
          api_key: process.env.KLAVIYO_API_KEY
      }
  }, (error, response, body) =&gt; {
      const profile = JSON.parse(body)
      console.log(profile)
      if (response.statusCode === 200) {
          res.json({ profile, status: 201 })
      } else {
          res.json({ error: 'Did not get customer data', status: 500, response: response, err: error })
      }
  })
  </code></pre>
  
  <p>I've also tried with:</p>
  
  <p>headers: {"Authorization": [API_KEY]}</p>
  
  <p>data: {api_key: [API_KEY]}</p>
  
  <p><strong>Solution:</strong> </p>
  
  <pre><code>const { id } = req.body
  
  request.get({
      url: `https://a.klaviyo.com/api/v1/person/${id}`,
      qs: {
          api_key: process.env.KLAVIYO_API_KEY
      }
  }, (error, response, body) =&gt; {
      const profile = JSON.parse(body)
      console.log(profile)
      if (response.statusCode === 200) {
          res.json({ profile, status: 201 })
      } else {
          res.json({ error: 'Did not get customer data', status: 500, response: response, err: error })
      }
  })
  </code></pre>