Skip to content

Messages API

Send and receive messages between buyers and sellers.

Endpoints Overview

MethodEndpointDescriptionAuth
GET/api/messagesList all message threadsRequired
GET/api/messages/unreadGet unread message countRequired
GET/api/messages/:threadIdGet messages in threadRequired
POST/api/messagesSend a messageRequired
PATCH/api/messages/:threadId/archiveArchive a threadRequired

Notification Endpoints

MethodEndpointDescriptionAuth
GET/api/notificationsList notificationsRequired
GET/api/notifications/unread-countGet unread countRequired
PATCH/api/notifications/:id/readMark as readRequired
PATCH/api/notifications/read-allMark all as readRequired

List Conversations

Get all conversations for the authenticated user.

Request

bash
GET /v1/messages/conversations
Authorization: Bearer YOUR_JWT_TOKEN

Query Parameters

ParameterTypeDescription
pageintegerPage number
limitintegerItems per page
statusstringall, unread, read, archived
rolestringbuyer, seller (for sellers)

Response

json
{
  "success": true,
  "data": {
    "conversations": [
      {
        "id": "conv_123",
        "listing": {
          "id": "lst_abc",
          "title": "2021 Volvo FH 500",
          "thumbnail": "https://cdn.menonmobility.com/thumb.jpg",
          "price": 85000,
          "status": "active"
        },
        "participant": {
          "id": "usr_456",
          "name": "John Smith",
          "avatar": "https://cdn.menonmobility.com/avatar.jpg",
          "type": "buyer",
          "verified": true
        },
        "last_message": {
          "content": "Is this vehicle still available?",
          "sender": "usr_456",
          "sent_at": "2024-01-15T14:30:00Z",
          "read": false
        },
        "unread_count": 2,
        "created_at": "2024-01-15T10:00:00Z",
        "updated_at": "2024-01-15T14:30:00Z"
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 20,
      "total": 45
    },
    "summary": {
      "total": 45,
      "unread": 8
    }
  }
}

Get Conversation

Get messages in a specific conversation.

Request

bash
GET /v1/messages/conversations/conv_123
Authorization: Bearer YOUR_JWT_TOKEN

Query Parameters

ParameterTypeDescription
pageintegerPage number
limitintegerMessages per page
beforestringMessages before timestamp

Response

json
{
  "success": true,
  "data": {
    "conversation": {
      "id": "conv_123",
      "listing": {
        "id": "lst_abc",
        "title": "2021 Volvo FH 500",
        "thumbnail": "https://cdn.menonmobility.com/thumb.jpg",
        "price": 85000,
        "status": "active"
      },
      "participant": {
        "id": "usr_456",
        "name": "John Smith",
        "type": "buyer",
        "verified": true,
        "online": true
      }
    },
    "messages": [
      {
        "id": "msg_1",
        "content": "Hello, I'm interested in this truck.",
        "sender_id": "usr_456",
        "type": "text",
        "read": true,
        "read_at": "2024-01-15T10:05:00Z",
        "sent_at": "2024-01-15T10:00:00Z"
      },
      {
        "id": "msg_2",
        "content": "Hi! Yes, it's still available. Would you like to schedule a viewing?",
        "sender_id": "usr_me",
        "type": "text",
        "read": true,
        "read_at": "2024-01-15T10:12:00Z",
        "sent_at": "2024-01-15T10:10:00Z"
      },
      {
        "id": "msg_3",
        "content": "Is this vehicle still available?",
        "sender_id": "usr_456",
        "type": "text",
        "read": false,
        "sent_at": "2024-01-15T14:30:00Z"
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 50,
      "total": 3,
      "has_more": false
    }
  }
}

Start Conversation

Start a new conversation about a listing.

Request

bash
POST /v1/messages/conversations
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json

Body

json
{
  "listing_id": "lst_abc123",
  "message": "Hello, I'm interested in this vehicle. Is it still available?"
}

Response

json
{
  "success": true,
  "data": {
    "conversation": {
      "id": "conv_new123",
      "listing": {
        "id": "lst_abc123",
        "title": "2021 Volvo FH 500"
      },
      "participant": {
        "id": "sel_789",
        "name": "ABC Trucks"
      },
      "created_at": "2024-01-15T15:00:00Z"
    },
    "message": {
      "id": "msg_1",
      "content": "Hello, I'm interested in this vehicle. Is it still available?",
      "sent_at": "2024-01-15T15:00:00Z"
    }
  }
}

Send Message

Send a message in an existing conversation.

Request

bash
POST /v1/messages/conversations/conv_123
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json

Body

json
{
  "content": "Thank you for your interest! Yes, it's available.",
  "type": "text"
}

Message Types

TypeDescription
textPlain text message
imageImage attachment
documentDocument attachment
quick_replyTemplate response

Send with Attachment

bash
POST /v1/messages/conversations/conv_123
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: multipart/form-data

content: Here are the service records
type: document
attachment: [file]

Response

json
{
  "success": true,
  "data": {
    "message": {
      "id": "msg_new",
      "content": "Thank you for your interest! Yes, it's available.",
      "type": "text",
      "sent_at": "2024-01-15T15:05:00Z"
    }
  }
}

Mark as Read

Mark conversation or specific messages as read.

Mark Conversation Read

bash
PUT /v1/messages/conversations/conv_123/read
Authorization: Bearer YOUR_JWT_TOKEN

Mark Specific Messages

bash
PUT /v1/messages/conversations/conv_123/read
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json

{
  "message_ids": ["msg_1", "msg_2", "msg_3"]
}

Archive Conversation

Archive

bash
PUT /v1/messages/conversations/conv_123/archive
Authorization: Bearer YOUR_JWT_TOKEN

Unarchive

bash
DELETE /v1/messages/conversations/conv_123/archive
Authorization: Bearer YOUR_JWT_TOKEN

Delete Conversation

bash
DELETE /v1/messages/conversations/conv_123
Authorization: Bearer YOUR_JWT_TOKEN

WARNING

Deletion is permanent and cannot be undone.

Message Templates

List Templates

bash
GET /v1/messages/templates
Authorization: Bearer YOUR_JWT_TOKEN

Response

json
{
  "success": true,
  "data": {
    "templates": [
      {
        "id": "tpl_1",
        "name": "Vehicle Available",
        "category": "inquiry",
        "content": "Thank you for your interest in the {{vehicle_title}}. Yes, it is still available at {{price}}. Would you like to schedule a viewing?"
      }
    ]
  }
}

Create Template

bash
POST /v1/messages/templates
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json

{
  "name": "Quick Response",
  "category": "inquiry",
  "content": "Thank you for contacting us..."
}

Use Template

bash
POST /v1/messages/conversations/conv_123
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json

{
  "template_id": "tpl_1",
  "variables": {
    "vehicle_title": "2021 Volvo FH 500",
    "price": "EUR 85,000"
  }
}

Unread Count

Get Unread Count

bash
GET /v1/messages/unread
Authorization: Bearer YOUR_JWT_TOKEN

Response

json
{
  "success": true,
  "data": {
    "unread_count": 8,
    "conversations_with_unread": 3
  }
}

Report Message

Report inappropriate messages.

bash
POST /v1/messages/msg_123/report
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json

{
  "reason": "spam",
  "details": "User is sending promotional content"
}

Webhooks

Subscribe to message events via webhooks. See Webhooks for details.

Events:

  • message.received
  • message.read
  • conversation.created

Commercial Vehicle Marketplace