Introduction to Anchor Endpoints#
Anchors are an attachment point. Resources attached to an anchor are called extensions. For example, comments and source links are extensions on anchors. Anchors may be created in an individual table cell, in a rich text element, or on drawing content.
In this guide, you’ll learn:
How do I retrieve anchors in rich text?
How do I retrieve anchors in a table?
What should I keep in mind when working with anchors?
Anchors are often used to create source links. You can read more about working with links at the Linking guide.
How do I retrieve anchors in rich text?#
In this exercise, you’ll retrieve a list of all anchors in rich text and then inspect a specific anchor to learn more about it.
Before starting, you’ll need a richTextId. To learn more about rich text, including how to obtain this id, read the Rich Text Guide.
Retrieving a list of rich text anchors#
To retrieve a list of rich text anchors, you pass in the richTextId. Replace this value (the characters between richText/ and /anchors) with your own value.
curl -X GET -H "Authorization: Bearer ${token}" https://api.app.wdesk.com/prototype/platform/content/richText/WA8jJy8nLubbkEHM99i4dIuJ4CNQDsW8rB7MvLmwCHucbKj61j6tmTLBft2g/anchors
{
"data": [
{
"id": "WA3V0cXR2BAtZrc6ANjr1BSO9BiL1R5nd8UXZ2Jr06BHt3MhDeV2QukapQZ3F89A9BT199fVl",
"content": {
"type": "richText",
"richText": "WA8jJy8nLubbkEHM99i4dIuJ4CNQDsW8rB7MvLmwCHucbKj61j6tmTLBft2g"
},
"attachmentPoint": {
"type": "richTextSelection",
"richTextSelection": {
"type": "comment",
"selection": {
"start": {
"paragraphIndex": 0,
"offset": 7
},
"stop": {
"paragraphIndex": 1,
"offset": 0
}
}
}
},
"revision": "2c6438ab4540aad2",
"extensionTypes": [
"comment"
]
},
{
"id": "WA2RlYGVnFRpIvN9ARJyvkFDKumaxA992ZtQGdnN6wrFWpmIwHPRnU9BgLtBdmBt6WU",
"content": {
"type": "richText",
"richText": "WA8jJy8nLubbkEHM99i4dIuJ4CNQDsW8rB7MvLmwCHucbKj61j6tmTLBft2g"
},
"attachmentPoint": {
"type": "richTextSelection",
"richTextSelection": {
"type": "sourceLink",
"selection": {
"start": {
"paragraphIndex": 2,
"offset": 0
},
"stop": {
"paragraphIndex": 2,
"offset": 17
}
}
}
},
"revision": "2c6438ab4540aad2",
"extensionTypes": [
"destinationLink"
]
}
]
}
Notice that this response contains two different anchors. The first is a “comment” anchor, and the second is a “sourceLink” anchor.
How do I retrieve anchors in tables?#
In this exercise, you’ll retrieve a list of all anchors in a table and then inspect a specific anchor to learn more about it.
Before starting, you’ll need a tableId. To learn more about tables, including how to obtain this id, read the Table Guide.
Retrieving a list of table anchors#
To retrieve a list of table anchors, you pass in the tableId. Replace this value (the characters between tables/ and /anchors) in the example with your own value.
curl -X GET -H "Authorization: Bearer ${token}" https://api.app.wdesk.com/prototype/platform/content/tables/WA69Atra6si12IXSib7E4lJBW8ViFO99K2kRMs2w9Bp07jIowdAh99lCcVw/anchors
{
"data": [
{
"id": "WA62vrqyuiV9AKXyqZ7kwnJhe9AVCNM99q9AmRsk0wfh27DAqw99Ij99FKeVa6lop2AnYCcgJyAnJmcmZSang",
"content": {
"type": "table",
"table": "WA69Atra6si12IXSib7E4lJBW8ViFO99K2kRMs2w9Bp07jIowdAh99lCcVw"
},
"revision": "2c6438ab4540aaa4",
"attachmentPoint": {
"type": "tableRange",
"tableRange": {
"range": {
"startRow": 0,
"stopRow": 0,
"startColumn": 0,
"stopColumn": 0
}
}
},
"extensionTypes": [
"destinationLink"
]
},
{
"id": "WA7GzsrCylUOWQzaF8lA7OguiSD99Q6rO6WtUo3eRq8Cw23849B6E6CSbK5voCcgZyAnICcgIWAhYiGhw",
"content": {
"type": "table",
"table": "WA69Atra6si12IXSib7E4lJBW8ViFO99K2kRMs2w9Bp07jIowdAh99lCcVw"
},
"revision": "2c6438ab4540aaa4",
"attachmentPoint": {
"type": "tableRange",
"tableRange": {
"range": {
"startRow": 1,
"stopRow": 1,
"startColumn": 0,
"stopColumn": 0
}
}
},
"extensionTypes": [
"comment"
]
}
]
}
Notice that this response contains two different anchors. The first is a “source link” anchor, which has a destination link as an extension. The second is a “comment” anchor.
How do I get the destinations on a source link anchor?#
Destinations are a type of extension on anchors. You can list all extensions on an anchor by either retrieving a list of table anchor extensions or retrieving a list of rich text anchor extensions. The extension’s response will contain a list of ids which you can look up by retrieving the destination link by id.
The following example retrieves the location of a destination on a table anchor. To run this, you will need a tableId and table anchorId. The example above illustrates how to obtain them.
In this example, you will make two calls, one to retrieve all the table anchor extensions, followed by a second call to retrieve the destination link.
Retrieve a list of table anchor extensions#
The first call retrieves a list of table anchor extensions.
curl -X GET -H "Authorization: Bearer ${token}" https://api.app.wdesk.com/prototype/platform/content/tables/WA69Atra6si12IXSib7E4lJBW8ViFO99K2kRMs2w9Bp07jIowdAh99lCcVw/anchors/WA62vrqyuiV9AKXyqZ7kwnJhe9AVCNM99q9AmRsk0wfh27DAqw99Ij99FKeVa6lop2AnYCcgJyAnJmcmZSang/extensions
{
"data": [
{
"id": "WAyUkISQmVFsJ9BZ7QZmqlVXPv2O0BticmVFsJ9BZ7QZmqlVXPv2O0BtiYm99lnvqAZLZve99hZ5qv0k99ZyEsoaWlpaU1",
"type": "destinationLink"
}
]
}
The next call retrieves a destination link by id.
curl -X GET -H "Authorization: Bearer ${token}" https://api.app.wdesk.com/prototype/platform/content/destinationLinks/WAwYEBQcFOOxAT9BoaSVKaD8g3McVg8AQN3d3b9AM2QSam2KxI2mEOq5wUOCTQrNys3KzcrNzI3Mj8wMQ
{
"id": "WAwYEBQcFOOxAT9BoaSVKaD8g3McVg8AQN3d3b9AM2QSam2KxI2mEOq5wUOCTQrNys3KzcrNzI3Mj8wMQ",
"content": {
"type": "table",
"table": "WAwIAAAMBPOhES9B4eTVaeC8wzNcFk99AAJ2dnf9BMmUTa2yLxYynEeu4w"
},
"revision": "2c6438ab4540aad1",
"source": {
"type": "anchor",
"anchor": {
"anchor": "WA2RlYGVnFRpIvN9ARJyvkFDKumaxA992ZtQGdnN6wrFWpmIwHPRnU9BgLtBdmBt6WU",
"content": {
"type": "richText",
"richText": "WA8jJy8nLubbkEHM99i4dIuJ4CNQDsW8rB7MvLmwCHucbKj61j6tmTLBft2g"
},
"revision": "2c6438ab45406bb6",
"location": "https://api.app.wdesk.com/prototype/platform/content/richText/WA8jJy8nLubbkEHM99i4dIuJ4CNQDsW8rB7MvLmwCHucbKj61j6tmTLBft2g/anchors/WA2RlYGVnFRpIvN9ARJyvkFDKumaxA992ZtQGdnN6wrFWpmIwHPRnU9BgLtBdmBt6WU?revision=2c6438ab45406bb6"
}
},
"status": "connected"
}
This response indicates that the destination is in a table (content.type: "table") and includes the id of the table. The destination link can be found in the table through querying for the table cells to find the CellDestinationLinkValue that has a matching destinationLinkId. To learn more about working with tables, read the Table Guide.
What should I keep in mind when working with anchors?#
Some anchors are reserved for a specific extension type. For example, rich text anchors are created with a specific anchor type; it is an error to try to add an extension of a different type to that anchor.