> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nextmed.med.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Videochamadas

> Contratos de Dyte, participantes e sincronizacao de presenca.

## Videochamadas

## Criar meeting no Dyte

```http theme={"system"}
POST /api/dyte/meeting
```

Body:

```json theme={"system"}
{
  "titleMeet": "referral-id-ou-titulo"
}
```

Chamada server-side para Dyte:

```http theme={"system"}
POST {DYTE_BASE_URL}/meetings
Authorization: Basic {DYTE_TOKEN}
```

Payload enviado para Dyte:

```json theme={"system"}
{
  "title": "referral-id-ou-titulo",
  "preferred_region": "ap-south-1",
  "record_on_start": false,
  "live_stream_on_start": false
}
```

Resposta interna:

```json theme={"system"}
{
  "data": {
    "id": "meeting-id",
    "title": "titulo",
    "preferred_region": "ap-south-1",
    "created_at": "2026-01-01T00:00:00Z",
    "record_on_start": false,
    "updated_at": "2026-01-01T00:00:00Z",
    "live_stream_on_start": false,
    "persist_chat": false,
    "summarize_on_end": false,
    "status": "ACTIVE",
    "recording_config": "NOT_CONFIGURED"
  }
}
```

## Adicionar participante

```http theme={"system"}
POST /api/dyte/participants
```

Body:

```ts theme={"system"}
type AddParticipantRequest = {
  user: {
    name: string;
    avatar: string;
    id: string;
  };
  idMeet: string;
  type_preset: "group_call_host" | "group_call_participant";
};
```

Resposta:

```json theme={"system"}
{
  "data": {
    "id": "participant-id",
    "name": "Nome",
    "picture": "https://...",
    "custom_participant_id": "user-id",
    "preset_name": "group_call_host",
    "created_at": "2026-01-01T00:00:00Z",
    "updated_at": "2026-01-01T00:00:00Z",
    "token": "dyte-token"
  }
}
```

## Atualizar status do usuario na meeting

```http theme={"system"}
POST /attendance-service/referrals/{referralId}/meetings/{meetingId}/user
```

Body:

```json theme={"system"}
{
  "inMeeting": false,
  "userId": "doctor-id"
}
```

## Endpoint interno para saida de medico

```http theme={"system"}
POST /api/update-doctor-meet
```

Body:

```json theme={"system"}
{
  "doctorID": "doctor-id",
  "referralID": "referral-id",
  "meetID": "meet-id"
}
```

## Webhook Dyte

```http theme={"system"}
POST /api/dyte/webhook
```

Body:

```ts theme={"system"}
type DyteWebhookRequest = {
  event: string;
  meeting: {
    id?: string;
    sessionId?: string;
    title: string;
    status?: string;
    createdAt?: string;
    startedAt?: string;
    endedAt?: string;
    organizedBy?: {
      id: string;
      name: string;
    };
  };
  reason: "HOST_ENDED_MEETING" | "ALL_PARTICIPANTS_LEFT";
};
```

Regra:

* `meeting.title` e tratado como `referralID`.
* quando `reason` e `ALL_PARTICIPANTS_LEFT`, a BFF busca o encaminhamento e marca solicitante e especialista como `inMeeting: false`.

Resposta:

```json theme={"system"}
{
  "message": "Videochamada atualizada com sucesso!"
}
```
