# Item Accounts

Bookkeeping accounts for sales lines, per item

## POST /api/v1/integrations/fortnox/item-accounts/sync

Sync accounts from Fortnox

Import active revenue (3xxx) accounts from the location's connected Fortnox and upsert them into Karma item-accounts (keyed on account number). Non-destructive and idempotent. Requires Fortnox to be connected.

**Permissions:** 🟠 `inventory.update`

Request body:

```ts
{
  locationId: number
}
```

Response 200 — Default Response

```ts
{
  status?: "success"
  data?: {
    created?: number
    updated?: number
    total?: number
  }
  meta?: {
    requestId: string
    timestamp: string // date-time
    executionTimeMs: number
  }
}
```

## GET /api/v1/item-accounts

List item accounts

List item accounts for a location (or company)

**Permissions:** 🔵 `inventory.read`

Query parameters:
- `locationId` (number, optional) — Filter by location ID
- `companyId` (number, optional) — Filter by company ID (joined through locations)

Response 200 — Default Response

```ts
{
  status: "success"
  data: {
    itemAccounts: Array<{
        vatId?: integer | null
        id: string // uuid
        account: string
        description: string | null
        locationId: number | null
        isInherited?: boolean
        sourceLocationId?: number | null
        inheritToChildren?: boolean
        createdAt: string // date-time
        updatedAt: string // date-time
      }>
  }
  meta: {
    requestId: string
    timestamp: string // date-time
    executionTimeMs: number
  }
}
```

## POST /api/v1/item-accounts

Create item account

Create a new item account

**Permissions:** 🟢 `inventory.create`

Request body:

```ts
{
  vatId?: integer | null
  account: string
  description?: string | null
  locationId?: number | null
}
```

Response 201 — Default Response

```ts
{
  status: "success"
  data: {
    vatId?: integer | null
    id: string // uuid
    account: string
    description: string | null
    locationId: number | null
    isInherited?: boolean
    sourceLocationId?: number | null
    inheritToChildren?: boolean
    createdAt: string // date-time
    updatedAt: string // date-time
  }
  meta: {
    requestId: string
    timestamp: string // date-time
    executionTimeMs: number
  }
}
```

## GET /api/v1/item-accounts/{id}

Get item account

Get a single item account by ID

**Permissions:** 🔵 `inventory.read`

Path parameters:
- `id` (string, required) — Item account UUID

Response 200 — Default Response

```ts
{
  status: "success"
  data: {
    vatId?: integer | null
    id: string // uuid
    account: string
    description: string | null
    locationId: number | null
    isInherited?: boolean
    sourceLocationId?: number | null
    inheritToChildren?: boolean
    createdAt: string // date-time
    updatedAt: string // date-time
  }
  meta: {
    requestId: string
    timestamp: string // date-time
    executionTimeMs: number
  }
}
```

## PUT /api/v1/item-accounts/{id}

Update item account

Update an item account. `locationId` cannot be changed.

**Permissions:** 🟠 `inventory.update`

Path parameters:
- `id` (string, required) — Item account UUID

Request body:

```ts
{
  vatId?: integer | null
  account?: string
  description?: string | null
}
```

Response 200 — Default Response

```ts
{
  status: "success"
  data: {
    vatId?: integer | null
    id: string // uuid
    account: string
    description: string | null
    locationId: number | null
    isInherited?: boolean
    sourceLocationId?: number | null
    inheritToChildren?: boolean
    createdAt: string // date-time
    updatedAt: string // date-time
  }
  meta: {
    requestId: string
    timestamp: string // date-time
    executionTimeMs: number
  }
}
```

## DELETE /api/v1/item-accounts/{id}

Delete item account

Delete an item account

**Permissions:** 🔴 `inventory.delete`

Path parameters:
- `id` (string, required) — Item account UUID

Response 200 — Default Response

```ts
{
  status: "success"
  data: {
    id: string // uuid
    deleted: boolean
  }
  meta: {
    requestId: string
    timestamp: string // date-time
    executionTimeMs: number
  }
}
```

## GET /api/v1/items/{itemId}/accounts

Get accounts linked to an item

List the item accounts associated with a given inventory item

**Permissions:** 🔵 `inventory.read`

Path parameters:
- `itemId` (string, required) — Inventory item ID

Response 200 — Default Response

```ts
{
  status: "success"
  data: {
    itemAccounts: Array<{
        vatId?: integer | null
        id: string // uuid
        account: string
        description: string | null
        locationId: number | null
        isInherited?: boolean
        sourceLocationId?: number | null
        inheritToChildren?: boolean
        createdAt: string // date-time
        updatedAt: string // date-time
      }>
  }
  meta: {
    requestId: string
    timestamp: string // date-time
    executionTimeMs: number
  }
}
```

## POST /api/v1/items/{itemId}/accounts

Link an account to an item

Associate an item account with an inventory item. Idempotent — succeeds if the link already exists.

**Permissions:** 🟠 `inventory.update`

Path parameters:
- `itemId` (string, required) — Inventory item ID

Request body:

```ts
{
  accountId: string // uuid
}
```

Response 200 — Default Response

```ts
{
  status: "success"
  data: {
    itemAccounts: Array<{
        vatId?: integer | null
        id: string // uuid
        account: string
        description: string | null
        locationId: number | null
        isInherited?: boolean
        sourceLocationId?: number | null
        inheritToChildren?: boolean
        createdAt: string // date-time
        updatedAt: string // date-time
      }>
  }
  meta: {
    requestId: string
    timestamp: string // date-time
    executionTimeMs: number
  }
}
```

## DELETE /api/v1/items/{itemId}/accounts/{accountId}

Unlink an account from an item

Remove an account-to-item association. Idempotent — succeeds if the link does not exist.

**Permissions:** 🟠 `inventory.update`

Path parameters:
- `itemId` (string, required) — Inventory item ID
- `accountId` (string, required) — Item account UUID

Response 200 — Default Response

```ts
{
  status: "success"
  data: {
    itemAccounts: Array<{
        vatId?: integer | null
        id: string // uuid
        account: string
        description: string | null
        locationId: number | null
        isInherited?: boolean
        sourceLocationId?: number | null
        inheritToChildren?: boolean
        createdAt: string // date-time
        updatedAt: string // date-time
      }>
  }
  meta: {
    requestId: string
    timestamp: string // date-time
    executionTimeMs: number
  }
}
```
