Skip to content

Beacon: a search was refined (facet-change telemetry)

POST
/api/v2/search-events/refined
curl --request POST \
--url https://crate.hosaka.fm/api/v2/search-events/refined \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "search_event_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "changed_facets": [ { "name": "genre", "from": [ "example" ], "to": [ "example" ] } ], "timestamp": "2026-04-15T12:00:00Z" }'

Client beacon reporting facet changes that refined a prior search (≤10 changed facets). Authenticated with the per-search beacon JWT (Authorization: Bearer), NOT the X-API-Key. Body ≤512 bytes; idempotent.

X-On-Behalf-Of
string
<= 128 characters /^[A-Za-z0-9._:@-]{1,128}$/

Optional. A partner fronting many end users with one key names the end user this call is made for (an opaque, stable id of YOUR choosing: 1–128 chars of [A-Za-z0-9._:@-]). The key stays the customer; the profile becomes a metering dimension — usage rolls up per profile (GET /api/v2/me/usage?profile=), per-profile caps apply UNDER the key tier limits (429 rate_limited with reason “profile_cap”; defaults 60/min and 2,000/UTC-day), and DELETE /api/v2/me/profiles/{profile_id} forgets a profile. crate stores only a salted, customer-scoped hash of the id — never the id. A malformed value is 400 invalid_on_behalf_of. The frozen v1 contract ignores the header.

Media type application/json
object
search_event_id
required
string format: uuid
changed_facets
required
Array<object>
<= 10 items
object
name
required
string
Allowed values: genre style year_from year_to country format label q
from
Any of:
string
to
Any of:
string
timestamp
required
string format: date-time

Beacon accepted (idempotent no-op on duplicate)

X-RateLimit-Limit
integer

Requests allowed in the current window.

X-RateLimit-Remaining
integer

Requests remaining in the current window.

X-RateLimit-Reset
integer

Unix epoch (seconds) when the current window resets.

X-Quota-Limit
integer

The tier’s included monthly 2xx allowance.

X-Quota-Remaining
integer

Included allowance minus the requests gated this month — an UPPER BOUND on billable 2xx (errors are counted at the gate but never billed; /api/v2/me/usage is the billable truth). 0 once the included bucket is spent (overage, where enabled, is flagged by X-Overage).

X-Quota-Reset
integer

Unix epoch (seconds) of the next UTC month start, when the monthly counter resets.

Validation failure — invalid_json, invalid_payload (with details = Zod flattened error object), or timestamp_skew (with skew_ms)

Media type application/json
object
error
required
string
details
skew_ms
number
Example
{
"error": "invalid_payload"
}

Beacon-token failure — missing_token, invalid_token, or token_search_event_mismatch

Media type application/json
object
error
required
string
details
skew_ms
number
Example
{
"error": "invalid_payload"
}

Payload too large (>512 bytes)

Media type application/json
object
error
required
string
details
skew_ms
number
Example
{
"error": "invalid_payload"
}