Skip to content

feat(api): add block object link REST endpoints with card presentation - #3200

Open
tayuLuc wants to merge 2 commits into
anyproto:developfrom
tayuLuc:local/ui-equiv-links-rest-tracker-v2
Open

feat(api): add block object link REST endpoints with card presentation#3200
tayuLuc wants to merge 2 commits into
anyproto:developfrom
tayuLuc:local/ui-equiv-links-rest-tracker-v2

Conversation

@tayuLuc

@tayuLuc tayuLuc commented Jul 8, 2026

Copy link
Copy Markdown

Summary

Add REST endpoints for managing object link blocks with full card presentation, matching desktop UI behavior. Links and backlinks now populate correctly when content is created via API.

New endpoints

POST /v1/spaces/{space_id}/objects/{object_id}/blocks/{block_id}/link — Set or update an object link on a block. A text block becomes a link block (card layout); an existing link block gets updated target and presentation. Uses the same internal BlockReplace path as the editor — links/backlinks derive normally.

DELETE /v1/spaces/{space_id}/objects/{object_id}/blocks/{block_id}/link — Remove a link block. Supports optional ?target_object_id= query parameter for safety.

New fields on PATCH …/objects

markdown_append — Append markdown as new blocks at the end without removing existing content. Mutually exclusive with markdown.

New query parameter on GET …/objects

?block_link_candidates=1 — Returns text and link block IDs with metadata (kind, text_preview, target_object_id, link_style, card_style, icon_size, link_description, relations, background_color) so clients can discover which blocks to operate on.

POST …/link request fields

Field Values
target_object_id (required) object to link to
link_style page, dataview, dashboard, archive
card_style text, card, inline
background_color grey, yellow, orange, red, pink, purple, blue, ice, teal, lime
icon_size none, small, medium
link_description none, added, content
relations array of relation keys to display on the card
sync_link_presentation_from_block_id copy icon_size, description, relations, fields from another link block on the same page

Idempotency

When both link payload and block-level chrome (background_color) already match, the endpoint returns replaced: false and skips the BlockReplace call.

Related

Checklist

  • New tests for block_object_link service and object service additions
  • go build ./core/api/... and go vet ./core/api/... pass
  • Generated OpenAPI docs need regeneration via make openapi (swaggo annotations are in place but docs.go, openapi.json, openapi.yaml are not updated in this PR)

Introduce UI-equivalent link block management through the REST API.
Links/backlinks now populate correctly when content is created via API,
matching desktop app behavior.

New endpoints:
  POST   /v1/spaces/{space}/objects/{obj}/blocks/{block_id}/link
  DELETE /v1/spaces/{space}/objects/{obj}/blocks/{block_id}/link

Set or remove an object link on a text/link block via the same
internal BlockReplace path the editor uses — links and backlinks
derive normally.

New request fields on POST …/link:
  target_object_id     — required, the object to link to
  link_style           — page / dataview / dashboard / archive
  card_style           — text / card / inline
  background_color     — grey, yellow, orange, red, pink, purple,
                         blue, ice, teal, lime
  icon_size            — none / small / medium
  link_description     — none / added / content
  relations            — []string, relation keys to show on the card

PATCH …/objects now also accepts:
  markdown_append      — append markdown as new blocks without
                         removing existing content (mutually exclusive
                         with markdown)

GET …/objects/{id} now accepts:
  ?block_link_candidates=1  — returns text and link block ids with
                              metadata for the POST …/link workflow

Closes anyproto/anytype-mcp#105 (partial — block links & card style)
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

CLA Assistant Lite bot:
Thank you for your pull request, we really appreciate it!

Please sign our Contributor License Agreement before we can accept your contribution.
You can sign the CLA by simply commenting on this pull request with the following text.


I have read the CLA Document and I hereby sign the CLA


1 out of 2 committers have signed the CLA.
@tayuLuc
@user
user seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request

@tayuLuc

tayuLuc commented Jul 8, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Are block-level REST endpoints planned? (for rich content creation)

1 participant