401 - Unauthorized when creating new Persons via API

I’m getting "{\"success\":false,\"error\":\"unauthorized access\",\"errorCode\":401,\"error_info\":\"Please check developers.pipedrive.com\"}" when attempting to create a new persons via the API. Can someone tell me what I am doing wrong here?

person = await axios.post(`https://REDACTED.pipedrive.com/api/v2/persons`, {

      name: 'John Smith',

      headers: {
        "x-api-token": apiKey,
      },
    });

The auth tokens are fine as I am able to call the persons API (list all persons / search for persons). I’ve also tried wrapping name into data: {name: ‘John Smith’}and params: {name: ‘John Smith’} with no success

Hey! It is likely failing because you are passing the ‘headers’ object as a part of the request payload body, not as actual request headers.