Skip to main content
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.
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.

Uploaded Audio

Create posts from audio objects or file IDs returned by the audio upload flow.

Platform-Aware

Use audio post creation only on SDKs that expose it in the public post builder.

Create an Audio Post

The examples below create an audio post in a community on SDKs that support audio post creation.
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
    )
}

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.