Desarrolladores

La API de Route Trim

Conecta tu CRM, tu web o tu programa de contabilidad: lee tipos de cita, horas libres, reservas y clientes, reserva y cambia visitas en las horas que ofreces, y recibe cada cambio como un webhook firmado.

URL base
https://routetrim.com/api

Descargar el archivo OpenAPILa referencia de abajo está en inglés, como la propia API.

Primeros pasos

  1. Crea una clave en Configuración → Integraciones (en Starter, Pro y durante la prueba). Las claves empiezan por rt_ y se muestran una sola vez.
  2. Pruébala: GET /v1/me responde con el nombre de tu organización.
  3. Construye a partir de la referencia de abajo, o conecta Zapier sin escribir código.
curl "https://routetrim.com/api/v1/me" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY"

Claves y permisos

Envía la clave en la cabecera Authorization: Bearer de cada petición, por https. Una clave solo puede hacer lo que permitiste al crearla:

  • bookings:read: Ver las reservas y las horas libres
  • bookings:write: Hacer, mover y cancelar reservas
  • customers:read: Ver los clientes
  • customers:write: Añadir y actualizar clientes
  • webhooks:manage: Configurar webhooks (para Zapier)

Cada clave puede hacer 120 peticiones por minuto; por encima, la API responde 429 con una cabecera Retry-After. Una clave que revocas en la página Integraciones deja de funcionar al instante.

Horas y páginas

Las horas van en ISO 8601 en UTC. Las listas llegan por páginas: pasa el nextCursor de la respuesta como cursor hasta que sea null.

Errores

Un error responde con un estado HTTP y un cuerpo con un code estable y un message legible:

{
  "error": {
    "code": "slot_unavailable",
    "message": "This time is not offered (any more). Pick one from GET /v1/slots."
  }
}
  • 400 The query or body is not valid (invalid_request).
  • 401 No key, or a key that is not valid or was revoked (unauthorized).
  • 403 The plan has no API (plan_required) or the key lacks the permission (insufficient_scope).
  • 404 Not found, or it belongs to another organization (not_found).
  • 409 The time is not offered (slot_unavailable), the booking is cancelled or has started (not_changeable), another customer has the email (email_taken), the webhook limit is reached (limit_reached), or a request with this Idempotency-Key is still running (idempotency_in_progress).
  • 422 The address could not be found (address_not_found), or the Idempotency-Key was used for another request (idempotency_key_reused).
  • 429 More than 120 requests a minute with this key (rate_limited); see Retry-After.
  • 503 Address lookup or routing is unavailable for a moment (unavailable).

Reintentar sin riesgo

Las escrituras aceptan una cabecera opcional Idempotency-Key (un UUID, por ejemplo). La misma clave enviada de nuevo en 24 horas recibe la primera respuesta, marcada Idempotent-Replayed: true, así que un reintento nunca reserva dos veces.

Webhooks

Añade un destino en Configuración → Integraciones, o suscríbete mediante la API, para enterarte de los cambios en reservas y clientes en cuanto ocurren. Cada evento se envía por POST como JSON con estas cabeceras. Una entrega fallida se reintenta durante un día aproximadamente; un destino que sigue fallando durante 3 días se desactiva y se avisa por correo a los propietarios.

CampoTipoDescripción
webhook-id
obligatorio
stringThe event’s id (msg_…), the same on every retry: use it to skip repeats.
webhook-timestamp
obligatorio
stringWhen this attempt was sent, in seconds since 1970 (UTC).
webhook-signature
obligatorio
stringSpace-separated v1,<base64> signatures: HMAC-SHA256 of <webhook-id>.<webhook-timestamp>.<body> keyed with the endpoint’s secret (the part after whsec_, base64-decoded). After “Roll secret” the old secret signs too for 24 hours.

Comprueba la firma (Standard Webhooks) antes de fiarte de un evento, rechaza marcas de tiempo desviadas más de 5 minutos y usa webhook-id para descartar repeticiones. En Node.js:

import { createHmac, timingSafeEqual } from 'node:crypto'

