Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mivicall.com/llms.txt

Use this file to discover all available pages before exploring further.

A integração programática via API requer API keys. Estas geram-se no dashboard em Settings → Integrations (em breve disponível). Por agora, contacta support@mivicall.com para receber uma chave de teste.

1. Configurar autenticação

Todas as chamadas usam Bearer auth com API key.
export MIVI_KEY="miv_test_..."

curl https://api.mivicall.com/v1/tenants/me \
  -H "Authorization: Bearer $MIVI_KEY"
Resposta:
{
  "id": "3917fecd-bfe0-4cac-b629-16d80ffe28c3",
  "name": "Clínica X",
  "specialty": "dental",
  "status": "active",
  "config": {
    "voice": "AWS.Polly.Ines-Neural",
    "timezone": "Europe/Lisbon"
  }
}

2. Listar consultas de hoje

TODAY=$(date -u +"%Y-%m-%dT00:00:00Z")
END=$(date -u -v+1d +"%Y-%m-%dT00:00:00Z")  # +1d em macOS, "tomorrow" em Linux

curl "https://api.mivicall.com/v1/appointments?from=$TODAY&to=$END" \
  -H "Authorization: Bearer $MIVI_KEY"

3. Marcar paciente como atendido

Quando o paciente chega à clínica (check-in no PMS), notifica-nos para o no-show detection não disparar.
curl https://api.mivicall.com/v1/appointments/$APPOINTMENT_ID \
  -X PATCH \
  -H "Authorization: Bearer $MIVI_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: pms-checkin-$APPOINTMENT_ID" \
  -d '{"status": "attended"}'

4. Receber webhooks

Configura uma URL no teu sistema. Mivicall faz POST com signature HMAC-SHA256.
Webhook receiver (Node)
import crypto from 'node:crypto'

const WEBHOOK_SECRET = process.env.MIVI_WEBHOOK_SECRET!

function verifySignature(rawBody: string, signature: string): boolean {
  const [tsKv, sigKv] = signature.split(',')
  const ts = tsKv.split('=')[1]
  const sig = sigKv.split('=')[1]

  const payload = `${ts}.${rawBody}`
  const expected = crypto
    .createHmac('sha256', WEBHOOK_SECRET)
    .update(payload)
    .digest('hex')

  return crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected))
}

app.post('/webhooks/mivicall', (req, res) => {
  const sig = req.header('X-Mivicall-Signature')
  if (!sig || !verifySignature(req.rawBody, sig)) {
    return res.status(401).end()
  }

  const event = JSON.parse(req.rawBody)
  console.log('Event:', event.type)

  res.status(200).end() // ack rápido — processa async se for demorado
})
Eventos comuns: appointment.created, appointment.cancelled, appointment.attended, appointment.no_show, call.completed. Lista completa em Eventos.

Próximo passo

Conceitos do modelo

Tenants, profissionais, serviços, marcações

Guia PMS completo

Padrão de integração para vendors