# Create poll

## Fields Information

### **Poll**

| Key                     | Type     | Description                                                         |
| ----------------------- | -------- | ------------------------------------------------------------------- |
| **question** `required` | `string` | The question/title of the Poll                                      |
| **identifier**          | `string` | Can be used to pass in custom identifier, eg - user id, email, etc. |
| **data**                | `object` | A flexible data field to store any meta data with each option       |

### **Option**

**Minimum 2 Options are required in a poll** (Just making the obvious known :sweat\_smile: )

| Key                 | Type     | Description                                                   |
| ------------------- | -------- | ------------------------------------------------------------- |
| **text** `required` | `string` | String to store the option's text                             |
| **data**            | `object` | A flexible data field to store any meta data with each option |

## Creating a Poll

<mark style="color:green;">`POST`</mark> `https://api.pollsapi.com/v1/create/poll`

This endpoint allows you to get free cakes.

#### Headers

| Name         | Type   | Description              |
| ------------ | ------ | ------------------------ |
| Content-Type | string | application/json         |
| api-key      | string | API Key for your account |

#### Request Body

| Name       | Type   | Description                                                                                  |
| ---------- | ------ | -------------------------------------------------------------------------------------------- |
| identifier | string | Can be used to store a custom identifier                                                     |
| data       | object | A flexible data field to store custom metadata                                               |
| question   | string | The question/title of the poll you are creating                                              |
| options    | array  | List of options the poll should have(Min. 2). Please check below for the structure of Option |

{% tabs %}
{% tab title="200 Poll Created" %}

```javascript
{
  "status": "success",
  "statusCode": 200,
  "data": {
    "identifier": null,
    "question": "Do you like polls?",
    "data": {},
    "created_at": "2020-10-24T02:28:46.391Z",
    "updated_at": "2020-10-24T02:28:46.391Z",
    "id": "5f93915e7e044c74074f072e",
    "entity": "Poll",
    "options": [
      {
        "text": "Yes",
        "votes_count": 0,
        "data": {},
        "poll_id": "5f93915e7e044c74074f072e",
        "created_at": "2020-10-24T02:28:46.422Z",
        "updated_at": "2020-10-24T02:28:46.422Z",
        "id": "5f93915e7e044c74074f072f",
        "entity": "Option"
      },
      {
        "text": "No",
        "votes_count": 0,
        "data": {},
        "poll_id": "5f93915e7e044c74074f072e",
        "created_at": "2020-10-24T02:28:46.422Z",
        "updated_at": "2020-10-24T02:28:46.422Z",
        "id": "5f93915e7e044c74074f0730",
        "entity": "Option"
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

### Example cURL request

```bash
curl -X POST \
  'https://api.pollsapi.com/v1/create/poll' \
  -H 'content-type: application/json' \
  -H "api-key: $API_KEY" \
  -d '
{
  "question": "Do you like polls?",
  "options": [
    {
      "text": "Yes"
    },
    {
      "text": "No"
    }
  ]
}
'
```

## Request Body

```javascript
{
    "question": "Does this doc help?",
    "identifier": "custom_identifier",
    "data": {
        "custom": "Poll Data"
    }
    "options": [
        {
            "text": "Option Text",
            "data": {
                "custom": "data"
            }
        },
        {
            "text": "Option Text2",
            "data": {
                "custom": "data"
            }
        }
    ]
}
```

##


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pollsapi.com/api/create-poll.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
