Chat

Creating a Chat

The following example shows how to call the private API to create a Chat.

In production, call this from your backend using your company’s API key. For development and testing, you can run it in your frontend to verify your integration without backend setup.

file.ts
export const createChatService = () => {
  const opts = {
    method: 'POST',
    headers: {
      'content-type': 'application/json',
      'Authorization': `Bearer ${'your-api-key'}`
    },
    body: JSON.stringify({
      arguments: [
        {
          metadata: { name: 'exampleChatName' },
          kind: 2
        }
      ]
    })
  };
 
  return fetch('https://chat.dev.zu.casa/chat.chats.private.v1.Service/Create', opts)
    .then(res => res.json())
    .then(res => {
      return res.chats[0];
    });
};
⚠️
Never expose in production your API KEY generation logic to the client. Always create chats from a secure backend in production.