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

# Sync Tag Groups with Dimensions

export const IntegrationDesignTagsSyncTagGroupsDiagram = () => {
  const [isDark, setIsDark] = useState(false);
  useEffect(() => {
    const check = () => setIsDark(document.documentElement.classList.contains("dark"));
    check();
    const observer = new MutationObserver(check);
    observer.observe(document.documentElement, {
      attributes: true,
      attributeFilter: ["class"]
    });
    return () => observer.disconnect();
  }, []);
  const nodeFill = isDark ? "#212222" : "#EEF4F4";
  const nodeStroke = isDark ? "#848989" : "#212222";
  const nodeTextStyle = isDark ? ",color:#EEF4F4" : ",color:#131414";
  const linkStyle = isDark ? "" : "linkStyle default stroke:#848989,stroke-width:1px;";
  const themeVariables = {
    fontSize: "12px",
    ...isDark ? {} : {
      edgeLabelBackground: "#FAFCFC"
    }
  };
  const diagram = `
%%{init: {"themeVariables": ${JSON.stringify(themeVariables)}}}%%
flowchart TD
    A[1. Pull selected Dimensions from AS] --> B[Check each Dimension is active]
    B -->|Active| C[2. Pull active and archived Tag Groups from Pleo]
    B -->|Inactive| D[Deselect Dimension, skip]
    C --> E[3. Match Dimension to Tag Group by code]
    E -->|Found, Pleo active| F[Preserve Tag Group as-is]
    E -->|Found, Pleo archived| G[Unarchive Tag Group]
    E -->|Not found| H[Create new Tag Group]
    F --> I[Proceed to Tag synchronisation]
    G --> I
    H --> I
    E -->|Pleo active, no matching AS Dimension| J[4. Archive unmatched Tag Groups]

    style A white-space:normal,fill:${nodeFill},stroke:${nodeStroke}${nodeTextStyle}
    style B white-space:normal,fill:${nodeFill},stroke:${nodeStroke}${nodeTextStyle}
    style C white-space:normal,fill:${nodeFill},stroke:${nodeStroke}${nodeTextStyle}
    style D white-space:normal,fill:${nodeFill},stroke:${nodeStroke}${nodeTextStyle}
    style E white-space:normal,fill:${nodeFill},stroke:${nodeStroke}${nodeTextStyle}
    style F white-space:normal,fill:${nodeFill},stroke:${nodeStroke}${nodeTextStyle}
    style G white-space:normal,fill:${nodeFill},stroke:${nodeStroke}${nodeTextStyle}
    style H white-space:normal,fill:${nodeFill},stroke:${nodeStroke}${nodeTextStyle}
    style I white-space:normal,fill:${nodeFill},stroke:${nodeStroke}${nodeTextStyle}
    style J white-space:normal,fill:${nodeFill},stroke:${nodeStroke}${nodeTextStyle}
${linkStyle}
`;
  return <Mermaid chart={diagram} />;
};

export const RememberCallout = ({title, children}) => <div className="callout-box callout-remember">
    <div className="callout-row">
      <span className="callout-icon">
        <svg width="22" height="22" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M229.66,98.34,172.39,155.8c11.46,22.93-1.72,45.86-10.11,57a8,8,0,0,1-12,.83L42.34,105.76A8,8,0,0,1,43,93.85c29.65-23.92,57.4-10,57.4-10l57.27-57.46a8,8,0,0,1,11.31,0L229.66,87A8,8,0,0,1,229.66,98.34Z" opacity="0.2" /><path d="M235.32,81.37,174.63,20.69a16,16,0,0,0-22.63,0L98.37,74.49c-10.66-3.34-35-7.37-60.4,13.14a16,16,0,0,0-1.29,23.78L85,159.71,42.34,202.34a8,8,0,0,0,11.32,11.32L96.29,171l48.29,48.29A16,16,0,0,0,155.9,224c.38,0,.75,0,1.13,0a15.93,15.93,0,0,0,11.64-6.33c19.64-26.1,17.75-47.32,13.19-60L235.33,104A16,16,0,0,0,235.32,81.37ZM224,92.69h0l-57.27,57.46a8,8,0,0,0-1.49,9.22c9.46,18.93-1.8,38.59-9.34,48.62L48,100.08c12.08-9.74,23.64-12.31,32.48-12.31A40.13,40.13,0,0,1,96.81,91a8,8,0,0,0,9.25-1.51L163.32,32,224,92.68Z" /></svg>
      </span>
      <div>
        {title && <div className="callout-title">
            {title}
          </div>}
        <div className="callout-body">
          {children}
        </div>
      </div>
    </div>
  </div>;

