> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lucidworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Links API

export const LwTemplate = ({title = "Key questions to get you started", icon = "sparkles", cta = "Powered by Agent Studio", linkHref = "https://lucidworks.com/demo/?utm_source=docs&utm_medium=referral&utm_campaign=docs_cta_ai"}) => {
  const [isLoaded, setIsLoaded] = useState(false);
  useEffect(() => {
    const timer = setTimeout(() => {
      setIsLoaded(true);
    }, 500);
    return () => clearTimeout(timer);
  }, []);
  return <div className="lw-template-container">
      <Card title={title} icon={icon}>
        {isLoaded && <span dangerouslySetInnerHTML={{
    __html: `<lw-template id="a029c1a9-28be-427e-b0e1-5d918920246a"></lw-template
            >`
  }} />}
        <Link href={linkHref} className="agent-studio-link text-left text-gray-600 gap-2 dark:text-gray-400 text-sm font-medium flex flex-row items-center hover:text-primary dark:hover:text-primary-light group-hover:text-primary group-hover:dark:text-primary-light">Powered by Lucidworks Agent Studio</Link>
      </Card>
    </div>;
};

[localhost link]: http://localhost:3000/docs/4/fusion-server/reference/api/links-api

[mintlify link]: https://doc.lucidworks.com/docs/4/fusion-server/reference/api/links-api

[old doc.lw link]: https://doc.lucidworks.com/fusion/5.9/319

The Links API manages the links that represent the relationships between Fusion objects. You can see these links in the [Object Explorer](/docs/4/fusion-server/concepts/object-explorer) by pressing CMD-K or CTRL-K from any screen in the Fusion UI. You can also export and import links using the [Objects API](/docs/4/fusion-server/reference/api/objects-api).

Links are structured as a tuple of `(subject, object, linkType)`. An example would be `(foo, bar, dependsOn)`, which would read as "foo dependsOn bar".

<LwTemplate />

## Link types and link reversibility

The possible values of `linkType` are as follows:

| Link type     | Example JSON                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `inContextOf` | The subject exists in the context of the object, which is an app. In this example, the "Movie\_Search" app is the context for a parser with the same name: `{"subject": "parser:Movie_Search","object": "app:Movie_Search","linkType": "inContextOf","originator": "unspecified"}`                                                                                                                         |
| `hasContext`  | The subject is an app that contains the object. In this example, an index profile exists in the context of the "Movie\_Search" app: `{"subject": "app:Movie_Search","object": "index-profile:Movie_Search","linkType": "hasContext","originator": "unspecified"}`                                                                                                                                          |
| `dependsOn`   | The subject depends on the object. In this example, a datasource called "web\_pokeapi\_co-default" depends on a parser by the same name: `{"subject": "datasource:web_pokeapi_co-default","object": "parser:web_pokeapi_co-default","linkType": "dependsOn"}`                                                                                                                                              |
| `supports`    | The subject is depended on by the object (the reverse of `dependsOn`). In this example, a parser called "web\_pokeapi\_co-default" supports a datasource by the same name: `{"subject": "parser:web_pokeapi_co-default","object": "datasource:web_pokeapi_co-default","linkType": "supports"}`                                                                                                             |
| `isPartOf`    | The subject is part of the object, where the object is a group. In this example, an aggregation called "click-signals-default" is part of a group called "signals-object-group-default": `{"subject": "aggregation:click-signals-default","object": "group:signals-object-group-default","linkType": "isPartOf"}`                                                                                          |
| `hasPart`     | The subject is a group, of which the object is a member (the reverse of `isPartOf`). In this example, a group called "signals-object-group-default" has an aggregation "click-signals-default": `{"subject": "group:signals-object-group-default","object": "aggregation:click-signals-default","linkType": "hasPart"}`                                                                                    |
| `relatesTo`   | The subject relates to the object. This is a uni‑directional relationship that associates two objects that have none of the relationships described above. For example, when recommendations are enabled for the default collection, Fusion creates a group which relates to the default collection: `{"subject": "group:recommendations-default","object": "collection:default","linkType": "relatesTo"}` |

With the exception of the `relatesTo` link type, links are reversible:

* `inContextOf` is the reverse of `hasContext` (and vice versa).
* `dependsOn` is the reverse of `supports` (and vice versa).
* `isPartOf` is the reverse of `hasPart` (and vice versa).

For example, here is the group of links for the `signals-default` collection:

```json wrap  theme={"dark"}
[
  {
    "subject": "group:4e6ee9a6-d4ab-413a-ac70-a27c1445bb60",
    "object": "collection:default_signals_aggr",
    "linkType": "hasPart"
  },
  {
    "subject": "group:4e6ee9a6-d4ab-413a-ac70-a27c1445bb60",
    "object": "spark:default_click_signals_aggregation",
    "linkType": "hasPart"
  },
  {
    "subject": "group:4e6ee9a6-d4ab-413a-ac70-a27c1445bb60",
    "object": "collection:default",
    "linkType": "relatesTo"
  },
  {
    "subject": "group:4e6ee9a6-d4ab-413a-ac70-a27c1445bb60",
    "object": "collection:default_signals",
    "linkType": "hasPart"
  }
]
```

When we request the links for one of the `hasPart` objects shown above, we get the reverse representation:

```sh wrap  theme={"dark"}
GET https://FUSION_HOST:8764/api/links?subject=collection:default_signals_aggr

[
  {
    "subject": "collection:default_signals_aggr",
    "object": "group:4e6ee9a6-d4ab-413a-ac70-a27c1445bb60",
    "linkType": "isPartOf"
  }
]
```

## Examples

**Get links to the default collection:**

```bash wrap  theme={"dark"}
curl https://FUSION_HOST:8764/api/links?subject=collection:default
```

**Output:**

```json wrap  theme={"dark"}
[ { "subject": "collection:default", "object": "index-pipeline:default", "linkType": "supports" } ]
```

**Create a new link:**

```bash wrap  theme={"dark"}
curl -X PUT https://FUSION_HOST:8764/api/links -H 'content-type: application/json' -d '{"linkType": "supports", "object": "index-pipeline:default", "subject": "collection:default"}'
```

**Output:**

```json wrap  theme={"dark"}
{ "subject" : "collection:default", "object" : "index-pipeline:default", "linkType" : "supports" }
```

**Delete a link:**

```bash wrap  theme={"dark"}
curl -X DELETE https://FUSION_HOST:8764/api/links?subject=collection:default
```
