HTTP API
Endpoints, keys, metering and status codes of the Emojisense API.
On this page
Two services, both Cloudflare Workers:
| Service | Package | Hosted | Local (wrangler dev) |
Purpose |
|---|---|---|---|---|
| Search API | packages/worker |
https://api.emojisense.com |
http://localhost:8788 |
search, reactions, image → emoji, static packs and shards |
| Dashboard | apps/dashboard |
https://app.emojisense.com |
http://localhost:8790 |
accounts, apps, keys, usage, billing, waitlist (/api/*) |
Shared contracts: @emojisense/platform (D1 schema, plans, key helpers) and
PACK_FORMAT.md (packs, vectors, shards).
- HTTPS only. The hosted API answers a Worker route over plain
http://with403and{ "error": "use https://api.emojisense.com: …" }, so a client set tohttpfails at once instead of sending keys and text unencrypted. Localwrangler dev(and anylocalhosthost) keeps plainhttp. - JSON responses are
application/json; charset=utf-8withX-Content-Type-Options: nosniffand CORS for every origin (Access-Control-Allow-Origin: *). Errors of the search, reaction, image and custom pack routes are{ "error": "<message>" }withCache-Control: no-store.
Authentication
| Key | Where | Sent as | Checks |
|---|---|---|---|
Publishable pk_live_… |
browsers, extensions | ?key= query parameter (no CORS preflight) |
Origin must match the key's allowed origins (an empty list allows any origin; only dev keys may have one) |
Secret sk_live_… |
servers only (MCP, bots, tenant writes) | Authorization: Bearer sk_live_… |
never accepted with an Origin header (blocks use from browsers) or in the URL |
| none (anonymous) | quick tries, local dev | — | stricter rate limit per IP, and no model calls (below) |
Every key belongs to one environment of its app: prod (every plan), dev (Solo and up) or
staging (Pro and up). The environment does not show in the key. A dev or staging key whose
account plan no longer includes its environment answers 402
{ "error": "plan_required", "message", "plan" }, with the cheapest plan that has it, until the
plan includes it again. prod keys never pause.
The Origin check stops misuse from other websites. It does not stop servers, which can forge
headers, so every caller is also rate limited:
| Caller | Limit | Counted per |
|---|---|---|
| A key | 120 requests a minute | key and IP address |
| A publishable key from Emojisense's own pages (website, dashboard) | 60 requests a minute | IP address |
| Anonymous | 30 requests a minute | IP address |
| Key lookups that miss the per-isolate key cache (each one a database read, unknown keys included) | 60 a minute | IP address |
Over the limit the answer is 429 with Retry-After: 60. An IPv6 address counts by its /64
network. The IP address is only an in-memory limiter key; it is never logged or stored. Static files, /v1/health and the emoji image routes
(/v1/sets/…, /v1/custom/…) are not limited per call. The key-lookup limit stops a flood of
random keys before it reaches the database; a key the instance knew before keeps working while
it holds, for at most three minutes after the instance last read it. The website's own publishable key is public (it ships in the site's JavaScript), so its
calls have their own per-IP limit, and the website account's plan (Pro) caps what the key can use
in a month.
Anonymous calls never reach Workers AI. Without a key, /v1/search reads no cache (the cache
is per account) and answers like an account over its limit: alias results in hybrid mode, none
in semantic mode, "overLimit": true, not cached. /v1/suggest-reactions ranks
without the embedding (alias results, "overLimit": true). /v1/classify-image and
/v1/custom-pack answer 401, the tenants API 401 unauthorized. Anonymous calls are never
metered, get no custom emoji, and are not in any app's analytics. When a key was sent but the key
store cannot be read and the key is not cached, the call is served as anonymous, except that
/v1/classify-image and /v1/custom-pack answer 503 (retry). The public demos on the website
use the website's own publishable key, so they are not anonymous.
Metering and plan limits
- Metered: each Worker call to
/v1/searchand/v1/suggest-reactions(semantic_calls, also when the response comes from the Cache API) and each/v1/classify-image(image_classifications). Calls with a key only: anonymous calls are never metered. An answer without a model call (Workers AI down, or over the limit and not in the cache) is not counted. - Not metered: static packs and shards, hosted emoji set images, custom emoji images and custom packs, on-device search.
- Monthly UTC periods, no daily caps. Limits come from
PLANSin@emojisense/platform. - Limits are per account. The plan belongs to the account (
accounts.plan), so the calls of all of its apps count against one limit per metric. When the account's total for the month reaches the limit, every app of the account gets"overLimit": true. Usage is still stored per app, so the dashboard shows each app's part. - Each API instance counts calls in memory. Its copy of the account's total is never older than a minute, and each write of its counts (about every 10 s while busy) refreshes it. So calls on other instances can take about a minute to count, and an account can go a little over its limit.
- One cache per account. The cache key is the key's account, the embedded query text,
locale, limit, mode, index version and a hash of the served packs, vector files and engine
(written by the Worker's
syncstep), so a data fix under the same pack version is not answered from older entries. It has no key, app or origin in it, so all apps of an account warm the same edge cache. Accounts never share entries: a hit (cached, a fast answer) would tell one customer what another customer's users searched. Anonymous calls read no cache. Entries stay for 7 days. Custom emoji and culture are applied after the cache, per request, and never stored in it. - Over the limit, the API never fails. A query that is in the account's cache is still answered
(
"cached": true, not metered). Other queries return200with"overLimit": trueand alias-only (hybrid) or empty (semantic) results. The SDK keeps asking (the edge cache may know the next query), remembers each over-limit miss, and stays on the on-device dictionary and shards for those.
GET /v1/search
| Param | Default | Notes |
|---|---|---|
q |
— | Required. Cut to 64 characters. The semantic tier embeds it with its accents and punctuation (PACK_FORMAT.md §3, "Embedding text"); aliases, custom emoji and analytics use its normalized form. |
locale |
en |
A pack locale: en, zh, hi, es, ar, fr, bn, pt, ru, id, tr. See Locales. Semantic search covers the English and this locale's emoji vectors (PACK_FORMAT.md §5). |
limit |
24 |
1–50. The ranking does not depend on it: both tiers bring at least 24 candidates, and the fused list is cut to limit (PACK_FORMAT.md §10). |
mode |
hybrid |
hybrid = alias + semantic fused on the server (thin clients). semantic = semantic only (the SDK fuses with its own on-device results). |
pack |
— | Client pack version (informational) |
key |
— | Publishable key |
tenant |
— | The app owner's id for one of their customers (tenants.external_id, ≤ 128 characters): that tenant's custom emoji are searched too |
culture |
1 |
The culture layer is on by default (1, true or none). 0 (or false) turns it off: the canonical ranking only. Any other value answers 400. |
region |
region of locale |
ISO 3166-1 alpha-2 code of the user's region, e.g. GB, BR (case does not matter), or auto. Turns on regional culture entries; not used with culture=0. Without it, the region of the locale tag applies (pt-BR → BR; none for pt). auto uses the country of the request, which Cloudflare's edge derives from the IP address (request.cf.country); when it is unknown, no regional entry applies. A code that is not a real region answers 400. See Region auto. |
day |
caller's local day | YYYY-MM-DD: the day the culture windows are checked against. Without it, the caller's local day in the time zone that Cloudflare's edge derives from the IP address (request.cf.timezone), else the UTC day. A value that is not a real calendar day answers 400. |
{
"query": "jurassic park",
"results": [{ "emoji": "🦖", "id": "1F996", "score": 0.82, "source": "alias" }],
"packVersion": "0.1.0",
"model": "embeddinggemma@768",
"calibration": { "floor": 0.35, "ceiling": 0.53, "gapFloor": 0.02, "gapCeiling": 0.1 },
"cached": false,
"degraded": false,
"overLimit": false,
"aliasLocale": "en",
"culture": { "from": "2026-10-01", "day": "2026-10-03", "region": null },
"confidence": 0.94,
"unsure": false
}| Field | Meaning |
|---|---|
query |
The normalized query (PACK_FORMAT.md §3) |
results[] |
{ emoji, id, score, source }, best first. id is the Emojibase hexcode of the base emoji. source: alias, semantic, custom (with imageUrl and shortcode, below) or culture (not with culture=0; with context and cultureId, see Culture in search) |
packVersion, model |
The data the Worker serves, e.g. 0.1.0 and bge-m3@1024 (model key @ dims) |
calibration |
The calibration of model: the score ranges over which its top match goes from rarely to usually right (PACK_FORMAT.md §10). A client that fuses semantic results with its own aliases uses it for fuse and the unsure verdict, so a model change on the server needs no client update. Absent in answers cached before 2026-10-03 |
cached |
The answer came from the edge cache of the key's account |
degraded |
Workers AI was unavailable, so the results are alias-only (and not cached) |
overLimit |
The key's account has used its monthly semantic_calls limit (see "Metering and plan limits") |
aliasLocale |
The locale whose aliases were fused into the results. null in semantic mode, or when that locale's pack could not be loaded (the results are then semantic-only and not cached) |
culture |
{ "from": "2026-10-01", "day": "2026-10-02", "region": "GB" }: the culture file's first day, the day its windows were checked against (day, else the caller's local day, else UTC), and the region (null without one). null with culture=0 or when the locale has no culture file |
region |
Only when the request has region: the region used for regional entries, uppercase. With region=auto, the request's country, or null when it is unknown. Also with culture=0, so an SDK can apply regional entries on the device. A region from the locale tag is not echoed here; culture.region shows it |
confidence, unsure |
How well the query was understood: see Unsure queries. Over the limit and for anonymous calls, unsure is the dictionary's verdict alone |
Headers: Server-Timing and Cache-Control. Server-Timing lists the stages of the request,
in ms, in the order they finished, then total (the whole request in the Worker, from routing to
the answer, key check included):
| Stage | What it timed |
|---|---|
auth |
The key check: an isolate-cached lookup, or a D1 read, plus the rate limiter |
cache |
The edge-cache lookup of the key's account (none without a key). It starts after the key check, at the same time as the reads below |
custom |
The app's custom emoji (isolate-cached for 60 s; 0 for an app without custom emoji) |
usage |
The account's usage for the plan limit, when this isolate must read it from D1 (a hit sends its answer first and counts after) |
culture |
The culture file (not with culture=0) |
rank |
The whole ranking of a miss: embed, vectors and locale at the same time, then fusion |
embed |
The Workers AI embedding call alone |
vectors, locale |
Waiting for the locale's vector file and alias engine (0 once they are resident in the isolate) |
Stages that run at the same time can add up to more than total. Inside Workers the clock
moves only on I/O, so pure computation reports 0.
| Answer | Cache-Control |
|---|---|
| Normal answer | public, max-age=3600, s-maxage=86400 |
| With culture (a culture file was applied) on a named or UTC day | public, max-age=3600 (no longer than the culture file) |
With culture on the caller's local day (from its time zone, no day=) |
private, max-age=3600 (the day is not in the URL) |
With region=auto |
private, max-age=3600 (the answer depends on the caller's country, which the URL does not show) |
| The app has custom emoji | private, max-age=60 |
| Over the limit (not from the cache), degraded, or a locale pack or vector file did not load | no-store |
Custom emoji. With a key, the app's custom emoji (app-wide, plus the tenant's with tenant=)
are matched against the query and put first, in both modes, within limit:
{ "emoji": ":party_parrot:", "id": "C-x7Kq2", "score": 0.95, "source": "custom",
"imageUrl": "https://api.emojisense.com/v1/custom/app_1/x7Kq2", "shortcode": "party_parrot" }- They are matched per request from a per-isolate copy of the app's emoji that is at most 60 s old, and never enter the shared cache. Over the plan limit and when Workers AI is down they are still merged.
- When the app has custom emoji, the answer has
Cache-Control: private, max-age=60. - A tenant emoji replaces an app-wide emoji with the same shortcode. An unknown
tenantsearches the app-wide emoji only. - Tenant emoji are not secret. Anyone with the app's publishable key (it is in your page) and
a tenant's
externalIdcan read that tenant's custom emoji (shortcodes, aliases, images) through search, reactions and/v1/custom-pack, like the custom emoji of a chat workspace, which every member sees. Image URLs need no key at all. So do not store private content in custom emoji, and use ids that other tenants cannot guess (not sequential numbers or public names) if tenants must not see each other's emoji. There is no signed tenant token yet.
Unsure queries
Names and pop culture that the emoji data does not mention ("kendrick lamar", "taylor swift", "la casa de papel") give a flat, low semantic list and at most a partial dictionary match. The search API says so, so that an app can show the results as guesses.
A query is unsure when the dictionary does not cover it with confidence (no phrase matches all
its words with whole tokens, or the top alias score is below 0.6) and the semantic list is flat
or low (semanticStrength < 0.6: the best cosine on the calibrated scale, halved when it does
not stand out from results 2–5). The SDKs compute the same verdict on the device
(assessConfidence in emojisense, Confidence in Swift and Kotlin).
| Field | Meaning |
|---|---|
confidence |
0–1: how well the dictionary or the semantic tier understood the query |
unsure |
true: neither did (the verdict above). Show the results as guesses |
No language model reads search queries. (An LLM concept tier for unsure queries was removed on 2026-10-02, DECISIONS.md.)
Locales
- The API accepts every pack locale. A BCP 47 tag counts as its language, case-insensitive:
en-US→en,pt-BR→pt,zh-Hansandzh-Hant→zh(the pack is Simplified Chinese). Nolocale(or an empty one) meansen. - Any other language answers
400with the supported list, e.g.unknown locale "de": use one of en, zh, hi, es, ar, fr, bn, pt, ru, id, tr (or a BCP 47 tag of one, e.g. pt-BR). - Search and reactions rank with the English core pack plus the requested locale's core and ext packs, close to what an SDK has after its idle-time load (it also has the English ext pack). English matches still count, slightly below the locale's own.
enandtrare built into the Worker. The other locales load their core and ext packs on the first request in a Worker instance (≈ 0.2–0.4 s once), then answer as fast asen.- Semantic search scores each emoji by its best match over the shared (English) vectors and the
locale's own vector file,
vectors.<model>.<dims>.<locale>.bin(PACK_FORMAT.md §5). The shared file is built into the Worker; a locale's file loads on its first query in an instance. When a pack or vector file cannot be loaded, the answer uses what is there and is not cached; the next request tries again.
POST /v1/suggest-reactions
Request { "text": "we just shipped the new onboarding!", "locale": "en", "limit": 8 }. The text
is truncated to 256 characters (≈ 64 tokens). locale follows the search rules and
picks the alias pack. The response has the same shape as search (aliasLocale, culture and
region included), with the caller's custom emoji first (tenant in the body or the query), and
Cache-Control: no-store. The body must be JSON of at most 16 KB (400 for other JSON, 413
for a larger body). The text is never logged or cached: it is chat content.
Results are reactions, not topics: "we just shipped the new onboarding!" gives 🎉 🙌 👏, not 📦.
The ranking fuses the emoji in the text, intent cues (thanks, congratulations, condolences,
laughter, agreement… in en, tr, es, fr, de, pt, it), a reaction vocabulary ranked by the message
embedding, alias hits per clause and the nearest emoji of the catalog. A topical emoji needs two
signals, or a very close embedding match, so "smoke tests are failing" does not give 🚬. One
embedding call per request, no LLM. source is semantic for the embedding signals and
alias for the rest; over the limit and without a key, all results are alias. The list can be
shorter than limit when the text gives little to go on.
Culture is on by default, as in search. Culture emoji whose trigger is in the message (as whole
words) come right after the top reaction: "thanks so much for the help!" with "region": "JP"
gives 🙏 then 🙇. A message never gets a regional lead. The body fields follow the search rules:
| Field | Default | Notes |
|---|---|---|
culture |
true |
false turns the culture layer off |
region |
region of locale |
ISO 3166-1 alpha-2 code, or "auto" (the request's country) |
day |
caller's local day | "YYYY-MM-DD"; without it, the caller's local day (request.cf.timezone), else UTC |
Any other value answers 400. Culture results carry source: "culture", context and
cultureId. Metering does not change.
POST /v1/classify-image
Needs a key (anonymous calls get 401). Request: Content-Type: image/jpeg or image/webp, max
256 KB. Clients downscale to ~384 px
first. Optional header X-Image-Hash: <16 hex> (for example a 64-bit perceptual hash) turns on
the label cache, so the same image sent many times costs one vision call. The cache key is the
SHA-256 of the bytes the API received, never the header, so only byte-identical images share a
label. Query: ?locale=&limit= (locale is checked as in search; the label is
English, so the keywords are ranked with English aliases; limit 1–50, default 8). Answers are
Cache-Control: no-store.
{ "caption": "a puppy asleep on a sofa", "reaction": "aww, so cute", "keywords": ["puppy", "sofa", "sleeping"], "results": [{ "emoji": "🐶", "id": "1F436", "score": 0.92, "source": "semantic" }], "cached": false, "degraded": false, "overLimit": false }The vision model returns the caption, a likely reaction, 3–6 keywords and up to 8 emoji of its
own choice. Proposed emoji that are not in the catalog are dropped. The results fuse those emoji,
an alias search per keyword and the nearest emoji to the caption embedding; an emoji with too
little evidence is dropped, so the list can be shorter than limit. Gender and direction
variants (🚵 🚵♀️ 🚵♂️) appear once. score is the fused evidence, 0–1. degraded: true = no
caption embedding (fewer results).
The image is never stored or logged. It is processed in memory and dropped. Only the label
(caption, reaction, keywords, proposed emoji) is cached, and only with X-Image-Hash, keyed by
the SHA-256 of the image bytes, the vision model and the prompt version. A wrong or reused
X-Image-Hash can never read or replace the label of another image.
Static files
| Path | Content | Cache |
|---|---|---|
/v1/pack/:version/manifest.json, pack.<locale>.json, pack.<locale>.ext.json, vectors.<model>.<dims>[.<locale>].bin |
data packs | public, max-age=31536000, immutable |
/p/:packVersion/index.json |
live index of the precomputed results (layer 2 shards) of locale=en, rebuilt nightly; names its files and the base layer's index (PACK_FORMAT.md §6) |
public, max-age=3600 |
/p/:packVersion/:locale/index.json |
the live index of another pack locale: the API's answers for that locale. en/ serves the English index. A locale without shards answers 404 |
public, max-age=3600 |
/p/:packVersion/f/<hash>.json |
a shard file or a base index, named by its content | public, max-age=31536000, immutable |
/p/:packVersion/[:locale/]<key>.json |
for clients from before hashed files: the key's file in the live index | public, max-age=86400 |
/v1/culture/:packVersion/culture.<locale>.json, /v1/culture/:packVersion/index.json |
culture layer: editorial associations by culture, region and moment (PACK_FORMAT.md §9) | public, max-age=3600 |
These are free and need no key. Packs are static assets and do not run the Worker; shards and
culture files run it, which serves the nightly (shards) or last published (culture,
CULTURE.md) build from R2 through the edge cache, else the deployed files. The same
shard files are on https://cdn.emojisense.com/p/… (cdn.emojisense.dev for dev), straight from
R2 through the CDN, with no Worker: use that host as shardsUrl. All send
Access-Control-Allow-Origin: *. A /v1/pack/ path that is not a published file answers 404
with Cache-Control: no-store, so a browser does not keep the miss. Until the first nightly
shard build exists, /p/<v>/index.json answers 404 (no static shards are deployed); the SDK's
shard provider then answers nothing and the query goes on to /v1/search.
Culture files
GET /v1/culture/0.1.0/culture.es.json returns the Spanish culture file: every lasting entry
plus the seasonal and event entries active in the next 12 months, with their exact windows, so the
SDK switches them on and off offline by the device's local day. No daily rebuild is needed. The
files change when a deploy brings new or edited entries under the same pack version, so they are
cached for an hour and never immutable. A locale without a file answers 404; clients then
search without the culture layer.
| Field of a culture result (SDK) | Meaning |
|---|---|
source |
"culture" |
context |
Why the emoji fits, in the file's locale |
cultureId |
The entry id, e.g. goat-football |
The SDK applies the culture layer on the device after fusion. For thin clients, the search and reactions APIs apply it by default (Culture in search). Culture results never rank above the top canonical result, except a regional sense in the caller's region (below).
Culture in search
GET /v1/search?q=goat (and ®ion=AR for regional entries):
{ "query": "goat",
"results": [
{ "emoji": "🐐", "id": "1F410", "score": 1, "source": "alias" },
{ "emoji": "⚽", "id": "26BD", "score": 0.6, "source": "culture",
"context": "Football's greatest-of-all-time debate", "cultureId": "goat-football" }
],
"culture": { "from": "2026-10-01", "day": "2026-10-02", "region": "AR" }, "…": "…" }- On by default.
culture=0gives the canonical ranking only. The SDKs sendculture=0and apply the culture file on the device after fusion, so it is never applied twice. - Culture results go right after the canonical (fused) top result, at most 5, cut to
limit;scoreis the entry's weight (0–1). Custom emoji still come first. - Regional senses (
kind: "regional", PACK_FORMAT.md §9) are the only exception: with a region in the entry's scope (region, else the region of thelocaletag), a query equal to its trigger puts its emoji first and the canonical answer second (footballwithregion=GB: ⚽ then 🏈). Without a region, or with a region outside the scope, the canonical answer stays first. - Windows are checked against one day,
culture.day: the request'sday, else the caller's local day in the time zone Cloudflare's edge derives from the IP address (request.cf.timezone), else the UTC day.culture.fromis the culture file's first day. The SDK uses the device's local day. - Culture is applied to each answer after the shared cache, like custom emoji. The cache holds
the canonical answer only, so
culture,regionanddaydo not split it and no answer carries another day's or region's culture. Culture answers sendCache-Control: public, max-age=3600(the culture file's own lifetime), orprivatewhen the day is the caller's local day (it is not in the URL, so a shared proxy must not keep it). - Metering does not change: a culture answer is one
semantic_callscall, cached or not.
Region auto
region=auto lets the API pick the region: the country of the request as Cloudflare's edge sees
it (request.cf.country, ISO 3166-1 alpha-2, derived from the IP address). Use it when the app
does not know the user's region.
- The country only selects the regional culture entries of this one answer, and the answer
names it in
region(andculture.region). It is not stored with the request, the key or any user. Like every keyed search, the request counts in the app's analytics under its country (query_daily, a count per app, day, query, locale and country; see Privacy). - Unknown countries (Cloudflare's
XX, Tor'sT1) giveregion: null: only entries for every region apply. - The shared cache key does not change: culture is still applied after the cache read, so every caller in every country shares one cache entry per query.
- Answers send
Cache-Control: private, max-age=3600: a shared proxy must not give one country's answer to a user in another. - The SDKs (
region: "auto"in the TypeScript session, React and the web component; KotlinSearchSession(region = "auto")) sendregion=autowith their semantic requests and apply regional entries with theregionof the first answer that has one. They never send a region code they know; until the first API answer, only entries for every region apply.
GET /v1/sets/:set/:hexcode.svg
One emoji image from a hosted set. Pickers use it when their emojiSet option is not native.
Hosted sets are a paid feature: the image needs a key whose account plan includes them (Solo and
up). Not metered, not rate limited per image.
| Part | Values |
|---|---|
set |
twemoji, noto, fluent |
hexcode |
Emojibase hexcode of a pack emoji or of one of its single-tone variants, e.g. 1F44D, 1F44D-1F3FD, 2764-FE0F-200D-1F525. Case and U+FE0F spelling do not matter. hexcodeOf(emoji) in emojisense makes it. |
key |
Query parameter: a publishable key, e.g. ?key=pk_live_… (emojiImageUrl(emoji, { endpoint, emojiSet, key }) adds it; the pickers pass their publishableKey). A server can send a secret key as Authorization: Bearer. |
Key checks. An
<img>request has noOriginheader, so a publishable key is checked against the origin of theReferer(orOriginwhen there is one). The SDK pickers setreferrerpolicy="strict-origin-when-cross-origin"on these images, so the page's origin (never its path) is sent even under a stricter page policy. A request with neither header is refused for a key bound to origins. Emojisense's own pages (website and dashboard) show set images without a key.Key errors:
401 key_required(no key),401unknown or revoked key,402 plan_requiredwithplan: "solo"(the account's plan has no hosted sets),403origin not allowed,429too many unknown keys from one IP,503when the key cannot be checked now. The image of an allowed request stays in browser caches for a year, also after a downgrade.200:image/svg+xmlwithCache-Control: public, max-age=31536000, immutable, CORS*, aLink: <license>; rel="license"header and a CSP that blocks scripts when the file is opened directly.Each file comes from a pinned upstream commit through jsDelivr, once per edge location, and then from the Cache API. The Worker fetches only paths of its own mapping (never a URL from the request).
Errors (JSON
{ error, message }):400 invalid_hexcode,404 unknown_set,404 unknown_emoji(not in the pack),404 not_in_set(the set does not draw it, e.g. country flags in Fluent),502 upstream_unavailable. The 404s are cacheable for a day.Coverage per set: packages/worker/reports/sets-coverage.md.
| Set | Upstream | License |
|---|---|---|
| Twemoji | jdecked/twemoji v17.0.3 |
graphics CC BY 4.0 |
| Noto | googlefonts/noto-emoji v2026-09-24-unicode18_0 |
images Apache 2.0, flags public domain |
| Fluent | microsoft/fluentui-emoji (2026-08-24) |
MIT |
Attribution: Twemoji graphics © Twitter, Inc. and the jdecked/twemoji contributors, CC BY 4.0. Noto Emoji © Google LLC, Apache 2.0. Fluent Emoji © Microsoft Corporation, MIT. The images are served unmodified. License texts: NOTICE. Apps that show these images should credit the set, for example on an "About" screen.
GET /v1/custom/:appId/:emojiId
The image of one custom emoji: the imageUrl of results, custom packs and the dashboard. No key,
not metered, not rate limited.
200: the stored bytes (image/png,image/gif,image/webporimage/svg+xml) withCache-Control: public, max-age=31536000, immutable, anETag, CORS*,Cross-Origin-Resource-Policy: cross-origin,X-Content-Type-Options: nosniffand a CSP that sandboxes the file and blocks scripts and requests when it is opened directly. An id always points at the same image (a new image is a new emoji), so browsers keep it.- The edge (Cache API) keeps a copy for one day only (
public, max-age=86400on the cached entry), then reads D1 and R2 again. 404for an unknown emoji, an emoji of another app, or a missing object.503when the database cannot be read (not cached).- Deletes (takedowns). A deleted emoji is gone from D1 and R2 at once. The delete (dashboard or tenants API) also purges the cached image in the data center that handled it; other edge locations stop serving it within a day. Browsers that already loaded the image can keep it.
GET /v1/custom-pack
The app's custom emoji as a pack (PACK_FORMAT.md §9), so the SDK searches them
on the device (loadCustomPack in emojisense). Not metered.
| Param | Notes |
|---|---|
key |
Required (a publishable key; a secret key goes in Authorization). Anonymous calls get 401. |
tenant |
Optional, as in search: adds that tenant's emoji. |
Cache-Control: public, max-age=60. The edge caches it for 60 s per app, tenant and pack layout version (no key in the cache key), so dashboard edits show up within about a minute.- Development keys (
DEV_KEYS) get an empty pack. When the database cannot be read, the answer is an empty pack withCache-Control: no-store.
POST /v1/events
A client's report of how its searches ended and which emoji people picked: one per page view,
from a sample of sessions (emojisense/stats, web component stats-url, React statsUrl).
Free, not metered, no key needed (?key=pk_… files it under the key's app; publishable keys keep
their allowed origins). Answers 204. Also on https://stats.emojisense.com
(stats.emojisense.dev), a host that takes this route only, so the reports can move to another
backend with no client update.
{ "v": 1, "sample": 0.1, "locale": "pt-BR",
"counts": { "device": 41, "memory": 6, "shard": 3, "api": 2, "none": 1, "error": 0, "cancelled": 9 },
"picks": [["bom dia", "2600"]] }| Field | Meaning |
|---|---|
sample |
the share of sessions that report (0.001–1); each report counts 1 / sample times |
counts |
keystrokes by how their search ended: on the device, from memory (a loaded shard or an answer seen before), a shard file, the API, no layer answering, an error, or replaced by the next keystroke while it waited |
picks |
up to 50 [normalized query, hexcode] pairs of search results that were chosen |
Sent as text/plain (navigator.sendBeacon), so no CORS preflight. At most 16 KB (a larger
body answers 413, also without Content-Length); a body that is not a report answers 400.
Pick text goes through the shard privacy filter; text it refuses is dropped and the emoji kept.
GET /v1/health
{ "ok": true, "packVersion": "0.1.0", "model": "bge-m3@1024", "semantic": true }. No key, not
metered, not rate limited. semantic: false = the Worker has no Workers AI binding (alias-only).
Tenants API (Scale, secret key)
Tenants are your own customers. Each tenant has its own custom emoji, next to the app-wide ones.
Call these routes from your server with a secret key: Authorization: Bearer sk_live_….
Browsers cannot call them (a request with an Origin header is refused, and CORS does not allow
Authorization). The account that owns the app must be on Scale. Writes need the secret key;
reads of a tenant's emoji in search and custom packs need only the publishable key and the
externalId (see "Tenant emoji are not secret" under search).
| Method + path | Body | Answer |
|---|---|---|
GET /v1/tenants?limit=&cursor= |
— | { tenants: Tenant[], nextCursor }, ordered by externalId. limit 1–500 (default 100). Pass nextCursor as cursor for the next page; null = last page. |
POST /v1/tenants |
JSON { externalId, name? } |
201 + Tenant when created. 200 + the existing Tenant when the externalId is taken (safe to call on every sign-in; name is not changed). |
DELETE /v1/tenants/:externalId |
— | { tenant: Tenant, emojiDeleted }. Deletes the tenant's custom emoji (rows and images) too. |
GET /v1/tenants/:externalId/emoji |
— | { emoji: CustomEmoji[], used, limit }. used / limit: custom emoji of every app of the account vs the plan limit. |
POST /v1/tenants/:externalId/emoji |
multipart/form-data: file, shortcode, aliases (comma-separated, optional) |
201 + CustomEmoji |
DELETE /v1/tenants/:externalId/emoji/:shortcode |
— | the deleted CustomEmoji |
// Tenant
{ "id": "Qm3xV0aT9cLr2PzK8wYe", "externalId": "acme", "name": "Acme Inc", "createdAt": 1760529600000, "emojiCount": 2 }
// CustomEmoji
{
"id": "h7Q2mXn4Lw9pRt0sVb1c",
"shortcode": "party_parrot",
"aliases": ["party time", "dance"],
"imageUrl": "https://api.emojisense.com/v1/custom/<appId>/h7Q2mXn4Lw9pRt0sVb1c",
"tenantId": "Qm3xV0aT9cLr2PzK8wYe",
"tenantExternalId": "acme",
"source": "api",
"bytes": 18234,
"createdAt": 1760529600000
}curl -X POST https://api.emojisense.com/v1/tenants \
-H "Authorization: Bearer $EMOJISENSE_SECRET_KEY" -H "Content-Type: application/json" \
-d '{"externalId":"acme","name":"Acme Inc"}'
curl -X POST https://api.emojisense.com/v1/tenants/acme/emoji \
-H "Authorization: Bearer $EMOJISENSE_SECRET_KEY" \
-F file=@party_parrot.gif -F shortcode=party_parrot -F aliases="party time, dance"externalId: your id for the customer, 1–128 characters of letters, digits and. _ ~ : @ + -. Encode it in the path (encodeURIComponent).shortcode: 1–64 characters ofa–z 0–9 _ + -;:party_parrot:is accepted and stored asparty_parrot. Unique per tenant. Aliases are normalized like search queries (≤ 20, ≤ 64 characters each).- Images: PNG, GIF, WebP or SVG, at most 256 KB. The type is read from the file's bytes. An SVG
with a script, an
on…=handler, ajavascript:link, an externalhreforurl(), a<foreignObject>or a DOCTYPE/ENTITY is refused (unsafe_svg). - Custom emoji count against the plan's
custom_emojilimit across all apps of the account. - Every create and delete sends a webhook event.
- Errors of these routes:
{ "error": "<code>", "message": "…", … }.
| Status | error |
When |
|---|---|---|
| 400 | invalid_request (+ field), invalid_json, invalid_multipart, unsafe_svg |
A field is missing or invalid |
| 401 | unauthorized |
No key (an unknown or revoked key: see the table below) |
| 402 | plan_required (+ plan: "scale") |
The account is not on Scale |
| 403 | secret_key_required, development_key, plan_limit (+ used, limit) |
A publishable key; a DEV_KEYS key (no app row); the custom emoji limit is reached |
| 404 | tenant_not_found, emoji_not_found, not_found |
No such tenant, shortcode or route |
| 409 | shortcode_taken |
The tenant already has this shortcode |
| 413 | image_too_large, body_too_large |
Image > 256 KB, JSON body > 16 KB |
| 415 | unsupported_media_type, unsupported_image |
Wrong Content-Type, or not PNG/GIF/WebP/SVG |
| 503 | unavailable, storage_unavailable |
The database or the image bucket is not reachable |
Status codes
| Status | Meaning |
|---|---|
| 200 | Also over a plan limit ("overLimit": true), without a key on search and reactions, and when Workers AI is down ("degraded": true): search never fails hard |
| 400 | Missing or empty q / text, a body that is not JSON (reactions), a locale without a pack, a culture other than 0/1/true/false (true/false in a reactions body), a region that is not an ISO 3166-1 alpha-2 region, a day that is not a calendar day YYYY-MM-DD, a wrong image Content-Type, a bad X-Image-Hash, an unreadable image, an invalid emoji set hexcode, or a tenant longer than 128 characters |
| 401 | Unknown or revoked key, an Authorization header that is not Bearer <key>, or no key for /v1/classify-image, /v1/custom-pack, a hosted set image (key_required) and the tenants API |
| 402 | The account's plan does not include the feature (tenants API, hosted sets: plan_required) |
| 403 | Plain http:// to the hosted API, an origin not allowed for this publishable key (for set images: the Referer's origin), a secret key in the URL, or a secret key with an Origin header (from a browser) |
| 404 | No such route, emoji set, emoji or custom emoji |
| 405 | Wrong method; Allow names the right one |
| 413 | Image larger than 256 KB, or a reaction body larger than 16 KB |
| 429 | Rate limited (per minute, see Authentication), also too many key lookups that miss the key cache from one IP. Retry after the seconds in Retry-After (60). |
| 502, 503 | An emoji set upstream did not answer (502); the custom emoji store cannot be read, or a key cannot be checked now on /v1/classify-image, /v1/custom-pack and set images (503, with Retry-After) |
Dashboard API (apps/dashboard, Clerk session)
Clerk signs people in, in the browser. Every signed-in route needs Authorization: Bearer <Clerk session token> (from Clerk's getToken()); cookies are not read. The Worker verifies the
token without a network call (Clerk's JWT public key, azp in CLERK_AUTHORIZED_PARTIES, issuer,
expiry, session not pending) and reads email, email_verified and name from the custom session
claims. The first request of a new Clerk user creates the account; without a verified email the
answer is 403 email_required and no account. Without a valid token the answer is
401 unauthorized; a token while Clerk is not configured gets 503 clerk_unconfigured.
The dashboard at https://app.emojisense.com calls these routes. API keys do not work here; from
your own server, use the Search API and the tenants API.
| Method + path | Purpose |
|---|---|
GET /api/auth/dev?login=<name> |
Local development only (ENVIRONMENT=development and localhost): sign in as <name>@dev.localhost with a cookie |
POST /api/auth/logout |
Clears the dev sign-in cookie. Clerk sessions end in the browser. |
GET /api/me |
Account, its own plan, appCount, billingStatus, teams: [{ ownerId, ownerName, role }] |
DELETE /api/me |
{ confirm } → { ok: true, clerkUserDeleted }. Deletes the account and everything it owns, see below (the account itself) |
GET /api/apps, POST /api/apps |
List own apps, then team apps (each with role, ownerId, ownerName, emojiSet, activeKeyCount, activeKeysByEnvironment) / create an app in the own account ({ name }; an environment field from older clients is ignored) |
GET /api/apps/:id |
App + keys (viewer+) |
PATCH /api/apps/:id |
{ name?, emojiSet? } (developer+). emojiSet other than native needs Solo+ |
POST /api/apps/:id/keys |
Create a key (kind, environment = prod (default), staging or dev, allowedOrigins). The full key is returned once. An environment the owner's plan does not include is 402 plan_required. (developer+) |
PATCH /api/keys/:id, DELETE /api/keys/:id |
Update origins / revoke (developer+) |
GET /api/apps/:id/usage?period=YYYY-MM |
Per metric: the account's total over all of its apps vs the owner's plan limit (used, limit, percent, status), and this app's part (appUsed). custom_emoji is the emoji stored now, in every period. (viewer+) |
GET /api/apps/:id/analytics?days=7|30|90[&country=BR][&locale=pt] |
Search analytics (Pro and Scale, viewer+), see below |
GET /api/apps/:id/tenants?limit=&cursor= |
{ tenants: [{ id, externalId, name, createdAt, emojiCount }], nextCursor } (Scale, viewer+) |
POST /api/apps/:id/tenants |
{ externalId, name? } → 201 { tenant }; a taken externalId is 409 tenant_exists (Scale, developer+) |
GET /api/apps/:id/tenants/:tenantId |
{ tenant } (Scale, viewer+) |
DELETE /api/apps/:id/tenants/:tenantId |
→ { tenant, emojiDeleted }, with the tenant's custom emoji (Scale, developer+) |
GET /api/apps/:id/webhooks |
{ webhooks: [{ id, appId, url, events, enabled, createdAt, disabledAt, lastDelivery }] } (Scale, viewer+) |
POST /api/apps/:id/webhooks |
{ url, events? } → 201 { webhook, secret }. The whsec_… secret is shown only here. events defaults to all. At most 10 per app (409 webhook_limit). (Scale, developer+) |
PATCH /api/webhooks/:id |
{ url?, events?, enabled? } → { webhook } (Scale, developer+) |
DELETE /api/webhooks/:id |
→ { ok: true }, with its deliveries (Scale, developer+) |
POST /api/webhooks/:id/test |
Sends one webhook.test event now (no retries, also when disabled) → { delivery }. At most 5 a minute per webhook, then 429 rate_limited (Scale, developer+) |
GET /api/webhooks/:id/deliveries |
{ deliveries: [{ id, event, status, ok, durationMs, createdAt }] }, the last 50, newest first (Scale, viewer+) |
GET /api/apps/:id/emoji[?tenantId=] |
Custom emoji → { emoji: CustomEmoji[], used, limit } (viewer+), see below |
POST /api/apps/:id/emoji |
Multipart upload: file, shortcode, aliases, tenantId? → 201 CustomEmoji (Solo+, developer+) |
PATCH /api/apps/:id/emoji/:emojiId |
{ shortcode?, aliases? } → CustomEmoji (developer+) |
DELETE /api/apps/:id/emoji/:emojiId |
→ { ok: true } (developer+, any plan) |
POST /api/apps/:id/emoji/import/slack |
{ token } → { imported, skipped, remaining, skippedBy } (Pro+, developer+) |
POST /api/apps/:id/emoji/import/discord |
{ botToken, guildId } → like the Slack import (Pro+, developer+) |
GET /api/team |
{ ownerId, role, members, invites } (Pro+, any member) |
POST /api/team/invites |
{ role, email? } → { invite, url }. The link /invite/<token> is shown once and works once, for 7 days (admin+) |
DELETE /api/team/invites/:id |
Withdraw an open invite (admin+) |
PATCH /api/team/members/:id |
{ role } (admin+). The owner cannot change. |
DELETE /api/team/members/:id |
Remove a member (admin+), or leave the team (the member) |
POST /api/invites/:token/accept |
Signed in: join the owner's team → { team: { ownerId, ownerName, role } }. An invite with an email works only when the caller's verified email (the email claim with email_verified: true) is that email; otherwise 403 invite_email_mismatch. |
GET /api/billing |
{ plan, period, usage, limits, appCount, provider: "whop" | null, subscription: { status, interval, currentPeriodEnd, graceUntil, manageUrl }, purchasable } (owner, admin; manageUrl only for the owner). See Billing. |
POST /api/billing/checkout |
{ plan: "solo" | "pro" | "scale", interval?: "month" | "year" } → { url }: Whop's hosted checkout (owner only). Yearly is Solo only. |
POST /api/whop/webhook |
Whop's signed billing events. No session; the Standard Webhooks signature is checked. |
POST /api/waitlist |
Public: { email, plan } (plan defaults to pro) as JSON, or the same fields as an HTML form (application/x-www-form-urlencoded). A form post without Accept: application/json gets 303 to <website>/waitlist/?status=ok#waitlist-joined or ?status=error#waitlist-failed (the website is the posting WEBSITE_ORIGINS entry, or the first one when there is no Origin). Other origins get 403; 5 posts per minute per IP. |
Roles, plans and errors
- Plan. It lives on the account (
accounts.plan). Every app of the account gets it, and team members see the owner's plan. Its monthly limits count the usage of all apps of the account. - Roles. owner > admin (everything except changing the plan) > developer (apps, keys, custom emoji, webhooks; no team management) > viewer (read only). A team membership counts only while the owner's plan includes team members (Pro, Scale).
- Team scope. Team and billing routes act on the caller's own account. Add
?owner=<accountId>to act on another owner's team (needs a membership with a high enough role). - Errors. Every error is
{ "error": { "code", "message", "field"?, "plan"? } }.
| Status | code |
When |
|---|---|---|
| 402 | plan_required |
The plan lacks the feature. plan = the cheapest plan that has it (also POST /api/apps past maxApps). |
| 403 | forbidden_role |
The caller can see the app or team, but the role is too low |
| 404 | not_found |
No app, key, team or member, or no access to it (the same answer) |
| 404 | invite_not_found |
Unknown or withdrawn invite link |
| 409 | invite_own_team, already_member, owner_immutable, already_on_plan |
Invite for the own team, a second membership, a change to the owner, a checkout for the plan and interval the account already pays for |
| 409 | tenant_exists, webhook_limit |
A tenant with this externalId exists; the app has 10 webhooks |
| 410 | invite_used, invite_expired |
The invite was accepted already, or is older than 7 days |
| 400 | confirmation_required |
DELETE /api/me without the right confirm value |
| 403 | invite_email_mismatch |
The invite names another email than the caller's verified one |
| 403 | email_required |
A new Clerk user whose session token has no verified email (or no custom claims) |
| 503 | storage_unavailable |
DELETE /api/me could not delete the custom emoji images. Nothing was deleted; try again. |
| 503 | clerk_unconfigured |
A bearer token reached a Worker without CLERK_PUBLISHABLE_KEY and CLERK_JWT_KEY |
| 502 | checkout_failed |
Whop did not create the checkout (error, timeout, or an answer without a whop.com URL) |
| 503 | billing_unavailable |
No WHOP_API_KEY, or no Whop variant for that plan and interval in WHOP_PLAN_IDS |
| 401, 503 | invalid_signature, billing_unconfigured |
POST /api/whop/webhook: a bad or old signature; no WHOP_WEBHOOK_SECRET or WHOP_PLAN_IDS (Whop retries) |
DELETE /api/me (account deletion)
{ "confirm": "ada@example.com" }confirmis the account's email (any case, spaces trimmed). An account without an email sends"delete my account". Only the signed-in account can delete itself. Team roles do not apply.- One request deletes the account and everything it owns: its apps with their API keys, monthly
usage, search analytics (
query_daily), tenants, custom emoji (rows and R2 images) and webhooks with their deliveries; its own team members and invites; its memberships in other teams; legacy session rows; and the waitlist entry of its email. - A Whop subscription that still renews is cancelled at the end of its paid period (best effort, after the answer; a failure is logged).
- The Clerk user goes too. With
CLERK_SECRET_KEYthe Worker deletes it (best effort, logged without ids) and answersclerkUserDeleted: true. Without the secret key it answersfalse, and the dashboard deletes the Clerk user with Clerk JS (user.delete(), which needs "allow users to delete their accounts" in Clerk). - A session token is checked without a network call, so one issued before the deletion stays
valid for up to a minute. For 10 minutes the Worker keeps the Clerk user id in
deleted_clerk_users, and such a token gets401instead of a new, empty account. - The R2 images go first. When R2 fails, the answer is
503 storage_unavailableand no row is deleted. Then one D1 batch (one transaction) deletes the rows. - The API Worker caches key lookups for 60 s per isolate, so a deleted key can work for up to a minute, as after a revocation. Usage that an isolate has not flushed yet for a deleted app is dropped.
- Not deleted: invites that other owners sent to this email (their data), anonymous Analytics Engine points (they have no app, key or account), copies of custom emoji images that an edge cache or a browser already holds (until evicted), and D1 Time Travel history (see Privacy).
- The dashboard's Settings page has a "Delete account" dialog that asks for the same
confirmtext (isDeleteAccountConfirmedinapps/dashboard/src/shared/contract.ts).
Custom emoji routes add these codes:
| Status | code |
When |
|---|---|---|
| 400 | invalid_request (field: shortcode, aliases, tenantId, file, token, botToken, guildId) |
A field breaks the rules below |
| 400 | unsafe_svg (field: file) |
The SVG has scripts, event handlers, javascript:, external links or url(), entity declarations or embedded documents |
| 400 | import_auth_failed (field: token, botToken or guildId) |
Slack or Discord refused the token, or the bot is not in the server. The message names the provider's error code, never the token. |
| 402 | plan_required |
Upload on Free (plan: "solo"), import below Pro (plan: "pro"), or the account is at its plan's custom emoji limit (plan = the cheapest plan with a higher limit) |
| 403 | plan_limit |
At the limit of the top plan (Scale) |
| 409 | shortcode_taken (field: shortcode) |
The shortcode exists in the same scope (app-wide, or the same tenant) |
| 413 | image_too_large (field: file) |
The image is larger than 256 KB |
| 415 | unsupported_image (field: file), unsupported_media_type |
The file is not PNG, GIF, WebP or SVG (checked by its bytes, not its name or type), or the upload is not multipart/form-data |
| 429 | import_rate_limited |
Slack or Discord is limiting requests (Retry-After: 60) |
| 502 | import_unavailable |
Slack or Discord did not answer, or answered with another error |
| 503 | storage_unavailable |
The R2 binding EMOJI is missing |
Custom emoji
type CustomEmoji = {
id: string;
shortcode: string; // without colons
aliases: string[]; // normalized search phrases
imageUrl: string; // `${API_URL}/v1/custom/<appId>/<id>`, immutable
tenantId: string | null; // tenants.id; null = app-wide
tenantExternalId?: string | null; // tenants API and webhooks only
source: "upload" | "slack" | "discord" | "api";
bytes: number;
createdAt: number; // epoch ms
};- List.
{ emoji, used, limit }, newest first.?tenantId=<tenants.id>lists one tenant's emoji.usedis what the limit counts: every emoji of every app of the owning account (tenants included);limitis the owner plan'scustom_emoji(0on Free,null= unlimited). Every role may list, on every plan. - Upload.
multipart/form-datawithfile(≤ 256 KB; PNG, GIF, WebP or SVG by magic bytes),shortcode,aliases(comma-separated, optional) andtenantId(optional, atenants.idof this app). Images are stored in R2 undercustom/<appId>/<tenantId or "_">/<id>.<ext>. - Shortcode. Surrounding colons and spaces are dropped and letters lowercased
(
":Party_Parrot:"→party_parrot); then it must be 1–64 characters ofa–z 0–9 _ + -with at least one letter or digit. Unique per app-wide scope and per tenant. - Aliases. A comma-separated string (forms) or a string array (JSON). Each is normalized like a query (PACK_FORMAT.md §3); empty and repeated ones are dropped; at most 20.
- Limit. The plan's
custom_emojilimit counts every emoji of every app of the account, tenant emoji included, the same rule as the tenants API andGET /api/billing. The check is part of the INSERT, so parallel uploads cannot pass it together. - Edit and delete are not plan-gated, so an account that moved to a lower plan can still clean up. A rename keeps the image and the id.
- Webhooks. Uploads, imports and deletes emit
custom_emoji.created/custom_emoji.deleted(Scale). A rename sends nothing. - Search. The API Worker serves the images and merges custom matches into
/v1/searchand/v1/suggest-reactionswithin about a minute of a change.
Slack and Discord import
- Slack:
{ token }, a user token (xoxp-…) withemoji:read. The dashboard callsGET https://slack.com/api/emoji.listwith it and downloads each image from Slack's CDN (*.slack-edge.comover HTTPS only).alias:entries are not imported. - Discord:
{ botToken, guildId }. The dashboard callsGET /api/v10/guilds/:guildId/emojiswithAuthorization: Bot …and downloadshttps://cdn.discordapp.com/emojis/<id>.gif|png?size=128. - Image downloads follow at most 2 redirects, each only to these CDN hosts; a redirect anywhere
else counts the emoji as
failed. - Names become shortcodes by the rules above (Discord names are lowercased). Emoji whose shortcode exists already, whose image fails the upload checks, or that do not fit the plan limit are skipped.
- Batches. One call stores at most 50 new emoji. While
remaining > 0, call again with the same token; emoji imported earlier then count asexists. - The token is used for that one request: never stored, logged or returned.
{ "imported": 50, "skipped": 7, "remaining": 12,
"skippedBy": { "alias": 4, "exists": 1, "invalid": 2, "limit": 0, "failed": 0 } }skippedBy: alias (Slack aliases), exists (shortcode taken), invalid (name or image breaks
the rules, or the provider entry is unusable), limit (over the plan limit), failed (download
failed).
GET /api/apps/:id/analytics
| Param | Default | Notes |
|---|---|---|
days |
30 |
7, 30 or 90. Cut to the plan's retention (Pro 30, Scale 365). |
country |
— | ISO 3166-1 alpha-2 (any case), or XX for searches from an unknown country. Other values answer 400 (field: "country"). |
locale |
— | A language code such as pt, or und for searches counted before locales were (migration 0004). Other values answer 400 (field: "locale"). |
{
"days": [{ "day": "2026-10-14", "searches": 0, "misses": 0 }, { "day": "2026-10-15", "searches": 412, "misses": 9 }],
"topQueries": [{ "query": "ship it", "searches": 120 }],
"topMisses": [{ "query": "lgtm", "misses": 7 }],
"countries": [{ "country": "BR", "searches": 230, "misses": 4 }, { "country": "XX", "searches": 6, "misses": 0 }],
"locales": [{ "locale": "pt", "searches": 180, "misses": 3 }],
"filters": { "country": null, "locale": null }
}days: one entry per UTC day of the window, oldest first, today last,0for days without searches. A miss is a search that returned no result.topQueries,topMisses: up to 20 entries over the window. A query is named only when the app saw it at least 5 times in the window (and in the filter). Day totals count every search.countries,locales: up to 50 entries each, most searches first. The country is the one Cloudflare's edge saw for each request (XX= unknown); the locale is the search'slocale.countryandlocalefilterdaysand the top lists. Each also filters the other breakdown:countriesfollowslocale,localesfollowscountry.filtersechoes them, normalized.- Only the app's own searches count. Nothing in the dashboard reads other customers' rows.
- The plan is the account's (team members see the owner's plan). Free and Solo get
402 { "error": { "code": "plan_required", "plan": "pro", "message": "…" } }. - Data comes from keyed
/v1/searchcalls only, cache hits and over-limit answers included, flushed in batches (≈ 10 s delay).
Webhooks (Scale)
Create webhooks in the dashboard (POST /api/apps/:id/webhooks). Each one has a URL, a list of
events and a secret (whsec_…, shown once). Emojisense sends each event as a POST with a JSON
body to every enabled webhook of the app that subscribes to it.
Events
type |
When | data |
|---|---|---|
tenant.created |
A tenant is created (tenants API or dashboard) | { id, externalId, name, createdAt } |
tenant.deleted |
A tenant is deleted | { id, externalId, name, createdAt, emojiDeleted } |
custom_emoji.created |
A custom emoji is uploaded (tenants API or dashboard) or imported from Slack or Discord (one event per emoji) | CustomEmoji with tenantExternalId (null for app-wide emoji) |
custom_emoji.deleted |
A custom emoji is deleted (tenants API or dashboard) | CustomEmoji with tenantExternalId |
usage.threshold |
The account reaches 80% or 100% of a monthly limit (semantic_calls, image_classifications) |
{ metric, threshold, period, used, limit } |
webhook.test |
"Send test event" in the dashboard; never subscribed | { webhookId, message } |
{
"id": "evt_7tQe2mV9xKp4Lr8Za1Bc3dWf",
"type": "tenant.created",
"createdAt": 1760529600000,
"appId": "Hn5sK2pQ8vRw1mXc4tYb",
"data": { "id": "Qm3xV0aT9cLr2PzK8wYe", "externalId": "acme", "name": "Acme Inc", "createdAt": 1760529600000 }
}usage.threshold counts every app of the account, because plan limits belong to the account. It
fires once per account, UTC month, metric and threshold, and goes to the webhooks of every app of
the account with the same id. A plan change in the month sets new thresholds, which can fire
again (the new limit is in data).
{
"id": "evt_3f9a1c0e5b7d2a4c6e8f0b1d3a5c7e9f",
"type": "usage.threshold",
"createdAt": 1760529600000,
"appId": "Hn5sK2pQ8vRw1mXc4tYb",
"data": { "metric": "semantic_calls", "threshold": 80, "period": "2026-10", "used": 12000000, "limit": 15000000 }
}Delivery
| Header | Value |
|---|---|
Content-Type |
application/json |
Emojisense-Signature |
t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<body>"> |
Emojisense-Event |
the event type |
Emojisense-Event-Id |
the event id (the same on every retry) |
User-Agent |
Emojisense-Webhooks/1.0 |
- Any
2xxanswer within 10 s is a success. Anything else (other status, redirect, timeout, network error) is retried: up to 3 attempts, at once, after 10 s and after 60 s more. Each attempt gets a freshtand signature; the body stays the same. - Redirects are not followed. Answer at the URL you registered.
- Every attempt is recorded (
GET /api/webhooks/:id/deliveries): event, HTTP status (nullfor a network error, a timeout or a refused URL), duration and time. Only the last 50 per webhook are kept. Bodies are not stored. - An event can arrive more than once (a retry after a slow answer, or one
usage.thresholdthrough two apps) and out of order. Use the eventidto drop duplicates. - A disabled webhook, or one of an account that is no longer on Scale, gets nothing. Disabling or deleting a webhook also stops its pending retries.
- ⚠ The retries run in the Worker's
waitUntil, which Cloudflare ends 30 s after the response. In production the 60 s attempt is therefore usually cut off. Do not rely on the third attempt.
URL rules. https only, and the host must be public: no localhost, private, loopback,
link-local or reserved IP addresses (IPv4 and IPv6, including IPv4-mapped forms), and no internal
names (*.local, *.internal, single-label hosts, …). No user name or password in the URL. The
rules are checked when the webhook is saved and again before each delivery. With
ENVIRONMENT=development, http://localhost, http://127.0.0.1 and http://[::1] are allowed
too, for local receivers.
Verify the signature
Compute HMAC-SHA256 over "<t>.<raw body>" with the whole secret (including whsec_) as the key.
Compare it in constant time with each v1 value, and refuse a t older than 5 minutes. Use the
raw body exactly as received: parsing and re-serializing JSON changes the bytes.
Node (Express):
import { createHmac, timingSafeEqual } from "node:crypto";
import express from "express";
export function verifyEmojisense(rawBody, header, secret, toleranceSeconds = 300) {
const fields = (header ?? "").split(",").map((part) => part.trim().split("="));
const t = Number(fields.find(([name]) => name === "t")?.[1]);
if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false;
const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest();
return fields
.filter(([name]) => name === "v1")
.some(([, value]) => {
const given = Buffer.from(value ?? "", "hex");
return given.length === expected.length && timingSafeEqual(given, expected);
});
}
const app = express();
app.post("/hooks/emojisense", express.raw({ type: "application/json" }), (req, res) => {
const rawBody = req.body.toString("utf8");
if (!verifyEmojisense(rawBody, req.get("Emojisense-Signature"), process.env.EMOJISENSE_WEBHOOK_SECRET)) {
return res.sendStatus(400);
}
const event = JSON.parse(rawBody);
// Handle event.type here; drop an event.id you have seen before.
res.sendStatus(204);
});Python:
import hashlib
import hmac
import time
def verify_emojisense(raw_body: bytes, header: str | None, secret: str, tolerance: int = 300) -> bool:
if not header:
return False
fields = [part.strip().partition("=") for part in header.split(",")]
timestamps = [value for name, _, value in fields if name == "t"]
signatures = [value for name, _, value in fields if name == "v1"]
if not timestamps or not timestamps[0].isdigit():
return False
t = int(timestamps[0])
if abs(time.time() - t) > tolerance:
return False
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
return any(hmac.compare_digest(expected, signature) for signature in signatures)
# Flask: verify_emojisense(request.get_data(), request.headers.get("Emojisense-Signature"), SECRET)Privacy
What the hosted service collects, and for how long:
| Data | Where | Kept |
|---|---|---|
Per app, UTC day, normalized search query (≤ 64 chars), locale and country: number of searches and of misses. The country is request.cf.country (ISO 3166-1 alpha-2, derived from the IP address at Cloudflare's edge; XX when unknown). Only keyed /v1/search calls. |
D1 query_daily |
Pro: 30 days. Scale: 365 days. Free and Solo: 7 days (not shown; an upgrade then shows the last week). A daily cron deletes older rows. |
| Normalized search query text (≤ 64 chars) of every search that reached the Worker, with cache status, latency and scores. No app. | Analytics Engine | Analytics Engine retention (3 months) |
| Public shard files: normalized query text and its emoji results, for queries over the shard thresholds (below), plus synthetic queries from our own data (the base layer). No app, account, day or count. | R2 emojisense-cdn, CDN and edge cache |
Rebuilt nightly. A file that no build names any more is deleted a day after the build that dropped it. Shard files are named by content and cached by browsers and the CDN for up to a year; a dropped query stays in such copies until they expire, but no index names it. |
Client reports (POST /v1/events, opt-in in the SDK, a sample of sessions): per app, counts of how searches ended and [normalized query ≤ 64 chars, hexcode] pairs of picked results. No IP, key, device or user id. |
Analytics Engine | Analytics Engine retention (3 months) |
Regional trends: normalized query text, locale, country (or *), score, searches and accounts, for queries over the trend thresholds (below). No app, account or user. Not served by any route. |
D1 trends_daily |
90 days (TRENDS_KEEP_DAYS). The daily cron deletes older rows. |
| Monthly call counts per app and metric | D1 usage_monthly |
until the account is deleted (apps have no delete route) |
Tenants: your externalId and optional name per customer |
D1 tenants |
until you delete the tenant or the account |
| Webhook deliveries: event type, HTTP status, duration, time. No body, no response. | D1 webhook_deliveries |
the last 50 per webhook |
| Custom emoji: shortcode, aliases, size, source, and the image | D1 custom_emoji, R2 emojisense-emoji |
until the emoji, its tenant or the account is deleted (edge copies of the image until evicted) |
| Paid plans: Whop membership id, plan, interval, subscription status, end of the paid period, grace end, manage link, time of the last Whop event applied. Card data stays at Whop. | D1 accounts |
until the account is deleted |
| Whop webhook ids already processed: id, event type, time (no personal data) | D1 whop_events |
30 days |
| Whop memberships seen by the webhook: membership id, the account id, state, end of the period, time of the newest event, retired and cancel-confirmed times | D1 whop_memberships |
Rows of an account: until the account is deleted. Then a membership that still renews stays without the account id, so it is cancelled and never grants a plan again. Rows of no account: 30 days. |
| Waitlist: email, plan, date of the first sign-up | D1 waitlist |
12 months after the first sign-up (WAITLIST_KEEP_MONTHS). The same daily cron deletes older rows. Also deleted with an account of the same email. |
| Accounts (Clerk user id, name, verified email), apps, keys (SHA-256 + first 12 chars), team, webhooks | D1 | until DELETE /api/me. Revoked keys stay, marked as revoked. Sign-in sessions live at Clerk; the dashboard stores none. |
Our own console records: event names, error types, counts |
Workers Logs | up to 7 days (Paid plan; 3 days on Free). invocation_logs is off in both wrangler.jsonc files, so request URLs are never logged. |
- The country of a request is used only as a count dimension of
query_dailyand, withregion=auto, to select the regional culture entries of that one answer. It is never stored with an IP address, a key or a user, and it is not part of the cache key. - The time zone of a request (
request.cf.timezone) only picks the caller's local day for the culture windows of that one answer. It is never stored, and it is not part of the cache key. - Never logged or stored: IP addresses (only an in-memory rate-limit key), user identifiers,
reaction text, images sent to
/v1/classify-image, Slack and Discord tokens. Keys are stored only as a hash and a 12-character prefix, never logged. - Logs never hold query or message text, keys, IP addresses or emails. Workers AI failures log the error type only, because a message could quote the input.
- Anonymous calls and development keys never reach
query_daily. - The dashboard names a query only when the app saw it ≥ 5 times in the window.
- The nightly shard job reads
query_dailyin aggregate. It publishes a query in the public shard files of a locale (/p/*) only when apps of ≥ 3 different accounts searched it ≥ 10 times in total in that locale over the last 6 complete UTC days, and only when it does not look like personal data (an email or web address, a phone, account or postal number, a user id, a long token, blocklisted words). The files hold the query text and its emoji results: no app, account, day or count. A query leaves them with the first nightly build after it no longer passes. Alias mining reads Analytics Engine and uses a query only when it was seen ≥ 5 times. - The daily trend job reads
query_dailyin aggregate too. It keeps a query for a locale and a country only when apps of ≥ 3 different accounts searched it ≥ 10 times there over the last 7 complete UTC days, with the same personal-data filter. Its rows (trends_daily) feed the culture proposals and are never public. Per-customer views (the dashboard) show only the customer's own apps; anything across customers is such a k-anonymous aggregate. DELETE /api/medeletes an account and everything it owns (see the Dashboard API). D1 Time Travel can still restore the database to a point in the last 30 days (Paid plan).
Billing (Whop)
Paid plans are sold through Whop (DECISIONS.md, "Whop for payments"). The website's paid plan
buttons open https://app.<domain>/billing?plan=<id>&interval=month|year; the dashboard keeps that
choice through sign-in, and its Upgrade button calls POST /api/billing/checkout.
- Checkout. The Worker calls Whop's
POST /checkout_configurationswith the variant id of the plan and interval fromWHOP_PLAN_IDS,metadata: { accountId, plan, interval, env }andredirect_url: <dashboard>/billing?checkout=success, and answers Whop'spurchase_url(only ahttps://*.whop.comURL is passed on). The plan does not change here. - Webhook.
POST /api/whop/webhookcheckswebhook-signature(v1,<base64>): HMAC-SHA256 over{webhook-id}.{webhook-timestamp}.{raw body}, keyed with the UTF-8 bytes of the wholews_…secret; timestamps more than 5 minutes off are refused. Each appliedwebhook-idis remembered (whop_events, written in the same D1 batch as the change), so a retry changes nothing; an ignored event is not remembered, so Whop's retry works after a configuration fix. The D1 change runs before the answer (a failure is a500, and Whop retries); cancelling retired memberships and cleanup run inwaitUntil. - Events.
payment.succeededandmembership.activatedset the plan: the plan always comes from the Whop variant id throughWHOP_PLAN_IDS. A membership the account already pays with needs no metadata; a new one needs metadata that names an existing account, this Worker'senv(ENVIRONMENT) and the same plan and interval as the variant.payment.failedkeeps the plan for a 7-day grace (past_due).membership.cancel_at_period_end_changedmarks the plan as ending (canceling) or resumes it.membership.deactivatedmoves the account to Free (except a deactivation while past due, which is the grace). An event older than the last one applied to the account changes nothing. Everything else answers200and logswhop_eventwithresult: "ignored"and a reason, without changing anything. - Plan changes. A change between paid plans is a new checkout. When it is paid, the old
membership is retired (
whop_memberships.retired_at): it never gives the account a plan again, even with valid metadata, and the Worker asks Whop to cancel it at the end of its period (POST /memberships/{id}/cancelwithcancellation_mode: "at_period_end"andcancel_at_period_end: true) until Whop confirms. It retries after each Whop event and in the daily cron, and cancels again when Whop reports that the membership renews or was resumed. Whop does not prorate. Down to Free is a cancel in Whop (Billing → Manage subscription). A deleted account's membership is retired the same way. - Events before the activation.
whop_membershipskeeps the newest state of each of our memberships with its event time, also when no account pays with it yet. An activation older than a stored deactivation grants nothing; one older than a stored cancellation grants a cancelled plan (canceling, with the stored period end). - Refunds and disputes. Whop does not document that they end a membership, so the Worker
acts on them: a full, succeeded refund of a payment of the current period (
refund.created,refund.updated) or a lost dispute (lost,prevented) moves the account to Free at once and retires the membership; an open dispute (needs_response,under_review) is the 7-day past-due grace; a won dispute ends that grace. Partial refunds, pending refunds, refunds of older payments and inquiries (warning_…) change nothing. - Lapses. A grace or a cancelled period that ran out, or an active period that ended 7 days
ago without a renewal payment (a lost final event), moves the account to Free: on the next Whop
event, when the owner opens the dashboard, and in the dashboard Worker's daily cron
(
17 4 * * *), which also retries Whop cancels (with a backoff of 1 hour up to a day per failing membership). A later payment of the same membership restores the plan. - Delay. The API Worker reads the plan from
accounts.planwith each key lookup and caches lookups for 60 s per isolate, so a plan change reaches every search within a minute. There is no cross-isolate invalidation.