LetsBot Menu
Mulakan Bahasa Melayu Bahasa

Meta Business Partner Syarikat Berdaftar di UK

Bahasa

Message Archive (read by date) · Titik akhir API

GET /api/v1/messages Baharu

Get messages by date

Read the message archive by date — incoming and outgoing, including replies your team types in Live Chat.

Read the message archive by date — incoming and outgoing, including replies your team types in Live Chat.

Authentication: Authorization: Bearer {{lb_api_key}} (the collection's bearer auth). The key is in the panel → API → Authentication data (visible to the account owner). Requires an active subscription with the API Access add-on (or an active trial). This is not the Zapier key (lbz_...).

Every number: this endpoint reads the whole workspace, so one key returns the messages of all your numbers and channels. To read one number, add channel_id (the channel.id a message or webhook reports) or business_phone (that number's digits). WhatsApp messages record their number from 2026-09-30; older messages record it only where it could be attributed without guessing (a workspace with a single WhatsApp number), and a message that records no number is not returned under these filters.

Pagination: results are ordered oldest first by message_date, then id. When next_cursor is not null, repeat the same request adding cursor=<next_cursor> until it is null. Rows that share a timestamp are never skipped or repeated across pages.

Each message

  • from_me — true for messages you sent, false for messages from the customer.
  • sent_by — where an outgoing message came from (live_chat, bot, api, ...); null for incoming.
  • agent — {id, name} of the team member who typed the message; null for automated and incoming messages. Use this, not sent_by, to identify human replies.
  • contact — {id, phone, chat_id, name} of the customer, or null.
  • type — text, image, video, audio, file, template_text, ...
  • status / status_text — the last status we recorded for the message (Pending, Sent, Delivered, Viewed, FAILED). It is not proof of delivery on every channel.
  • message_date — ISO-8601 with offset, in the requested timezone.
  • channel_platform — whatsapp, messenger, instagram, email, ...
  • channel — {id, global_id, phone, platform, is_official} of the workspace channel the message belongs to, when the message records it; null otherwise (never guessed). WhatsApp messages record their number from 2026-09-30.
  • referral — for an incoming message that started from a Click-to-WhatsApp ad, the ad it came from: {source_type, ad_id, source_url, headline, body, media_type, media_url, ctwa_clid}. source_type is always ad; ad_id is Meta's ad id (Meta calls it source_id); media_type is image or video and media_url its image, video or thumbnail URL; ctwa_clid is Meta's click id, for the Conversions API. Any field Meta did not send is null. referral is null for every other message, including everything you sent. Available on past messages too. Count leads per ad by grouping incoming messages on referral.ad_id.

Internal notes, reactions, system lines and deleted messages are not returned.

Response-time analytics: pair each incoming message with the next outgoing message for the same contact.phone whose agent is not null.

Errors: 422 with {"Status": false, "Message": "..."} for invalid parameters (including a channel_id or business_phone that matches none of your channels, or the two naming different numbers); 401 for a missing or wrong key; 402 when the subscription or API add-on is not active.

Example

curl -G "https://letsbot.net/api/v1/messages" \
  -H "Authorization: Bearer YOUR_LB_API_KEY" \
  -H "Accept: application/json" \
  --data-urlencode "date_from=2026-09-09" \
  --data-urlencode "date_to=2026-09-09" \
  --data-urlencode "from_me=1" \
  --data-urlencode "timezone=Europe/Kyiv"

Parameter pertanyaan

ParameterWajibContohPenerangan
date_from Ya 2026-09-09 Required. Start of the range. `YYYY-MM-DD` covers the whole day; a full ISO-8601 datetime (e.g. `2026-09-09T08:00:00+03:00`) is an exact, inclusive bound.
date_to Ya 2026-09-09 Required. End of the range. `YYYY-MM-DD` covers the whole day (`date_from=date_to` is one full day); a full ISO-8601 datetime is an exact, inclusive bound. Must not be before `date_from`.
timezone Ya Europe/Kyiv Optional, default `UTC`. IANA timezone used to read bare dates and to format every `message_date` (always returned with its offset).
from_me Ya 1 Optional. `1`/`true` = outgoing only, `0`/`false` = incoming only. Omit for both directions.
sent_by Tidak live_chat Optional. Only messages from this source: `live_chat`, `bot`, `api`, `mcp`, `send_bulk`, `zapier`, `salla`, `zid`, `woocommerce`, `shopify`, `hubspot`, `pipedrive`, `stripe`, `magento`, `agent`, `drip`, `cart`, `system`, `ai`. `ai` (an AI assistant reply) is written only for workspaces that enabled the AI/rule split; elsewhere AI replies are `bot`, so filter on both to get every bot reply.
phone Tidak {{phone}} Optional. Only messages with this customer (international format, digits; a leading `+` is accepted).
channel_id Tidak 12 Optional. Only messages on this workspace channel — the `channel.id` a message or a webhook reports (one of your numbers). `422` when no channel with this id exists in the workspace.
business_phone Tidak 966501234567 Optional. Only messages on your WhatsApp number with these digits, international format (`+`, spaces and dashes are ignored). `422` when none of the workspace's WhatsApp numbers matches. Sent together with `channel_id`, both must name the same number.
limit Tidak 50 Optional. Page size, default 50, maximum 200.
cursor Tidak Optional. Pass `next_cursor` from the previous response, unchanged, to get the next page. A `null` `next_cursor` means there are no more pages.

Contoh permintaan

curl -G "https://letsbot.net/api/v1/messages" \
  -H "Authorization: Bearer YOUR_LB_API_KEY" \
  -H "Accept: application/json" \
  --data-urlencode "date_from=2026-09-09" \
  --data-urlencode "date_to=2026-09-09" \
  --data-urlencode "timezone=Europe/Kyiv" \
  --data-urlencode "from_me=1"
const response = await fetch("https://letsbot.net/api/v1/messages?date_from=2026-09-09&date_to=2026-09-09&timezone=Europe%2FKyiv&from_me=1", {
  method: "GET",
  headers: {
    "Authorization": "Bearer YOUR_LB_API_KEY",
    "Accept": "application/json",
  },
});

const data = await response.json();
console.log(data);
<?php

$ch = curl_init('https://letsbot.net/api/v1/messages?date_from=2026-09-09&date_to=2026-09-09&timezone=Europe%2FKyiv&from_me=1');

curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_LB_API_KEY',
        'Accept: application/json',
    ],
]);

