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

> Send audio chat messages on SDKs that expose audio message creation.

Use audio messages for voice notes and audio attachments. TypeScript creates audio messages from an uploaded file ID. iOS and Android use `AmityMessageAttachment`. The current Flutter public message create selector does not expose an audio creator.

<Info>
  Flutter supports text, image, file, video, and custom message creators in the current public `createMessage` selector. Do not use a fabricated Flutter audio creator; use another supported message type or confirm audio-message support in your SDK version first.
</Info>

## Parameters

| Parameter               | Required | Description                                                                                           |
| ----------------------- | -------- | ----------------------------------------------------------------------------------------------------- |
| `subChannelId`          | Yes      | Target subchannel where the audio message will be created.                                            |
| `fileId` / `attachment` | Yes      | Uploaded audio file ID on TypeScript or platform attachment on iOS and Android.                       |
| `fileName`              | Depends  | File name for iOS local URL attachments.                                                              |
| `parentId`              | No       | Parent message ID when sending the audio message as a reply, where supported by the platform builder. |
| `tags`                  | No       | App-defined tags for message filtering, where supported by the platform builder.                      |
| `metadata`              | No       | App-defined metadata stored with the message, where supported by the platform builder.                |

## Send An Audio Message

Create an audio message from an uploaded file ID or platform attachment, depending on the SDK.

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

  const { data: message } = await MessageRepository.createMessage({
    subChannelId,
    dataType: 'audio',
    fileId,
  });

  renderResults(message);
  ```

  ```swift iOS theme={null}
  let audioURL = URL(fileURLWithPath: "/tmp/voice.m4a")
  let options = AmityAudioMessageCreateOptions(
      subChannelId: "sub-channel-id",
      attachment: .localURL(url: audioURL),
      fileName: "voice.m4a"
  )

  let message = try await messageRepository.createAudioMessage(options: options)
  showSuccessMessage(message.messageId)
  ```

  ```kotlin Android theme={null}
  val attachment = AmityMessageAttachment.FILE_ID(fileId)

  val disposable = AmityChatClient.newMessageRepository()
      .createAudioMessage(
          subChannelId = subChannelId,
          attachment = attachment,
      )
      .build()
      .send()
      .subscribe(
          { showSuccessMessage() },
          { error -> handleGeneralError(error) },
      )
  ```
</CodeGroup>

## Related Topics

<CardGroup cols={2}>
  <Card title="File Message" href="./file-message" icon="file">
    Send the audio file as a generic file attachment if that fits your product behavior.
  </Card>

  <Card title="Video Message" href="./video-message" icon="video">
    Send video attachments.
  </Card>
</CardGroup>
