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

# Look up related styles

> Read the links between a style and its related style — resolve one style's relation or list every related-style link across the organisation.

<Info>
  **When to use this.** A style relation links one style to a related style within a brand's
  collection — for example a carry-over or a variant of an existing style. These endpoints are
  **read-only**: you resolve the relation set on a style, or list every relation across the
  organisation. Relations are created and edited in the Delogue application, not through this API.
</Info>

## The workflow

There are two ways in. When you already hold a style, read its relation directly. When you are
reconciling relations in bulk, list them across the organisation and filter.

<Steps>
  <Step title="Resolve one style's relation">
    `GET /api/styles/{styleId}/related-style` returns the related style, or a payload with only
    `styleId` set when the style has no relation.
  </Step>

  <Step title="List across the organisation">
    `GET /api/style-relations` lists every related-style link, filterable by `styleId` or
    `relatedStyleId`.
  </Step>

  <Step title="Open the related style">
    Follow `relatedStyleId` to the style itself with `GET /api/styles/{id}`.
  </Step>
</Steps>

```mermaid theme={"dark"}
sequenceDiagram
  participant D as Designer
  participant API as Delogue API
  D->>API: GET /api/styles/8801/related-style
  API-->>D: related style SS26-1042
  D->>API: GET /api/styles/8815
  API-->>D: the related style's detail
```

## Walkthrough

List the relations across the organisation, then resolve a single style's relation by id. The
list is paginated — pass `pageSize` and `pageNumber`, or follow the opaque `cursor` for keyset
pagination.

<CodeGroup>
  ```bash cURL theme={"dark"}
  curl "https://service.my.delogue.com/api/style-relations" \
    -H "Accept: application/json" \
    -H "X-Auth-Token: Bearer YOUR_API_KEY"
  ```

  ```js JavaScript theme={"dark"}
  const res = await fetch("https://service.my.delogue.com/api/style-relations", {
    method: "GET",
    headers: {
      "Accept": "application/json",
      "X-Auth-Token": "Bearer YOUR_API_KEY",
    },
  });
  const { data } = await res.json();
  ```
</CodeGroup>

```json theme={"dark"}
{
  "status": "success",
  "code": "style_relations_retrieved",
  "data": [
    {
      "id": 5501,
      "styleId": 8801,
      "relatedStyleId": 8815,
      "relatedStyleNumber": "SS26-1042",
      "relatedStyleName": "Linen Blazer"
    },
    {
      "id": 5502,
      "styleId": 8802,
      "relatedStyleId": 8830,
      "relatedStyleNumber": "SS26-1108",
      "relatedStyleName": "Cotton Chinos"
    }
  ],
  "pagination": {
    "hasMore": false,
    "cursor": ""
  }
}
```

On the style-scoped read, a style with **no** related style still returns **200** — the payload
carries `styleId` while `relatedStyleId`, `relatedStyleNumber` and `relatedStyleName` are
`null`. Treat that as "no relation", not an error.

## Field reference

The fields returned on a style relation:

| Field                | What it means at Delogue                                                                                            |
| -------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `id`                 | Unique identifier of the related-style link. Null on the style-scoped read when the style has no related style set. |
| `relatedStyleId`     | Identifier of the related style. Null on the style-scoped read when no related style is set.                        |
| `relatedStyleName`   | Name of the related style. Null when no related style is set.                                                       |
| `relatedStyleNumber` | Style number (customer-defined identifier) of the related style. Null when no related style is set.                 |
| `styleId`            | Identifier of the style that owns the link.                                                                         |

## Roles & permissions

Reading style relations requires the **`styles`** permission (read level), and the organisation
must have the **Relation of Styles** module enabled. Both designer and supplier accounts may
read — `CompanyAdmin`, `CompanyUser`, `SupplierAdmin`, and `SupplierUser`. Supplier callers see
relations only for the styles their organisation actually supplies.

## When things go wrong

Errors use the standard envelope (`status: "error"`, a `code`, and `error.details[]`). On the
style-scoped read, a `styleId` that belongs to another organisation returns **403**; a `styleId`
that exists nowhere returns **404**. See [Errors & responses](/concepts/errors) for the full
list of codes and how to resolve them.

## What to call next

<CardGroup cols={2}>
  <Card title="Styles" href="/guides/styles">
    Create and maintain the styles that relations link together.
  </Card>

  <Card title="Get a style" href="/api-reference/styles/get-a-single-style-by-id">
    Follow a relation to its target: `GET /api/styles/{id}`.
  </Card>

  <Card title="Authentication" href="/authentication">
    How to get and send your `X-Auth-Token` API key.
  </Card>
</CardGroup>
