Paint alternatives for your backend, ready for your own storefront.
Get started
The base URL is https://battlestack.fr/chromastack/api/v1. Direct mode searches the global catalogue without a merchant catalogue import. Merchant recommendations use an imported catalogue of your products.
Direct mode was added as a second integration workflow. It still uses the /api/v1 path and returns meta.api_version: "v1".
The threshold of 5 is an explicit example choice, not an API default. Choose a threshold appropriate for your use case.
Authentication
Send Authorization: Bearer <YOUR_API_KEY> with every request. Send Content-Type: application/json for POST requests.
Keep your API key on your server. Your browser or storefront should call a backend relay you operate. Never embed keys in HTML, JavaScript bundles, URLs or analytics events.
A missing, invalid or revoked key returns 401. A key associated with a disabled merchant returns 403. Key provisioning and rotation are arranged with ChromaStack; this documentation exposes no administrative endpoints.
Identify a paint
Send one source object. Its kind determines the accepted fields. Unknown properties are rejected. Omit optional fields instead of sending null.
Brand label: the brand name, its key or a declared alias. A label carried by two brands is `ambiguous_source`.
name
string · required
Exact paint name, compared case- and whitespace-insensitively. A name carried by two paints of the brand is `ambiguous_source`.
Names are resolved exactly after normalisation, not by fuzzy search. Ambiguous brands or paint names return ambiguous_source; paint-name ambiguity can include candidate identities. Use a canonical identity to disambiguate.
Strict `#RRGGBB` colour. The external colour never becomes a catalogue paint: a catalogue paint of the same colour stays a candidate. Pattern: ^#[0-9a-fA-F]{6}$.
functional_category
string · required
Functional category the merchant declares for its own paint.
brand_key
string · optional
Optional canonical brand key; required by `exclude_same_brand`.
A HEX source needs a recognised functional category, even in color_only mode. It remains an external colour: a catalogue paint with the same HEX can still be returned. To exclude the source brand, supply its canonical brand_key.
Brand keys are limited to 64 characters; slugs to 128; brand labels and paint names to 128. Range names are limited to 64 characters.
Options and filters
options
Field
Type / requirement
Details
limit
integer · optional
Maximum number of alternatives. Applied after every filter, never before. Default: 3. Minimum: 1. Maximum: 10.
match_mode
string · optional
`compatible` keeps the paints functionally compatible with the source and exposes `match_relation`; `color_only` compares colours only and always answers `match_relation: null`. Allowed: "compatible", "color_only". Default: "compatible".
max_delta_e
number · optional
Maximum Delta-E (CIEDE2000) of an accepted alternative. **Mandatory**: a request that omits it uses the threshold configured for the merchant, and a merchant without a configured threshold gets `400 invalid_request`. No default is applied and the value 3,0 is never assumed; higher values are not a match percentage. Greater than 0. Maximum: 100.
If max_delta_e is omitted, the merchant's configured threshold applies. If neither is available, the API returns 400 invalid_request. No implicit threshold is supplied.
filters
Field
Type / requirement
Details
brands
array · optional
Restriction by canonical brand key; an empty array restricts nothing. At most 16 items.
ranges
array · optional
Restriction by `(brand_key, range)` couple actually present in the catalogue. At most 32 items.
exclude_same_brand
boolean · optional
Drop every candidate of the source brand; needs a known brand. Default: false.
exclude_paints
array · optional
Paints to drop from the candidates. At most 64 items.
exclude_discontinued
boolean · optional
Drop discontinued candidates; a discontinued source stays resolvable. Default: true.
Filters combine: an allowed range must also pass any brand restriction. Empty brand and range arrays impose no restriction. Excluding discontinued paints applies to candidates; a discontinued source can still be resolved.
Read the response
Successful direct requests return data, an array of paint alternatives, and meta, the applied search context. An empty array is a valid result when no eligible alternative satisfies the filters and threshold.
Each direct alternative
Field
Type / requirement
Details
brand_key
string · required
brand_name
string · required
slug
string · required
name
string · required
hex
string · required
Pattern: ^#[0-9a-fA-F]{6}$.
type
string · required
range
string · required
family
string · required
functional_category
string · required
delta_e
number · required
CIEDE2000 distance rounded to two decimals; ranking and threshold use the unrounded value. Minimum: 0.
match_relation
string or null · required
Functional relation in `compatible` mode; always `null` in `color_only`. Allowed: "direct", "partial", null.
discontinued
boolean · required
Direct response metadata
Field
Type / requirement
Details
api_version
string · required
Value: "v1".
request_id
string · required
count
integer · required
Minimum: 0.
search_scope
string · required
The candidates come from the global ChromaStack catalogue. Value: "global".
max_delta_e
number · required
Threshold actually applied: the request override, else the merchant's configured value.
match_mode
string · required
`compatible` keeps the paints functionally compatible with the source and exposes `match_relation`; `color_only` compares colours only and always answers `match_relation: null`. Allowed: "compatible", "color_only". Default: "compatible".
source
object · required
The resolved source: its canonical identity (`brand_key`, `slug`) for `id` and `name`, its normalized characteristics (`hex`, `functional_category`, optional `brand_key`) for `hex`.
For identity or name sources, meta.source contains canonical brand_key and slug. For HEX sources it contains hex, functional_category and, if supplied, brand_key.
Example response shape
This illustrates a valid empty result and metadata; it is not a captured result for the example paint.
Direct mode does not return merchant SKUs, product URLs, prices or availability. Join paint identities to your own product catalogue when building product links.
API operations
All paths below are relative to https://battlestack.fr/chromastack. They require a bearer key.
POST/api/v1/merchants/recommendations
Best eligible equivalents of a paint, or of a hex colour.
Two request modes share this operation: send `brand_key` + `slug` to compare one paint of the catalogue, or `hex` to compare an arbitrary colour. Sending both is `400 invalid_request`. The merchant catalogue is filtered first (compatibility rule, then the Delta-E threshold), ranked on the unrounded Delta-E with the deterministic tie-break `(delta_e, brand_key, slug)`, and truncated to `top_k` last. An empty `data` array is a normal answer.
GET/api/v1/paints/{brand_key}/{slug}
Resolve one paint of the merchant catalogue.
The canonical identity of a paint is the pair `(brand_key, slug)`: a paint that is not part of the merchant catalogue answers `404 not_found`, exactly like a paint that does not exist in the reference catalogue.
The quota is counted per key in a shared store, so the value is identical across workers. Reading the quota is itself a counted request: the answer carries the three `X-RateLimit-*` headers, and `429 rate_limited` once the window is exhausted.
Closest paints of the global catalogue for one resolved source.
V2 direct mode: the merchant sends the identity of a paint (`kind: id`), a brand label and a name (`kind: name`), or an external colour with its functional category (`kind: hex`), and receives the best alternatives of the global ChromaStack catalogue. No merchant catalogue is read, so one valid key is enough for the very first request. The answer never holds merchant data: no SKU, no product URL, no price, no availability. Filters run on the whole catalogue, then the eligibility rule, the compatibility rule (in `compatible` mode) and the Delta-E threshold, then the deterministic ranking on the unrounded Delta-E `(delta_e, brand_key, slug)`, and the `limit` last. The threshold is the request override when present, else the merchant's configured value: no default is ever applied. A rejection answers `400 invalid_request` (`404 not_found` for an unknown paint) with a frozen `error.details.reason`; an ambiguous source also carries `error.details.candidates`. The request body is limited to 16 KiB: a larger one is rejected `400 invalid_request` with `details.reason` `body_too_large`.
Alternatively send {"hex":"#1F3A5F","max_delta_e":5,"top_k":3}. Do not combine HEX with brand/slug. top_k defaults to 3 and is limited to 10. Recommendations and paint lookup are scoped to the merchant catalogue; an unknown or out-of-catalogue paint returns the same 404.
Merchant recommendations return your imported sku, product_url and available fields alongside paint information. This availability reflects your catalogue data, not a live stock query. Unlike direct mode, merchant delta_e is not rounded.
Errors and limits
HTTP
Code
Meaning
400
invalid_request
Invalid JSON, parameters, source or missing configured threshold.
401
unauthorized
Missing, unknown or revoked API key.
403
forbidden
The merchant associated with the key is disabled.
404
not_found
Unknown paint or resource, or a paint outside the merchant catalogue.
429
rate_limited
The request quota has been exhausted.
500
internal_error
An internal error; quote the request identifier when reporting it.
Unknown paths and unsupported methods within the B2B namespace return 404 not_found, rather than 405.
Validation detail
{
"error": {
"code": "invalid_request",
"message_key": "b2b.error.invalid_request",
"message": "The request is malformed. Check the JSON body and each parameter value (brand, slug, ΔE threshold, result count).",
"http": 400,
"request_id": "example-request-id",
"details": {
"reason": "invalid_limit",
"field": "options.limit"
}
}
}
Example error text is English; use the machine code and reason, not the localised message, for application logic. Direct validation errors may include details.reason, details.field and ambiguity candidates.
Direct request bodies are limited to 16,384 bytes. Oversized bodies return 400 with reason body_too_large. JSON must be valid UTF-8 and cannot contain NaN or Infinity.
Quotas and request identifiers
Header
Meaning
X-Request-Id
Request identifier, also present in the response body.
X-RateLimit-Limit
Allowed requests in the quota window.
X-RateLimit-Remaining
Requests remaining in the current window.
X-RateLimit-Reset
Window end as a Unix timestamp in seconds.
Retry-After
Seconds to wait after a 429 response.
Quota headers are emitted on successful responses and quota rejections; do not assume they accompany every validation or authentication error. Quotas are shared across workers. Respect Retry-After and avoid retry loops. Even reading /usage consumes a request.
What a match means
delta_e is a CIEDE2000 colour distance: lower values indicate closer colours. It is not a percentage or a guarantee that two paints behave identically.
compatible is the default mode and applies functional compatibility rules. Results may be direct or partial. color_only bypasses compatibility rules and returns match_relation: null; interpret these results as colour comparisons only.
Filtering and thresholds apply before the result limit. Ranking uses the unrounded distance, followed by brand key and slug to make ties deterministic. Direct responses round the displayed distance to two decimals.
Digital colour references cannot reproduce the full appearance of a real paint. Metallic effects, finish, opacity, undercoat and application can change the result. Check the product characteristics before recommending a substitution.