// secret: the whsec_… shown when you added the endpoint
// rawBody: the request body exactly as received, before parsing
function verify(secret, headers, rawBody) {
  const id = headers['webhook-id']
  const timestamp = headers['webhook-timestamp']
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false
  const key = Buffer.from(secret.slice('whsec_'.length), 'base64')
  const expected = Buffer.from(
    createHmac('sha256', key).update(id + '.' + timestamp + '.' + rawBody).digest('base64'),
  )
  return headers['webhook-signature'].split(' ').some((part) => {
    const given = Buffer.from(part.slice('v1,'.length))
    return part.startsWith('v1,') && given.length === expected.length && timingSafeEqual(given, expected)
  })
}

Zapier

Nuestra app de Zapier es privada por ahora: pídenos una invitación en la página de contacto. Conéctala con una clave de «Acceso completo». Los Zaps pueden empezar cuando se hace, cambia o cancela una reserva o se añade un cliente, y pueden añadir o actualizar un cliente, buscar un cliente y reservar la primera hora libre.

Referencia

Todas las peticiones que acepta la API. Las rutas son relativas a la URL base.

Tu clave

The key and its organization

get/v1/me

Cualquier clave válida puede llamarlo.

Any valid key may call this. Use it to test a connection.

Respuesta

200 con Me. Errores: 401, 403, 429.

Ejemplo
curl "https://routetrim.com/api/v1/me" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY"

Tipos de cita

List appointment types

get/v1/appointment-types

Permiso: bookings:read (Ver las reservas y las horas libres)

Every appointment type, active or not, sorted by name.

Parámetros de consulta
CampoTipoDescripción
locale
opcional
stringLanguage of appointment type names (default: the organization’s language).
Uno de:ennlfres
Respuesta

200 con AppointmentTypeList. Errores: 400, 401, 403, 429.

Ejemplo
curl "https://routetrim.com/api/v1/appointment-types" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY"

Horas libres

Find bookable times

get/v1/slots

Permiso: bookings:read (Ver las reservas y las horas libres)

The times an active appointment type can be booked at a place, as the booking page offers them: working hours, existing visits, busy time and the drive between visits are taken into account. Give lat and lng, or an address to look up in the organization's country. Sorted by time; rank 0 fits the route best.

Parámetros de consulta
CampoTipoDescripción
type
obligatorio
integerThe appointment type’s id.
lat
opcional
numberThe visit’s latitude (with lng).
lng
opcional
numberThe visit’s longitude (with lat).
address
opcional
stringThe visit’s address, looked up when lat and lng are not given.
from
opcional
string (date-time)Start of the search (default: now).
to
opcional
string (date-time)End of the search (default: a week after from; at most 31 days).
Respuesta

200 con SlotList. Errores: 400, 401, 403, 404, 422, 429, 503.

Ejemplo
curl "https://routetrim.com/api/v1/slots?type=12&address=Grote%20Markt%201%2C%202000%20Antwerpen" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY"

Reservas

List bookings

get/v1/bookings

Permiso: bookings:read (Ver las reservas y las horas libres)

Bookings sorted by start time, a page at a time. Follow nextCursor for the next page.

Parámetros de consulta
CampoTipoDescripción
status
opcional
stringOne status or a comma-separated list: pending, confirmed, completed, cancelled, no_show.
from
opcional
string (date-time)Bookings starting at or after this time.
to
opcional
string (date-time)Bookings starting before this time.
updatedSince
opcional
string (date-time)Bookings changed at or after this time (to sync changes).
customer
opcional
integerOnly this customer’s bookings.
locale
opcional
stringLanguage of appointment type names (default: the organization’s language).
Uno de:ennlfres
limit
opcional
integerItems per page, 1–100.
cursor
opcional
stringThe nextCursor of the previous page.
Respuesta

200 con BookingList. Errores: 400, 401, 403, 429.

Ejemplo
curl "https://routetrim.com/api/v1/bookings?status=confirmed&limit=20" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY"

Get a booking

get/v1/bookings/:id

Permiso: bookings:read (Ver las reservas y las horas libres)

Parámetros de ruta
CampoTipoDescripción
id
obligatorio
integerThe id.
Parámetros de consulta
CampoTipoDescripción
locale
opcional
stringLanguage of appointment type names (default: the organization’s language).
Uno de:ennlfres
Respuesta

