> ## Documentation Index
> Fetch the complete documentation index at: https://learn.social.plus/llms.txt
> Use this file to discover all available pages before exploring further.

# Live Stream Posts (Deprecated)

> Create legacy live stream posts from an existing stream ID. For new live and co-host experiences, use room posts.

Live stream posts are the legacy feed representation for an existing live stream. The stream itself must be created through the Video SDK first, then its `streamId` can be attached to a post.

<Warning>
  For new live and co-host room experiences, create a room and publish a room post instead. The iOS live stream post API is deprecated in favor of `createRoomPost`.
</Warning>

## When to Use

| Use case                                      | Recommended post type   |
| --------------------------------------------- | ----------------------- |
| Existing legacy live stream integration       | Live stream post        |
| New live broadcast or co-host room experience | Room post               |
| Uploaded video playback                       | Video post or clip post |

## Parameters

| Parameter    | Required | Description                                          |
| ------------ | -------- | ---------------------------------------------------- |
| `streamId`   | Yes      | ID of the live stream created before post creation   |
| `text`       | No       | Caption text shown with the post                     |
| `targetType` | Yes      | Feed target, usually `community` or `user`           |
| `targetId`   | Yes      | Community ID or user ID for the target feed          |
| `metadata`   | No       | Custom metadata stored with the post where supported |

## Create a Live Stream Post

Create a legacy live stream post only when your product still has an existing stream ID from the older live-stream flow.

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

  const { data: post } = await PostRepository.createPost({
    targetType: "community",
    targetId: communityId,
    dataType: "liveStream",
    data: {
      streamId,
      text: "Watch this live session",
    },
  });
  ```

  ```kotlin Android theme={null}
  fun createLegacyLiveStreamPost(streamId: String, communityId: String) {
      postRepository.createLiveStreamPost(
          targetType = AmityPost.TargetType.COMMUNITY,
          targetId = communityId,
          streamId = streamId,
          text = "Watch this live session"
      )
          .subscribe(
              { post -> showSuccessMessage(post.getPostId()) },
              { error -> handleGeneralError(error) }
          )
  }
  ```

  ```swift iOS theme={null}
  func createLegacyLiveStreamPost(
      streamId: String,
      communityId: String
  ) async throws -> AmityPost {
      let postRepository = AmityPostRepository()
      let builder = AmityLiveStreamPostBuilder(
          streamId: streamId,
          text: "Watch this live session"
      )

      return try await postRepository.createLiveStreamPost(
          builder,
          targetId: communityId,
          targetType: .community,
          metadata: nil,
          mentionees: nil
      )
  }
  ```

  ```dart Flutter theme={null}
  Future<AmityPost> createLegacyLiveStreamPost(
    String streamId,
    String communityId,
  ) {
    return AmitySocialClient.newPostRepository()
        .createPost()
        .targetCommunity(communityId)
        .liveStream(streamId)
        .text('Watch this live session')
        .post();
  }
  ```
</CodeGroup>

## Platform Notes

* TypeScript creates a legacy live stream post through `PostRepository.createPost()` with `dataType: "liveStream"`.
* Android exposes `AmityPostRepository.createLiveStreamPost()`.
* iOS exposes `AmityPostRepository.createLiveStreamPost()`, but the method is deprecated in favor of `createRoomPost()`.
* Flutter exposes `.liveStream(streamId)` on the public post creation builder.

## Related Topics

<CardGroup cols={3}>
  <Card title="Room Posts" icon="users-viewfinder" href="./room-post">
    Use room posts for new live and co-host experiences.
  </Card>

  <Card title="Video Posts" icon="film" href="./video-post">
    Create posts from uploaded video files.
  </Card>

  <Card title="Video SDK" icon="video" href="/social-plus-sdk/video-new/broadcasting/overview">
    Create and manage live streams before posting.
  </Card>
</CardGroup>
