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

# Audio Posts

> Create audio posts where the SDK exposes audio post creation.

Audio posts attach uploaded audio files to a post. Upload the audio first, then pass the uploaded audio objects or file IDs to the post creation API.

<Info>
  TypeScript, Android, and iOS expose audio post creation APIs. Flutter can upload audio files, but the current public Flutter post creation builder does not expose an audio post creation method.
</Info>

<CardGroup cols={2}>
  <Card title="Uploaded Audio" icon="file-audio">
    Create posts from audio objects or file IDs returned by the audio upload flow.
  </Card>

  <Card title="Platform-Aware" icon="code">
    Use audio post creation only on SDKs that expose it in the public post builder.
  </Card>
</CardGroup>

## Parameters

| Parameter                               | Required | Description                                                   |
| --------------------------------------- | -------- | ------------------------------------------------------------- |
| `audios`, `uploadedAudios`, or `fileId` | Yes      | Uploaded audio objects or audio file IDs, depending on SDK.   |
| `text`                                  | No       | Caption text shown with the audio 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 an Audio Post

The examples below create an audio post in a community on SDKs that support audio post creation.

<CodeGroup>
  ```swift iOS theme={null}
  func createAudioPost(
      uploadedAudios: [AmityAudioData],
      communityId: String
  ) async throws -> AmityPost {
      let postRepository = AmityPostRepository()
      let builder = AmityAudioPostBuilder()
      builder.setAudios(uploadedAudios)
      builder.setText("Listen to this")

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

  ```kotlin Android theme={null}
  fun createAudioPost(
      uploadedAudios: Set<AmityAudio>,
      communityId: String
  ) {
      postRepository.createAudioPost(
          targetType = AmityPost.TargetType.COMMUNITY,
          targetId = communityId,
          audios = uploadedAudios,
          text = "Listen to this"
      )
          .subscribe({ post ->
              showSuccessMessage(post.getPostId())
          }, { error ->
              handleGeneralError(error)
          })
  }
  ```

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

  const { data: post } = await PostRepository.createAudioPost({
    targetType: "community",
    targetId: communityId,
    data: {
      text: "Listen to this",
    },
    attachments: [
      {
        type: "audio",
        fileId,
      },
    ],
  });
  ```
</CodeGroup>

## Flutter Support

Flutter's public file repository supports audio upload, but the public post creation builder currently exposes text, image, video, file, poll, live stream, and custom post creation paths. It does not expose `.audio(...)` or a dedicated audio post creator.

Use a supported Flutter post type, or create audio posts from a platform/backend layer that exposes audio post creation.

## Notes

* TypeScript accepts audio attachments as `{ type: "audio", fileId }`.
* Android accepts a `Set<AmityAudio>`.
* iOS accepts `[AmityAudioData]`.
* Do not set `structureType` manually; the service derives post structure from the created post data.

## Related Topics

<CardGroup cols={3}>
  <Card title="File Handling" icon="upload" href="/social-plus-sdk/core-concepts/content-handling/files-images-and-videos/file">
    Upload files before creating attachment-based posts.
  </Card>

  <Card title="Mixed Media Posts" icon="layer-group" href="./mixed-media-post">
    Combine multiple supported media attachment types.
  </Card>

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