200 con Booking. Errores: 400, 401, 403, 404, 429.

Ejemplo
curl "https://routetrim.com/api/v1/bookings/123" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY"

Make a booking

post/v1/bookings

Permiso: bookings:write (Hacer, mover y cancelar reservas)

Books a time from GET /v1/slots for the customer, as the booking page would: the engine picks who comes and checks the time is still offered. The customer is matched by email (or added) and gets the confirmation email.

Cuerpo JSON
CampoTipoDescripción
appointmentType
obligatorio
integerThe appointment type’s id.
start
obligatorio
string (date-time)The start, as a time from GET /v1/slots. ISO 8601 with an offset or Z.
customer
obligatorio
object
customer.name
obligatorio
string
customer.email
obligatorio
string (email)Customers are matched by email address (any case).
customer.phone
opcional
stringStored with its country code (+32470123456) when it can be read as a number of the organization’s country or with a country code; otherwise as sent.
address
obligatorio
stringWhere the visit takes place.
location
opcional
objectCoordinates (WGS 84). Without them the address is looked up.
location.lat
obligatorio
number
location.lng
obligatorio
number
locale
opcional
stringThe language for the customer’s emails (default: the organization’s).
Uno de:ennlfres
Respuesta

201 con Booking. Errores: 400, 401, 403, 404, 409, 422, 429, 503.

Ejemplo
curl -X POST "https://routetrim.com/api/v1/bookings" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d @body.json

Cancel a booking

post/v1/bookings/:id/cancel

Permiso: bookings:write (Hacer, mover y cancelar reservas)

Cancels a booking that has not started. The customer and the rep are told.

Parámetros de ruta
CampoTipoDescripción
id
obligatorio
integerThe id.
Respuesta

200 con Booking. Errores: 400, 401, 403, 404, 409, 422, 429.

Ejemplo
curl -X POST "https://routetrim.com/api/v1/bookings/123/cancel" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY" \
  -H "Idempotency-Key: $(uuidgen)"

Move a booking

post/v1/bookings/:id/reschedule

Permiso: bookings:write (Hacer, mover y cancelar reservas)

Moves a booking that has not started to another time, same person and address, if that time is offered. The customer gets the new time and a new link to manage it.

Parámetros de ruta
CampoTipoDescripción
id
obligatorio
integerThe id.
Cuerpo JSON
CampoTipoDescripción
start
obligatorio
string (date-time)The start, as a time from GET /v1/slots. ISO 8601 with an offset or Z.
Respuesta

200 con Booking. Errores: 400, 401, 403, 404, 409, 422, 429, 503.

Ejemplo
curl -X POST "https://routetrim.com/api/v1/bookings/123/reschedule" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d @body.json

Clientes

List customers

get/v1/customers

Permiso: customers:read (Ver los clientes)

Customers in the order they were added, a page at a time. Pass email to find one customer.

Parámetros de consulta
CampoTipoDescripción
email
opcional
stringFind the customer with this email address.
updatedSince
opcional
string (date-time)Customers changed at or after this time (to sync changes).
limit
opcional
integerItems per page, 1–100.
cursor
opcional
stringThe nextCursor of the previous page.
Respuesta

200 con CustomerList. Errores: 400, 401, 403, 429.

Ejemplo
curl "https://routetrim.com/api/v1/customers?email=jan%40example.com" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY"

Get a customer

get/v1/customers/:id

Permiso: customers:read (Ver los clientes)

Parámetros de ruta
CampoTipoDescripción
id
obligatorio
integerThe id.
Respuesta

200 con Customer. Errores: 401, 403, 404, 429.

Ejemplo
curl "https://routetrim.com/api/v1/customers/123" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY"

Add or update a customer

post/v1/customers

Permiso: customers:write (Añadir y actualizar clientes)

Adds the customer (201), or updates the one with this email (200).

Cuerpo JSON
CampoTipoDescripción
email
obligatorio
string (email)Customers are matched by email address (any case).
name
opcional
string
phone
opcional
string | nullStored with its country code (+32470123456) when it can be read as a number of the organization’s country or with a country code; otherwise as sent. Null clears it.
address
opcional
stringThe customer’s address. Without location it is looked up in the background (location is null meanwhile).
location
opcional
objectCoordinates (WGS 84). Without them the address is looked up.
location.lat
obligatorio
number
location.lng
obligatorio
number
locale
opcional
stringThe language emails to this customer are sent in.
Uno de:ennlfres
Respuesta

