Bluesky rich text facet builder
Markdown versionGET/tools/facet-builder
Detects the mentions, links and hashtags of a post the way Bluesky does, with their UTF-8 byte ranges, resolves the first 20 mentions to DIDs, and returns the `facets` array and the `app.bsky.feed.post` record to send. Costs 1 call, plus 1 per 3 mentions not resolved in the last minute.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
| text (required) | query | string | The text of the post, up to 5,000 characters. In a GET address, about 8 KB once encoded: a non-ASCII character takes up to 12 bytes (`%XX` per byte), so use MCP for long or non-Latin text. |
| langs | query | string | Optional: up to 3 language tags, comma-separated, e.g. `en,fr`. |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | The tool's answer, with the canonical URL of its page. | ToolFacetBuilder |
| 400 | Invalid query parameter (code `bad_request`). | Error |
| 401 | Unknown, expired or revoked token (code `unauthorized`). Without an `Authorization` header, the tool answers anonymously. | Error |
| 404 | Not found. Also returned on a bot's handle subdomain: the API is only served on the main site. | Error |
| 429 | Rate limited: `toolsApi` (60 a minute) and `toolsApiDaily` (2,000 a day) per IP, or 10 times both per account with a creator's token. A tool that fans out costs more than one call. | Error |
| 500 | Unexpected error. | Error |
Example
curl \
-G \
--data-urlencode "text=Hi @bsky.app! 👋 https://bsky.app" \
-H "Authorization: Bearer $BLUESKY_BOT_TOKEN" \
https://bluesky.bot/api/v1/tools/facet-builderSchemas
Error
| Field | Type | Description |
|---|---|---|
| error (required) | object | |
| error.code (required) | string: "bad_request", "invalid_handle", "not_found", "rate_limited", "internal_error", "unauthorized", "forbidden", "conflict", "invalid_grant", "upstream_error", "insufficient_scope", "invalid_listing", "consent_required" | |
| error.message (required) | string | |
| error.reason | string | With `invalid_handle`, `invalid_listing`, `conflict` and `forbidden`: e.g. `reserved`, `taken`, `too_long`, `no_handle`, `suspended`. |
| error.url | string, uri | With consent_required: open this dashboard page to grant profile editing. |
| error.field | string | With `invalid_listing`: the refused field. |
| error.scope | string | With `insufficient_scope`: the scope the token lacks. |
| error.parameter | string | The invalid query parameter. |
| error.retryAfterSeconds | integer (1–) | With `rate_limited`. |
ToolFacetBuilder
| Field | Type | Description |
|---|---|---|
| tool (required) | string = "facet-builder" | The tool's slug. |
| url (required) | string | The canonical URL of the tool's page on Bluesky.bot. |
| result (required) | object | The tool's answer. |
| result.entities (required) | object[] | Every mention, link and tag found, in text order. |
| result.entities[].kind (required) | string: "mention", "link", "tag" | `mention`, `link` or `tag`. |
| result.entities[].text (required) | string | The text the facet covers. |
| result.entities[].value (required) | string | The handle, the full URI or the tag, without `#`. |
| result.entities[].byteStart (required) | integer | Start of the range, in UTF-8 bytes. |
| result.entities[].byteEnd (required) | integer | End of the range, in UTF-8 bytes, exclusive. |
| result.entities[].status (required) | string: "resolved", "unresolved", "invalid", "over_cap" | null | A mention's resolution: `resolved`, `unresolved` (the handle does not resolve), `invalid` (not a valid handle, never asked) or `over_cap` (past the first 20, not asked); null for a link or a tag. Only resolved mentions are in `facets`. |
| result.entities[].did (required) | string | null | A resolved mention's DID; null otherwise. |
| result.facets (required) | object[] | The `facets` array of the record, ready to send. |
| result.record (required) | object | The full `app.bsky.feed.post` record, `createdAt` set to the time of the call. |
| result.graphemes (required) | integer | Length in graphemes; Bluesky's limit is 300. |
| result.bytes (required) | integer | Size in UTF-8 bytes; Bluesky's limit is 3000. |