Primeros pasos
- 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. - Pruébala:
GET /v1/me responde con el nombre de tu organización. - 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 libresbookings:write: Hacer, mover y cancelar reservascustomers:read: Ver los clientescustomers:write: Añadir y actualizar clienteswebhooks: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.
| Campo | Tipo | Descripción |
|---|
webhook-idobligatorio | string | The event’s id (msg_…), the same on every retry: use it to skip repeats. |
webhook-timestampobligatorio | string | When this attempt was sent, in seconds since 1970 (UTC). |
webhook-signatureobligatorio | string | Space-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
| Campo | Tipo | Descripción |
|---|
localeopcional | string | Language of appointment type names (default: the organization’s language). Uno de:ennlfres |
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
| Campo | Tipo | Descripción |
|---|
typeobligatorio | integer | The appointment type’s id. |
latopcional | number | The visit’s latitude (with lng). |
lngopcional | number | The visit’s longitude (with lat). |
addressopcional | string | The visit’s address, looked up when lat and lng are not given. |
fromopcional | string (date-time) | Start of the search (default: now). |
toopcional | 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
| Campo | Tipo | Descripción |
|---|
statusopcional | string | One status or a comma-separated list: pending, confirmed, completed, cancelled, no_show. |
fromopcional | string (date-time) | Bookings starting at or after this time. |
toopcional | string (date-time) | Bookings starting before this time. |
updatedSinceopcional | string (date-time) | Bookings changed at or after this time (to sync changes). |
customeropcional | integer | Only this customer’s bookings. |
localeopcional | string | Language of appointment type names (default: the organization’s language). Uno de:ennlfres |
limitopcional | integer | Items per page, 1–100. |
cursoropcional | string | The 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
| Campo | Tipo | Descripción |
|---|
idobligatorio | integer | The id. |
Parámetros de consulta
| Campo | Tipo | Descripción |
|---|
localeopcional | string | Language 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
| Campo | Tipo | Descripción |
|---|
appointmentTypeobligatorio | integer | The appointment type’s id. |
startobligatorio | string (date-time) | The start, as a time from GET /v1/slots. ISO 8601 with an offset or Z. |
customerobligatorio | object | |
customer.nameobligatorio | string | |
customer.emailobligatorio | string (email) | Customers are matched by email address (any case). |
customer.phoneopcional | string | Stored 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. |
addressobligatorio | string | Where the visit takes place. |
locationopcional | object | Coordinates (WGS 84). Without them the address is looked up. |
location.latobligatorio | number | |
location.lngobligatorio | number | |
localeopcional | string | The 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
| Campo | Tipo | Descripción |
|---|
idobligatorio | integer | The 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
| Campo | Tipo | Descripción |
|---|
idobligatorio | integer | The id. |
Cuerpo JSON
| Campo | Tipo | Descripción |
|---|
startobligatorio | 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
| Campo | Tipo | Descripción |
|---|
emailopcional | string | Find the customer with this email address. |
updatedSinceopcional | string (date-time) | Customers changed at or after this time (to sync changes). |
limitopcional | integer | Items per page, 1–100. |
cursoropcional | string | The nextCursor of the previous page. |
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
| Campo | Tipo | Descripción |
|---|
idobligatorio | integer | The 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
| Campo | Tipo | Descripción |
|---|
emailobligatorio | string (email) | Customers are matched by email address (any case). |
nameopcional | string | |
phoneopcional | string | null | Stored 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. |
addressopcional | string | The customer’s address. Without location it is looked up in the background (location is null meanwhile). |
locationopcional | object | Coordinates (WGS 84). Without them the address is looked up. |
location.latobligatorio | number | |
location.lngobligatorio | number | |
localeopcional | string | The 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
| Campo | Tipo | Descripción |
|---|
idobligatorio | integer | The id. |
Cuerpo JSON
| Campo | Tipo | Descripción |
|---|
emailopcional | string (email) | Customers are matched by email address (any case). |
nameopcional | string | |
phoneopcional | string | null | Stored 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. |
addressopcional | string | The customer’s address. Without location it is looked up in the background (location is null meanwhile). |
locationopcional | object | Coordinates (WGS 84). Without them the address is looked up. |
location.latobligatorio | number | |
location.lngobligatorio | number | |
localeopcional | string | The 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
| Campo | Tipo | Descripción |
|---|
urlobligatorio | string | Where to POST the events: https, on a public address. |
eventsobligatorio | string[] | The events to send there. |
descriptionopcional | string | Shown on the Integrations page. |
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
| Campo | Tipo | Descripción |
|---|
idobligatorio | integer | The 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
| Campo | Tipo | Descripción |
|---|
latobligatorio | number | |
lngobligatorio | number | |
AppointmentType
| Campo | Tipo | Descripción |
|---|
idobligatorio | integer | |
nameobligatorio | string | |
descriptionobligatorio | string | null | |
slugobligatorio | string | |
durationMinutesobligatorio | integer | |
bookingWindowDaysobligatorio | integer | How many days ahead customers may book. |
minNoticeHoursobligatorio | integer | The shortest notice customers may book with. |
activeobligatorio | boolean | Inactive types take no bookings and have no slots. |
bookingUrlobligatorio | string (uri) | The public booking page for this type. |
Customer
| Campo | Tipo | Descripción |
|---|
idobligatorio | integer | |
nameobligatorio | string | |
emailobligatorio | string | |
phoneobligatorio | string | null | |
addressobligatorio | string | null | |
locationobligatorio | Location | null | Null while the address is not placed on the map. |
localeobligatorio | string | The language emails to this customer are sent in. Uno de:ennlfres |
createdAtobligatorio | string (date-time) | When the customer was added. ISO 8601, in UTC. |
updatedAtobligatorio | string (date-time) | When the customer last changed. ISO 8601, in UTC. |
Booking
| Campo | Tipo | Descripción |
|---|
idobligatorio | integer | |
statusobligatorio | string | Uno de:pendingconfirmedcompletedcancelledno_show |
startobligatorio | string (date-time) | The start of the visit. ISO 8601, in UTC. |
endobligatorio | string (date-time) | The end of the visit. ISO 8601, in UTC. |
addressobligatorio | string | Where the visit takes place. |
locationobligatorio | Location | |
appointmentTypeobligatorio | object | |
appointmentType.idobligatorio | integer | |
appointmentType.nameobligatorio | string | |
repobligatorio | object | The person who makes the visit. |
rep.idobligatorio | integer | |
rep.nameobligatorio | string | null | |
customerobligatorio | Customer | |
sourceobligatorio | string | Where the booking came from. Uno de:bookingPagemaintenanceInviteapicrm |
localeobligatorio | string | The language the customer booked in. Uno de:ennlfres |
cancelledAtobligatorio | string (date-time) | null | |
createdAtobligatorio | string (date-time) | When the booking was made. ISO 8601, in UTC. |
updatedAtobligatorio | string (date-time) | When the booking last changed. ISO 8601, in UTC. |
Slot
| Campo | Tipo | Descripción |
|---|
startobligatorio | string (date-time) | The start of the visit. ISO 8601, in UTC. |
endobligatorio | string (date-time) | The end of the visit. ISO 8601, in UTC. |
rankobligatorio | integer | How well the time fits the route: 0 is the best fit. |
BookingList
| Campo | Tipo | Descripción |
|---|
dataobligatorio | Booking[] | |
nextCursorobligatorio | string | null | Pass as cursor to get the next page; null on the last page. |
CustomerList
| Campo | Tipo | Descripción |
|---|
dataobligatorio | Customer[] | |
nextCursorobligatorio | string | null | Pass as cursor to get the next page; null on the last page. |
AppointmentTypeList
SlotList
| Campo | Tipo | Descripción |
|---|
timeZoneobligatorio | string | The organization’s time zone (IANA), for showing the times. |
dataobligatorio | Slot[] | |
Me
| Campo | Tipo | Descripción |
|---|
organizationobligatorio | object | |
organization.idobligatorio | integer | |
organization.nameobligatorio | string | |
organization.slugobligatorio | string | |
keyobligatorio | object | |
key.idobligatorio | integer | |
key.labelobligatorio | string | |
key.prefixobligatorio | string | |
key.scopesobligatorio | string[] | |
Error
| Campo | Tipo | Descripción |
|---|
errorobligatorio | object | |
error.codeobligatorio | string | unauthorized, 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.messageobligatorio | string | |
BookingEvent
| Campo | Tipo | Descripción |
|---|
typeobligatorio | string | Uno de:booking.createdbooking.updatedbooking.cancelled |
timestampobligatorio | string (date-time) | When the event happened. ISO 8601, in UTC. |
dataobligatorio | Booking | |
changeopcional | string | Only 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
| Campo | Tipo | Descripción |
|---|
typeobligatorio | string | Uno de:customer.createdcustomer.updated |
timestampobligatorio | string (date-time) | When the event happened. ISO 8601, in UTC. |
dataobligatorio | Customer | |
TestEvent
| Campo | Tipo | Descripción |
|---|
typeobligatorio | string | Uno de:webhook.test |
timestampobligatorio | string (date-time) | When the event happened. ISO 8601, in UTC. |
dataobligatorio | object | |
data.endpointIdobligatorio | integer | |
data.messageobligatorio | string | |
WebhookSubscription
| Campo | Tipo | Descripción |
|---|
idobligatorio | integer | |
urlobligatorio | string | |
eventsobligatorio | string[] | |
descriptionobligatorio | string | null | |
statusobligatorio | string | Uno de:activedisabled |
secretobligatorio | string | The signing secret (whsec_…) for webhook-signature. Only shown in this answer. |
createdAtobligatorio | string (date-time) | When it was added. ISO 8601, in UTC. |
WebhookDeleted
| Campo | Tipo | Descripción |
|---|
idobligatorio | integer | |
deletedobligatorio | boolean | Uno de:true |
Eventos de webhook
Los eventos a los que puede suscribirse un destino, con el objeto que lleva cada uno.