200 / 201 con Customer. Errores: 400, 401, 403, 409, 422, 429.

Ejemplo
curl -X POST "https://routetrim.com/api/v1/customers" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d @body.json

Update a customer

patch/v1/customers/:id

Permiso: customers:write (Añadir y actualizar clientes)

Parámetros de ruta
CampoTipoDescripción
id
obligatorio
integerThe id.
Cuerpo JSON
CampoTipoDescripción
email
opcional
string (email)Customers are matched by email address (any case).
name
opcional
string
phone
opcional
string | nullStored with its country code (+32470123456) when it can be read as a number of the organization’s country or with a country code; otherwise as sent. Null clears it.
address
opcional
stringThe customer’s address. Without location it is looked up in the background (location is null meanwhile).
location
opcional
objectCoordinates (WGS 84). Without them the address is looked up.
location.lat
obligatorio
number
location.lng
obligatorio
number
locale
opcional
stringThe language emails to this customer are sent in.
Uno de:ennlfres
Respuesta

200 con Customer. Errores: 400, 401, 403, 404, 409, 422, 429.

Ejemplo
curl -X PATCH "https://routetrim.com/api/v1/customers/123" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d @body.json

Suscripciones de webhook

Subscribe a webhook

post/v1/webhooks

Permiso: webhooks:manage (Configurar webhooks (para Zapier))

Adds a webhook endpoint for the given events (REST hooks, as Zapier uses them) and answers its signing secret once. An organization may have 50 endpoints added through the API (409 limit_reached beyond). An endpoint that answers 410 Gone is removed.

Cuerpo JSON
CampoTipoDescripción
url
obligatorio
stringWhere to POST the events: https, on a public address.
events
obligatorio
string[]The events to send there.
description
opcional
stringShown on the Integrations page.
Respuesta

201 con WebhookSubscription. Errores: 400, 401, 403, 409, 422, 429.

Ejemplo
curl -X POST "https://routetrim.com/api/v1/webhooks" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d @body.json

Unsubscribe a webhook

delete/v1/webhooks/:id

Permiso: webhooks:manage (Configurar webhooks (para Zapier))

Removes an endpoint added through the API, with its delivery log. Endpoints added on the Integrations page are not found here.

Parámetros de ruta
CampoTipoDescripción
id
obligatorio
integerThe id.
Respuesta

200 con WebhookDeleted. Errores: 400, 401, 403, 404, 409, 422, 429.

Ejemplo
curl -X DELETE "https://routetrim.com/api/v1/webhooks/123" \
  -H "Authorization: Bearer $ROUTE_TRIM_KEY" \
  -H "Idempotency-Key: $(uuidgen)"

Objetos

Lo que responde la API. Un campo que puede estar vacío lleva null en su tipo.

Location

CampoTipoDescripción
lat
obligatorio
number
lng
obligatorio
number

AppointmentType

CampoTipoDescripción
id
obligatorio
integer
name
obligatorio
string
description
obligatorio
string | null
slug
obligatorio
string
durationMinutes
obligatorio
integer
bookingWindowDays
obligatorio
integerHow many days ahead customers may book.
minNoticeHours
obligatorio
integerThe shortest notice customers may book with.
active
obligatorio
booleanInactive types take no bookings and have no slots.
bookingUrl
obligatorio
string (uri)The public booking page for this type.

Customer

CampoTipoDescripción
id
obligatorio
integer
name
obligatorio
string
email
obligatorio
string
phone
obligatorio
string | null
address
obligatorio
string | null
location
obligatorio
Location | nullNull while the address is not placed on the map.
locale
obligatorio
stringThe language emails to this customer are sent in.
Uno de:ennlfres
createdAt
obligatorio
string (date-time)When the customer was added. ISO 8601, in UTC.
updatedAt
obligatorio
string (date-time)When the customer last changed. ISO 8601, in UTC.

Booking

