Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Send MAM Message

marktwtn edited this page Jul 21, 2020 · 6 revisions

Sending Masked Authenticated Message

Masked Authenticated Message let you create a channel and publish message stream within. In this API, tangle-accelerator provides user ability to create a unique channel stream and broadcast a message whose size can be bigger than one transaction. After the MAM bundle has been wrapped up, tangle-accelerator will broadcast it to the tangle and return the bundle hash and channel id back to users. Header of Content-Type with application/json is required.

POST /mam/send

Request

Parameters

Name Type Required or Optional Description
x-api-key string Optional API token for Alfred.
seed string Required Channel root seed. It is an 81-trytes string.
message string Required Message payload of the MAM packet in ASCII. Arbitrary length string.
protocol string Required The protocol the current request used. Now only MAM_V1 is supported.

Sample Request

{
	"x-api-key": "3bff60110c9f0e40628031b16dfefe2eb45a6b0c2237b49ef5109f9aa8eb19a8",
	"data": {
		"seed": "ABFXQETKSHDYPFUDO9ILVCAVQIXOHXKCECZYFLPBNVIX9JUXQZJE9URQEEUWPWYZOIACTCGZX9IDIODCA",
		"message": "this is message No1"
	},
	"protocol": "MAM_V1"
}

Response

Result

Name Type Description
bundle_hash string The hash of IOTA transaction bundle. It is an 81-trytes string.
chid string Channel ID. It is an 81-trytes string.
msg_id string Message ID which is unique under a channel. It is an 21-trytes string.

Sample Response

{
	"bundle_hash": "DZUJLFILAFTSZVXWZGVBNSLWTULUHEH9ETGXIWLAEJVAOPGT9C9OKKRVUBRIITCVSUQLGAJFGYBWJGLAA",
	"chid": "JVYTMGBIWU9NMUKUOVBAVBVW9QMSOOGUK9SB9OMILKMEVHWMPFALZBGPEBRAXESZZKEUGK9QEHAABTOIJ",
	"msg_id": "IONONZOXVGTNGVEOCXPUI"
}

curl Example

$ curl node.deviceproof.org:5566/mam/send \
    -X POST \
    -H 'Content-Type: application/json' \
    -d '{"x-api-key": "3bff60110c9f0e40628031b16dfefe2eb45a6b0c2237b49ef5109f9aa8eb19a8","data": {"seed": "ABFXQETKSHDYPFUDO9ILVCAVQIXOHXKCECZYFLPBNVIX9JUXQZJE9URQEEUWPWYZOIACTCGZX9IDIODCA","message": "This is message No1"},"protocol": "MAM_V1"}'

Errors

In the following conditions that a client who send a request will receive an HTTP error code 400 and JSON object in response body.

  • The absence of any required field
  • seed field is less than 81 trytes
  • protocol field is filled with not supported standard (currently tangle-accelerator supports only MAM_V1)