Developer documentation

Build with ChromaStack.

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".

Request an API key by discussing your integration. Then make requests from your server.

Your first direct request

curl --request POST \
  'https://battlestack.fr/chromastack/api/v1/paints/alternatives' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "source": {
    "kind": "id",
    "brand_key": "citadel",
    "slug": "abaddon-black"
  },
  "options": {
    "limit": 3,
    "match_mode": "compatible",
    "max_delta_e": 5
  },
  "filters": {
    "exclude_same_brand": true,
    "exclude_discontinued": true
  }
}'

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.

By canonical identity

{
  "source": {
    "kind": "id",
    "brand_key": "citadel",
    "slug": "abaddon-black"
  }
}
FieldType / requirementDetails
kindstring · requiredValue: "id".
brand_keystring · requiredCanonical brand key.
slugstring · requiredCanonical or legacy slug; the answer always carries the canonical one.

By brand and name

{
  "source": {
    "kind": "name",
    "brand": "Citadel (Games Workshop)",
    "name": "Abaddon Black"
  }
}
FieldType / requirementDetails
kindstring · requiredValue: "name".
brandstring · requiredBrand label: the brand name, its key or a declared alias. A label carried by two brands is `ambiguous_source`.
namestring · requiredExact 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.

By external HEX colour

{
  "source": {
    "kind": "hex",
    "hex": "#1F3A5F",
    "functional_category": "standard_opaque"
  },
  "options": {
    "max_delta_e": 5
  }
}
FieldType / requirementDetails
kindstring · requiredValue: "hex".
hexstring · requiredStrict `#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_categorystring · requiredFunctional category the merchant declares for its own paint.
brand_keystring · optionalOptional 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

FieldType / requirementDetails
limitinteger · optionalMaximum number of alternatives. Applied after every filter, never before. Default: 3. Minimum: 1. Maximum: 10.
match_modestring · 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_enumber · optionalMaximum 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

FieldType / requirementDetails
brandsarray · optionalRestriction by canonical brand key; an empty array restricts nothing. At most 16 items.
rangesarray · optionalRestriction by `(brand_key, range)` couple actually present in the catalogue. At most 32 items.
exclude_same_brandboolean · optionalDrop every candidate of the source brand; needs a known brand. Default: false.
exclude_paintsarray · optionalPaints to drop from the candidates. At most 64 items.
exclude_discontinuedboolean · optionalDrop discontinued candidates; a discontinued source stays resolvable. Default: true.

Range and paint references

FieldType / requirementDetails
brand_keystring · required
rangestring · requiredRange name as the catalogue spells it.
FieldType / requirementDetails
brand_keystring · required
slugstring · required
{
  "filters": {
    "brands": [
      "citadel"
    ],
    "ranges": [
      {
        "brand_key": "citadel",
        "range": "Base"
      }
    ],
    "exclude_paints": [
      {
        "brand_key": "citadel",
        "slug": "abaddon-black"
      }
    ]
  }
}

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

FieldType / requirementDetails
brand_keystring · required
brand_namestring · required
slugstring · required
namestring · required
hexstring · requiredPattern: ^#[0-9a-fA-F]{6}$.
typestring · required
rangestring · required
familystring · required
functional_categorystring · required
delta_enumber · requiredCIEDE2000 distance rounded to two decimals; ranking and threshold use the unrounded value. Minimum: 0.
match_relationstring or null · requiredFunctional relation in `compatible` mode; always `null` in `color_only`. Allowed: "direct", "partial", null.
discontinuedboolean · required

Direct response metadata

FieldType / requirementDetails
api_versionstring · requiredValue: "v1".
request_idstring · required
countinteger · requiredMinimum: 0.
search_scopestring · requiredThe candidates come from the global ChromaStack catalogue. Value: "global".
max_delta_enumber · requiredThreshold actually applied: the request override, else the merchant's configured value.
match_modestring · 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".
sourceobject · requiredThe 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.

{
  "data": [],
  "meta": {
    "api_version": "v1",
    "request_id": "example-request-id",
    "count": 0,
    "search_scope": "global",
    "max_delta_e": 5,
    "match_mode": "compatible",
    "source": {
      "brand_key": "citadel",
      "slug": "abaddon-black"
    }
  }
}

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.

curl 'https://battlestack.fr/chromastack/api/v1/paints/citadel/abaddon-black' \
  --header 'Authorization: Bearer <YOUR_API_KEY>'

GET/api/v1/usage

Quota window of the key that made the call.

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.

curl 'https://battlestack.fr/chromastack/api/v1/usage' \
  --header 'Authorization: Bearer <YOUR_API_KEY>'

POST/api/v1/paints/alternatives

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`.

Merchant recommendation example

curl --request POST \
  'https://battlestack.fr/chromastack/api/v1/merchants/recommendations' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{"brand_key":"citadel","slug":"abaddon-black","max_delta_e":5,"top_k":3}'

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

HTTPCodeMeaning
400invalid_requestInvalid JSON, parameters, source or missing configured threshold.
401unauthorizedMissing, unknown or revoked API key.
403forbiddenThe merchant associated with the key is disabled.
404not_foundUnknown paint or resource, or a paint outside the merchant catalogue.
429rate_limitedThe request quota has been exhausted.
500internal_errorAn 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.

Reasons: ambiguous_source, unknown_brand, unknown_paint, unknown_range, invalid_hex, unknown_functional_category, invalid_source_kind, invalid_limit, invalid_max_delta_e, invalid_match_mode, unknown_property, body_too_large, invalid_type, exclude_same_brand_without_brand.

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

HeaderMeaning
X-Request-IdRequest identifier, also present in the response body.
X-RateLimit-LimitAllowed requests in the quota window.
X-RateLimit-RemainingRequests remaining in the current window.
X-RateLimit-ResetWindow end as a Unix timestamp in seconds.
Retry-AfterSeconds 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.