Skip to content
WhatSync/DocsAPI v1

Read context around a WhatsApp message

Read up to 25 permitted saved messages before and after one exact message.

POST/api/v1/tools/get_message_contextRead
Key permissions
Read chats and messages
Authentication
Authorization: Bearer $WHATSYNC_API_KEY
How keys work

How it works

If the original is unavailable, available quoted text from a permitted reply may be returned; this does not recover the original conversation.

Body parameters

messageIdstringrequired

See the example and input schema for this value.

beforeintegeroptional

Upper date boundary or pagination value. Follow the pagination instructions below.

afterintegeroptional

Lower date boundary or pagination value. Keep the same filters between pages.

Response

HTTP 200 returns this tool's JSON directly, without an MCP content wrapper. Optional provider fields may be absent or null; check pagination and coverage before treating a page as complete.

Every response includes X-Request-Id. Errors use the shared error format and retry rules.

Schemas

Input JSON Schema
Input JSON Schema
{
  "type": "object",
  "properties": {
    "messageId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 250
    },
    "before": {
      "type": "integer",
      "minimum": 0,
      "maximum": 25
    },
    "after": {
      "type": "integer",
      "minimum": 0,
      "maximum": 25
    }
  },
  "required": [
    "messageId"
  ],
  "additionalProperties": false,
  "$schema": "http://json-schema.org/draft-07/schema#"
}
Response JSON Schema
Response JSON Schema
{
  "type": "object",
  "properties": {
    "target_message_id": {
      "type": "string"
    },
    "found": {
      "type": "boolean"
    },
    "conversation_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "chronological_order": {
      "type": "boolean"
    },
    "messages": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "message_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "conversation_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "channel": {
            "type": [
              "string",
              "null"
            ]
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "direction": {
            "type": [
              "string",
              "null"
            ]
          },
          "sender": {
            "type": [
              "string",
              "null"
            ]
          },
          "recipient": {
            "type": [
              "string",
              "null"
            ]
          },
          "contact_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "group_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "participant_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "provider_phone_number_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "quoted_message_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "delivery_status": {
            "type": [
              "string",
              "null"
            ]
          },
          "type": {
            "type": [
              "string",
              "null"
            ]
          },
          "text": {
            "type": [
              "string",
              "null"
            ]
          },
          "attachment": {
            "anyOf": [
              {
                "type": "object",
                "additionalProperties": true,
                "description": "Provider or tool-specific fields; preserve unknown fields."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [],
        "additionalProperties": true
      }
    },
    "quoted_text": {
      "type": [
        "string",
        "null"
      ]
    },
    "quoted_in_message_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "note": {
      "type": "string"
    }
  },
  "required": [],
  "additionalProperties": true
}