Conversations

List team chats and channels, and send messages to them.

Endpoints

MethodEndpointDescription
GET/chat/v1/conversationsGet team chats and channels
POST/chat/v1/conversations/{conversationId}/messageSend message to conversation

Get Conversations

Retrieve a paginated list of team chats and channels. Private conversations are excluded.

Query Parameters

ParameterTypeRequiredDefaultDescription
limitintegerNo10Results per page (1-100)
offsetintegerNo0Pagination offset

Example Request

curl --request GET \
  --url 'https://api.connecteam.com/chat/v1/conversations?limit=50' \
  --header 'X-API-KEY: YOUR_API_KEY'

Response

{
  "requestId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "data": {
    "conversations": [
      {
        "id": "conv-abc123",
        "title": "Engineering Team",
        "type": "team"
      },
      {
        "id": "conv-def456",
        "title": "Company Announcements",
        "type": "channel"
      }
    ]
  },
  "paging": {
    "offset": 2
  }
}

Response Fields

FieldTypeDescription
idstringUnique conversation identifier
titlestringConversation display name
typestringteam or channel

Send Message to Conversation

Send a message to a team chat or channel.

Path Parameters

ParameterTypeRequiredDescription
conversationIdstringYesConversation ID

Request Body

FieldTypeRequiredDescription
senderIdintegerYesCustom publisher ID
textstringYesMessage content (max 1000 chars)
attachmentsarrayNoList of file/image attachments

Attachment Object

FieldTypeRequiredDescription
typestringYesimage or file
fileIdstringYesFile ID from Attachments API

Example: Send Text Message

curl --request POST \
  --url https://api.connecteam.com/chat/v1/conversations/conv-abc123/message \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: YOUR_API_KEY' \
  --data '{
    "senderId": 12345,
    "text": "Daily standup reminder: Meeting starts in 15 minutes!"
  }'

Example: Send Message with Image

curl --request POST \
  --url https://api.connecteam.com/chat/v1/conversations/conv-abc123/message \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: YOUR_API_KEY' \
  --data '{
    "senderId": 12345,
    "text": "Here is the updated floor plan",
    "attachments": [
      {
        "type": "image",
        "fileId": "file-abc123"
      }
    ]
  }'

Example: Send Message with File

curl --request POST \
  --url https://api.connecteam.com/chat/v1/conversations/conv-abc123/message \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: YOUR_API_KEY' \
  --data '{
    "senderId": 12345,
    "text": "Attached is the weekly report",
    "attachments": [
      {
        "type": "file",
        "fileId": "file-def456"
      }
    ]
  }'

Response

{
  "requestId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "data": {}
}

Integration Example

class ChatIntegration {
  constructor(apiKey) {
    this.apiKey = apiKey;
    this.baseUrl = 'https://api.connecteam.com/chat/v1/conversations';
  }

  async getConversations(limit = 100) {
    const conversations = [];
    let offset = 0;

    while (true) {
      const response = await fetch(
        `${this.baseUrl}?limit=${limit}&offset=${offset}`,
        { headers: { 'X-API-KEY': this.apiKey } }
      );
      const data = await response.json();
      
      conversations.push(...data.data.conversations);
      
      if (data.data.conversations.length < limit) break;
      offset = data.paging.offset;
    }

    return conversations;
  }

  async sendMessage(conversationId, senderId, text, attachments = []) {
    const response = await fetch(
      `${this.baseUrl}/${conversationId}/message`,
      {
        method: 'POST',
        headers: {
          'X-API-KEY': this.apiKey,
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({ senderId, text, attachments })
      }
    );
    return response.json();
  }

  async broadcastToAllTeams(senderId, text) {
    const conversations = await this.getConversations();
    const teamChats = conversations.filter(c => c.type === 'team');
    
    for (const chat of teamChats) {
      await this.sendMessage(chat.id, senderId, text);
    }
  }
}

// Usage
const chat = new ChatIntegration('YOUR_API_KEY');
await chat.sendMessage('conv-abc123', 12345, 'Hello team!');

Error Responses

404 Not Found

Conversation not found:

{
  "detail": "Conversation not found"
}

Sender not found:

{
  "detail": "Sender id not found"
}

400 Bad Request

Multiple non-image attachments:

{
  "detail": "Multiple non-image attachments are not allowed"
}

Attachment not uploaded:

{
  "detail": "File upload not completed"
}

API Reference