API

Here's how you can use the Memaila API

Authentication

Parameters

Name

Is required

UserName
Yes
Password
Yes
API Endpoint
https://{teamName}.memaila.com/api/token
Request Headers
Content-Type: application/json
Request Method
POST
Request Body Format
{
   "Username": "your username",
   "Password": "your password"
}
Response
{
   "access_token": "eyJhbGcpXVCJ9.eyJ1bmlxdWVfbmMDgh0dZbSJ9._K7t17s",
   "token_type": "Bearer",
   "expires_in": 3600,
   "issued": "2019-08-28T17:26:45.5876216Z",
   "expires": "2019-08-28T18:26:45.5876216Z"
}

All Mailboxes

API Endpoint
https://{teamName}.memaila.com/api/mailboxes
Request Headers
Authorization:  Bearer <access_token>
Request Method
GET
Response
{
   "ok": true,
   "mailboxes": [
       {
           "id": 1,
           "email": "sales@scannergear.com"
       }
   ]
}

Get Messages

Parameters

Name

Is required

ID
Yes
API Endpoint
https://{teamName}.memaila.com/api/mailboxes/{id}/messages
Request Headers
Authorization:  Bearer <access_token>
pageIndex:  <page_number>
Request Method
GET
Response
{
   "ok": true,
   "messages": [
       {
           "id": 25035,
           "threadId": 25035,
           "transactionNumber": 1,
           "subject": "Test Mail",
           "messageDate": "2019-08-28T08:06:56-04:00",
           "sender": {
               "name": "John Smith",
               "address": "john@gmail.com"
           },
           "isClosed": false,
           "isAssigned": true
       }
   ],
   "hasMore": true,
   "currentPage": 1
}

Transactions Messages

Parameters

Name

Is required

ID
Yes
ThreadID
Yes
API Endpoint
https://{teamName}.memaila.com/api/mailboxes/{id}/messages/{threadId}
Request Headers
Authorization:  Bearer <access_token>
Request Method
GET
Response
{
   "ok": true,
   "messages": [
       {
           "id": 25035,
           "threadId": 25035,
           "transactionNumber": 1,
           "subject": " Test Mail ",
           "textBody": "Thanks",
           "htmlBody": "<div dir=\"ltr\">Thanks<br clear=\"all\"><div> ",
           "messageDate": "2019-08-28T17:36:56+05:30",
           "sender": {
               "name": "John Smith",
               "address": "john@gmail.com"
           },
           "ToRecipients": null,
           "CcRecipients": null,
           "Attachments": null,
           "isClosed": false,
           "isAssigned": true
       }
   ]
}

Message by Transaction Number

Parameters

Name

Is required

ID
Yes
ThreadID
Yes
TransactionId
Yes
API Endpoint
https://{teamName}.memaila.com/api/mailboxes/{id}/messages/{threadId}/{transactionId}
Request Headers
Authorization:  Bearer <access_token>
Request Method
GET
Response
{
   "ok": true,
   "messages": [
       {
           "id": 25036,
           "threadId": 25036,
           "transactionNumber": 1,
           "subject": "Test attachment 2",
           "textBody": "Thanks ",
           "htmlBody": "<div dir=\"ltr\">Thanks<br clear=\"all\"><div ",
           "messageDate": "2019-08-28T17:38:01+05:30",
           "sender": {
               "name": "John Smith",
               "address": "john@gmail.com "
           },
           "ToRecipients": [
               {
                   "name": "",
                   "address": "sales@scannergear.com "
               }
           ],
           "CcRecipients": [],
           "Attachments": [
               {
                   "Id": 1233,
                   "contentId": "",
                   "fileName": "1436d3de6a71dfafa0902292ca667d8e.jpg",
                   "downloadLink": "https://admin.memaila.com/api/mailboxes/153/messages/25036/1/attachments/1233",
                   "isInLine": false,
                   "contentType": "image/jpeg"
               }
           ],
           "isClosed": true,
           "isAssigned": false
       }
   ]
}

Download Attachment

Parameters

Name

Is required

ID
Yes
ThreadID
Yes
TransactionId
Yes
AttachmentId
Yes
API Endpoint
https://{teamName}.memaila.com/api/mailboxes/{id}/messages/{threadId}/{transactionId}/attachments/{attachmentID}
Request Headers
Authorization:  Bearer <access_token>
Request Method
GET
Response
File

New Thread

Parameters

Name

Is required

ID
Yes
API Endpoint
https://{teamName}.memaila.com/api/mailboxes/{id}/messages
Request Headers
Content-Type: application/json
Authorization:  Bearer <access_token>
Request Method
POST
Response Body Format
{
   "subject": "Test compose",
   "textBody": "thanks",
   "htmlBody": "<div>thanks</div>",
   "ToAddressList": [
       {
           "address": "sales@scannergear.com"
       }
   ],
   "CcAddressList": [],
   "BccAddressList": [],
   "attachments": [
       {
           "name": "attachment.txt",
           "contentType": "text/plain",
           "contentBytes": "SGVsbG8gV29ybGQh"
       }
   ]
}
Response
OK

Send Reply Thread for Existing Thread

Parameters

Name

Is required

ID
Yes
ThreadId
Yes
API Endpoint
https://{teamName}.memaila.com/api/mailboxes/{id}/messages/{threadId}/reply
Request Headers
Content-Type: application/json
Authorization:  Bearer <access_token>
Request Method
POST
Response Body Format
{
   "textBody": "thanks",
   "htmlBody": "<div>thanks</div>",
   "attachments": [
       {
           "name": "attachment.txt",
           "contentType": "text/plain",
           "contentBytes": "SGVsbG8gV29ybGQh"
       }
   ]
}
Response
OK

Thread Notes

Parameters

Name

Is required

ID
Yes
ThreadId
Yes
API Endpoint
https://{teamName}.memaila.com/api/mailboxes/{id}/messages/{threadId}/notes
Request Headers
Authorization:  Bearer <access_token>
Request Method
GET
Response
{
   "ok": true,
   "Notes": [
       {
           "id": 26,
           "addedBy": "John",
           "note": "Note 1",
           "dateAdded": "2019-08-28T08:15:17.107"
       }
   ]
}

Add Note

Parameters

Name

Is required

ID
Yes
ThreadId
Yes
API Endpoint
https://{teamName}.memaila.com/api/mailboxes/{id}/messages/{threadId}/notes
Request Headers
Content-Type: application/json
Authorization:  Bearer <access_token>
Request Method
POST
Request Body Format
{
   "note": "Test thread note"
}
Response
OK