api_key query parameter. Things to know before you call:
- Two hosts, two generations. Optimizations use the v4 API on
api.route4me.com/api.v4; routes, orders, vehicles, the address book, customers and team users use the v5 API onwh.route4me.com/modules. Both are wrapped here, so a caller does not have to know which generation a resource lives on. - The v5 host needs
Accept: application/json.wh.route4me.comalso serves the web app, and a request that does not ask for JSON is redirected to the login page — even with a valid key. The plugin always sends that header. If you call this host yourself, send it too, or a rejected key looks like an HTML login page rather than a 401. - The error envelopes differ. v4 answers
{ errors: [...], error_code }; v5 answers{ status: false, error, code, messages: [...] }.Route4MeAPIError.errorsholds every message in both cases. - v5 validates with 406. A rejected field or filter comes back as
406, not400, and the plugin treats it as a validation failure rather than a request that might succeed on a retry. - Two kinds of paging. The v5 collections page by
page/per_pageand return ametablock;next_pageis derived frommeta.current_pageandmeta.last_page. The address book pages bylimit/offsetand the plugin returnsnext_offset, which is null on a short page. v4 optimizations page bylimit/offsetwithtotalRecords. optimizations.listaccepts one or many. Passingoptimization_problem_idmakes v4 answer a single object instead of a collection; the plugin normalises both into the sameoptimizationsarray and reportstotal_records: 1.optimizations.getis the clearer call when you already have the id.- Creating an optimization is asynchronous. The solver queues the problem and returns an id with
state: 0. Polloptimizations.getuntilstatereaches 4 (Optimized); 5 is an error and 6 means directions are still being computed. - Coordinates are required for an address book contact.
addresses.createneedscached_latandcached_lngalongside the street address, because Route4Me will not geocode on write. An optimization stop, by contrast, takes either an address or a coordinate pair. - Choosing a stop type.
address_stop_typetakes one ofDELIVERY,PICKUP,BREAK,MEETUP,SERVICEorVISIT; leaving it out lets Route4Me use the account default. - Order contact fields are renamed on the wire.
orders.createsendsfirst_name,last_name,emailandphoneasEXT_FIELD_first_nameand so on, which is what the v5 API reads. - Retries. Route4Me documents no throughput window and no
Retry-After, so a 429 is retried three times with exponential backoff. A 5xx is retried only for calls declared read-only: v5’s list routes are POSTs, so the HTTP method alone would misclassify them.
- 13 typed API operations
Setup
1
Install
2
Add the plugin
corsair.ts
multiTenancy: true, scope calls with corsair.withTenant(id). See Quick start for KEK + Hub keys, and Multi-tenancy for account isolation.3
Choose authentication
- API Key (Recommended)
No setup required yet. When you make your first request as a tenant, Corsair prompts for the API key.More: API Key
4
Connect a tenant
Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see Connect / OAuth.
Example API calls
List routes with page pagingWhat’s next
API reference
Every
route4me.api.* operation with input and output types.Connect / OAuth
createLink, Hub delivery, and tenant connect flows.
Use with agents
Expose this plugin’s operations as MCP tools.