> For the complete documentation index, see [llms.txt](https://pollz.gitbook.io/pollz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pollz.gitbook.io/pollz/guides/create-a-poll.md).

# Create a Poll

## Guide: Creating a Poll with pollz-js SDK

### Prerequisites

Before you proceed with creating a poll using the pollz-js SDK, ensure that you have already initialized the SDK by following the steps in the "[Initializing the pollz-js SDK](/pollz/guides/initializing-your-app.md)" guide.

### Create a Poll

Now that your SDK is initialized, you can easily create a poll with options using the pollz-js SDK.

#### Step 1: Import the SDK

In your Node.js application, ensure you have already imported the pollz-js SDK:

```javascript
const { PollzSDK, PollTypes } = require('pollz-js');
```

#### Step 2: Create a Poll

Use the `create` method provided by the `polls` module of the SDK to create a new poll. Provide the poll details such as the name, options, and poll type (MultipleChoice or SingleChoice).

```javascript
const pollz = new PollzSDK();

// Replace 'your-app-id' and 'your-app-secret' with actual credentials
const initInput = {
  appId: 'your-app-id',
  appSecret: 'your-app-secret',
};

// Initialize the SDK
await pollz.init(initInput);

// Create a poll
const createPollInput = {
  name: 'Favorite Programming Language',
  options: ['JavaScript', 'Python', 'Java', 'TypeScript'],
  pollTypeId: PollTypes.MultipleChoice, // or PollTypes.SingleChoice
};

try {
  const createdPoll = await pollz.polls.create(createPollInput);
  console.log('Poll created successfully:', createdPoll);
} catch (error) {
  console.error('Failed to create poll:', error.message);
}
```

Replace 'your-app-id' and 'your-app-secret' with the actual credentials obtained from the Pollz platform.

Congratulations! You have successfully created a poll using the pollz-js SDK. Continue exploring the SDK to enhance your application with additional features like voting and real-time updates. For more details on other functionalities, refer to the relevant guides in the "Guides" section.