$data = json_decode(curl_exec($ch), true);
curl_close($ch);

print_r($data);
import requests

response = requests.request(
    "GET",
    "https://letsbot.net/api/v1/messages",
    headers={
        "Authorization": "Bearer YOUR_LB_API_KEY",
        "Accept": "application/json",
    },
    params={
        "date_from": "2026-09-09",
        "date_to": "2026-09-09",
        "timezone": "Europe/Kyiv",
        "from_me": "1",
    },
)

print(response.json())

Respons

200 — outgoing Live Chat replies for one day (Kyiv time)200
{
    "Status": true,
    "timezone": "Europe/Kyiv",
    "data": [
        {
            "id": 4812,
            "message_id": "wamid.HBgMMzgwOTM1MDAwMDAxFQIAERgSN0Y0QjM2QjI5RjA1MDFEQjQ4AA==",
            "from_me": true,
            "sent_by": "live_chat",
            "agent": {
                "id": 3,
                "name": "Olena (Sales)"
            },
            "contact": {
                "id": 127,
                "phone": "380935000001",
                "chat_id": "380935000001@s.whatsapp.net",
                "name": "Customer name"
            },
            "group_id": null,
            "type": "text",
            "body": "Good afternoon! The 20 kg epoxy kit ships tomorrow.",
            "caption": null,
            "attachment": null,
            "status": 3,
            "status_text": "Viewed",
            "message_date": "2026-09-09T12:45:49+03:00",
            "channel_platform": "whatsapp",
            "channel": null,
            "referral": null
        },
        {
            "id": 4815,
            "message_id": "wamid.HBgMMzgwOTM1MDAwMDAxFQIAERgSQzE5RDA4NjM0MzhFRkY3M0Q1AA==",
            "from_me": true,
            "sent_by": "live_chat",
            "agent": {
                "id": 3,
                "name": "Olena (Sales)"
            },
            "contact": {
                "id": 127,
                "phone": "380935000001",
                "chat_id": "380935000001@s.whatsapp.net",
                "name": "Customer name"
            },
            "group_id": null,
            "type": "image",
            "body": null,
            "caption": "Colour sample",
            "attachment": {
                "url": "https://example.com/media/sample.jpg",
                "mimetype": "image/jpeg"
            },
            "status": 2,
            "status_text": "Delivered",
            "message_date": "2026-09-09T13:14:51+03:00",
            "channel_platform": "whatsapp",
            "channel": null,
            "referral": null
        },
        {
            "id": 4816,
            "message_id": "wamid.HBgMMzgwOTM1MDAwMDAyFQIAEhggQTFCMkMzRDRFNUY2QTdCOEM5RDBFMUYyQTNCNEM1RDYA",
            "from_me": false,
            "sent_by": null,
            "agent": null,
            "contact": {
                "id": 128,
                "phone": "966512345678",
                "chat_id": "966512345678@s.whatsapp.net",
                "name": "New lead"
            },
            "group_id": null,
            "type": "text",
            "body": "Hello! Is this kit still available?",
            "caption": null,
            "attachment": null,
            "status": 2,
            "status_text": "Delivered",
            "message_date": "2026-09-09T13:20:07+03:00",
            "channel_platform": "whatsapp",
            "channel": null,
            "referral": {
                "source_type": "ad",
                "ad_id": "120212345678900123",
                "source_url": "https://fb.me/3abcDEF",
                "headline": "Epoxy kit 20 kg",
                "body": "Message us on WhatsApp",
                "media_type": "image",
                "media_url": "https://scontent.xx.fbcdn.net/ad-image.jpg",
                "ctwa_clid": "ARAkLkA8rmlFeiCktEJQ-QTwRiyYHAFDLMNDBH0CD3qpjd0HR4irJ6LEkR7JwFF4XvnO2E4Nx0"
            }
        }
    ],
    "next_cursor": "eyJkIjoiMjAyNi0wOS0wOSAxMzoyMDowNyIsImkiOjQ4MTZ9"
}
422 — date_to before date_from422
{
    "Status": false,
    "Message": "The date to must not be before the date from.",
    "errors": {}
}
422 — date_from missing422
{
    "Status": false,
    "Message": "The date from field is required.",
    "errors": {
        "date_from": [
            "The date from field is required."
        ]
    }
}
401 — wrong or missing lb_api_key401
{
    "Status": false,
    "Message": "lb_api_key Incorrect"
}
402 — API add-on not active402
{
    "Status": false,
    "Message": "API access is not included in your current subscription. Please upgrade your plan or add the API addon.",
    "error_code": "API_ADDON_REQUIRED"
}

Sedia bila-bila anda sedia

Cuba titik akhir ini dengan nombor anda sendiri

API berfungsi semasa percubaan percuma. Cipta akaun, sambungkan nombor WhatsApp anda dan salin kunci anda daripada API → Data Pengesahan.