# I am not able to initate a ncw wallet from a api key in nodejs getting error 401

**URL:** <https://community.fireblocks.com/t/i-am-not-able-to-initate-a-ncw-wallet-from-a-api-key-in-nodejs-getting-error-401/1439>\
**Category:** Developer Discussion\
**Created:** [September 17, 2024, 3:14pm UTC](https://community.fireblocks.com/t/i-am-not-able-to-initate-a-ncw-wallet-from-a-api-key-in-nodejs-getting-error-401/1439 "2024-09-17T15:14:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeetvani](https://sea1.discourse-cdn.com/flex015/user_avatar/community.fireblocks.com/jeetvani/32/405_2.png) [@jeetvani](https://community.fireblocks.com/u/jeetvani)\
**Post date:** [September 17, 2024, 3:14pm UTC](https://community.fireblocks.com/t/i-am-not-able-to-initate-a-ncw-wallet-from-a-api-key-in-nodejs-getting-error-401/1439/1 "2024-09-17T15:14:26Z")

</div>

even if i have added right api keys and right secret file iam getting 401 error from the backend side

here is the nodejs code - 🙂

// Import required modules  
const { FireblocksSDK } = require(“fireblocks-sdk”); // Correct way to import Fireblocks SDK  
const fs = require(“fs”);

// Initialize Fireblocks Client with API Key and Secret  
const apiSecret = fs.readFileSync(“src/utils/fireblock/fireblock.pem”, “utf8”); // Replace with your actual file path  
const apiKey = “786fe7bf-0e26-448f-806e-e7c1ca5b8e6d”; // Replace with your actual Fireblocks API Key  
const fireblocks = new FireblocksSDK(apiSecret, apiKey);

// Function to Create a New Customer Wallet  
async function createNewCustomerWallet(walletName, assets = ) {  
try {  
// Create wallet options  
const options = {  
name: walletName,  
assets: assets, // Array of asset symbols you want to include in the wallet (e.g., [“BTC”, “ETH”])  
};

```
    // Call the Fireblocks API to create a new wallet
    const response = await fireblocks.createVaultAccount(walletName); // Correct function to create a vault account
    console.log("Customer Wallet Created:", response);
    return response;
} catch (error) {
    console.error("Error creating customer wallet:", error.message);
}

```

}

// Example usage of the function  
(async() =\> {  
const walletName = “My New Customer Wallet”; // Replace with your desired wallet name  
const assets = [“BTC”, “ETH”]; // Specify assets for the wallet (optional)

```
// Create the customer wallet
await createNewCustomerWallet(walletName, assets);

```

})();

---

<div class="post-metadata">

**Author:** ![mnamakwala](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mnamakwala](https://community.fireblocks.com/u/mnamakwala)\
**Post date:** [September 17, 2024, 4:27pm UTC](https://community.fireblocks.com/t/i-am-not-able-to-initate-a-ncw-wallet-from-a-api-key-in-nodejs-getting-error-401/1439/2 "2024-09-17T16:27:43Z")

</div>

Hi Jeetvani,  
I am mohammed from Fireblocks.  
I have a few questions. so the API key mentioned in the above code is the one you are using correct?  
Also, I do not see an NCW signer in the workspace. Please do create one.  
Secondly, did you initialize the SDK?

> **[Initializing the SDK](https://ncw-developers.fireblocks.com/docs/initializing-the-sdk)**
>
> Overall flow Generate a device ID by calling the generateDeviceId() static method of the SDK. Assign the deviceId to a wallet on your backend server. ( POST /v1/wallets/ can be executed at this point.) Initialize a new SDK instance. Initialize the...

Also, before adding an asset wallet, you. We need to generate keys and backup the keys before adding asset wallets.

I recommend taking a look at our demo to check out the implementation.

> **[Quickstart](https://ncw-developers.fireblocks.com/docs/setup-1)**
>
> The open-source backend demo application, which encompasses all the necessary backend operations for the Fireblocks Non-Custodial Wallet (NCW), can be accessed on our official GitHub account . This application provides all the essential endpoints for...

> **[Setup](https://ncw-developers.fireblocks.com/docs/setup)**
>
> Overview The React Demo Application uses the Fireblocks Non-Custodial Wallet (NCW) Web SDK and was built as a reference for Fireblocks customers (or any developer looking for reference code for NCW implementation). It communicates with the Backend...

Below, we have an implementation article as well. Please feel free to take a look.

> **[Implementation Steps](https://ncw-developers.fireblocks.com/docs/implementation-steps)**
>
> Step-by-step process The process of implementing the Fireblocks Embedded Wallet (EW) involves the following step-by-step sequence: Complete the onboarding process to establish and configure your workspace. Ensure comprehensive disaster readiness by...

---

<div class="post-metadata">

**Author:** ![jeetvani](https://sea1.discourse-cdn.com/flex015/user_avatar/community.fireblocks.com/jeetvani/32/405_2.png) [@jeetvani](https://community.fireblocks.com/u/jeetvani)\
**Post date:** [September 17, 2024, 4:50pm UTC](https://community.fireblocks.com/t/i-am-not-able-to-initate-a-ncw-wallet-from-a-api-key-in-nodejs-getting-error-401/1439/3 "2024-09-17T16:50:06Z")

</div>

> [@mnamakwala](#):
>
> ireblocks.  
> I have a few questions. so the API key mentioned in the above code is the one you are using correct?  
> Also, I do not see an NCW sign

i will be doing it but is it possible for you to share and let me know if your sdk works on backend nodejs or not?

---

<div class="post-metadata">

**Author:** ![mnamakwala](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mnamakwala](https://community.fireblocks.com/u/mnamakwala)\
**Post date:** [September 17, 2024, 5:06pm UTC](https://community.fireblocks.com/t/i-am-not-able-to-initate-a-ncw-wallet-from-a-api-key-in-nodejs-getting-error-401/1439/4 "2024-09-17T17:06:51Z")

</div>

Yes, the backend uses node JS.

> **[Quickstart](https://ncw-developers.fireblocks.com/docs/setup-1)**
>
> The open-source backend demo application, which encompasses all the necessary backend operations for the Fireblocks Non-Custodial Wallet (NCW), can be accessed on our official GitHub account . This application provides all the essential endpoints for...

Please take a look at the demo code.
