TS Commerce Developers

Messages API

Current version: v1.1 beta

List chat

Get the list of available chats. A merchant can only communicate with users who have started the conversation first

GET
/messages/chat_list.json
List chat Request

$storeden = new Storeden\Storeden($config);
$chat_list = $storeden->get('/messages/chat_list.json');
					
List chat Response

[
    {
        "name": "Test User",
        "with_id": 48617,
        "last_message_at": "2015-09-29T16:30:05+0200",
        "last_message_content": "ciao"
    },
    {
        "name": "James Bond",
        "with_id": 49077,
        "last_message_at": "2018-10-11T10:26:18+0200",
        "last_message_content": "👍"
    },
	...
]
					

Get chat content

Each page can contain a max of 30 message

GET
/messages/chat.json
with_id required (int) Unique id of conversation user
page (int) Each page can contain a max of 30 messages
Get chat content Request

$storeden = new Storeden\Storeden($config);
$result = $storeden->get('/messages/chat.json?with_id=49077');
					
Get chat content Response

{
    "messages": [
        {
            "from_id": 132,
            "from_myself": true,
            "message": "Lorem Ipsum 4",
            "send_date": "2018-10-11T10:26:18+0200",
            "message_id": "5bbf092a16f46a0119e55a80",
            "read_by": {
                "myself_id": "2018-10-26T23:11:44+0200",
                "with_id": ""
            }
        },
        {
            "from_id": 132,
            "from_myself": true,
            "message": "Lorem Ipsum 3",
            "send_date": "2018-01-10T11:44:26+0100",
            "message_id": "5a55ee8a16f46a094a06a11d",
            "read_by": {
                "myself_id": "2018-10-26T23:11:44+0200",
                "with_id": "2018-04-03T11:28:18+0200"
            }
        },
        {
            "from_id": 132,
            "from_myself": true,
            "message": "Lorem Ipsum 2",
            "send_date": "2018-01-10T11:43:18+0100",
            "message_id": "5a55ee4616f46aec4906a11d",
            "read_by": {
                "myself_id": "2018-10-26T23:11:44+0200",
                "with_id": "2018-04-03T11:28:18+0200"
            }
        },
        {
            "from_id": 132,
            "from_myself": true,
            "message": "Lorem Ipsum 1",
            "send_date": "2017-10-18T11:36:29+0200",
            "message_id": "59e7209d16f46ab504d20d22",
            "read_by": {
                "myself_id": "2018-10-26T23:11:44+0200",
                "with_id": "2018-04-03T11:28:18+0200"
            }
        },
        ...
        {
            "from_id": 132,
            "from_myself": false,
            "message": "test message",
            "send_date": "2014-09-01T17:47:34+0200",
            "message_id": "5404951616f46afe57e9e938",
            "read_by": {
                "myself_id": "2014-09-01T18:18:06+0200",
                "with_id": "2014-09-01T18:13:44+0200"
            }
        }
    ],
    "next_page": "https://connect.storeden.com/v1.1/messages/chat.json?with_id=49077&page=2"
}
					

Write new message to chat

POST
/messages/chat.json
with_id required (int) Unique id of conversation user
message required (string) Text content of chat
Write new message to chat Request

$storeden = new Storeden\Storeden($config);

$payload = array();
$payload['with_id'] = 49077;
$payload['message'] = 'Ciao!';

$result = $storeden->post('/messages/chat.json', $payload);
					
Write new message to chat Response

{
    "message_id": "5bf1b94116f46a731b7b23c6"
}