API reference

Leads

Leads are the visitors of the business's customer chat, the chat on its website, as the Leads tab shows them. Read who wrote and what they said, post the team's answer in a visitor's chat, or choose whether Okaymate answers on its own, writes drafts or lets the team answer.

The lead object

A visitor of the business's customer chat, as the Leads tab shows them. A visitor becomes a lead with their first message.

Attributes

  • objectstring
    Always lead.
  • idstring
    The visitor's ID, the same in every event about them.
  • namestring or null
    The visitor's name, once they gave it.
  • message_countinteger
    Messages in the conversation, the visitor's and the answers.
  • last_messageobject or null
    The conversation's last message.
  • last_message_atstring or null
    When the last message was sent, ISO 8601.
  • ai_modestring
    Who answers the visitor. auto when Okaymate answers, draft when Okaymate writes a draft and the team sends it, Semi-auto in the app, off when the team answers. Only when you retrieve or update one lead.
    autodraftoff
Lead object
{
  "object": "lead",
  "id": "k3v9q2m7x4w8n1p6",
  "name": "Emma",
  "message_count": 2,
  "last_message": {
    "object": "message",
    "id": "b2n7x4w8p5",
    "lead": "k3v9q2m7x4w8n1p6",
    "direction": "out",
    "author": "Lumen Studio",
    "text": "Yes, Beginners Flow runs every Saturday at 10am. Want me to save you a spot?",
    "files": [],
    "created_at": "2026-11-24T09:12:51.000Z"
  },
  "last_message_at": "2026-11-24T09:12:51.000Z",
  "ai_mode": "auto"
}

List leads

GET/v1/leadsRead access

Returns the customer chat's leads, the latest activity first.

Query parameters

  • limitinteger
    How many objects to return, from 1 to 100. Defaults to 20.
  • cursorstring
    The next_cursor of the previous page, to get the page after it. See Pagination.

Returns

A list of lead objects, without ai_mode.

Errors

GET/v1/leads
curl -G https://okaymate.ai/api/v1/leads \
  -H "Authorization: Bearer $OKAYMATE_API_KEY" \
  -d limit=20
Response200
{
  "object": "list",
  "data": [
    {
      "object": "lead",
      "id": "k3v9q2m7x4w8n1p6",
      "name": "Emma",
      "message_count": 2,
      "last_message": {
        "object": "message",
        "id": "b2n7x4w8p5",
        "lead": "k3v9q2m7x4w8n1p6",
        "direction": "out",
        "author": "Lumen Studio",
        "text": "Yes, Beginners Flow runs every Saturday at 10am. Want me to save you a spot?",
        "files": [],
        "created_at": "2026-11-24T09:12:51.000Z"
      },
      "last_message_at": "2026-11-24T09:12:51.000Z"
    }
  ],
  "has_more": true,
  "next_cursor": "MjAyNi0xMS0yMlQxNjo0MDoxMi4wMDBa"
}

Retrieve a lead

GET/v1/leads/:idRead access

Returns one lead, with who answers them in ai_mode.

Path parameters

  • idstringRequired
    The lead's ID.

Returns

A lead object.

Errors

GET/v1/leads/:id
curl https://okaymate.ai/api/v1/leads/k3v9q2m7x4w8n1p6 \
  -H "Authorization: Bearer $OKAYMATE_API_KEY"
Response200
{
  "object": "lead",
  "id": "k3v9q2m7x4w8n1p6",
  "name": "Emma",
  "message_count": 2,
  "last_message": {
    "object": "message",
    "id": "b2n7x4w8p5",
    "lead": "k3v9q2m7x4w8n1p6",
    "direction": "out",
    "author": "Lumen Studio",
    "text": "Yes, Beginners Flow runs every Saturday at 10am. Want me to save you a spot?",
    "files": [],
    "created_at": "2026-11-24T09:12:51.000Z"
  },
  "last_message_at": "2026-11-24T09:12:51.000Z",
  "ai_mode": "auto"
}

Update a lead

PATCH/v1/leads/:idRead and write access

Chooses who answers the visitor, as the switch of their conversation in the Leads tab.

Path parameters

  • idstringRequired
    The lead's ID.

Body parameters

  • ai_modestringRequired
    Who answers the visitor. auto when Okaymate answers, draft when Okaymate writes a draft and the team sends it, Semi-auto in the app, off when the team answers.
    autodraftoff

