We do not handle life-threatening emergencies: call 112.

+34 611 673 280

DevelopersAPI v1

Reference

Code samples

Copy-ready samples in curl, JavaScript/TypeScript, Python, PHP, Java and C# to create, read and cancel visits and to verify webhooks.

Last reviewed: October 1, 2026

Every sample reads the base URL and the key from two environment variables, so the same code works in the sandbox and in production:

Shell
export SERAD_API_URL="https://sandbox-api.saludenruta.es/api/integrations/v1"   # in production: https://api.saludenruta.es/api/integrations/v1
export SERAD_API_KEY="srd_test_…"

Pick your language in any block: your choice is remembered across every sample in the documentation.

Create a visit

With an Idempotency-Key so you can retry without creating duplicates (idempotency). Every field is described in visits.

curl -X POST "$SERAD_API_URL/visits" \
  -H "X-Api-Key: $SERAD_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: crm-exp-2026-004512-1" \
  -d '{
    "patient": { "firstName": "María", "lastName": "García López", "documentType": "DNI",
                 "documentNumber": "12345678Z", "birthDate": "1948-05-17", "phone": "+34600111222" },
    "address": { "line1": "Calle de Alcalá 120", "line2": "3º B", "postalCode": "28009", "city": "Madrid" },
    "serviceTypeCode": "GENERAL_CONSULTATION",
    "priority": "URGENT",
    "reason": "Fiebre alta desde ayer, 39 ºC",
    "externalRef": "EXP-2026-004512"
  }'

Retrieve a visit

curl "$SERAD_API_URL/visits/$VISIT_ID" \
  -H "X-Api-Key: $SERAD_API_KEY"

Cancel a visit

Only while it's PENDING or ASSIGNED; otherwise you get a 409 and have to call the dispatch centre (cancel).

curl -X POST "$SERAD_API_URL/visits/$VISIT_ID/cancel" \
  -H "X-Api-Key: $SERAD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "reason": "El paciente ya no necesita la visita" }'

Verify a webhook

The verification function, in each language. The full explanation (and how to plug it into Express, Flask, Spring or ASP.NET Core) is in webhooks.

# Computes the expected signature of a body saved in body.json, to compare by hand.
TIMESTAMP=1790847600
printf '%s.%s' "$TIMESTAMP" "$(cat body.json)" \
  | openssl dgst -sha256 -hmac "$SERAD_WEBHOOK_SECRET" -hex \
  | sed 's/^.* /sha256=/'

Something missing or not matching what you see? Email our technical team: info@saludenruta.es.