> ## Documentation Index
> Fetch the complete documentation index at: https://social-b97141fb-feat-user-history-moderation-detail.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Message

> Send image chat messages with platform-specific file ID, attachment, or URI inputs.

Use image messages after the user selects or uploads an image. TypeScript creates image messages with a file ID. iOS and Android use `AmityMessageAttachment`. Flutter sends image messages from a `Uri`.

## Parameters

| Parameter | Required | Description |
| - | - | - |
| `subChannelId` | Yes | Target subchannel where the image message will be created. |
| `fileId` / `attachment` / `Uri` | Yes | Image input for the message: uploaded file ID, platform attachment, or Flutter `Uri`. |
| `caption` | No | Text caption attached to the image message where the platform exposes it. |
| `fullImage` | No | iOS option for sending the full image variant. |
| `parentId` | No | Parent message ID when sending the image as a reply. |
| `tags` | No | App-defined tags for filtering or grouping image messages. |
| `metadata` | No | App-defined metadata stored with the message. |

## Send An Image Message

Create an image message from an uploaded file ID, native attachment, or Flutter image URI.

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

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

  renderResults(message);
  ```

  ```swift iOS theme={null}
  let imageURL = URL(fileURLWithPath: "/tmp/photo.jpg")
  let options = AmityImageMessageCreateOptions(
      subChannelId: "sub-channel-id",
      attachment: .localURL(url: imageURL),
      caption: "Photo from today"
  )

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

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

  val disposable = AmityChatClient.newMessageRepository()
      .createImageMessage(
          subChannelId = subChannelId,
          attachment = attachment,
      )
      .caption("Photo from today")
      .build()
      .send()
      .subscribe(
          { showSuccessMessage() },
          { error -> handleGeneralError(error) },
      )
  ```

  ```dart Flutter theme={null}
  final imageUri = Uri.parse('file:///tmp/photo.jpg');

  final message = await AmityChatClient.newMessageRepository()
      .createMessage(subChannelId)
      .image(imageUri)
      .caption('Photo from today')
      .send();
  ```
</CodeGroup>

## Optional Context

Add captions, tags, metadata, or reply context when your product needs richer image-message behavior.

<CodeGroup>
  ```swift iOS theme={null}
  let imageURL = URL(fileURLWithPath: "/tmp/photo.jpg")
  let options = AmityImageMessageCreateOptions(
      subChannelId: "sub-channel-id",
      attachment: .localURL(url: imageURL),
      caption: "Launch photo",
      fullImage: true,
      tags: ["launch"],
      metadata: ["source": "composer"],
      parentId: "parent-message-id"
  )

  let reply = try await messageRepository.createImageMessage(options: options)
  showSuccessMessage(reply.messageId)
  ```

  ```kotlin Android theme={null}
  val metadata = JsonObject().apply {
      addProperty("source", "composer")
  }

  val disposable = AmityChatClient.newMessageRepository()
      .createImageMessage(subChannelId, AmityMessageAttachment.FILE_ID(fileId))
      .caption("Launch photo")
      .tags(AmityTags(listOf("launch")))
      .metadata(metadata)
      .parentId(messageId)
      .build()
      .send()
      .subscribe()
  ```
</CodeGroup>

## Related Topics

<CardGroup cols={2}>
  <Card title="File Message" href="./file-message" icon="file">
    Send non-image file attachments.
  </Card>

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.