CampoTipoDescripción
id
obligatorio
integer
status
obligatorio
string
Uno de:pendingconfirmedcompletedcancelledno_show
start
obligatorio
string (date-time)The start of the visit. ISO 8601, in UTC.
end
obligatorio
string (date-time)The end of the visit. ISO 8601, in UTC.
address
obligatorio
stringWhere the visit takes place.
location
obligatorio
Location
appointmentType
obligatorio
object
appointmentType.id
obligatorio
integer
appointmentType.name
obligatorio
string
rep
obligatorio
objectThe person who makes the visit.
rep.id
obligatorio
integer
rep.name
obligatorio
string | null
customer
obligatorio
Customer
source
obligatorio
stringWhere the booking came from.
Uno de:bookingPagemaintenanceInviteapicrm
locale
obligatorio
stringThe language the customer booked in.
Uno de:ennlfres
cancelledAt
obligatorio
string (date-time) | null
createdAt
obligatorio
string (date-time)When the booking was made. ISO 8601, in UTC.
updatedAt
obligatorio
string (date-time)When the booking last changed. ISO 8601, in UTC.

Slot

CampoTipoDescripción
start
obligatorio
string (date-time)The start of the visit. ISO 8601, in UTC.
end
obligatorio
string (date-time)The end of the visit. ISO 8601, in UTC.
rank
obligatorio
integerHow well the time fits the route: 0 is the best fit.

BookingList

CampoTipoDescripción
data
obligatorio
Booking[]
nextCursor
obligatorio
string | nullPass as cursor to get the next page; null on the last page.

CustomerList

CampoTipoDescripción
data
obligatorio
Customer[]
nextCursor
obligatorio
string | nullPass as cursor to get the next page; null on the last page.

SlotList

CampoTipoDescripción
timeZone
obligatorio
stringThe organization’s time zone (IANA), for showing the times.
data
obligatorio
Slot[]

Me

CampoTipoDescripción
organization
obligatorio
object
organization.id
obligatorio
integer
organization.name
obligatorio
string
organization.slug
obligatorio
string
key
obligatorio
object
key.id
obligatorio
integer
key.label
obligatorio
string
key.prefix
obligatorio
string
key.scopes
obligatorio
string[]

Error

CampoTipoDescripción
error
obligatorio
object
error.code
obligatorio
stringunauthorized, plan_required, insufficient_scope, rate_limited, not_found, invalid_request, address_not_found, slot_unavailable, not_changeable, email_taken, limit_reached, idempotency_key_reused, idempotency_in_progress, unavailable or internal_error.
error.message
obligatorio
string

BookingEvent

CampoTipoDescripción
type
obligatorio
string
Uno de:booking.createdbooking.updatedbooking.cancelled
timestamp
obligatorio
string (date-time)When the event happened. ISO 8601, in UTC.
data
obligatorio
Booking
change
opcional
stringOnly on booking.updated: rescheduled (a new time, by the customer or the API), moved (staff re-planned the day) or reassigned (another person makes the visit).
Uno de:rescheduledmovedreassigned

CustomerEvent

CampoTipoDescripción
type
obligatorio
string
Uno de:customer.createdcustomer.updated
timestamp
obligatorio
string (date-time)When the event happened. ISO 8601, in UTC.
data
obligatorio
Customer

TestEvent

CampoTipoDescripción
type
obligatorio
string
Uno de:webhook.test
timestamp
obligatorio
string (date-time)When the event happened. ISO 8601, in UTC.
data
obligatorio
object
data.endpointId
obligatorio
integer
data.message
obligatorio
string

WebhookSubscription

CampoTipoDescripción
id
obligatorio
integer
url
obligatorio
string
events
obligatorio
string[]
description
obligatorio
string | null
status
obligatorio
string
Uno de:activedisabled
secret
obligatorio
stringThe signing secret (whsec_…) for webhook-signature. Only shown in this answer.
createdAt
obligatorio
string (date-time)When it was added. ISO 8601, in UTC.

WebhookDeleted

CampoTipoDescripción
id
obligatorio
integer
deleted
obligatorio
boolean
Uno de:true

Eventos de webhook

Los eventos a los que puede suscribirse un destino, con el objeto que lleva cada uno.