Create a new message in message feed
curl --request POST \
--url https://apix.us.amity.co/api/v5/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"messageFeedId": "507f191e810c19729de860ea",
"referenceId": "1530b11ec8df87da22b06b27",
"dataType": "text",
"parentId": "abc665afd7dbb8d036037eea",
"data": {
"text": "test"
},
"fileId": "76bfe68974157a114053364d",
"metadata": {
"refId": "d601c27c0675baa2103ec573"
},
"tags": [
"tag1",
"tag2"
],
"mentionedUsers": [
{
"type": "user",
"userIds": [
"3cac302ab992aa17b215ba21",
"adb34ec2aeedca03a38e1d54"
]
}
],
"createdAt": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://apix.us.amity.co/api/v5/messages"
payload = {
"messageFeedId": "507f191e810c19729de860ea",
"referenceId": "1530b11ec8df87da22b06b27",
"dataType": "text",
"parentId": "abc665afd7dbb8d036037eea",
"data": { "text": "test" },
"fileId": "76bfe68974157a114053364d",
"metadata": { "refId": "d601c27c0675baa2103ec573" },
"tags": ["tag1", "tag2"],
"mentionedUsers": [
{
"type": "user",
"userIds": ["3cac302ab992aa17b215ba21", "adb34ec2aeedca03a38e1d54"]
}
],
"createdAt": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messageFeedId: '507f191e810c19729de860ea',
referenceId: '1530b11ec8df87da22b06b27',
dataType: 'text',
parentId: 'abc665afd7dbb8d036037eea',
data: {text: 'test'},
fileId: '76bfe68974157a114053364d',
metadata: {refId: 'd601c27c0675baa2103ec573'},
tags: ['tag1', 'tag2'],
mentionedUsers: [
{
type: 'user',
userIds: ['3cac302ab992aa17b215ba21', 'adb34ec2aeedca03a38e1d54']
}
],
createdAt: '2023-11-07T05:31:56Z'
})
};
fetch('https://apix.us.amity.co/api/v5/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apix.us.amity.co/api/v5/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'messageFeedId' => '507f191e810c19729de860ea',
'referenceId' => '1530b11ec8df87da22b06b27',
'dataType' => 'text',
'parentId' => 'abc665afd7dbb8d036037eea',
'data' => [
'text' => 'test'
],
'fileId' => '76bfe68974157a114053364d',
'metadata' => [
'refId' => 'd601c27c0675baa2103ec573'
],
'tags' => [
'tag1',
'tag2'
],
'mentionedUsers' => [
[
'type' => 'user',
'userIds' => [
'3cac302ab992aa17b215ba21',
'adb34ec2aeedca03a38e1d54'
]
]
],
'createdAt' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apix.us.amity.co/api/v5/messages"
payload := strings.NewReader("{\n \"messageFeedId\": \"507f191e810c19729de860ea\",\n \"referenceId\": \"1530b11ec8df87da22b06b27\",\n \"dataType\": \"text\",\n \"parentId\": \"abc665afd7dbb8d036037eea\",\n \"data\": {\n \"text\": \"test\"\n },\n \"fileId\": \"76bfe68974157a114053364d\",\n \"metadata\": {\n \"refId\": \"d601c27c0675baa2103ec573\"\n },\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"mentionedUsers\": [\n {\n \"type\": \"user\",\n \"userIds\": [\n \"3cac302ab992aa17b215ba21\",\n \"adb34ec2aeedca03a38e1d54\"\n ]\n }\n ],\n \"createdAt\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apix.us.amity.co/api/v5/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"messageFeedId\": \"507f191e810c19729de860ea\",\n \"referenceId\": \"1530b11ec8df87da22b06b27\",\n \"dataType\": \"text\",\n \"parentId\": \"abc665afd7dbb8d036037eea\",\n \"data\": {\n \"text\": \"test\"\n },\n \"fileId\": \"76bfe68974157a114053364d\",\n \"metadata\": {\n \"refId\": \"d601c27c0675baa2103ec573\"\n },\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"mentionedUsers\": [\n {\n \"type\": \"user\",\n \"userIds\": [\n \"3cac302ab992aa17b215ba21\",\n \"adb34ec2aeedca03a38e1d54\"\n ]\n }\n ],\n \"createdAt\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apix.us.amity.co/api/v5/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messageFeedId\": \"507f191e810c19729de860ea\",\n \"referenceId\": \"1530b11ec8df87da22b06b27\",\n \"dataType\": \"text\",\n \"parentId\": \"abc665afd7dbb8d036037eea\",\n \"data\": {\n \"text\": \"test\"\n },\n \"fileId\": \"76bfe68974157a114053364d\",\n \"metadata\": {\n \"refId\": \"d601c27c0675baa2103ec573\"\n },\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"mentionedUsers\": [\n {\n \"type\": \"user\",\n \"userIds\": [\n \"3cac302ab992aa17b215ba21\",\n \"adb34ec2aeedca03a38e1d54\"\n ]\n }\n ],\n \"createdAt\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"messages": [
{
"referenceId": "1530b11ec8df87da22b06b27",
"messageId": "a85dca058f5b585f86a29f14",
"networkId": "9530b11ec8de87db22b06b27",
"channelId": "abc665aed9dbb8d036037eed",
"channelType": "community",
"messageFeedId": "507f191e810c19729de860ea",
"segment": 123,
"dataType": "text",
"data": {
"text": "test"
},
"fileId": "76bfe68974157a114053364d",
"thumbnailFileId": "76bfe68974157a114053364e",
"metadata": {
"refId": "d601c27c0675baa2103ec573"
},
"tags": [
"tag1",
"tag2"
],
"creatorId": "5349b4ddd2781d08c09890f4",
"mentionedUsers": [
{
"type": "user",
"userIds": [
"3cac302ab992aa17b215ba21",
"adb34ec2aeedca03a38e1d54"
]
}
],
"reactions": {
"like": 1,
"love": 2
},
"reactionCount": 123,
"parentId": "abc665afd7dbb8d036037eea",
"path": "12cba9779cc479e1fcefd1de/chat/f00ab16cbd27d4a9525aea6d/32b468ae0b1bd0cc7976719d/0a003482f0ac53a71e7c9239",
"flagCount": 123,
"childCount": 123,
"isDeleted": false,
"editedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"myReactions": [
"like",
"love"
]
}
],
"messageFeeds": [
{
"messageFeedId": "a85dca058f5b585f86a29f14",
"channelId": "abc665aed9dbb8d036037eeb",
"channelPublicId": "abc665aed9dbb8d036037eeb",
"channelType": "community",
"name": "text",
"creatorId": "8aa313c8dbb00af911b07672",
"path": "12cba9779cc479e1fcefd1de/chat/f00ab16cbd27d4a9525aea6d/32b468ae0b1bd0cc7976719d/0a003482f0ac53a71e7c9239",
"childCount": 123,
"isDeleted": false,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"lastMessageId": "9530b11ec8de87db22b06b21",
"lastMessageTimestamp": "2023-11-07T05:31:56Z",
"editedAt": "2023-11-07T05:31:56Z",
"messagePreviewId": "<string>"
}
],
"files": [
{
"fileId": "<string>",
"fileUrl": "<string>",
"accessType": "public",
"altText": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"attributes": {
"name": "<string>",
"extension": "<string>",
"size": 123,
"mimeType": "<string>",
"metadata": {
"exif": {},
"gps": {},
"height": 123,
"width": 123,
"isFull": true
}
}
}
],
"users": [
{
"userId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"_id": "<string>",
"path": "<string>",
"roles": [
"<string>"
],
"displayName": "<string>",
"flagCount": 123,
"hashFlag": {
"bits": 123,
"hashes": 123,
"hash": [
"<string>"
]
},
"metadata": {},
"isDeleted": true
}
]
}Message
Create a new message in message feed
Create a new message
POST
/
api
/
v5
/
messages
Create a new message in message feed
curl --request POST \
--url https://apix.us.amity.co/api/v5/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"messageFeedId": "507f191e810c19729de860ea",
"referenceId": "1530b11ec8df87da22b06b27",
"dataType": "text",
"parentId": "abc665afd7dbb8d036037eea",
"data": {
"text": "test"
},
"fileId": "76bfe68974157a114053364d",
"metadata": {
"refId": "d601c27c0675baa2103ec573"
},
"tags": [
"tag1",
"tag2"
],
"mentionedUsers": [
{
"type": "user",
"userIds": [
"3cac302ab992aa17b215ba21",
"adb34ec2aeedca03a38e1d54"
]
}
],
"createdAt": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://apix.us.amity.co/api/v5/messages"
payload = {
"messageFeedId": "507f191e810c19729de860ea",
"referenceId": "1530b11ec8df87da22b06b27",
"dataType": "text",
"parentId": "abc665afd7dbb8d036037eea",
"data": { "text": "test" },
"fileId": "76bfe68974157a114053364d",
"metadata": { "refId": "d601c27c0675baa2103ec573" },
"tags": ["tag1", "tag2"],
"mentionedUsers": [
{
"type": "user",
"userIds": ["3cac302ab992aa17b215ba21", "adb34ec2aeedca03a38e1d54"]
}
],
"createdAt": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messageFeedId: '507f191e810c19729de860ea',
referenceId: '1530b11ec8df87da22b06b27',
dataType: 'text',
parentId: 'abc665afd7dbb8d036037eea',
data: {text: 'test'},
fileId: '76bfe68974157a114053364d',
metadata: {refId: 'd601c27c0675baa2103ec573'},
tags: ['tag1', 'tag2'],
mentionedUsers: [
{
type: 'user',
userIds: ['3cac302ab992aa17b215ba21', 'adb34ec2aeedca03a38e1d54']
}
],
createdAt: '2023-11-07T05:31:56Z'
})
};
fetch('https://apix.us.amity.co/api/v5/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apix.us.amity.co/api/v5/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'messageFeedId' => '507f191e810c19729de860ea',
'referenceId' => '1530b11ec8df87da22b06b27',
'dataType' => 'text',
'parentId' => 'abc665afd7dbb8d036037eea',
'data' => [
'text' => 'test'
],
'fileId' => '76bfe68974157a114053364d',
'metadata' => [
'refId' => 'd601c27c0675baa2103ec573'
],
'tags' => [
'tag1',
'tag2'
],
'mentionedUsers' => [
[
'type' => 'user',
'userIds' => [
'3cac302ab992aa17b215ba21',
'adb34ec2aeedca03a38e1d54'
]
]
],
'createdAt' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apix.us.amity.co/api/v5/messages"
payload := strings.NewReader("{\n \"messageFeedId\": \"507f191e810c19729de860ea\",\n \"referenceId\": \"1530b11ec8df87da22b06b27\",\n \"dataType\": \"text\",\n \"parentId\": \"abc665afd7dbb8d036037eea\",\n \"data\": {\n \"text\": \"test\"\n },\n \"fileId\": \"76bfe68974157a114053364d\",\n \"metadata\": {\n \"refId\": \"d601c27c0675baa2103ec573\"\n },\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"mentionedUsers\": [\n {\n \"type\": \"user\",\n \"userIds\": [\n \"3cac302ab992aa17b215ba21\",\n \"adb34ec2aeedca03a38e1d54\"\n ]\n }\n ],\n \"createdAt\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apix.us.amity.co/api/v5/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"messageFeedId\": \"507f191e810c19729de860ea\",\n \"referenceId\": \"1530b11ec8df87da22b06b27\",\n \"dataType\": \"text\",\n \"parentId\": \"abc665afd7dbb8d036037eea\",\n \"data\": {\n \"text\": \"test\"\n },\n \"fileId\": \"76bfe68974157a114053364d\",\n \"metadata\": {\n \"refId\": \"d601c27c0675baa2103ec573\"\n },\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"mentionedUsers\": [\n {\n \"type\": \"user\",\n \"userIds\": [\n \"3cac302ab992aa17b215ba21\",\n \"adb34ec2aeedca03a38e1d54\"\n ]\n }\n ],\n \"createdAt\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apix.us.amity.co/api/v5/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messageFeedId\": \"507f191e810c19729de860ea\",\n \"referenceId\": \"1530b11ec8df87da22b06b27\",\n \"dataType\": \"text\",\n \"parentId\": \"abc665afd7dbb8d036037eea\",\n \"data\": {\n \"text\": \"test\"\n },\n \"fileId\": \"76bfe68974157a114053364d\",\n \"metadata\": {\n \"refId\": \"d601c27c0675baa2103ec573\"\n },\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"mentionedUsers\": [\n {\n \"type\": \"user\",\n \"userIds\": [\n \"3cac302ab992aa17b215ba21\",\n \"adb34ec2aeedca03a38e1d54\"\n ]\n }\n ],\n \"createdAt\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"messages": [
{
"referenceId": "1530b11ec8df87da22b06b27",
"messageId": "a85dca058f5b585f86a29f14",
"networkId": "9530b11ec8de87db22b06b27",
"channelId": "abc665aed9dbb8d036037eed",
"channelType": "community",
"messageFeedId": "507f191e810c19729de860ea",
"segment": 123,
"dataType": "text",
"data": {
"text": "test"
},
"fileId": "76bfe68974157a114053364d",
"thumbnailFileId": "76bfe68974157a114053364e",
"metadata": {
"refId": "d601c27c0675baa2103ec573"
},
"tags": [
"tag1",
"tag2"
],
"creatorId": "5349b4ddd2781d08c09890f4",
"mentionedUsers": [
{
"type": "user",
"userIds": [
"3cac302ab992aa17b215ba21",
"adb34ec2aeedca03a38e1d54"
]
}
],
"reactions": {
"like": 1,
"love": 2
},
"reactionCount": 123,
"parentId": "abc665afd7dbb8d036037eea",
"path": "12cba9779cc479e1fcefd1de/chat/f00ab16cbd27d4a9525aea6d/32b468ae0b1bd0cc7976719d/0a003482f0ac53a71e7c9239",
"flagCount": 123,
"childCount": 123,
"isDeleted": false,
"editedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"myReactions": [
"like",
"love"
]
}
],
"messageFeeds": [
{
"messageFeedId": "a85dca058f5b585f86a29f14",
"channelId": "abc665aed9dbb8d036037eeb",
"channelPublicId": "abc665aed9dbb8d036037eeb",
"channelType": "community",
"name": "text",
"creatorId": "8aa313c8dbb00af911b07672",
"path": "12cba9779cc479e1fcefd1de/chat/f00ab16cbd27d4a9525aea6d/32b468ae0b1bd0cc7976719d/0a003482f0ac53a71e7c9239",
"childCount": 123,
"isDeleted": false,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"lastMessageId": "9530b11ec8de87db22b06b21",
"lastMessageTimestamp": "2023-11-07T05:31:56Z",
"editedAt": "2023-11-07T05:31:56Z",
"messagePreviewId": "<string>"
}
],
"files": [
{
"fileId": "<string>",
"fileUrl": "<string>",
"accessType": "public",
"altText": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"attributes": {
"name": "<string>",
"extension": "<string>",
"size": 123,
"mimeType": "<string>",
"metadata": {
"exif": {},
"gps": {},
"height": 123,
"width": 123,
"isFull": true
}
}
}
],
"users": [
{
"userId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"_id": "<string>",
"path": "<string>",
"roles": [
"<string>"
],
"displayName": "<string>",
"flagCount": 123,
"hashFlag": {
"bits": 123,
"hashes": 123,
"hash": [
"<string>"
]
},
"metadata": {},
"isDeleted": true
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Message object that needs to be added
Message feed id of message
Maximum string length:
30Example:
"507f191e810c19729de860ea"
A reference ID
Maximum string length:
30Example:
"1530b11ec8df87da22b06b27"
Type of data
Maximum string length:
20Example:
"text"
Parent id of message
Maximum string length:
30Example:
"abc665afd7dbb8d036037eea"
A custom object for storing message. The size of this object must be less than 10 kb.
Example:
{ "text": "test" }
File id
Maximum string length:
30Example:
"76bfe68974157a114053364d"
A custom object for storing the other data. The size of this object must be less than 20 kb.
Example:
{ "refId": "d601c27c0675baa2103ec573" }
List of tags for searching
Maximum array length:
10Maximum string length:
30Example:
["tag1", "tag2"]
List of mentioned users
Show child attributes
Show child attributes
A created date/time of message
Response
Create message payload
⌘I