Returns

The updated lead object.

Errors

PATCH/v1/leads/:id
curl -X PATCH \
  https://okaymate.ai/api/v1/leads/k3v9q2m7x4w8n1p6 \
  -H "Authorization: Bearer $OKAYMATE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "ai_mode": "off"
  }'
Response200
{
  "object": "lead",
  "id": "k3v9q2m7x4w8n1p6",
  "name": "Emma",
  "message_count": 2,
  "last_message": {
    "object": "message",
    "id": "b2n7x4w8p5",
    "lead": "k3v9q2m7x4w8n1p6",
    "direction": "out",
    "author": "Lumen Studio",
    "text": "Yes, Beginners Flow runs every Saturday at 10am. Want me to save you a spot?",
    "files": [],
    "created_at": "2026-11-24T09:12:51.000Z"
  },
  "last_message_at": "2026-11-24T09:12:51.000Z",
  "ai_mode": "off"
}

The message object

One message of a visitor's conversation, sent by the visitor, by Okaymate or by the team.

Attributes

  • objectstring
    Always message.
  • idstring
    Unique identifier for the message.
  • leadstring
    The ID of the lead whose conversation it is in.
  • directionstring
    in when the visitor wrote it, out for an answer of Okaymate or of the team.
    inout
  • authorstring or null
    Who wrote it. The visitor's name, the business's name for Okaymate's answers, and for the team's a name followed by (team), the key's name for an answer posted with the API.
  • textstring
    The message's text.
  • filesarray of objects
    The files attached to the message.
  • created_atstring
    When it was sent, ISO 8601.
Message object
{
  "object": "message",
  "id": "a8f3k2m9q1",
  "lead": "k3v9q2m7x4w8n1p6",
  "direction": "in",
  "author": "Emma",
  "text": "Hi, do you have a class for beginners on Saturday morning?",
  "files": [],
  "created_at": "2026-11-24T09:12:44.000Z"
}

List a lead's messages

GET/v1/leads/:id/messagesRead access

Returns the messages of a visitor's conversation, the newest first.

Path parameters

  • idstringRequired
    The lead's ID.

Query parameters

  • limitinteger
    How many objects to return, from 1 to 100. Defaults to 20.
  • cursorstring
    The next_cursor of the previous page, to get the page after it. See Pagination.

Returns

A list of message objects.

Errors

GET/v1/leads/:id/messages
curl -G \
  https://okaymate.ai/api/v1/leads/k3v9q2m7x4w8n1p6/messages \
  -H "Authorization: Bearer $OKAYMATE_API_KEY" \
  -d limit=50
Response200
{
  "object": "list",
  "data": [
    {
      "object": "message",
      "id": "b2n7x4w8p5",
      "lead": "k3v9q2m7x4w8n1p6",
      "direction": "out",
      "author": "Lumen Studio",
      "text": "Yes, Beginners Flow runs every Saturday at 10am. Want me to save you a spot?",
      "files": [],
      "created_at": "2026-11-24T09:12:51.000Z"
    },
    {
      "object": "message",
      "id": "a8f3k2m9q1",
      "lead": "k3v9q2m7x4w8n1p6",
      "direction": "in",
      "author": "Emma",
      "text": "Hi, do you have a class for beginners on Saturday morning?",
      "files": [],
      "created_at": "2026-11-24T09:12:44.000Z"
    }
  ],
  "has_more": false,
  "next_cursor": null
}

Send a message

POST/v1/leads/:id/messagesRead and write access

Posts the team's answer in the visitor's chat, under the key's name, as a teammate does from the Leads tab.

Path parameters

  • idstringRequired
    The lead's ID.

Body parameters

  • textstringRequired
    The answer, from 1 to 4000 characters.

Returns

The new message object, its direction set to out.

Errors

POST/v1/leads/:id/messages
curl -X POST \
  https://okaymate.ai/api/v1/leads/k3v9q2m7x4w8n1p6/messages \
  -H "Authorization: Bearer $OKAYMATE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Your spot is saved, see you Saturday!"
  }'
Response201
{
  "object": "message",
  "id": "c5q1m8k3v6",
  "lead": "k3v9q2m7x4w8n1p6",
  "direction": "out",
  "author": "Helpdesk (team)",
  "text": "Your spot is saved, see you Saturday!",
  "files": [],
  "created_at": "2026-11-24T09:20:03.000Z"
}