Skip to main content

Admin API: Lexicons

Manage lexicons and network lexicons. See the Lexicons guide for background on how lexicons drive indexing and XRPC routing.

# All examples assume $TOKEN is an API key (hv_...)
AUTH="Authorization: Bearer $TOKEN"

Upload / upsert a lexicon

POST /admin/lexicons
curl -X POST http://localhost:3000/admin/lexicons \
-H "$AUTH" \
-H "Content-Type: application/json" \
-d '{
"lexicon_json": { "lexicon": 1, "id": "xyz.statusphere.status", "defs": { "main": { "type": "record", "key": "tid", "record": { "type": "object", "required": ["status", "createdAt"], "properties": { "status": { "type": "string", "maxGraphemes": 1 }, "createdAt": { "type": "string", "format": "datetime" } } } } } },
"backfill": true,
"target_collection": null
}'
FieldTypeRequiredDescription
lexicon_jsonobjectyesRaw lexicon JSON (must have lexicon: 1 and id)
backfillbooleannoWhether uploading triggers historical backfill (default true)
target_collectionstringnoFor query/procedure lexicons, the record collection they operate on
scriptstringnoLua script for query/procedure endpoints
index_hookstringnoIndex hook Lua script for record lexicons

Response: 201 Created (new) or 200 OK (upsert)

{
"id": "xyz.statusphere.status",
"revision": 1
}

List lexicons

GET /admin/lexicons
curl http://localhost:3000/admin/lexicons -H "$AUTH"

Response: 200 OK

[
{
"id": "xyz.statusphere.status",
"revision": 1,
"lexicon_type": "record",
"backfill": true,
"created_at": "2025-01-01T00:00:00Z",
"updated_at": "2025-01-01T00:00:00Z"
}
]

Get a lexicon

GET /admin/lexicons/{id}
curl http://localhost:3000/admin/lexicons/xyz.statusphere.status -H "$AUTH"

Response: 200 OK with full lexicon details including raw JSON.

Delete a lexicon

DELETE /admin/lexicons/{id}
curl -X DELETE http://localhost:3000/admin/lexicons/xyz.statusphere.status -H "$AUTH"

Response: 204 No Content

Network Lexicons

Network lexicons are fetched from the atproto network via DNS TXT resolution and kept updated via the Jetstream subscription. See Lexicons - Network lexicons for background.

Add a network lexicon

POST /admin/network-lexicons
curl -X POST http://localhost:3000/admin/network-lexicons \
-H "$AUTH" \
-H "Content-Type: application/json" \
-d '{
"nsid": "xyz.statusphere.status",
"target_collection": null
}'
FieldTypeRequiredDescription
nsidstringyesThe NSID of the lexicon to watch
target_collectionstringnoFor query/procedure lexicons, the record collection they operate on

HappyView resolves the NSID authority via DNS TXT, fetches the lexicon from the authority's PDS, parses it, and stores it.

Response: 201 Created

{
"nsid": "xyz.statusphere.status",
"authority_did": "did:plc:authority",
"revision": 1
}

List network lexicons

GET /admin/network-lexicons
curl http://localhost:3000/admin/network-lexicons -H "$AUTH"

Response: 200 OK

[
{
"nsid": "xyz.statusphere.status",
"authority_did": "did:plc:authority",
"target_collection": null,
"last_fetched_at": "2025-01-01T00:00:00Z",
"created_at": "2025-01-01T00:00:00Z"
}
]

Remove a network lexicon

DELETE /admin/network-lexicons/{nsid}
curl -X DELETE http://localhost:3000/admin/network-lexicons/xyz.statusphere.status \
-H "$AUTH"

Removes the network lexicon tracking and also deletes the lexicon from the lexicons table and in-memory registry.

Response: 204 No Content