This page describes **[Step 2 of Tags Sync](/docs/current/integration-design/accounting-integrations/imports/tags/integration-design-tags-overview#sync-steps)**: synchronising selected Accounting Dimensions from the Accounting System with Tag Groups in Pleo.

This step runs at the start of every Tags Sync cycle, before Tag synchronisation.

## Implementation

* [Tags Sync Workflow Guide](/docs/current/guides/accounting-integrations/imports/tags-sync-workflow-guide#2-sync-tag-groups-with-dimensions): workflow context and sequencing
* [How to Sync Tag Groups with Accounting Dimensions](/docs/current/how-tos/accounting-integrations/imports/tags/how-to-sync-tag-groups-with-accounting-dimensions): API usage and step-by-step instructions

For a conceptual overview of how AS Dimensions map to Pleo Tag Groups, see [Platform Capabilities: Tags Sync](/docs/current/platform/accounting-integrations/imports/tags/tags-sync-overview).

## Matching Rules

* Matching is performed using the **code** field on both ends.
* Matching is **case-insensitive**: a Dimension with code `DEPT` matches a Tag Group with code `dept`.
* Name differences do not affect matching: only code is used for matching. Names are updated separately if they differ.

## Sync Process

<IntegrationDesignTagsSyncTagGroupsDiagram />

### 1. Pull selected Dimensions

Retrieve the Dimensions currently selected for synchronisation.

For each selected Dimension, check whether it is still **active** in the AS:

* **Active**: proceed with synchronisation.
* **Inactive**: automatically deselect the Dimension. The corresponding Tag Group will be archived. This Dimension is not used in the steps below.

### 2. Pull Tag Groups from Pleo

Retrieve **active and archived** Tag Groups from Pleo for the connected company.

### 3. Match Dimensions to Tag Groups

For every selected active Dimension, match against Tag Groups using the Dimension's **code** (case-insensitive).

#### Code found: Tag Group is active

The AS Dimension is active and the matching Pleo Tag Group is also active. No action required.

#### Code found: Tag Group is archived

The AS Dimension is active but the matching Pleo Tag Group is archived. **Unarchive** the Tag Group.

#### Code not found

The AS Dimension is active but no matching Pleo Tag Group exists. **Create a new Tag Group** with the Dimension's name and code.

### 4. Archive unmatched Tag Groups

Pleo Tag Groups that are active but have no matching selected AS Dimension must be **archived**.

This covers Tag Groups that existed from a previously selected Dimension that has since been deselected or removed.

<RememberCallout title="Remember">
  Tag Groups are never permanently deleted. Archiving preserves historical data and allows unarchiving if the Dimension is re-selected.
</RememberCallout>

***

## What Comes Next?

* [Sync Tags with Dimension Values](/docs/current/integration-design/accounting-integrations/imports/tags/integration-design-tags-sync-tags)

***

## Related Reading

* [How to Sync Tag Groups with Accounting Dimensions](/docs/current/how-tos/accounting-integrations/imports/tags/how-to-sync-tag-groups-with-accounting-dimensions)
* [Tags Sync Workflow Guide](/docs/current/guides/accounting-integrations/imports/tags-sync-workflow-guide)
* [Platform Capabilities: Tags Sync](/docs/current/platform/accounting-integrations/imports/tags/tags-sync-overview)

***
