Generate applink

Is there any API to create an applink, just like right click on an item and select “Copy as” and then “Link”

Hi, @Amerehei
We are actively working to connect with the proper subject matter expert and gather up-to-date information for you. We will share our findings as soon as we are able. Thank you for being so patient. :smiley:

Hi @Amerehei,

You can programmatically build an appLink URL by using the workspaceId and the objectId you want to link to.

The appLink format is:
https://client.apps.us.bluescape.com/applink/<yourWorkspaceId>?objectId=<objectToLinkTo>

You can set traits to create an appLink using the following format, using traits vocab and content:

traits:{
  vocab: "http://bluescape.dev/hyperlinks/v1/", 
    content: {
        link: "#64c01b747b56b021723c62f8"
    }
}

You can either use this to create an element, or you can use updateTraits to update an existing element. These can be done with either REST or graphQL APIs.

A graphQL example of creating a new shape with an appLink pointing to another element:

#create shape with json-ld traits data
mutation createShapeWithLinkTraits($ws: String! $x:Float! $y:Float!, $width:Float!, $height:Float!, $textContent:String!) {
        shape1:createShape(
        workspaceId: $ws
            input: {
                text:$textContent
                traits:{
                    vocab: "http://bluescape.dev/hyperlinks/v1/", 
                    content: {
                        link: "#64c01b747b56b021723c62f8"
                    }
                }
                
                mirrorY: false 
                style: {
                    regularShape:{

                        kind:Rectangle
                        width:$width height:$height strokeWidth: 5 
                        #fillColor not working in beta1
                        fillColor: {r:255 g:34 b:255 a:1}
                        strokeColor:{r:0 g:255 b:0 a:1}
                    }   
                }
                transform:{x:$x y:$y}
                textStyle:{
                    fontSize:12
                    verticalAlign:bottom
                    color:{
                        r:0
                        g:0
                        b:255
                        a:1
                    }
                }
            })

        #return values:
        {id kind mirrorY traits}
    }

with variables:

{
    "ws": "{{workspaceID}}",
    "textContent" : "graphQL shape with simple traits",
    "x": 0,
    "y": 0,
    "width": 800,
    "height": 300
}

Or you can use updateTraits to update an existing element:

#update element JSON-LD traits metadata
mutation updateTraitsForLink ($workspaceId:String!, $id:String!, $linkToId:String!){
  updateTraits(workspaceId: $workspaceId id:$id input: {
    vocab: "http://bluescape.dev/hyperlinks/v1/"
    content: {
      link: $linkToId
    }
  })
}

with variables:

{
    "workspaceId": "{{workspaceID}}",
    "id" : "64c031db65246380966440a3",
    "linkToId":"#64c01b747b56b021723c62f8"
}
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.