{
  "openapi": "3.1.0",
  "info": {
    "title": "Thikaa Messaging API",
    "version": "2.0.0",
    "contact": {
      "name": "Thikaa Support",
      "email": "support@thikaa.com",
      "url": "https://thikaa.com"
    },
    "description": "REST API for Thikaa, the AI chatbot and unified inbox platform for MENA. Send and receive messages on WhatsApp (QR and Cloud API), Telegram, Facebook Messenger, Instagram and TikTok; read conversations; reply to comments; manage bots, knowledge and WhatsApp sessions. Incoming events are delivered to your webhook, signed with HMAC-SHA256. Available on every plan. Every call is `?action=<name>` on the base URL, authenticated with `Authorization: Bearer <key>` (keys from Bot Hub → Messaging API). Human docs with curl examples: https://thikaa.com/messaging-api-docs.php"
  },
  "servers": [
    {
      "url": "https://thikaa.com/thik_tenant_{store}/api/messaging/",
      "description": "Per-workspace base URL — {store} is your workspace slug (the part after thik_tenant_ in your dashboard URL).",
      "variables": {
        "store": {
          "default": "yourstore"
        }
      }
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/": {
      "get": {
        "summary": "GET actions",
        "description": "- `status` — Key, plan and channel status for this workspace.\n- `me` — The workspace and key identity.\n- `channels` — Connected channels and WhatsApp numbers (account id + display number usable as `from`).\n- `conversations` — List conversations, newest activity first. Params: channel, status (all|open|closed), search, limit (1-50), offset (<=10000). Returns has_more / next_offset.\n- `conversation-messages` — Messages of one conversation. Params: conversation_id (required), limit (1-100), before_message_id.\n- `templates` — Approved WhatsApp Cloud message templates.\n- `comments` — Recent Facebook / Instagram / TikTok comments delivered to this workspace (limited to the key's channels).\n- `comment-media` — The post a comment belongs to. Params: comment_id or post_id.\n- `groups` — WhatsApp QR groups per connected number.\n- `sessions` — WhatsApp QR sessions created through the API.\n- `session-status` — Status of one session. Params: session_token.\n- `session-qr` — QR code for linking a session. Params: session_token.\n- `bots` — Bots in the workspace.\n- `bot` — One bot. Params: bot_id.\n- `knowledge` — Knowledge entries of a bot. Params: bot_id.\n- `knowledge-search` — Search a bot's knowledge. Params: bot_id, q.\n- `posts` — Social posts (drafts and scheduled).\n- `smart-layers` — Automation layers and their on/off state.\n\nAliases also accepted: send-message→send, reaction→react, reply-comment→comment-reply, list-conversations→conversations, conversation / messages / list-messages→conversation-messages, message-templates→templates, session-create→create-session, pairing-code→pair-code, connections→channels, connect-url→connect-link, disconnect→disconnect-channel, knowledge-list→knowledge, groups-enabled→enable-groups.",
        "parameters": [
          {
            "name": "action",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "status",
                "me",
                "channels",
                "conversations",
                "conversation-messages",
                "templates",
                "comments",
                "comment-media",
                "groups",
                "sessions",
                "session-status",
                "session-qr",
                "bots",
                "bot",
                "knowledge",
                "knowledge-search",
                "posts",
                "smart-layers"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success (JSON). Message ids are integers; timestamps come as created_at (server local) and created_at_utc (ISO 8601).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Key not allowed for this channel/action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown action or object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, e.g. from_not_available or channel requires the customer to message first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited (see Retry-After)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "POST actions",
        "description": "- `send` — Send a message. Body: channel (wd|wa|tg|fb|ig|tt), to or conversation_id, text and/or media_url + media_type, optional from (WhatsApp QR: account id or number from ?action=channels; unknown value → 409 from_not_available), optional reply_to.\n- `react` — React to a message with an emoji. Body: message_id, emoji.\n- `comment-reply` — Reply to a comment publicly and/or privately. Body: comment_id, message, private_message. TikTok has no private reply.\n- `create-session` — Create a WhatsApp QR session. Body: label, external_ref, webhook_only, history_sync.\n- `pair-code` — Request a phone pairing code for a session. Body: session_token, phone.\n- `delete-session` — Delete a session. Body: session_token.\n- `enable-groups` — Turn WhatsApp group handling on/off for a number. Body: account_id, enabled.\n- `connect-link` — Create a hosted link for connecting a Facebook/Instagram page. Body: channel, redirect_url.\n- `connect-telegram` — Connect a Telegram bot. Body: bot_token.\n- `disconnect-channel` — Disconnect a channel. Body: channel, account_id.\n- `bot-create` — Create a bot (created inactive).\n- `bot-update` — Update a bot. Body: bot_id + fields.\n- `knowledge-add` — Add a knowledge entry. Body: bot_id, question, answer, expires_at.\n- `knowledge-remove` — Remove a knowledge entry. Body: bot_id, id.\n- `post-create` — Create a social post draft (scheduled only when scheduled_at is given).\n- `post-delete` — Delete a post. Body: post_id.\n- `smart-layer-set` — Switch an automation layer on or off. Body: layer, enabled.\n\nAliases also accepted: send-message→send, reaction→react, reply-comment→comment-reply, list-conversations→conversations, conversation / messages / list-messages→conversation-messages, message-templates→templates, session-create→create-session, pairing-code→pair-code, connections→channels, connect-url→connect-link, disconnect→disconnect-channel, knowledge-list→knowledge, groups-enabled→enable-groups.",
        "parameters": [
          {
            "name": "action",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "send",
                "react",
                "comment-reply",
                "create-session",
                "pair-code",
                "delete-session",
                "enable-groups",
                "connect-link",
                "connect-telegram",
                "disconnect-channel",
                "bot-create",
                "bot-update",
                "knowledge-add",
                "knowledge-remove",
                "post-create",
                "post-delete",
                "smart-layer-set"
              ]
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success (JSON). Message ids are integers; timestamps come as created_at (server local) and created_at_utc (ISO 8601).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Key not allowed for this channel/action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown action or object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, e.g. from_not_available or channel requires the customer to message first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited (see Retry-After)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Workspace API key (tk_live_…) or an OAuth access token for connected apps."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Machine-readable code, e.g. missing_api_key, invalid_api_key, channel_not_allowed, from_not_available, invalid_json, offset_too_large, rate_limited, internal_error"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      }
    }
  }
}
