Image Messages

An Image Message has a few uses:

  • Allow a user to drag and drop one or more Images from their desktop and send them as Messages that just show the image and nothing more
  • Allow an application to send images with titles, subtitles and other annotations. For example, one might send a product picture with the name and description of the product associated with it.
Basic Image Message
Image with Details
Name Required Type Description
mime_type Yes String application/vnd.layer.image+json
source_url No String URL to a remote Image (do not use this if source is in use)
title No String Title for the Image Message
subtitle No String Rendered below the title
author No String Rendered below the subtitle
width Recommended Number Width in pixels of the source image
height Recommended Number Height in pixels of the source image
custom_data No Object Data that will not be understood by any Layer provided Renderer, but which will allow additional context to be stored in the Message so your server can better understand it when next your server sees the Message

If text is provided, but no title, subtitle or author then this Text Message will render as a regular chat bubble rather than look like a quoted message with metadata shown below it:

SAPI payload for creating a Basic Image Message:

{
	"sender_id": "layer:///identities/frodo-the-dodo",
	"parts": [
		{
			"id": "layer:///messages/GENERATE_A_UUID/parts/GENERATE_A_UUID",
			"mime_type": "application/vnd.layer.image+json;role=root",
			"body": JSON.stringify({
        "source_url": "https://78.media.tumblr.com/1b019b4237ab18f789381941eca98784/tumblr_nlmlir7Lhk1u0k6deo1_400.gif",
        "width": 254,
        "height": 210
      })
		}
	]
}

SAPI payload for a Full Image Message:

{
	"sender_id": "layer:///identities/frodo-the-dodo",
	"parts": [
		{
			"id": "layer:///messages/GENERATE_A_UUID/parts/GENERATE_A_UUID",
			"mime_type": "application/vnd.layer.image+json;role=root",
			"body": JSON.stringify({
        "source_url": "https://78.media.tumblr.com/1b019b4237ab18f789381941eca98784/tumblr_nlmlir7Lhk1u0k6deo1_400.gif",
        "width": 254,
        "height": 210,
        "title": "T'is only a flesh wound!"
      })
		}
	]
}