Routa constructor validates the configuration synchronously and builds the transport every resource uses.
Options
Retries
The client retries:- network failures and timeouts;
429responses;5xxresponses;- a
409that means “an identical request is still in progress” (idempotency_in_progress).
Retry-After header when the server sends it. 4xx responses such as 401, 402, 403, 404 and 422 are never retried, because repeating them would only repeat the same failure. A 402 lasts until someone changes the plan or the payment. A 409 is not retried either, except idempotency_in_progress: idempotency_key_reuse and the other conflicts are client errors.
Idempotency
messages.send() sends an Idempotency-Key automatically and reuses it on every retry, so a retry never creates a second message. Pass your own key with send({ ..., idempotencyKey }).
message._replayed is true.
Project key and partner key
Routa accepts only project keys. Passing a partner key throws on construction, with a message that points to RoutaPartner. A partner key is only accepted by the partner routes, and never sends messages.
RoutaPartner accepts the same transport options (baseURL, timeout, maxRetries, logger and fetch). See Partners.
Logger
Custom fetch
Replacefetch to inject a proxy agent or, in tests, to respond without a network: