# Get started creating a subproject using Node.js

This guide will walk you through creating a new subproject for a Sinch project using Node.js.

Note
Before you can get started, you need the following already set up:

- All Subproject API [configuration settings](/docs/subprojects/getting-started/).
- [Node.js](https://nodejs.org/en/) and a familiarity with how to create a new app.


Steps
1. [Set up](#set-up-your-node.js-application) your Node.js application.
2. [Create](#create-your-subproject) your subproject.


## Set up your Node.js application

1. Once you setup your free Sinch account, create a new node app with npm.

```shell
npm init
```
2. Accept the defaults for the application.
3. Add the fetch package with npm to generate the necessary dependencies.

```shell
npm install node-fetch
```
4. Create a new file named `index.mjs` in the project and paste the provided code into the file.


index.mjs
```javascript index.mjs
import fetch from 'node-fetch';

const projectId = 'YOUR_projectId'; // Your parent project ID
const displayName = 'My Customer Subproject'; // Display name for the subproject
const labels = {
  'customer': 'Acme Corp',
  'region': 'US-Northwest',
  'contract': 'enterprise'
};

const keyId = 'YOUR_Key_ID'; // Your Key ID from Sinch Build Dashboard
const keySecret = 'YOUR_Key_Secret'; // Your Key Secret from Sinch Build Dashboard

const createData = {
  displayName: displayName,
  labels: labels
};

async function createSubproject() {
  try {
    const response = await fetch(
      `https://subproject.api.sinch.com/v1/projects/${projectId}/subprojects`,
      {
        method: 'POST',
        headers: {
          'Authorization': `Basic ${Buffer.from(`${keyId}:${keySecret}`).toString('base64')}`,
          'Content-Type': 'application/json'
        },
        body: JSON.stringify(createData)
      }
    );

    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }

    const data = await response.json();
    console.log('Subproject created successfully:', data);
    return data;
  } catch (error) {
    console.error('Error creating subproject:', error);
    throw error;
  }
}

// Execute the function
createSubproject();
```

## Create your subproject

Now, we'll customize and run the code that will create a subproject under your specified Sinch project ID.

### Fill in your parameters

1. Assign your values to the following parameters:
| Parameter | Your value |
|  --- | --- |
| `YOUR_projectId` | The corresponding project ID that you would like to create a subproject under. Your `projectId` can be found in the [Sinch Build Dashboard](https://dashboard.sinch.com/settings/access-keys) under **Settings**, then **Access Keys**. |
| `displayName` | The display name is a name given to represent this particular subproject. In a resale setting, this would be your customer's business name. |
| `labels` | Labels contain a series of key:value pairs that are completely customizable. You can assign your own key *and* value. This is a great way to keep metadata with the subproject. |
| `YOUR_Key_ID` | Your Key ID from the [Sinch Build Dashboard](https://dashboard.sinch.com/settings/access-keys) under **Settings**, then **Access Keys**. |
| `YOUR_Key_Secret` | Your Key Secret from the [Sinch Build Dashboard](https://dashboard.sinch.com/settings/access-keys) under **Settings**, then **Access Keys**. |
2. Save the file.
3. Execute the code and create your first subproject.
Run the following command:

```shell
node index.mjs
```


## Next Steps

Check out our full [API reference](/docs/subprojects/api-reference) for more subproject options.