> ## 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.

# Mixed Media Posts

> Create posts that combine multiple uploaded media attachment types where the SDK exposes mixed media creation.

Mixed media posts combine two or more uploaded attachment types in one post, such as images with videos or files with audio. Upload each media item first, then pass the uploaded media objects or file IDs to the mixed media creation API.

<Info>
  TypeScript, Android, and iOS expose mixed media post creation APIs. The current public Flutter post creation builder exposes single attachment-type creators for image, video, and file posts, but it does not expose a mixed media post creator.
</Info>

<CardGroup cols={2}>
  <Card title="Combined Attachments" icon="layer-group">
    Keep related uploaded media in one post instead of splitting it into separate posts.
  </Card>

  <Card title="Derived Structure" icon="diagram-project">
    The service derives the post structure from the attachment types; do not set it manually.
  </Card>
</CardGroup>

## Parameters

| Parameter                                       | Required | Description                                                                            |
| ----------------------------------------------- | -------- | -------------------------------------------------------------------------------------- |
| `attachments`, uploaded media sets, or file IDs | Yes      | Uploaded media items to combine in one post. Supported attachment types depend on SDK. |
| `text`                                          | No       | Caption text shown with the mixed media 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.                                  |
| `mentionees`                                    | No       | User mention payload where supported by the platform builder.                          |

## Create a Mixed Media Post

The examples below combine image and video attachments in a community post. Add audio or file attachments on SDKs that expose those uploaded media object types.

<CodeGroup>
  ```swift iOS theme={null}
  func createMixedMediaPost(
      uploadedImages: [AmityImageData],
      uploadedVideos: [AmityVideoData],
      communityId: String
  ) async throws -> AmityPost {
      let postRepository = AmityPostRepository()
      let builder = AmityMixedMediaPostBuilder()
      builder.setText("Photos and video from today")
      builder.setImages(uploadedImages)
      builder.setVideos(uploadedVideos)

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

  ```kotlin Android theme={null}
  fun createMixedMediaPost(
      uploadedImages: Set<AmityImage>,
      uploadedVideos: Set<AmityVideo>,
      communityId: String
  ) {
      val attachments = mutableSetOf<AmityAttachment>()
      attachments.addAll(uploadedImages)
      attachments.addAll(uploadedVideos)

      postRepository.createMixedAttachmentPost(
          targetType = AmityPost.TargetType.COMMUNITY,
          targetId = communityId,
          attachments = attachments,
          text = "Photos and video from today"
      )
          .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,
    data: {
      text: "Photos and video from today",
    },
    attachments: [
      {
        type: "image",
        fileId: imageFileId,
      },
      {
        type: "video",
        fileId: videoFileId,
      },
    ],
  });
  ```
</CodeGroup>

## Flutter Support

Flutter's current public post creation builder exposes `.image(...)`, `.video(...)`, and `.file(...)` for single attachment-type posts. It does not expose a public mixed media builder that accepts multiple attachment types in one post creation call.

Create a single supported post type from Flutter, or create mixed media posts from a platform/backend layer that exposes mixed attachment creation.

## Notes

* TypeScript accepts mixed attachments in `PostRepository.createPost`.
* Android accepts a `Set<AmityAttachment>` through `createMixedAttachmentPost`.
* iOS accepts uploaded media through `AmityMixedMediaPostBuilder`.
* Do not pass `structureType` in the create request. The service derives it from the attachment composition.

## Related Topics

<CardGroup cols={3}>
  <Card title="Image Posts" icon="image" href="./image-post">
    Create image-only posts from uploaded images.
  </Card>

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

  <Card title="File Posts" icon="file" href="./file-post">
    Create file-only posts from uploaded files.
  </Card>
</CardGroup>
