Skip to main content
POST
/
consultations
/
create
curl -X POST https://api.medagenda.com/consultations/create \
  -H "Content-Type: application/json" \
  -d '{
    "patient": {
      "cpf": "12345678901"
    },
    "doctor": {
      "crm": "123456SP"
    },
    "dateTime": "2024-03-15T14:30:00",
    "isUrgent": false,
    "observation": "Patient reports mild headaches for the past week"
  }'
{
  "consultationId": "550e8400-e29b-41d4-a716-446655440000",
  "dateTime": "2024-03-15T14:30:00",
  "duracaoMinutos": 60,
  "patient": {
    "cpf": "12345678901",
    "name": "João Silva",
    "email": "joao.silva@email.com",
    "dateOfBirth": "1985-06-15",
    "address": "Rua das Flores, 123, São Paulo, SP",
    "medicalHistory": "Hypertension, controlled with medication"
  },
  "doctor": {
    "crm": "123456SP",
    "name": "Dr. Maria Santos",
    "email": "maria.santos@medagenda.com",
    "specialty": "Cardiologia",
    "telephone": "+5511987654321",
    "consultationValue": 350.00
  },
  "isUrgent": false,
  "observation": "Patient reports mild headaches for the past week"
}
Creates a new consultation in the system. This endpoint validates that both the patient (by CPF) and doctor (by CRM) exist in the database before scheduling. Upon successful creation, a payment record is automatically created with PENDING status, and a confirmation email is sent.

Request Body

patient
object
required
Patient information object
doctor
object
required
Doctor information object
dateTime
string
required
Consultation date and time in ISO 8601 format (e.g., “2024-03-15T14:30:00”)
isUrgent
boolean
required
Whether this is an urgent consultation
observation
string
Additional notes or observations for the consultation

Response

consultationId
string
UUID of the created consultation
dateTime
string
Scheduled date and time of the consultation
duracaoMinutos
integer
Duration of the consultation in minutes (default: 60)
patient
object
Complete patient information
doctor
object
Complete doctor information
isUrgent
boolean
Whether this is an urgent consultation
observation
string
Additional notes or observations

Side Effects

Payment Creation

A payment record is automatically created with:
  • Amount set to the doctor’s consultationValue
  • Status set to PENDING
  • Linked to the created consultation

Email Notification

A confirmation email is sent to delivered@resend.dev with:
  • Subject: “Consulta confirmada”
  • Body: “Sua consulta foi marcada para [dateTime]”
curl -X POST https://api.medagenda.com/consultations/create \
  -H "Content-Type: application/json" \
  -d '{
    "patient": {
      "cpf": "12345678901"
    },
    "doctor": {
      "crm": "123456SP"
    },
    "dateTime": "2024-03-15T14:30:00",
    "isUrgent": false,
    "observation": "Patient reports mild headaches for the past week"
  }'
{
  "consultationId": "550e8400-e29b-41d4-a716-446655440000",
  "dateTime": "2024-03-15T14:30:00",
  "duracaoMinutos": 60,
  "patient": {
    "cpf": "12345678901",
    "name": "João Silva",
    "email": "joao.silva@email.com",
    "dateOfBirth": "1985-06-15",
    "address": "Rua das Flores, 123, São Paulo, SP",
    "medicalHistory": "Hypertension, controlled with medication"
  },
  "doctor": {
    "crm": "123456SP",
    "name": "Dr. Maria Santos",
    "email": "maria.santos@medagenda.com",
    "specialty": "Cardiologia",
    "telephone": "+5511987654321",
    "consultationValue": 350.00
  },
  "isUrgent": false,
  "observation": "Patient reports mild headaches for the past week"
}

Build docs developers (and LLMs) love