> ## Documentation Index
> Fetch the complete documentation index at: https://social-b97141fb-feat-user-history-moderation-detail.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Poll Posts

> Create poll posts that reference an existing social.plus poll.

Poll posts share an existing poll in a user or community feed. Create the poll first with the Poll Repository, then create a post that references the returned `pollId`.

<Warning>
  Create the poll before creating the post. See [Poll Creation Guidelines](/social-plus-sdk/core-concepts/content-handling/poll#create-a-poll) for poll creation examples.
</Warning>

<CardGroup cols={2}>
  <Card title="Poll Reference" icon="square-poll-vertical">
    A poll post points to a `pollId` returned by the poll creation flow.
  </Card>

  <Card title="Feed Delivery" icon="rss">
    Publish the poll into a user feed or community feed with optional text.
  </Card>
</CardGroup>

## Parameters

| Parameter | Required | Platforms | Description |
| - | - | - | - |
| `pollId` | Yes | TypeScript, iOS, Android, Flutter | ID of an existing poll created before post creation. |
| `text` | No | TypeScript, iOS, Android, Flutter | Feed caption or prompt shown with the poll post. |
| `targetType` | Yes | TypeScript, iOS, Android, Flutter | Feed target, usually `community` or `user`. |
| `targetId` | Yes | TypeScript, iOS, Android, Flutter | Community ID or user ID for the target feed. |
| `metadata` | No | TypeScript, iOS, Android, Flutter | Custom metadata stored with the post where supported. |
| `mentionees` | No | TypeScript, iOS, Android, Flutter | User mention payload where supported by the platform builder. |
| `productTags` | No | TypeScript, iOS | Products named in the parent post text. Poll choices are not product-tag targets. |

## Create a Poll Post

The examples below create a poll post in a community from an existing `pollId`.

<CodeGroup>
  ```swift iOS theme={null}
  func createPollPost(
      pollId: String,
      communityId: String
  ) async throws -> AmityPost {
      let postRepository = AmityPostRepository()
      let builder = AmityPollPostBuilder()
      builder.setPollId(pollId)
      builder.setText("Vote for featured product")

      return try await postRepository.createPollPost(
          builder,
          targetId: communityId,
          targetType: .community,
          metadata: nil,
          mentionees: nil,
          productTags: [
              AmityTextProductTag(productId: "prod_001", index: 9, length: 12)
          ]
      )
  }
  ```

  ```kotlin Android theme={null}
  postRepository.createPollPost(
      targetType = AmityPost.TargetType.COMMUNITY,
      targetId = communityId,
      pollId = pollId,
      text = "Vote in this poll"
  )
      .subscribe({ post ->
          showSuccessMessage(post.getPostId())
      }, { error ->
          handleGeneralError(error)
      })
  ```

  ```typescript TypeScript theme={null}
  import { PostRepository } from "@amityco/ts-sdk";

  const { data: post } = await PostRepository.createPost({
    targetType: "community",
    targetId: communityId,
    dataType: "poll",
    data: {
      text: "Vote for featured product",
      pollId,
    },
    productTags: [
      { productId: "prod_001", text: "featured product", index: 9, length: 16 },
    ],
  });
  ```

  ```dart Flutter theme={null}
  final post = await AmitySocialClient.newPostRepository()
      .createPost()
      .targetCommunity(communityId)
      .poll(pollId)
      .text('Vote in this poll')
      .post();
  ```
</CodeGroup>

<Note>
  **Product tags (SDK API).** A poll post has a text parent and a poll child. TypeScript's generic `createPost({ dataType: "poll", ... })` and iOS `createPollPost` expose text `productTags` for the parent caption. The public Android and Flutter poll creators expose no product-tag field, and a poll child has no attachment-tag input. UIKit's product-tag UI is a separate surface and may support fewer post types; see [UIKit Product Tagging](/uikit/components/social/product-tagging).
</Note>

## Notes

* The post creation call does not create the poll. It only attaches an existing poll by ID.
* Keep the poll question, answers, answer type, and close time in the poll creation flow.
* Use the post text for feed context or a short prompt; the poll object remains the source of truth for answer options and voting behavior.

## Related Topics

<CardGroup cols={3}>
  <Card title="Poll Creation" icon="square-poll-vertical" href="/social-plus-sdk/core-concepts/content-handling/poll#create-a-poll">
    Create the poll object before publishing a poll post.
  </Card>

  <Card title="Text Posts" icon="text" href="./text-post">
    Create a simple feed post without a poll attachment.
  </Card>

  <Card title="Posts Overview" icon="newspaper" href="../overview">
    Review post concepts, retrieval, and moderation flows.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.