Skip to content

Smart tags ​

A smart tag is a typed kind of post. You declare it; Canopi stores it, validates it, draws it and governs it. Smart tags from the SDK are declarative: no tag code runs in feeds or on pages.

Example (modules/page-note-tag in the SDK):

json
"smartTag": {
  "tagType": "page-note",
  "emoji": "📝",
  "label": "Page note",
  "statusMode": "coordinated",
  "payloadSchema": {
    "type": "object",
    "required": ["note", "kind"],
    "additionalProperties": false,
    "properties": {
      "note":   { "type": "string", "minLength": 1, "maxLength": 1000 },
      "kind":   { "enum": ["note", "question", "correction"], "x-canopi-index": "enum" },
      "source": { "type": "string", "format": "uri", "maxLength": 500 }
    }
  },
  "summary": "{{note}}",
  "form": { "order": ["kind", "note", "source"], "labels": { "source": "Source link" } },
  "presentation": {
    "pill": { "emoji": "📝", "label": "Page note", "metric": { "type": "field", "field": "kind" } },
    "popovers": [{ "trigger": "hover", "title": "Note", "body": [
      { "type": "text", "field": "note" }, { "type": "link", "field": "source", "label": "Source" }
    ] }],
    "onClick": "openFocus"
  },
  "surfaces": { "discuss": "inline", "home": "live.canopi.page-notes", "composer": "both" }
}

Where the data lives ​

Every instance is a Canopi post: a row in messages.

PartWhat Canopi does
payload.dataYour fields, validated against the published version's payloadSchema (JSON Schema 2020-12, formats checked). At most 64 KB; each text field at most 20,000 characters. The community's word list runs on every text field.
contentAlways your summary template rendered over the fields (, plain text, at most 2,000 characters). The word list runs on it too. Search, notifications, moderation and apps that don't know your tag show this. Text sent by the client is ignored.
payload.tag{ moduleId, moduleVersionId, schemaVersion }: which version wrote it
Indexed fieldsFields marked x-canopi-index (up to 5) are copied to an index, so you can filter and sort on them

An instance is never edited in place. PATCH /api/messages/:id answers 409 module_tag_instances_are_superseded. To change one, supersede it.

Presentation: what shows on hover and click ​

Canopi draws your presentation everywhere the tag appears. It uses the same code as Canopi's own Patch, which is the first tag built this way.

  • pill sits above the post: emoji, label, and an optional metric. The metric is {type:"field", field}, {type:"tally", of}, or {type:"charDelta", field} (characters added or removed against the anchored text).

  • popovers: up to two hover popovers and one click popover. Each has a title and a body made of blocks.

  • Blocks:

    BlockShows
    text {field, label?}A field as text (basic markdown)
    quote {field}A quoted field
    kv {fields}Label and value rows; labels come from form.labels
    link {field, label}A link, http(s) only, opened with noopener noreferrer nofollow
    badge {field}A chip
    rating {field, max}, progress {field, max}A meter
    authorThe author's name
    timestamp {field?}A date
    textDiff {field}Word diff against the anchored text (Patch)
    insertPreview {field, positionField}Text to insert above or below the anchor (Insert)
    revisionPickerThe revision, and whether it is superseded
    tally {of}votes, acceptance, reviews or replies
  • onClick: openFocus (the default: the anchor and every post on it), openPopover, openTablication, or openPagePreview.

  • What Canopi controls: every value is escaped, and Canopi owns timing, placement and z-order. A tag chooses what shows, never how.

Surfaces ​

surfaces.discuss:

  • inline: the tag shows in the Discuss feed.
  • filter: hidden from the main feed.
  • none: only in its home tablication.

Focus mode always lists every post on an anchor. surfaces.home names the tablication where the tag lives. surfaces.composer says where its composer appears.

Posting and reading through the API ​

Post a tag the same way you post anything else, with tagType and payload.data:

bash
curl -s https://api.canopi.live/api/messages \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{ "pageId": "example_org_article", "communityId": "<community uuid>",
        "tagType": "page-note", "payload": { "data": { "kind": "question", "note": "Source for the 2019 figure?" } } }'

Errors are 400 invalid_payload_data (with details), 400 summary_empty, 413, 422 content_blocked, or 400 tag_type_not_active (the tag is switched off).

MethodPathWhoWhat
GET/v1/smart-tags/instances?tagType=&pageId=&where[field]=&orderBy=&order=&limit=anyone (as the viewer)Instances of one SDK tag. Filter (up to 3) and sort on indexed fields only, plus createdAt. limit ≤ 50. Only what the viewer may read.
GET/v1/smart-tags/instances/:id/stackanyone who can read itLineage (rootId, revision, supersededBy), provenance, votes, community acceptance
POST/v1/smart-tags/instances/:id/supersede { data }the author (or a Canopi admin), who must still be allowed to post in that communityA new revision; the original keeps its text. Superseding a post twice gives 409 already_superseded.
POST/v1/smart-tags/instances/:id/vote { vote: 1 | -1 }signed-in peopleOne vote per person
POST/v1/smart-tags/instances/:id/acceptance { overlayId, overlayKind, state }community membersAccept or reject for a community

Agent tokens can read these endpoints and post tags with the post scope. Supersede, vote and acceptance are for people.

Canopi — Metaweb coordination layer for community-aware presence and messaging.