Transport for the Increase API: environment selection, Bearer auth,
the Idempotency-Key header, JSON bodies with unset fields dropped,
query strings in Increase's status.in=a,b style, cursor pagination,
and errors parsed into HttpError with account and routing numbers
redacted.
No retries. Nothing here retries a request. A transport failure
or a 5xx on a write may still have reached Increase: look the object
up with find-by-idempotency-key, then resend the same call with the
same idempotency key if it isn't there. Increase returns the original
object for a repeated key, so a resend can't move money twice.
Per-call credentials. Every function that calls the API takes an
optional trailing opts Map, resolved by resolve: opts first,
then context, then defaults. Nothing from opts is written to ctx,
and per-call credentials are masked in call records. An api-key
present but blank or null is an Err, never a fallback to context. A
per-call environment that differs from increase.environment needs
an api-key in the same opts: a context key never goes to another
environment's host.
Context Vars
increase.api.keyincrease.environmentincrease.transfers.require-approval
Values
MAX_IDEMPOTENCY_KEY_LENGTH
MAX_IDEMPOTENCY_KEY_LENGTH: Int 200
MAX_PAGES
MAX_PAGES: Int 1000
SENSITIVE_KEYS
SENSITIVE_KEYS: Vec [
"account_number",
"routing_number",
"updated_account_number",
"updated_routing_number",
"debtor_account_number",
"debtor_routing_number",
"creditor_account_number",
"originator_routing_number",
"receiver_id_number",
"individual_id",
"primary_account_number",
"card_verification_code",
"verification_code",
"pin",
"expiration_month",
"expiration_year",
"tax_identifier",
"date_of_birth",
"number",
"shared_secret",
"secret"
]
USER_AGENT
USER_AGENT: Str "hot-dev-increase/0.1.0"
Functions
apply-approval-default
fn (params: Map, required: Bool): Map
params with require_approval: true added when required is true and the caller didn't set require_approval either way. Exposed for testing.
approval-required-by-default
fn (): Bool
True when the increase.transfers.require-approval context variable is true (or "true").
blank-option
fn (opts: Map, names: Vec): Str?
The first of names that opts has but with a blank or null value, else null. Such a key is an Err, never a fallback to context: a tenant whose key or environment is missing must not run on the project's. Exposed for testing.
body-excerpt
fn (body: Any): Str
build-request
fn (method: Str, url: Str, body: Any, headers: Map, api-key: Str): ::hot::http/HttpRequest
Build (without sending) the HttpRequest for an Increase call. url
is the full URL including any query string. A non-empty Map body is
compacted and JSON-encoded with Content-Type: application/json;
otherwise no body is sent. headers (e.g. from option-headers) are
merged last. Exposed for testing.
Example
req ::increase::api/build-request("POST", "https://sandbox.increase.com/account_transfers", {amount: 100}, {Idempotency-Key: "k1"}, "test_key")
req.headers.Authorization // => "Bearer test_key"
req.body // => "{\\"amount\\":100}"
call
fn (method: Str, path: Str): Any
fn (method: Str, path: Str, params: Map): Any
fn (method: Str, path: Str, params: Map, opts: Map): Any
Call an Increase endpoint by path and return the decoded JSON body,
or an Err: HttpError for a non-2xx response, or the transport
error. params become the query string for GET and the JSON body
otherwise; null values are omitted. opts takes api-key,
environment and idempotency-key (see resolve). The call is made
exactly once.
Prefer the typed functions; this is the escape hatch for endpoints they don't cover.
Example
programs ::increase::api/call("GET", "/programs", {limit: 10})
collect-all
fn (path: Str): Vec
fn (path: Str, params: Map): Vec
fn (path: Str, params: Map, limit: Int): Vec
fn (path: Str, params: Map, limit: Int, opts: Map): Vec
Every object from a list endpoint, following cursors: up to limit
objects (default 1000; 0 means all, stopping after MAX_PAGES
pages). Pages are fetched 100 at a time. An Err on any page is
returned as is.
Example
open ::increase::api/collect-all("/accounts", {"status.in": ["open"]})
collect-pages
fn (fetch: Fn, params: Map, limit: Int, acc: Vec, pages: Int): Vec
Follow next_cursor from params, concatenating each page's data, until limit items (0 means no limit), the last page, or MAX_PAGES pages. fetch takes the params for one page and returns it. An Err from any page is returned as is. Exposed for testing; collect-all uses it.
compact
fn (value: Any): Any
Drop null values from a request body, recursively through nested maps and the maps inside vectors, so unset optionals are omitted rather than sent as JSON null. false, 0 and "" are kept. Exposed for testing.
create
fn (path: Str, params: Map, required: Vec, opts: Map, operation: Str): Map
POST a create request after checking that params has every required field. The idempotency key is optional here (it is required by move-money).
current-environment
fn (): Str
The configured environment: increase.environment normalized to "sandbox" or "production", "sandbox" when unset or empty, and an Err for any other value.
decode-body
fn (body: Any): Any
environment-base-url
fn (environment: Str): Str
The base URL for an environment name: "sandbox" is https://sandbox.increase.com and "production" is https://api.increase.com. Surrounding whitespace and case are ignored; anything else errs, so a typo can never send requests to an unintended host. Exposed for testing.
environment-of
fn (opts: Map): Str
The environment a call with opts would use: its environment, else increase.environment ("sandbox" when unset). An Err for an invalid value.
error-message
fn (status: Int, body: Any): Str
The readable message line for an error body (already redacted): increase: HTTP {status} {type}: {title} {detail}, or a body excerpt when the body isn't an Increase error object. Exposed for testing.
field
fn (body: Any, key: Str): Any
find-by-idempotency-key
fn (path: Str, idempotency-key: Str): Map?
fn (path: Str, idempotency-key: Str, opts: Map): Map?
The object a list endpoint holds for idempotency-key, or null when
the key was never used. Increase's list endpoints filter on
idempotency_key. Use it after a create call failed in transit to
learn whether the transfer was made before deciding to resend.
Example
existing ::increase::api/find-by-idempotency-key("/ach_transfers", "invoice-42-payout")
is-error-type
fn (error: Result, type-name: Str): Bool
True when error (an HttpError, or a Result.Err holding one) has this Increase error type, e.g. "idempotency_key_already_used_error".
is-sandbox
fn (): Bool
True when the configured environment is "sandbox"; false for "production" and for an invalid value.
list-page
fn (path: Str, params: Map): Map
fn (path: Str, params: Map, opts: Map): Map
GET one page of a list endpoint: {data: [...], next_cursor}.
params are the endpoint's filters plus limit (1-100, default 100)
and cursor (the previous page's next_cursor).
Example
page ::increase::api/list-page("/transactions", {account_id: "account_in71c4amph0vgo2qllky", limit: 50})
more ::increase::api/list-page("/transactions", ::increase::api/next-page-params({account_id: "account_in71c4amph0vgo2qllky", limit: 50}, page))
missing-fields
fn (params: Map, fields: Vec): Vec
The names in fields that are null or absent in params. Exposed for testing.
move-money
fn (path: Str, params: Map, required: Vec, approval: Bool, opts: Map, operation: Str): Map
POST a money-movement request: check that opts has an
idempotency-key and that params has every required field, apply
the increase.transfers.require-approval default when approval is
true, then send it once. Any failed check is an Err and nothing is
sent. The transfer and return functions are built on it.
next-cursor
fn (page: Any): Str?
The next_cursor of a list page, or null on the last page.
next-page-params
fn (params: Map, page: Any): Map?
The params for the page after page: the original filters plus
cursor (Increase requires the same filters on every page), or null
when there is no next page.
Example
::increase::api/next-page-params({account_id: "account_1", limit: 2}, {data: [{id: "t1"}, {id: "t2"}], next_cursor: "djE6"})
// => {account_id: "account_1", limit: 2, cursor: "djE6"}
non-blank
fn (value: Any): Str?
normalize-environment
fn (environment: Str): Str
"sandbox" or "production" for an environment name (case and whitespace ignored), or an Err for anything else. Exposed for testing.
option-headers
fn (opts: Map): Map
The headers opts adds: Idempotency-Key when opts has an idempotency-key. Exposed for testing.
parse-int
fn (value: Any): Int?
An Int from an Int or a decimal-digit Str; null for anything else. Never errs on bad input. Exposed for testing.
plain-error
fn (error: Result): Any
present
fn (value: Any): Bool
query-pairs
fn (params: Map, prefix: Str): Vec<Str>
Flatten query params the way Increase reads them: nested maps join
their keys with dots ({created_at: {after: "2026-01-01T00:00:00Z"}}
gives created_at.after=...), vectors become comma-delimited lists
({"status.in": ["open", "closed"]} gives status.in=open,closed),
and null values and empty vectors are dropped. Keys and values are
percent-encoded. Exposed for testing.
query-string
fn (params: Map): Str
?a=1&b=2 from params (see query-pairs), or "" when nothing remains.
query-value
fn (value: Any): Str
redact
fn (value: Any): Any
Remove sensitive data from a decoded response body: values under
SENSITIVE_KEYS (account and routing numbers, card numbers, tax ids,
secrets) become "[redacted]", and long digit runs in every other
string are masked by redact-text. Applied to every HttpError.
Exposed for testing.
redact-text
fn (text: Str): Str
Mask every run of 8 or more digits in text down to its last four ("acct 123456789" becomes "acct ****6789"), so an account or routing number echoed in an error detail is never kept whole. Exposed for testing.
require-fields
fn (params: Map, fields: Vec, operation: Str): Map
params when every name in fields is set, otherwise an Err listing the missing names (never their values). Exposed for testing.
require-idempotency-key
fn (opts: Map, operation: Str): Map
opts when it carries a non-empty idempotency-key of at most 200 characters, otherwise an Err. Every money-movement function checks this before sending anything.
require-sandbox
fn (environment: Str, operation: Str): Bool
true when environment is "sandbox", otherwise an Err naming operation. Simulation endpoints check the environment their call would use, so they never reach production. Exposed for testing.
resolve
fn (opts: Map): Map
The settings for one call: {api-key, environment, base-url, idempotency-key}. Each comes from opts first, then context
(increase.api.key, increase.environment), then the default
("sandbox"). Never writes to context, so parallel calls for
different tenants can't see each other's keys, and marks a per-call
api-key so it is masked in call records.
Errs when no API key is available, when the environment is invalid,
when api-key or environment is in opts but blank or null (that
never falls back to context), and when environment in opts differs
from increase.environment without an api-key in the same opts:
sandbox and production keys differ, so a context key is never sent to
the other environment's host.
Example
settings ::increase::api/resolve({api-key: "tenant_b_key", environment: "production"})
settings.base-url // => "https://api.increase.com"
response-body
fn (body: Any): Any
Normalize a 2xx body: empty text becomes null; anything else passes through. Exposed for testing.
seg
fn (id: Any): Str
Percent-encode one path segment (an object id), so an id from user input can't change which endpoint is called.
str-field
fn (body: Any, key: Str): Str?
Types
HttpError
HttpError type {
status: Int,
headers: Map,
body: Any,
message: Str,
type: Str?,
title: Str?,
detail: Str?,
reason: Str?,
resource_id: Str?,
errors: Vec?,
retry_after: Int?
}
A non-2xx Increase response. Increase errors are application/problem+json
objects; their fields are lifted to the top:
status: the HTTP statustype: e.g."invalid_parameters_error","invalid_operation_error","idempotency_key_already_used_error","object_not_found_error","insufficient_permissions_error","rate_limited_error","invalid_api_key_error","environment_mismatch_error"titleanddetail: human-readable textreason: forinvalid_api_key_error, e.g."wrong_environment"resource_id: foridempotency_key_already_used_error, the object the key already createderrors: forinvalid_parameters_error, the per-field problemsretry_after: seconds, forrate_limited_errormessage: one readable line, e.g."increase: HTTP 409 invalid_operation_error: The action you specified can't be performed on the object in its current state."
body is the decoded error body. Account and routing numbers and
other sensitive values are redacted from body, detail and
message (see redact), so an HttpError is safe to log.