# API Open Mercato

Version: 0.8.0

Automatycznie wygenerowana definicja OpenAPI dla wszystkich włączonych modułów.

## Servers
- https://manifaktura.vicoop.com/api – Domyślne środowisko

## GET `/ai_assistant/ai/actions/{id}`

Fetch the current state of an AI pending action by id.

Returns the tenant-scoped {@link AiPendingAction} addressed by `:id`. Powers the chat UI reconnect/polling path: after a page reload or SSE reconnect the client carries the `pendingActionId` from an earlier `mutation-preview-card` UI part and calls this route to re-hydrate the card. Server-internal fields (`normalizedInput`, `createdByUserId`, `idempotencyKey`) are stripped by a whitelist serializer. Enforces tenant/org scoping via the repository.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Serialized pending action. Never includes normalizedInput, createdByUserId, or idempotencyKey.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks the `ai_assistant.view` feature.

Content-Type: `application/json`

**404** – No pending action with the given id is accessible to the caller.

Content-Type: `application/json`

**500** – Internal runtime failure.

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/ai/actions/:id" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/ai_assistant/ai/actions/{id}/cancel`

Cancel an AI pending action without executing the wrapped tool.

Flips a pending AI action from `pending` to `cancelled` and emits the `ai.action.cancelled` event. The tool handler is never invoked. Idempotent: a second call on a row already in `cancelled` status returns 200 with the current row without re-emitting the event. Rows whose `expiresAt` is in the past are flipped to `expired` and returned as 409 `expired` so the client can surface the TTL loss instead of silently masking it as a cancellation.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Cancellation complete (or idempotent replay); body includes the serialized pending action with status `cancelled`.

Content-Type: `application/json`

**400** – Invalid cancel request body (unknown field, reason exceeds 500 chars, wrong type).

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks `ai_assistant.view`.

Content-Type: `application/json`

**404** – Pending action not found in the caller scope.

Content-Type: `application/json`

**409** – Pending action is not in `pending` status (already confirmed/failed/executing) or has expired.

Content-Type: `application/json`

**500** – Unexpected server failure during cancel.

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/ai_assistant/ai/actions/:id/cancel" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/ai_assistant/ai/actions/{id}/confirm`

Confirm an AI pending action, re-running every server-side check before execution.

Re-verifies the full contract from spec §9.4 (status, expiry, agent registration, required features, mutation policy, tool whitelist, attachment tenant scope, record version, and schema drift), flips the pending-action state machine to `executing`, invokes the wrapped tool handler, and persists `executionResult`. Idempotent: a second call on a row already in `confirmed` state returns the prior result without re-executing the handler.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Confirmation complete; body includes the serialized pending action and the mutation result.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks `ai_assistant.view`, a required agent feature, tool whitelist, or accesses attachments outside their tenant.

Content-Type: `application/json`

**404** – Pending action or agent not found in the caller scope.

Content-Type: `application/json`

**409** – Pending action is not in `pending` status or has expired.

Content-Type: `application/json`

**412** – Record version changed between propose and confirm, or the input schema no longer accepts the stored payload.

Content-Type: `application/json`

**500** – Unexpected server failure during confirm.

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/ai_assistant/ai/actions/:id/confirm" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/ai_assistant/ai/agents`

List registered AI agents, filtered by the caller's features.

Returns `{ agents: [...] }` — the subset of agents from `ai-agents.generated.ts` that the authenticated caller can invoke based on each agent's `requiredFeatures`. Mirrors the `meta.list_agents` tool handler so backoffice pages (e.g. the playground) can render an agent picker without going through the MCP tool transport.

**Tags:** AI Assistant

**Requires authentication.**

### Responses

**200** – Accessible agent summaries.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**500** – Internal failure while loading the agent registry.

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/ai/agents" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/ai_assistant/ai/agents/{agentId}/loop-override`

Remove the loop-policy columns from the agent-scoped runtime override row.

Nulls out all seven loop columns on the agent-scoped `ai_agent_runtime_overrides` row. Idempotent — returns 200 even when no override exists. Requires `ai_assistant.settings.manage`.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| agentId | path | any | Required |

### Responses

**200** – Loop override cleared (or already absent).

Content-Type: `application/json`

**400** – Invalid agent id.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks `ai_assistant.settings.manage`.

Content-Type: `application/json`

**404** – Unknown agent id.

Content-Type: `application/json`

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/ai_assistant/ai/agents/:agentId/loop-override" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/ai_assistant/ai/agents/{agentId}/loop-override`

Read the current loop-policy override for this agent, if any.

Returns `{ agentId, override }` where `override` is the agent-scoped loop-policy row from `ai_agent_runtime_overrides` (or `null`). Requires `ai_assistant.view`.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| agentId | path | any | Required |

### Responses

**200** – Loop override payload.

Content-Type: `application/json`

**400** – Invalid agent id.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks `ai_assistant.view`.

Content-Type: `application/json`

**404** – Unknown agent id.

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/ai/agents/:agentId/loop-override" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/ai_assistant/ai/agents/{agentId}/loop-override`

Set (or replace) the tenant-scoped loop-policy override for this agent.

Body: loop columns. All fields are nullable/optional; `null` explicitly clears that axis. Validates `loopStopWhenJson` items and `loopActiveToolsJson` membership. Requires `ai_assistant.settings.manage`.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| agentId | path | any | Required |

### Request Body

Content-Type: `application/json`

```json
{
  "loopDisabled": null,
  "loopMaxSteps": null,
  "loopMaxToolCalls": null,
  "loopMaxWallClockMs": null,
  "loopMaxTokens": null,
  "loopStopWhenJson": null,
  "loopActiveToolsJson": null
}
```

### Responses

**200** – Override persisted.

Content-Type: `application/json`

**400** – Invalid agent id or validation error.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks `ai_assistant.settings.manage`.

Content-Type: `application/json`

**404** – Unknown agent id.

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/ai_assistant/ai/agents/:agentId/loop-override" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"loopDisabled\": null,
  \"loopMaxSteps\": null,
  \"loopMaxToolCalls\": null,
  \"loopMaxWallClockMs\": null,
  \"loopMaxTokens\": null,
  \"loopStopWhenJson\": null,
  \"loopActiveToolsJson\": null
}"
```

## GET `/ai_assistant/ai/agents/{agentId}/models`

Get the providers and curated models available for the chat-UI picker for this agent

Returns all configured providers with their curated model catalogs, filtered to providers that have an API key configured in the current environment. When the agent declares `allowRuntimeOverride: false`, the response reflects that constraint so the UI picker can hide itself. Includes the agent's resolved default provider/model so the picker can render a "(default)" badge next to the right entry. When a tenant-scoped lookup (the allowlist snapshot or the per-agent runtime override) cannot be loaded, the route still answers 200 with a partially resolved provider list and sets `degraded: true` plus a `degradedReason` code, so callers can tell a full entitlement list from a partial one. RBAC: requires the same features as the agent itself (typically `ai_assistant.view`).

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| agentId | path | any | Required |

### Responses

**200** – Providers and curated models available for the agent picker. Empty `providers` array when `allowRuntimeOverride` is false. `degraded` is `false` and `degradedReason` is `null` on a fully resolved response; `degraded: true` with `degradedReason: "tenant_allowlist_unavailable"` means a tenant-scoped lookup failed, so `providers` may be missing the tenant allowlist and/or the per-agent override narrowing — one code covers the whole tenant-scoped block because no client can act differently per source. Clients SHOULD render the list but MUST NOT treat it as the tenant's authoritative entitlement (for example, do not prune a stored model selection against it).

Content-Type: `application/json`

**401** – Unauthenticated.

Content-Type: `application/json`

**403** – Caller lacks the agent's required features.

Content-Type: `application/json`

**404** – Unknown agent id.

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/ai/agents/:agentId/models" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/ai_assistant/ai/agents/{agentId}/mutation-policy`

Remove the tenant-scoped mutationPolicy override for this agent.

Deletes the override row if it exists; subsequent calls fall back to the agent's code-declared policy. Idempotent — returns 200 even when no override exists. Requires `ai_assistant.settings.manage`.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| agentId | path | any | Required |

### Responses

**200** – Override cleared (or already absent).

Content-Type: `application/json`

**400** – Invalid agent id.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks `ai_assistant.settings.manage`.

Content-Type: `application/json`

**404** – Unknown agent id.

Content-Type: `application/json`

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/ai_assistant/ai/agents/:agentId/mutation-policy" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/ai_assistant/ai/agents/{agentId}/mutation-policy`

Read the effective mutationPolicy for an agent — code-declared value plus any tenant override.

Returns `{ agentId, codeDeclared, override }` where `codeDeclared` is the agent's compiled-in `mutationPolicy` and `override` is the persisted tenant-scoped override (or `null`). Requires `ai_assistant.view`.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| agentId | path | any | Required |

### Responses

**200** – Effective mutationPolicy payload.

Content-Type: `application/json`

**400** – Invalid agent id.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks `ai_assistant.view`.

Content-Type: `application/json`

**404** – Unknown agent id.

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/ai/agents/:agentId/mutation-policy" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/ai_assistant/ai/agents/{agentId}/mutation-policy`

Set (or replace) the tenant-scoped mutationPolicy override for this agent.

Body: `{ mutationPolicy: "read-only" | "confirm-required" | "destructive-confirm-required", notes? }`. The override MUST NOT escalate beyond the agent's code-declared policy. Escalation attempts are rejected with 400 + `code: "escalation_not_allowed"`. Requires `ai_assistant.settings.manage`.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| agentId | path | any | Required |

### Request Body

Content-Type: `application/json`

```json
{
  "mutationPolicy": "read-only"
}
```

### Responses

**200** – Override persisted.

Content-Type: `application/json`

**400** – Invalid agent id, malformed body, or escalation attempt.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks `ai_assistant.settings.manage`.

Content-Type: `application/json`

**404** – Unknown agent id.

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/ai_assistant/ai/agents/:agentId/mutation-policy" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"mutationPolicy\": \"read-only\"
}"
```

## GET `/ai_assistant/ai/agents/{agentId}/prompt-override`

Read the latest prompt-section override for an agent plus recent version history.

Returns `{ agentId, override, versions }` where `override` is the latest persisted row (or `null`) and `versions` is the newest-first history capped at 10 rows. Tenant-scoped; requires `ai_assistant.settings.manage`.

**Tags:** AI Assistant

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| agentId | path | any | Required |

### Responses

**200** – Latest override + recent version history.

Content-Type: `application/json`

**400** – Invalid agent id.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks `ai_assistant.settings.manage`.

Content-Type: `application/json`

**404** – Unknown agent id.

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/ai/agents/:agentId/prompt-override" \
  -H "Accept: application/json"
```

## POST `/ai_assistant/ai/agents/{agentId}/prompt-override`

Save a new prompt-section override version for the agent.

Persists an additive `{ sections: Record<sectionId, text>, notes? }` override, allocating the next monotonic version for `(tenant, org, agent)`. Reserved policy keys (`mutationPolicy`, `readOnly`, `allowedTools`, `acceptedMediaTypes`) are rejected with 400 / `reserved_key`. Requires `ai_assistant.settings.manage`.

**Tags:** AI Assistant

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| agentId | path | any | Required |

### Request Body

Content-Type: `application/json`

```json
{}
```

### Responses

**200** – Override persisted. Returns `{ ok: true, version, updatedAt }`.

Content-Type: `application/json`

**400** – Invalid agent id, malformed body, or reserved policy key.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks `ai_assistant.settings.manage`.

Content-Type: `application/json`

**404** – Unknown agent id.

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/ai_assistant/ai/agents/:agentId/prompt-override" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{}"
```

## POST `/ai_assistant/ai/chat`

Stream a chat turn for a registered AI agent

Dispatches a chat turn to the focused AI agent identified by `?agent=<module>.<agent>`. Enforces agent-level `requiredFeatures`, tool whitelisting, read-only / mutationPolicy, execution-mode compatibility, and attachment media-type policy. The streaming response body uses an AI SDK-compatible `text/event-stream` transport. Optional `?provider=`, `?model=`, and `?baseUrl=` query params let callers override the resolved provider/model/base-URL for this turn (Phase 4a). Provider must be registered and configured; baseUrl must match `AI_RUNTIME_BASEURL_ALLOWLIST` when set. Both are suppressed when the agent declares `allowRuntimeOverride: false`.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| agent | query | any | Required |
| provider | query | any | Optional |
| model | query | any | Optional |
| baseUrl | query | any | Optional |
| loopBudget | query | any | Optional |

### Request Body

Content-Type: `application/json`

```json
{
  "messages": [
    {
      "role": "user",
      "content": "string"
    }
  ]
}
```

### Responses

**200** – Streaming text/event-stream response compatible with AI SDK chat transports.

Content-Type: `text/event-stream`

**400** – Invalid query param, malformed payload, or message count above the cap. Typed codes: `runtime_override_disabled` (agent has allowRuntimeOverride:false), `provider_unknown` (provider id not registered), `provider_not_configured` (provider registered but no API key in env), `baseurl_not_allowlisted` (baseUrl not in AI_RUNTIME_BASEURL_ALLOWLIST).

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks agent-level or tool-level required features.

Content-Type: `application/json`

**404** – Unknown agent id.

Content-Type: `application/json`

**409** – Agent/tool/execution-mode policy violation.

Content-Type: `application/json`

**500** – Internal runtime failure.

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/ai_assistant/ai/chat?agent=string" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"messages\": [
    {
      \"role\": \"user\",
      \"content\": \"string\"
    }
  ]
}"
```

## GET `/ai_assistant/ai/conversations`

List AI chat conversations visible to the caller.

Returns `{ items, nextCursor }` for the authenticated caller, ordered by `lastMessageAt` descending. View-only callers receive only their own conversations. Callers with `ai_assistant.conversations.manage` may list conversations across users in the same tenant/organization. The `agent` and `status` filters are optional; `cursor` is the ISO timestamp returned by a previous response.

**Tags:** AI Assistant

**Requires authentication.**

### Responses

**200** – Caller-owned conversation summaries.

Content-Type: `application/json`

**400** – Invalid query parameters.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks the `ai_assistant.view` feature.

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/ai/conversations" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/ai_assistant/ai/conversations`

Idempotently create a new AI chat conversation.

If a non-deleted conversation already exists with the supplied `conversationId` for the authenticated caller in this tenant/org, returns the existing summary. Otherwise creates a fresh row and writes the owner-participant row in the same transaction.

**Tags:** AI Assistant

**Requires authentication.**

### Responses

**200** – Existing conversation (idempotent path).

Content-Type: `application/json`

**201** – Newly created conversation.

Content-Type: `application/json`

**400** – Invalid request body.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks the `ai_assistant.view` feature.

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/ai_assistant/ai/conversations" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/ai_assistant/ai/conversations/{conversationId}`

Soft-delete a conversation and its messages.

View-only callers can delete only their own conversations. Callers with `ai_assistant.conversations.manage` can delete conversations in the same tenant/organization. Marks the conversation row and every undeleted message row with a `deleted_at` timestamp in one transaction. The transcript remains in the database for audit/restore until a future retention worker hard-deletes it.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| conversationId | path | any | Required |

### Responses

**200** – Soft-delete acknowledgment.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks the `ai_assistant.view` feature.

Content-Type: `application/json`

**404** – No conversation accessible to the caller.

Content-Type: `application/json`

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/ai_assistant/ai/conversations/:conversationId" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/ai_assistant/ai/conversations/{conversationId}`

Fetch a conversation summary and recent transcript.

Returns `{ conversation, messages, nextCursor }` for the supplied `conversationId`. View-only callers can load only their own conversations. Callers with `ai_assistant.conversations.manage` can load conversations across users in the same tenant/organization. Messages are ordered ascending by `createdAt`. The `before` cursor returns the next older page when paging back through long transcripts.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| conversationId | path | any | Required |

### Responses

**200** – Conversation transcript page for the authenticated owner.

Content-Type: `application/json`

**400** – Invalid path or query parameters.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks the `ai_assistant.view` feature.

Content-Type: `application/json`

**404** – No conversation accessible to the caller.

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/ai/conversations/:conversationId" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PATCH `/ai_assistant/ai/conversations/{conversationId}`

Update an existing conversation.

Accepts a partial body containing any of `title`, `status`, `pageContext`. Setting `status` to `closed` archives the conversation while keeping its transcript intact. View-only callers can update only their own conversations; conversation managers can update conversations in the same tenant/organization.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| conversationId | path | any | Required |

### Responses

**200** – Updated conversation summary.

Content-Type: `application/json`

**400** – Invalid request body.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks the `ai_assistant.view` feature.

Content-Type: `application/json`

**404** – No conversation accessible to the caller.

Content-Type: `application/json`

### Example

```bash
curl -X PATCH "https://manifaktura.vicoop.com/api/ai_assistant/ai/conversations/:conversationId" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/ai_assistant/ai/conversations/{conversationId}/participants`

List active participants of a conversation.

Returns the list of active (non-revoked) participants for the conversation. Only the conversation owner or a caller with `ai_assistant.conversations.manage` can call this endpoint.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| conversationId | path | any | Required |

### Responses

**200** – List of active participants.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks required features.

Content-Type: `application/json`

**404** – Conversation not found or not accessible.

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/ai/conversations/:conversationId/participants" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/ai_assistant/ai/conversations/{conversationId}/participants`

Add a participant to a conversation.

Grants a named user read access to the conversation. Requires `ai_assistant.conversations.share`. Only the conversation owner may add participants. If the user was previously revoked, the soft-deleted row is restored.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| conversationId | path | any | Required |

### Responses

**201** – Participant added; conversation visibility updated to "shared".

Content-Type: `application/json`

**400** – Invalid request body.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks required feature or is not the owner.

Content-Type: `application/json`

**404** – Conversation not found.

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/ai_assistant/ai/conversations/:conversationId/participants" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/ai_assistant/ai/conversations/{conversationId}/participants/{userId}`

Revoke a participant from a conversation (soft-delete).

Soft-deletes the participant row. If no active non-owner participants remain, the conversation visibility is reset to "private". Only the conversation owner or a manager may revoke participants.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| conversationId | path | any | Required |
| userId | path | any | Required |

### Responses

**204** – Participant revoked.

**400** – Invalid path parameters.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks required features or is not the owner.

Content-Type: `application/json`

**404** – Conversation not found.

Content-Type: `application/json`

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/ai_assistant/ai/conversations/:conversationId/participants/:userId" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/ai_assistant/ai/conversations/import`

Import a conversation that previously lived only in browser localStorage.

Idempotent: messages with `clientMessageId` already present in the server transcript are skipped and counted in `skippedMessageCount`. New messages are appended with the original `clientMessageId` so subsequent retries continue to dedupe. Up to 100 messages per request. Attachment previews stored as `data:` URLs in the source localStorage record MUST NOT be forwarded to this endpoint; the UI strips them before upload.

**Tags:** AI Assistant

**Requires authentication.**

### Responses

**200** – Import result including imported/skipped counters.

Content-Type: `application/json`

**400** – Invalid request body.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks the `ai_assistant.view` feature.

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/ai_assistant/ai/conversations/import" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/ai_assistant/ai/run-object`

Run an object-mode AI agent and return the generated object

Invokes `runAiAgentObject` server-side for the registered AI agent identified by `agent` (matching "<module>.<agent>"). Enforces the same `requiredFeatures`, tool whitelisting, mutationPolicy, and attachment media-type policy as the chat dispatcher, but additionally requires the agent to declare `executionMode: "object"`. Returns the generated object in a single JSON response (no streaming).

**Tags:** AI Assistant

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "agent": "string",
  "messages": [
    {
      "role": "user",
      "content": "string"
    }
  ]
}
```

### Responses

**200** – Object-mode run completed; response body contains `{ object, usage?, finishReason? }`.

Content-Type: `application/json`

**400** – Malformed payload or message cap exceeded.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks agent-level or tool-level required features.

Content-Type: `application/json`

**404** – Unknown agent id.

Content-Type: `application/json`

**409** – Agent/tool/execution-mode policy violation.

Content-Type: `application/json`

**422** – Agent does not support object-mode execution.

Content-Type: `application/json`

**500** – Internal runtime failure.

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/ai_assistant/ai/run-object" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"agent\": \"string\",
  \"messages\": [
    {
      \"role\": \"user\",
      \"content\": \"string\"
    }
  ]
}"
```

## POST `/ai_assistant/chat`

Send message to AI agent via SSE stream

**Tags:** AI Assistant

**Requires authentication.**

### Responses

**201** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/ai_assistant/chat" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/ai_assistant/health`

Check OpenCode and MCP connection status

**Tags:** AI Assistant

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/health" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/ai_assistant/mcp-key`

Generate MCP API key

Generates a persistent `omk_` API key scoped to the calling user's tenant/organization and carrying the caller's own roles, so the key has the same ACL as the user.

**Tags:** AI Assistant

**Requires authentication.**

### Responses

**200** – API key created

Content-Type: `application/json`

```json
{
  "id": "string",
  "name": "string",
  "keyPrefix": "string",
  "secret": "string",
  "tenantId": null,
  "organizationId": null,
  "roles": [
    "string"
  ]
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Failed to create MCP API key

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/ai_assistant/mcp-key" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/ai_assistant/moderation-flags`

List input-moderation audit flags for the current tenant.

Returns the append-only `ai_moderation_flags` audit rows (category flags + scores only — never prompt content) for the caller's tenant. Always tenant-scoped; cross-tenant access is impossible. Optionally filtered by `agentId`, `userId`, and a `from`/`to` date window. Paginated (`pageSize` ≤ 100). Requires `ai_assistant.settings.manage`.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| agentId | query | any | Optional |
| userId | query | any | Optional |
| from | query | any | Optional |
| to | query | any | Optional |

### Responses

**200** – Paginated moderation-flag rows: `{ items, total, page, pageSize }`.

Content-Type: `application/json`

**400** – Invalid query parameters.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks `ai_assistant.settings.manage`.

Content-Type: `application/json`

**500** – Internal failure.

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/moderation-flags?page=1&pageSize=50" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/ai_assistant/route`

Route user query to appropriate AI handler

**Tags:** AI Assistant

**Requires authentication.**

### Responses

**201** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/ai_assistant/route" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/ai_assistant/session-key`

Generate session key

Generates a new session token that can be included in MCP tool calls via the _sessionToken parameter. The token inherits the calling user's roles and organization context.

**Tags:** AI Assistant

**Requires authentication.**

### Responses

**200** – Session key created successfully

Content-Type: `application/json`

```json
{
  "sessionToken": "string",
  "expiresAt": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Failed to create session key

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/ai_assistant/session-key" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/ai_assistant/settings`

Clear per-tenant AI runtime override

Soft-deletes the active per-tenant runtime override. Pass `agentId` to clear only the agent-specific row; omit to clear the tenant-wide default. Gated by `ai_assistant.settings.manage`. Idempotent — returns 200 with `cleared: false` when no active row existed.

**Tags:** AI Assistant

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "agentId": null
}
```

### Responses

**200** – Returns `{ cleared: boolean }` indicating whether a row was found and removed.

Content-Type: `application/json`

**401** – Unauthenticated.

Content-Type: `application/json`

**403** – Caller lacks ai_assistant.settings.manage.

Content-Type: `application/json`

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/ai_assistant/settings" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"agentId\": null
}"
```

## GET `/ai_assistant/settings`

Get AI provider configuration

**Tags:** AI Assistant

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/settings" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/ai_assistant/settings`

Upsert per-tenant AI runtime override

Creates or updates the per-tenant AI runtime override (provider, model, baseURL). Optionally scoped to a specific agent via `agentId`. Gated by `ai_assistant.settings.manage`. baseURL must match AI_RUNTIME_BASEURL_ALLOWLIST when set.

**Tags:** AI Assistant

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "providerId": null,
  "modelId": null,
  "baseURL": null,
  "agentId": null,
  "allowedOverrideProviders": null,
  "inputModeration": null
}
```

### Responses

**200** – Override saved. Returns the saved row.

Content-Type: `application/json`

**400** – Validation error: unknown provider, invalid URL, or baseURL not allowlisted.

Content-Type: `application/json`

**401** – Unauthenticated.

Content-Type: `application/json`

**403** – Caller lacks ai_assistant.settings.manage.

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/ai_assistant/settings" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"providerId\": null,
  \"modelId\": null,
  \"baseURL\": null,
  \"agentId\": null,
  \"allowedOverrideProviders\": null,
  \"inputModeration\": null
}"
```

## DELETE `/ai_assistant/settings/allowlist`

Clear per-tenant AI provider/model allowlist

Soft-deletes the tenant allowlist row. Tenant overrides revert to env-only enforcement. Idempotent — returns `{ cleared: false }` when no active row existed.

**Tags:** AI Assistant

**Requires authentication.**

### Responses

**200** – Returns `{ cleared: boolean }`.

Content-Type: `application/json`

**401** – Unauthenticated.

Content-Type: `application/json`

**403** – Caller lacks ai_assistant.settings.manage.

Content-Type: `application/json`

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/ai_assistant/settings/allowlist" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/ai_assistant/settings/allowlist`

Upsert per-tenant AI provider/model allowlist

Persists the per-tenant allowlist of providers and models. The runtime intersects this with the env allowlist (`OM_AI_AVAILABLE_*`) at resolution time. Tenant values that fall outside the env allowlist are rejected with `provider_not_in_env_allowlist` / `model_not_in_env_allowlist` 400 codes. Gated by `ai_assistant.settings.manage`.

**Tags:** AI Assistant

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "allowedProviders": null
}
```

### Responses

**200** – Allowlist saved. Returns the saved snapshot.

Content-Type: `application/json`

**400** – Validation error or values outside env allowlist.

Content-Type: `application/json`

**401** – Unauthenticated.

Content-Type: `application/json`

**403** – Caller lacks ai_assistant.settings.manage.

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/ai_assistant/settings/allowlist" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"allowedProviders\": null
}"
```

## GET `/ai_assistant/tools`

List available MCP tools filtered by user permissions

**Tags:** AI Assistant

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/tools" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/ai_assistant/tools/execute`

Execute a specific MCP tool by name

**Tags:** AI Assistant

**Requires authentication.**

### Responses

**201** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/ai_assistant/tools/execute" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/ai_assistant/usage/daily`

Fetch daily token-usage rollup rows for a date window.

Returns aggregated token-usage data from `ai_token_usage_daily` for the given date window. Tenant-scoped. Optionally filtered by `agentId` and/or `modelId`. Requires `ai_assistant.settings.manage`.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| from | query | any | Required |
| to | query | any | Required |
| agentId | query | any | Optional |
| modelId | query | any | Optional |

### Responses

**200** – Array of daily rollup rows.

Content-Type: `application/json`

**400** – Invalid query parameters.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks `ai_assistant.settings.manage`.

Content-Type: `application/json`

**500** – Internal failure.

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/usage/daily?from=string&to=string" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/ai_assistant/usage/sessions`

List per-session token usage totals for a date window.

Returns aggregated token-usage data grouped by `session_id` from `ai_token_usage_events` for the given date window. Tenant-scoped. Optionally filtered by `agentId`. Paginated via `limit` / `offset`. Requires `ai_assistant.settings.manage`.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| from | query | any | Required |
| to | query | any | Required |
| agentId | query | any | Optional |
| limit | query | any | Required |
| offset | query | any | Required |

### Responses

**200** – Array of session-level usage summaries plus pagination metadata.

Content-Type: `application/json`

**400** – Invalid query parameters.

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks `ai_assistant.settings.manage`.

Content-Type: `application/json`

**500** – Internal failure.

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/usage/sessions?from=string&to=string" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/ai_assistant/usage/sessions/{sessionId}`

Fetch per-step token usage event rows for a single session.

Returns up to 200 raw `ai_token_usage_events` rows for the given `sessionId`, ordered by `created_at ASC, step_index ASC`. Tenant-scoped. Requires `ai_assistant.settings.manage`.

**Tags:** AI Assistant

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| sessionId | path | any | Required |

### Responses

**200** – Array of per-step event rows for the session.

Content-Type: `application/json`

**400** – Invalid session id (must be a UUID).

Content-Type: `application/json`

**401** – Unauthenticated caller.

Content-Type: `application/json`

**403** – Caller lacks `ai_assistant.settings.manage`.

Content-Type: `application/json`

**404** – No events found for the given session id in the caller's tenant.

Content-Type: `application/json`

**500** – Internal failure.

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/ai_assistant/usage/sessions/:sessionId" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/api_keys/keys`

Delete API key

Removes an API key by identifier. The key must belong to the current tenant and fall within the requester organization scope.

**Tags:** API Keys

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | query | any | Required. API key identifier to delete |

### Responses

**200** – Key deleted successfully

Content-Type: `application/json`

```json
{
  "success": true
}
```

**400** – Missing or invalid identifier

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside allowed scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Key not found within scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/api_keys/keys?id=00000000-0000-4000-8000-000000000000" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/api_keys/keys`

List API keys

Returns paginated API keys visible to the current user, including per-key role assignments and organization context.

**Tags:** API Keys

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| search | query | any | Optional |

### Responses

**200** – Collection of API keys

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "string",
      "name": "string",
      "description": null,
      "keyPrefix": "string",
      "organizationId": null,
      "organizationName": null,
      "createdAt": "string",
      "lastUsedAt": null,
      "expiresAt": null,
      "roles": [
        {
          "id": "string",
          "name": null
        }
      ]
    }
  ],
  "total": 1,
  "page": 1,
  "pageSize": 1,
  "totalPages": 1
}
```

**400** – Tenant context missing

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Forbidden by organization scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/api_keys/keys" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/api_keys/keys`

Create API key

Creates a new API key, returning the one-time secret value together with the generated key prefix and scope details.

**Tags:** API Keys

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "name": "string",
  "description": null,
  "tenantId": null,
  "organizationId": null,
  "roles": [],
  "expiresAt": null
}
```

### Responses

**201** – API key created successfully

Content-Type: `application/json`

```json
{
  "id": "string",
  "name": "string",
  "keyPrefix": "string",
  "tenantId": null,
  "organizationId": null,
  "roles": [
    {
      "id": "string",
      "name": null
    }
  ]
}
```

**400** – Invalid payload or missing tenant context

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside allowed scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/api_keys/keys" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"name\": \"string\",
  \"description\": null,
  \"tenantId\": null,
  \"organizationId\": null,
  \"roles\": [],
  \"expiresAt\": null
}"
```

## DELETE `/attachments`

Delete attachment

Removes an uploaded attachment and deletes the stored asset.

**Tags:** Attachments

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | query | any | Required |

### Responses

**200** – Attachment deleted

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Missing attachment identifier

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Attachment not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/attachments?id=00000000-0000-4000-8000-000000000000" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/attachments`

List attachments for a record

Returns uploaded attachments for the given entity record, ordered by newest first.

**Tags:** Attachments

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| entityId | query | any | Required. Entity identifier that owns the attachments |
| recordId | query | any | Required. Record identifier within the entity |
| page | query | any | Optional |
| pageSize | query | any | Optional |

### Responses

**200** – Attachments found for the record

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "string",
      "url": "string",
      "fileName": "string",
      "fileSize": 1,
      "createdAt": "string",
      "mimeType": null,
      "content": null
    }
  ]
}
```

**400** – Missing entity or record identifiers

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/attachments?entityId=string&recordId=string" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/attachments`

Upload attachment

Uploads a new attachment using multipart form-data and stores metadata for later retrieval.

**Tags:** Attachments

**Requires authentication.**

### Request Body

Content-Type: `multipart/form-data`

```text
entityId=string
recordId=string
file=string
```

### Responses

**200** – Attachment stored successfully

Content-Type: `application/json`

```json
{
  "ok": true,
  "item": {
    "id": "string",
    "url": "string",
    "fileName": "string",
    "fileSize": 1,
    "content": null
  }
}
```

**400** – Payload validation error

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Attachment violates field constraints

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/attachments" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: multipart/form-data" \
  -d "{
  \"entityId\": \"string\",
  \"recordId\": \"string\",
  \"file\": \"string\"
}"
```

## GET `/attachments/file/{id}`

Download or serve attachment file

Returns the raw file content for an attachment. Path parameter: {id} - Attachment UUID. Query parameter: ?download=1 - Force file download with Content-Disposition header. Access control is enforced based on partition settings.

**Tags:** Attachments

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – File content with appropriate MIME type

Content-Type: `application/json`

**400** – Missing attachment ID

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized - authentication required for private partitions

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Forbidden - insufficient permissions

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Attachment or file not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Partition misconfigured

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/attachments/file/:id" \
  -H "Accept: application/json"
```

## GET `/attachments/image/{id}/{slug}`

Serve image with optional resizing

Returns an image attachment with optional on-the-fly resizing and cropping. Resized images are cached for performance. Only works with image MIME types. Path parameter: {id} - Attachment UUID. Query parameters: ?width=N (1-4000 pixels), ?height=N (1-4000 pixels), ?cropType=cover|contain (resize behavior).

**Tags:** Attachments

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |
| slug | path | any | Optional |

### Responses

**200** – Binary image content (Content-Type: image/jpeg, image/png, etc.)

Content-Type: `application/json`

**400** – Invalid parameters, missing ID, or non-image attachment

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized - authentication required for private partitions

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Forbidden - insufficient permissions

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Image not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Partition misconfigured or image rendering failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/attachments/image/:id/:slug" \
  -H "Accept: application/json"
```

## GET `/attachments/library`

List attachments

Returns paginated list of attachments with optional filtering by search term, partition, and tags. Includes available tags and partitions.

**Tags:** Attachments

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional. Page number for pagination |
| pageSize | query | any | Optional. Number of items per page (max 100) |
| search | query | any | Optional. Search by file name (case-insensitive) |
| partition | query | any | Optional. Filter by partition code |
| tags | query | any | Optional. Filter by tags (comma-separated) |
| sortField | query | any | Optional. Field to sort by |
| sortDir | query | any | Optional. Sort direction |

### Responses

**200** – Attachments list with pagination and metadata

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "fileName": "string",
      "fileSize": 1,
      "mimeType": "string",
      "partitionCode": "string",
      "partitionTitle": null,
      "url": null,
      "createdAt": "string",
      "tags": [
        "string"
      ],
      "assignments": [],
      "content": null
    }
  ],
  "total": 1,
  "page": 1,
  "pageSize": 1,
  "totalPages": 1,
  "availableTags": [
    "string"
  ],
  "partitions": [
    {
      "code": "string",
      "title": "string",
      "description": null,
      "isPublic": true
    }
  ]
}
```

**400** – Invalid query parameters

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/attachments/library?page=1&pageSize=25" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/attachments/library/{id}`

Delete attachment

Permanently deletes an attachment file from storage and database. Emits CRUD side effects.

**Tags:** Attachments

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Attachment deleted successfully

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Invalid attachment ID

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Attachment not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/attachments/library/:id" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/attachments/library/{id}`

Get attachment details

Returns complete details of an attachment including metadata, tags, assignments, and custom fields.

**Tags:** Attachments

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Attachment details

Content-Type: `application/json`

```json
{
  "item": {
    "id": "00000000-0000-4000-8000-000000000000",
    "fileName": "string",
    "fileSize": 1,
    "mimeType": "string",
    "partitionCode": "string",
    "partitionTitle": null,
    "tags": [
      "string"
    ],
    "assignments": [],
    "content": null,
    "customFields": null
  }
}
```

**400** – Invalid attachment ID

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Attachment not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/attachments/library/:id" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PATCH `/attachments/library/{id}`

Update attachment metadata

Updates attachment tags, assignments, and custom fields. Emits CRUD side effects for indexing and events.

**Tags:** Attachments

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Request Body

Content-Type: `application/json`

```json
{}
```

### Responses

**200** – Attachment updated successfully

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Invalid payload or attachment ID

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Attachment not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Failed to save attributes

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PATCH "https://manifaktura.vicoop.com/api/attachments/library/:id" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{}"
```

## DELETE `/attachments/partitions`

Delete partition

Deletes a partition. Default partitions cannot be deleted. Partitions with existing attachments cannot be deleted.

**Tags:** Attachments

**Requires authentication.**

### Responses

**200** – Partition deleted successfully

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Invalid ID or default partition deletion attempt

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Partitions locked in demo mode

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Partition not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Partition in use

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/attachments/partitions" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/attachments/partitions`

List all attachment partitions

Returns all configured attachment partitions with storage settings, OCR configuration, and access control settings.

**Tags:** Attachments

**Requires authentication.**

### Responses

**200** – List of partitions

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "code": "string",
      "title": "string",
      "description": null,
      "isPublic": true,
      "requiresOcr": true,
      "ocrModel": null,
      "configJson": null,
      "createdAt": null,
      "updatedAt": null,
      "envKey": "string"
    }
  ]
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/attachments/partitions" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/attachments/partitions`

Create new partition

Creates a new attachment partition with specified storage and OCR settings. Requires unique partition code.

**Tags:** Attachments

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "code": "string",
  "title": "string",
  "description": null,
  "ocrModel": null,
  "storageDriver": "local",
  "configJson": null
}
```

### Responses

**201** – Partition created successfully

Content-Type: `application/json`

```json
{
  "item": {
    "id": "00000000-0000-4000-8000-000000000000",
    "code": "string",
    "title": "string",
    "description": null,
    "isPublic": true,
    "requiresOcr": true,
    "ocrModel": null,
    "configJson": null,
    "createdAt": null,
    "updatedAt": null,
    "envKey": "string"
  }
}
```

**400** – Invalid payload or partition code

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Partitions locked in demo mode

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Partition code already exists

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/attachments/partitions" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"code\": \"string\",
  \"title\": \"string\",
  \"description\": null,
  \"ocrModel\": null,
  \"storageDriver\": \"local\",
  \"configJson\": null
}"
```

## PUT `/attachments/partitions`

Update partition

Updates an existing partition. Partition code cannot be changed. Title, description, OCR settings, and access control can be modified.

**Tags:** Attachments

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "code": "string",
  "title": "string",
  "description": null,
  "ocrModel": null,
  "storageDriver": "local",
  "configJson": null,
  "id": "00000000-0000-4000-8000-000000000000"
}
```

### Responses

**200** – Partition updated successfully

Content-Type: `application/json`

```json
{
  "item": {
    "id": "00000000-0000-4000-8000-000000000000",
    "code": "string",
    "title": "string",
    "description": null,
    "isPublic": true,
    "requiresOcr": true,
    "ocrModel": null,
    "configJson": null,
    "createdAt": null,
    "updatedAt": null,
    "envKey": "string"
  }
}
```

**400** – Invalid payload or code change attempt

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Partitions locked in demo mode

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Partition not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/attachments/partitions" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"code\": \"string\",
  \"title\": \"string\",
  \"description\": null,
  \"ocrModel\": null,
  \"storageDriver\": \"local\",
  \"configJson\": null,
  \"id\": \"00000000-0000-4000-8000-000000000000\"
}"
```

## POST `/attachments/transfer`

Transfer attachments to different record

Transfers one or more attachments from one record to another within the same entity type. Updates attachment assignments and metadata to reflect the new record.

**Tags:** Attachments

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entityId": "string",
  "attachmentIds": [
    "00000000-0000-4000-8000-000000000000"
  ],
  "toRecordId": "string"
}
```

### Responses

**200** – Attachments transferred successfully

Content-Type: `application/json`

```json
{
  "ok": true,
  "updated": 1
}
```

**400** – Invalid payload

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Attachments not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Attachment model missing

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/attachments/transfer" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entityId\": \"string\",
  \"attachmentIds\": [
    \"00000000-0000-4000-8000-000000000000\"
  ],
  \"toRecordId\": \"string\"
}"
```

## GET `/audit_logs/audit-logs/access`

Retrieve access logs

Fetches paginated access audit logs scoped to the authenticated user. Tenant administrators can optionally expand the search to other actors or organizations.

**Tags:** Audit & Action Logs

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| organizationId | query | any | Optional. Limit results to a specific organization |
| actorUserId | query | any | Optional. Filter by actor user id (tenant administrators only) |
| resourceKind | query | any | Optional. Restrict to a resource kind such as `order` or `product` |
| accessType | query | any | Optional. Access type filter, e.g. `read` or `export` |
| page | query | any | Optional. Page number (default 1) |
| pageSize | query | any | Optional. Page size (default 50) |
| limit | query | any | Optional. Explicit maximum number of records when paginating manually |
| before | query | any | Optional. Return logs created before this ISO-8601 timestamp |
| after | query | any | Optional. Return logs created after this ISO-8601 timestamp |

### Responses

**200** – Access logs returned successfully

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "string",
      "resourceKind": "string",
      "resourceId": "string",
      "accessType": "string",
      "actorUserId": null,
      "actorUserName": null,
      "tenantId": null,
      "tenantName": null,
      "organizationId": null,
      "organizationName": null,
      "fields": [
        "string"
      ],
      "context": null,
      "createdAt": "string"
    }
  ],
  "canViewTenant": true,
  "page": 1,
  "pageSize": 1,
  "total": 1,
  "totalPages": 1
}
```

**400** – Invalid filters supplied

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Caller has no resolved tenant scope and is not a superadmin

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/audit_logs/audit-logs/access" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/audit_logs/audit-logs/actions`

Fetch action logs

Returns recent action audit log entries. Tenant administrators can widen the scope to other actors or organizations, and callers can optionally restrict results to undoable actions.

**Tags:** Audit & Action Logs

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| organizationId | query | any | Optional. Limit results to a specific organization |
| actorUserId | query | any | Optional. Filter logs created by specific actor IDs (tenant administrators only). Accepts a single UUID or a comma-separated UUID list. |
| resourceKind | query | any | Optional. Filter by resource kind (e.g., "order", "product") |
| resourceId | query | any | Optional. Filter by resource ID (UUID of the specific record) |
| actionType | query | any | Optional. Filter by action type (`create`, `edit`, `delete`, `assign`). Accepts a single value or a comma-separated list. |
| fieldName | query | any | Optional. Filter to entries where the given field changed. Accepts a single field name or a comma-separated list. |
| includeRelated | query | any | Optional. When `true`, also returns changes to child entities linked via parentResourceKind/parentResourceId |
| includeTotal | query | any | Optional. When `true`, the response includes the filtered total count. |
| undoableOnly | query | any | Optional. When `true`, only undoable actions are returned |
| limit | query | any | Optional. Maximum number of records to return (default 50, max 1000) |
| offset | query | any | Optional. Zero-based record offset for pagination (legacy — prefer page/pageSize) |
| page | query | any | Optional. Page number (default 1) |
| pageSize | query | any | Optional. Page size (default 50, max 200) |
| sortField | query | any | Optional. Sort field: `createdAt`, `user`, `action`, `field`, or `source`. |
| sortDir | query | any | Optional. Sort direction: `asc` or `desc`. |
| before | query | any | Optional. Return actions created before this ISO-8601 timestamp |
| after | query | any | Optional. Return actions created after this ISO-8601 timestamp |

### Responses

**200** – Action logs retrieved successfully

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "string",
      "commandId": "string",
      "actionLabel": null,
      "executionState": "done",
      "actorUserId": null,
      "actorUserName": null,
      "tenantId": null,
      "tenantName": null,
      "organizationId": null,
      "organizationName": null,
      "resourceKind": null,
      "resourceId": null,
      "parentResourceKind": null,
      "parentResourceId": null,
      "undoToken": null,
      "createdAt": "string",
      "updatedAt": "string",
      "snapshotBefore": null,
      "snapshotAfter": null,
      "changes": null,
      "context": null
    }
  ],
  "canViewTenant": true,
  "page": 1,
  "pageSize": 1,
  "total": 1,
  "totalPages": 1
}
```

**400** – Invalid filter values

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Caller has no resolved tenant scope and is not a superadmin

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/audit_logs/audit-logs/actions?includeRelated=false&includeTotal=false&undoableOnly=false" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/audit_logs/audit-logs/actions/export`

Export action logs as CSV

Returns a CSV attachment containing filtered action audit log entries. Tenant administrators can widen the scope to other actors or organizations.

**Tags:** Audit & Action Logs

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| organizationId | query | any | Optional. Limit results to a specific organization |
| actorUserId | query | any | Optional. Filter logs created by specific actor IDs (tenant administrators only). Accepts a single UUID or a comma-separated UUID list. |
| resourceKind | query | any | Optional. Filter by resource kind (e.g., "order", "product") |
| resourceId | query | any | Optional. Filter by resource ID (UUID of the specific record) |
| actionType | query | any | Optional. Filter by action type (`create`, `edit`, `delete`, `assign`). Accepts a single value or a comma-separated list. |
| fieldName | query | any | Optional. Filter to entries where the given field changed. Accepts a single field name or a comma-separated list. |
| includeRelated | query | any | Optional. When `true`, also returns changes to child entities linked via parentResourceKind/parentResourceId |
| undoableOnly | query | any | Optional. When `true`, only undoable actions are returned |
| limit | query | any | Optional. Maximum number of records to export (default 1000, capped at 1000) |
| sortField | query | any | Optional. Sort field: `createdAt`, `user`, `action`, `field`, or `source`. |
| sortDir | query | any | Optional. Sort direction: `asc` or `desc`. |
| before | query | any | Optional. Return actions created before this ISO-8601 timestamp |
| after | query | any | Optional. Return actions created after this ISO-8601 timestamp |

### Responses

**200** – CSV export generated successfully

Content-Type: `application/json`

```json
{
  "file": "csv"
}
```

**400** – Invalid filter values

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Caller has no resolved tenant scope and is not a superadmin

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/audit_logs/audit-logs/actions/export?includeRelated=false&undoableOnly=false" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/audit_logs/audit-logs/actions/redo`

Redo by action log id

Redoes the latest undone command owned by the caller. Requires the action to still be eligible for redo within tenant and organization scope.

**Tags:** Audit & Action Logs

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "logId": "string"
}
```

### Responses

**200** – Redo executed successfully

Content-Type: `application/json`

```json
{
  "ok": true,
  "logId": null,
  "undoToken": null
}
```

**400** – Log not eligible for redo

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Redo blocked by scope checks

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/audit_logs/audit-logs/actions/redo" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"logId\": \"string\"
}"
```

## POST `/audit_logs/audit-logs/actions/undo`

Undo action by token

Replays the undo handler registered for a command. The provided undo token must match the latest undoable log entry accessible to the caller.

**Tags:** Audit & Action Logs

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "undoToken": "string"
}
```

### Responses

**200** – Undo applied successfully

Content-Type: `application/json`

```json
{
  "ok": true,
  "logId": "string"
}
```

**400** – Invalid or unavailable undo token

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Undo blocked by organization or tenant scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Undo deliberately blocked by a beforeUndo command interceptor. The interceptor chooses the status (any 4xx/5xx) and may replace the body.

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/audit_logs/audit-logs/actions/undo" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"undoToken\": \"string\"
}"
```

## GET `/auth/admin/nav`

Resolve backend chrome bootstrap payload

Returns the backend chrome payload available to the authenticated administrator after applying scope, RBAC, role defaults, and personal sidebar preferences.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Responses

**200** – Backend chrome payload

Content-Type: `application/json`

```json
{
  "brand": null,
  "groups": [
    {
      "name": "string",
      "items": [
        {
          "href": "string",
          "title": "string"
        }
      ]
    }
  ],
  "settingsSections": [
    {
      "id": "string",
      "label": "string",
      "items": [
        {
          "id": "string",
          "label": "string",
          "href": "string"
        }
      ]
    }
  ],
  "settingsPathPrefixes": [
    "string"
  ],
  "profileSections": [
    {
      "id": "string",
      "label": "string",
      "items": [
        {
          "id": "string",
          "label": "string",
          "href": "string"
        }
      ]
    }
  ],
  "profilePathPrefixes": [
    "string"
  ],
  "grantedFeatures": [
    "string"
  ],
  "roles": [
    "string"
  ],
  "currentOrganization": null
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/auth/admin/nav" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/auth/autologin`

Auto sign-in using env-configured demo credentials

When OM_AUTOLOGIN_EMAIL / OM_AUTOLOGIN_PASSWORD are configured, signs the visitor in with those credentials and redirects into the app. Intended for single-tenant demo instances only. Falls back to the login page when disabled or misconfigured.

**Tags:** Authentication & Accounts

### Responses

**200** – Success response

Content-Type: `application/json`

**307** – Redirect into the app (or to /login on failure)

Content-Type: `text/html`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/auth/autologin" \
  -H "Accept: application/json"
```

## POST `/auth/feature-check`

Check feature grants for the current user

Evaluates which of the requested features are available to the signed-in user within the active tenant / organization context.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "features": [
    "string"
  ]
}
```

### Responses

**200** – Evaluation result

Content-Type: `application/json`

```json
{
  "ok": true,
  "granted": [
    "string"
  ],
  "userId": "string"
}
```

**400** – Invalid request — features array missing, too large, or contains invalid entries

Content-Type: `application/json`

```json
{
  "ok": false,
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "ok": false,
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/auth/feature-check" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"features\": [
    \"string\"
  ]
}"
```

## GET `/auth/features`

List declared feature flags

Returns all static features contributed by the enabled modules along with their module source.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Responses

**200** – Aggregated feature catalog

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "string",
      "title": "string",
      "module": "string"
    }
  ],
  "modules": [
    {
      "id": "string",
      "title": "string"
    }
  ]
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/auth/features" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/auth/locale`

Set locale and redirect

Stores the selected locale in a cookie and redirects to a safe local path.

**Tags:** Authentication & Accounts

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| locale | query | any | Required. A locale code this tenant serves — one of the `servable` entries returned by `GET /api/translations/locales`. Codes are canonicalized (`de-AT` → `de`). |
| redirect | query | any | Optional |

### Responses

**200** – Success response

Content-Type: `application/json`

**302** – Locale cookie set and request redirected

Content-Type: `application/json`

**400** – Invalid locale

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/auth/locale?locale=string" \
  -H "Accept: application/json"
```

## POST `/auth/locale`

Set locale

Stores the selected locale in a cookie and returns a JSON success response.

**Tags:** Authentication & Accounts

### Request Body

Content-Type: `application/json`

```json
{
  "locale": "string"
}
```

### Responses

**200** – Locale cookie set

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Invalid locale or malformed request body

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/auth/locale" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"locale\": \"string\"
}"
```

## POST `/auth/login`

Authenticate user credentials

Validates the submitted credentials and issues a bearer token cookie for subsequent API calls.

**Tags:** Authentication & Accounts

### Request Body

Content-Type: `application/x-www-form-urlencoded`

```text
email=user%40example.com&password=string
```

### Responses

**200** – Authentication succeeded

Content-Type: `application/json`

```json
{
  "ok": true,
  "token": "string",
  "redirect": null
}
```

**400** – Validation failed

Content-Type: `application/json`

```json
{
  "ok": false,
  "error": "string"
}
```

**401** – Invalid credentials

Content-Type: `application/json`

```json
{
  "ok": false,
  "error": "string"
}
```

**403** – User lacks required role

Content-Type: `application/json`

```json
{
  "ok": false,
  "error": "string"
}
```

**429** – Too many login attempts

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/auth/login" \
  -H "Accept: application/json" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "email=user%40example.com&password=string"
```

## POST `/auth/logout`

Invalidate session and redirect

Clears authentication cookies and redirects the browser to the login page.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Responses

**201** – Success response

Content-Type: `application/json`

**302** – Redirect to login after successful logout

Content-Type: `text/html`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/auth/logout" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/auth/profile`

Get current profile

Returns the email address, display name, and roles for the signed-in user. The display name is null when unset.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Responses

**200** – Profile payload

Content-Type: `application/json`

```json
{
  "email": "user@example.com",
  "name": null,
  "roles": [
    "string"
  ]
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – User not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/auth/profile" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/auth/profile`

Update current profile

Updates the email address or password for the signed-in user.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{}
```

### Responses

**200** – Profile updated

Content-Type: `application/json`

```json
{
  "ok": true,
  "email": "user@example.com"
}
```

**400** – Invalid payload

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/auth/profile" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{}"
```

## POST `/auth/reset`

Send reset email

Requests a password reset email for the given account. The endpoint always returns `ok: true` to avoid leaking account existence.

**Tags:** Authentication & Accounts

### Request Body

Content-Type: `application/x-www-form-urlencoded`

```text
email=user%40example.com
```

### Responses

**200** – Reset email dispatched (or ignored for unknown accounts)

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Invalid request origin

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**429** – Too many password reset requests

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Password reset email origin is not configured

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/auth/reset" \
  -H "Accept: application/json" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "email=user%40example.com"
```

## POST `/auth/reset/confirm`

Complete password reset

Validates the reset token and updates the user password.

**Tags:** Authentication & Accounts

### Request Body

Content-Type: `application/x-www-form-urlencoded`

```text
token=string&password=string
```

### Responses

**200** – Password reset succeeded

Content-Type: `application/json`

```json
{
  "ok": true,
  "redirect": "string"
}
```

**400** – Invalid token or payload

Content-Type: `application/json`

```json
{
  "ok": false,
  "error": "string"
}
```

**429** – Too many reset confirmation attempts

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/auth/reset/confirm" \
  -H "Accept: application/json" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "token=string&password=string"
```

## POST `/auth/reset/validate`

Check whether a password reset token is still usable

Reports whether a reset token exists, is unused, and has not expired, so the reset page can render a terminal state instead of a form the token can never submit. The token is never consumed and the response never distinguishes unknown, used, and expired tokens.

**Tags:** Authentication & Accounts

### Request Body

Content-Type: `application/x-www-form-urlencoded`

```text
token=string
```

### Responses

**200** – Token state resolved

Content-Type: `application/json`

```json
{
  "ok": true,
  "valid": true
}
```

**429** – Too many token validation attempts

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/auth/reset/validate" \
  -H "Accept: application/json" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "token=string"
```

## DELETE `/auth/roles`

Delete role

Deletes a role by identifier. Fails when users remain assigned.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | query | any | Required. Role identifier |

### Responses

**200** – Role deleted

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Role cannot be deleted

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Role not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/auth/roles?id=00000000-0000-4000-8000-000000000000" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/auth/roles`

List roles

Returns available roles within the current tenant. Super administrators receive visibility across tenants.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | query | any | Optional |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| search | query | any | Optional |
| tenantId | query | any | Optional |

### Responses

**200** – Role collection

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "name": "string",
      "usersCount": 1,
      "tenantId": null,
      "tenantName": null,
      "updatedAt": null
    }
  ],
  "total": 1,
  "totalPages": 1
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/auth/roles?page=1&pageSize=50" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/auth/roles`

Create role

Creates a new role anchored to the caller's tenant. Non-superadmins cannot target another tenant; supplying a foreign `tenantId` is rejected.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "name": "string"
}
```

### Responses

**201** – Role created

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000"
}
```

**400** – Invalid payload

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/auth/roles" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"name\": \"string\"
}"
```

## PUT `/auth/roles`

Update role

Updates mutable fields on an existing role.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000"
}
```

### Responses

**200** – Role updated

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Invalid payload

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Role not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/auth/roles" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\"
}"
```

## GET `/auth/roles/acl`

Fetch role ACL

Returns the feature and organization assignments associated with a role within the current tenant.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| roleId | query | any | Required |
| tenantId | query | any | Optional |

### Responses

**200** – Role ACL entry

Content-Type: `application/json`

```json
{
  "isSuperAdmin": true,
  "features": [
    "string"
  ],
  "organizations": null,
  "updatedAt": null
}
```

**400** – Invalid role id

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Role not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/auth/roles/acl?roleId=00000000-0000-4000-8000-000000000000" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/auth/roles/acl`

Update role ACL

Replaces the feature list, super admin flag, and optional organization assignments for a role.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "roleId": "00000000-0000-4000-8000-000000000000",
  "organizations": null
}
```

### Responses

**200** – Role ACL updated

Content-Type: `application/json`

```json
{
  "ok": true,
  "sanitized": true
}
```

**400** – Invalid payload

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Insufficient privileges to modify ACL

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Role not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/auth/roles/acl" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"roleId\": \"00000000-0000-4000-8000-000000000000\",
  \"organizations\": null
}"
```

## GET `/auth/session/refresh`

Refresh auth cookie from session token (browser)

Exchanges an existing `session_token` cookie for a fresh JWT auth cookie and redirects the browser.

**Tags:** Authentication & Accounts

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| redirect | query | any | Optional. Absolute or relative URL to redirect after refresh |

### Responses

**200** – Success response

Content-Type: `application/json`

**302** – Redirect to target location when session is valid

Content-Type: `text/html`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/auth/session/refresh" \
  -H "Accept: application/json"
```

## POST `/auth/session/refresh`

Refresh access token (API/mobile)

Exchanges a refresh token for a new JWT access token. Pass the refresh token obtained from login in the request body.

**Tags:** Authentication & Accounts

### Request Body

Content-Type: `application/json`

```json
{
  "refreshToken": "string"
}
```

### Responses

**200** – New access token issued

Content-Type: `application/json`

```json
{
  "ok": true,
  "accessToken": "string",
  "expiresIn": 1
}
```

**400** – Missing refresh token

Content-Type: `application/json`

```json
{
  "ok": false,
  "error": "string"
}
```

**401** – Invalid or expired token

Content-Type: `application/json`

```json
{
  "ok": false,
  "error": "string"
}
```

**429** – Too many refresh attempts

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/auth/session/refresh" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"refreshToken\": \"string\"
}"
```

## DELETE `/auth/sidebar/preferences`

Delete a role sidebar variant

Removes the role variant for the current tenant + locale. Idempotent. Requires `auth.sidebar.manage`.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Responses

**200** – Variant deleted (or never existed)

Content-Type: `application/json`

```json
{
  "ok": true,
  "scope": {
    "type": "user"
  }
}
```

**400** – Missing roleId query parameter

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing features

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Role not found in current tenant scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/auth/sidebar/preferences" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/auth/sidebar/preferences`

Get sidebar preferences

Returns sidebar customization for the current user (default) or the specified role (`?roleId=…`, requires `auth.sidebar.manage`).

**Tags:** Authentication & Accounts

**Requires authentication.**

### Responses

**200** – Current sidebar configuration

Content-Type: `application/json`

```json
{
  "locale": "string",
  "settings": {
    "version": 1,
    "groupOrder": [
      "string"
    ],
    "groupLabels": {
      "key": "string"
    },
    "itemLabels": {
      "key": "string"
    },
    "hiddenItems": [
      "string"
    ],
    "itemOrder": {
      "key": [
        "string"
      ]
    }
  },
  "canApplyToRoles": true,
  "roles": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "name": "string",
      "hasPreference": true
    }
  ],
  "scope": {
    "type": "user"
  },
  "updatedAt": null
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing features for role-scope read

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Role not found in current tenant scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/auth/sidebar/preferences" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/auth/sidebar/preferences`

Update sidebar preferences

Updates sidebar configuration. With `scope.type === "user"` (default) writes the calling user's personal preferences and may optionally apply the same settings to selected roles via `applyToRoles[]`. With `scope.type === "role"` writes the named role variant directly (requires `auth.sidebar.manage`); `applyToRoles[]` and `clearRoleIds[]` are rejected in this mode.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{}
```

### Responses

**200** – Preferences saved

Content-Type: `application/json`

```json
{
  "locale": "string",
  "settings": {
    "version": 1,
    "groupOrder": [
      "string"
    ],
    "groupLabels": {
      "key": "string"
    },
    "itemLabels": {
      "key": "string"
    },
    "hiddenItems": [
      "string"
    ],
    "itemOrder": {
      "key": [
        "string"
      ]
    }
  },
  "canApplyToRoles": true,
  "roles": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "name": "string",
      "hasPreference": true
    }
  ],
  "scope": {
    "type": "user"
  },
  "updatedAt": null,
  "appliedRoles": [
    "00000000-0000-4000-8000-000000000000"
  ],
  "clearedRoles": [
    "00000000-0000-4000-8000-000000000000"
  ]
}
```

**400** – Invalid payload

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing features for role-wide updates

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Role not found in current tenant scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/auth/sidebar/preferences" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{}"
```

## GET `/auth/sidebar/variants`

List sidebar variants

Returns the named sidebar variants saved by the current user for the current tenant + locale.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Responses

**200** – Variant list

Content-Type: `application/json`

```json
{
  "locale": "string",
  "variants": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "name": "string",
      "isActive": true,
      "settings": {
        "version": 1,
        "groupOrder": [
          "string"
        ],
        "groupLabels": {
          "key": "string"
        },
        "itemLabels": {
          "key": "string"
        },
        "hiddenItems": [
          "string"
        ],
        "itemOrder": {
          "key": [
            "string"
          ]
        }
      },
      "createdAt": "string",
      "updatedAt": null
    }
  ]
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/auth/sidebar/variants" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/auth/sidebar/variants`

Create a sidebar variant

Creates a new variant. If `name` is omitted or blank, an auto-name like "My preferences", "My preferences 2", … is assigned.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{}
```

### Responses

**200** – Variant created

Content-Type: `application/json`

```json
{
  "locale": "string",
  "variant": {
    "id": "00000000-0000-4000-8000-000000000000",
    "name": "string",
    "isActive": true,
    "settings": {
      "version": 1,
      "groupOrder": [
        "string"
      ],
      "groupLabels": {
        "key": "string"
      },
      "itemLabels": {
        "key": "string"
      },
      "hiddenItems": [
        "string"
      ],
      "itemOrder": {
        "key": [
          "string"
        ]
      }
    },
    "createdAt": "string",
    "updatedAt": null
  }
}
```

**400** – Invalid payload

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/auth/sidebar/variants" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{}"
```

## DELETE `/auth/sidebar/variants/{id}`

Delete a sidebar variant

Soft-deletes the variant (sets deleted_at).

**Tags:** Authentication & Accounts

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Variant deleted

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Variant not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/auth/sidebar/variants/:id" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/auth/sidebar/variants/{id}`

Get a sidebar variant

**Tags:** Authentication & Accounts

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Variant

Content-Type: `application/json`

```json
{
  "locale": "string",
  "variant": {
    "id": "00000000-0000-4000-8000-000000000000",
    "name": "string",
    "isActive": true,
    "settings": {
      "version": 1,
      "groupOrder": [
        "string"
      ],
      "groupLabels": {
        "key": "string"
      },
      "itemLabels": {
        "key": "string"
      },
      "hiddenItems": [
        "string"
      ],
      "itemOrder": {
        "key": [
          "string"
        ]
      }
    },
    "createdAt": "string",
    "updatedAt": null
  }
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Variant not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/auth/sidebar/variants/:id" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/auth/sidebar/variants/{id}`

Update a sidebar variant

Updates the variant's name, settings, and/or isActive flag. Setting `isActive: true` deactivates other variants in the same scope (only one active per user/tenant/locale).

**Tags:** Authentication & Accounts

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Request Body

Content-Type: `application/json`

```json
{}
```

### Responses

**200** – Variant updated

Content-Type: `application/json`

```json
{
  "locale": "string",
  "variant": {
    "id": "00000000-0000-4000-8000-000000000000",
    "name": "string",
    "isActive": true,
    "settings": {
      "version": 1,
      "groupOrder": [
        "string"
      ],
      "groupLabels": {
        "key": "string"
      },
      "itemLabels": {
        "key": "string"
      },
      "hiddenItems": [
        "string"
      ],
      "itemOrder": {
        "key": [
          "string"
        ]
      }
    },
    "createdAt": "string",
    "updatedAt": null
  }
}
```

**400** – Invalid payload

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Variant not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/auth/sidebar/variants/:id" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{}"
```

## DELETE `/auth/users`

Delete user

Deletes a user by identifier. Rejected when the target is the last active holder of a protected role in the tenant. Undo support is provided via the command bus.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | query | any | Required. User identifier |

### Responses

**200** – User deleted

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – User cannot be deleted, or is the last active holder of a protected role

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – User not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/auth/users?id=00000000-0000-4000-8000-000000000000" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/auth/users`

List users

Returns users for the effective selected tenant and organization scope. Search matches email, organization name, and role name. Super administrators may scope the response via the topbar context, organization filters, or role filters. Pass scopeToActiveOrganization=1 to restrict results to the caller's active organization (used by recipient/assignee pickers so suggestions stay within the org that owns the resulting record). Pass ids=<uuid>,<uuid> (max 100) to resolve a known set of users in one request, for example to label a list of foreign keys; it intersects with id and roleId, and a supplied ids value that contains no valid identifier matches nothing.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | query | any | Optional |
| ids | query | any | Optional. Comma-separated user identifiers, at most 100 |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| search | query | any | Optional |
| name | query | any | Optional |
| organizationId | query | any | Optional |
| scopeToActiveOrganization | query | any | Optional |
| roleIds | query | any | Optional |

### Responses

**200** – User collection

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "email": "user@example.com",
      "name": null,
      "organizationId": null,
      "organizationName": null,
      "tenantId": null,
      "tenantName": null,
      "roles": [
        "string"
      ],
      "isConfirmed": true,
      "updatedAt": null
    }
  ],
  "total": 1,
  "totalPages": 1
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/auth/users?page=1&pageSize=50" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/auth/users`

Create user

Creates a new confirmed user within the specified organization, optional display name, and optional roles.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "email": "user@example.com",
  "name": null,
  "organizationId": "00000000-0000-4000-8000-000000000000"
}
```

### Responses

**201** – User created

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000"
}
```

**400** – Invalid payload or duplicate email

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Attempted to assign privileged roles

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/auth/users" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"email\": \"user@example.com\",
  \"name\": null,
  \"organizationId\": \"00000000-0000-4000-8000-000000000000\"
}"
```

## PUT `/auth/users`

Update user

Updates profile fields including display name, organization assignment, credentials, or role memberships. A destination organization must be within the caller's descendant-expanded organization scope. Retained and newly assigned roles must belong to the destination tenant and be grantable by the caller. Setting isConfirmed=false deactivates the account: the user can no longer sign in and every active session is revoked; isConfirmed=true reactivates it. A tenant cannot drop below a protected role's minimum active holder count, so revoking the role from, deactivating, moving, or deleting the last active administrator is rejected.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "name": null
}
```

### Responses

**200** – User updated

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Invalid payload, duplicate email, or the update would remove the last active holder of a protected role

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Destination organization is outside caller scope, or a retained or assigned role is not grantable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – User or destination organization not found in the caller tenant scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/auth/users" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"name\": null
}"
```

## GET `/auth/users/acl`

Fetch user ACL

Returns custom ACL overrides for a user, scoped to the requested tenant when supplied and to the actor or target user tenant otherwise.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| userId | query | any | Required |
| tenantId | query | any | Optional |

### Responses

**200** – User ACL entry

Content-Type: `application/json`

```json
{
  "hasCustomAcl": true,
  "isSuperAdmin": true,
  "features": [
    "string"
  ],
  "organizations": null,
  "updatedAt": null
}
```

**400** – Invalid user id

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Insufficient privileges for the requested tenant scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/auth/users/acl?userId=00000000-0000-4000-8000-000000000000" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/auth/users/acl`

Update user ACL

Updates a per-user ACL override. Omitted super admin, feature, and organization fields preserve their stored values. Authorization evaluates the merged ACL, so a partial request returns 403 when a preserved grant is outside the actor's grantable ACL. An organization-scoped non-super-admin override requires at least one feature grant.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "userId": "00000000-0000-4000-8000-000000000000",
  "organizations": null
}
```

### Responses

**200** – User ACL updated

Content-Type: `application/json`

```json
{
  "ok": true,
  "sanitized": true
}
```

**400** – Invalid payload or unresolved tenant scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Insufficient privileges to modify ACL

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/auth/users/acl" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"userId\": \"00000000-0000-4000-8000-000000000000\",
  \"organizations\": null
}"
```

## GET `/auth/users/consents`

List user consents

Returns all consent records for a given user, with integrity verification status.

**Tags:** Auth

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| userId | query | any | Required |

### Responses

**200** – Consent list returned

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/auth/users/consents?userId=00000000-0000-4000-8000-000000000000" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/auth/users/resend-invite`

Resend invitation email

Resends the invitation email to a user who has not yet set up their password. Generates a new 48-hour setup token and invalidates prior tokens.

**Tags:** Authentication & Accounts

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000"
}
```

### Responses

**200** – Invite email sent

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Invalid request origin

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – User not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – User already has a password

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Validation error

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**429** – Rate limit exceeded

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Invitation email origin is not configured

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/auth/users/resend-invite" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\"
}"
```

## POST `/booksy/cases/rebuild`

Recompute the Booksy cases of whole months (all organizations with a legal entity in them)

**Tags:** Booksy

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "monthFrom": "string",
  "monthTo": "string"
}
```

### Responses

**200** – Counters of the rebuild

Content-Type: `application/json`

```json
{
  "ok": true,
  "result": {
    "monthFrom": "string",
    "monthTo": "string",
    "organizationIds": [
      "00000000-0000-4000-8000-000000000000"
    ],
    "detected": 1,
    "sync": {
      "inserted": 1,
      "updated": 1,
      "reopened": 1,
      "autoResolved": 1,
      "unchanged": 1,
      "obsoleted": 1,
      "byType": {
        "key": 1
      }
    }
  }
}
```

**400** – Invalid months

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing booksy.imports.manage

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/booksy/cases/rebuild" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"monthFrom\": \"string\",
  \"monthTo\": \"string\"
}"
```

## GET `/booksy/commission-check`

Commission base from the sales list vs the Booksy commission report (amounts in grosze)

**Tags:** Booksy

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| month | query | any | Required |
| basis | query | any | Optional |

### Responses

**200** – Base per Booksy staff alias

Content-Type: `application/json`

```json
{
  "month": "string",
  "dateBasis": "settled_date",
  "includeAddonsColumn": true,
  "toleranceGr": 1,
  "items": [
    {
      "personAliasId": "00000000-0000-4000-8000-000000000000",
      "personId": null,
      "baseGr": 1,
      "booksyRevenueGr": null,
      "diffGr": null,
      "matches": true
    }
  ],
  "aliasNames": {
    "key": "string"
  }
}
```

**400** – Missing or invalid month

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/booksy/commission-check?month=string" \
  -H "Accept: application/json"
```

## GET `/booksy/commissions`

List imported Booksy commissions (grosze) per person and month

**Tags:** Booksy

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| month | query | any | Optional |
| monthFrom | query | any | Optional |
| monthTo | query | any | Optional |
| personId | query | any | Optional |
| personAliasId | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Commission rows

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000"
    }
  ]
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/booksy/commissions?page=1&pageSize=50" \
  -H "Accept: application/json"
```

## GET `/booksy/imports`

List applied Booksy import batches

**Tags:** Booksy

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| reportType | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Import batches

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "reportType": "string",
      "periodFrom": null,
      "periodTo": null,
      "counts": null,
      "mode": "regular"
    }
  ]
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/booksy/imports?page=1&pageSize=50" \
  -H "Accept: application/json"
```

## POST `/booksy/imports`

Preview or apply Booksy reports (1-8 XLSX files)

**Tags:** Booksy

### Request Body

Content-Type: `multipart/form-data`

```text
file=string
```

### Responses

**200** – Preview (dryRun) or applied import; aggregates only. `files[]` per file; `summary` (and `batchId`) only for a single file. After applying: `casesRebuilt` and post-import counters.

Content-Type: `application/json`

```json
{
  "dryRun": true,
  "files": [
    {
      "index": 1,
      "fileSha256": "string",
      "reportType": null,
      "canApply": true,
      "summary": null,
      "error": null
    }
  ]
}
```

**400** – Missing, invalid or too many files

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization not allowed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**413** – File larger than 10 MB or upload larger than 25 MB

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**415** – Not multipart/form-data

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Unsupported report, rows with errors, the same file twice, overlapping periods, or a refused history import (history_overlaps_settled_period, history_cases_enabled)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Import failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/booksy/imports" \
  -H "Accept: application/json" \
  -H "Content-Type: multipart/form-data" \
  -d "{
  \"file\": \"string\"
}"
```

## GET `/booksy/mappings/persons`

Staff names from Booksy with status, mapped person and row counts

**Tags:** Booksy

### Responses

**200** – Aliases

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "displayName": "string",
      "status": "unmapped",
      "personId": null,
      "source": "string",
      "rawPosition": null,
      "firstSeenDate": null,
      "lastSeenDate": null,
      "visits": 1,
      "saleLines": 1,
      "workTimes": 1,
      "commissions": 1,
      "updatedAt": null
    }
  ],
  "total": 1
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/booksy/mappings/persons" \
  -H "Accept: application/json"
```

## PUT `/booksy/mappings/persons`

Map a staff name to a person, mark it "no person" or unmap it (reason required, undoable)

**Tags:** Booksy

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "aliasId": "00000000-0000-4000-8000-000000000000",
  "status": "unmapped",
  "personId": null,
  "reason": "string"
}
```

### Responses

**200** – Mapping saved; rows rewritten and cases rebuilt

Content-Type: `application/json`

```json
{
  "ok": true,
  "result": {
    "aliasId": "00000000-0000-4000-8000-000000000000",
    "status": "string",
    "targetId": null,
    "rowsUpdated": 1,
    "remapChanges": 1,
    "affectedFrom": null,
    "affectedTo": null,
    "casesRebuilt": true
  }
}
```

**400** – Invalid input, missing reason or unknown person

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing booksy.mappings.manage

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Alias not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Changed by someone else (optimistic lock)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/booksy/mappings/persons" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"aliasId\": \"00000000-0000-4000-8000-000000000000\",
  \"status\": \"unmapped\",
  \"personId\": null,
  \"reason\": \"string\"
}"
```

## POST `/booksy/mappings/persons/inactive`

Create an inactive salon person for each unmapped staff alias and map it (1-50 aliases, reason required)

**Tags:** Booksy

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "items": [
    {
      "aliasId": "00000000-0000-4000-8000-000000000000",
      "displayName": "string"
    }
  ],
  "reason": "string"
}
```

### Responses

**200** – Persons created (inactive, kind contractor) and aliases mapped; mapped aliases are skipped

Content-Type: `application/json`

```json
{
  "ok": true,
  "result": {
    "created": 1,
    "mapped": 1,
    "skipped": [
      {
        "aliasId": "00000000-0000-4000-8000-000000000000",
        "code": "alias_not_found"
      }
    ],
    "createdPersons": [
      {
        "aliasId": "00000000-0000-4000-8000-000000000000",
        "personId": "00000000-0000-4000-8000-000000000000"
      }
    ]
  }
}
```

**400** – Invalid input, missing reason or name

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing booksy.mappings.manage or salon.persons.manage, or a role limited to some organizations

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/booksy/mappings/persons/inactive" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"items\": [
    {
      \"aliasId\": \"00000000-0000-4000-8000-000000000000\",
      \"displayName\": \"string\"
    }
  ],
  \"reason\": \"string\"
}"
```

## GET `/booksy/mappings/services`

Service names from Booksy with status, catalog service and row counts

**Tags:** Booksy

### Responses

**200** – Aliases

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "displayName": "string",
      "status": "unmapped",
      "serviceId": null,
      "source": "string",
      "lastRawCategory": null,
      "seenInVisits": true,
      "seenInSales": true,
      "firstSeenDate": null,
      "lastSeenDate": null,
      "visits": 1,
      "saleLines": 1,
      "updatedAt": null
    }
  ],
  "total": 1
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/booksy/mappings/services" \
  -H "Accept: application/json"
```

## PUT `/booksy/mappings/services`

Map a service name to a catalog service, skip it or unmap it (reason required, undoable)

**Tags:** Booksy

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "aliasId": "00000000-0000-4000-8000-000000000000",
  "status": "unmapped",
  "serviceId": null,
  "reason": "string"
}
```

### Responses

**200** – Mapping saved; rows rewritten and cases rebuilt

Content-Type: `application/json`

```json
{
  "ok": true,
  "result": {
    "aliasId": "00000000-0000-4000-8000-000000000000",
    "status": "string",
    "targetId": null,
    "rowsUpdated": 1,
    "remapChanges": 1,
    "affectedFrom": null,
    "affectedTo": null,
    "casesRebuilt": true
  }
}
```

**400** – Invalid input, missing reason or unknown service

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing booksy.mappings.manage

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Alias not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Changed by someone else (optimistic lock)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/booksy/mappings/services" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"aliasId\": \"00000000-0000-4000-8000-000000000000\",
  \"status\": \"unmapped\",
  \"serviceId\": null,
  \"reason\": \"string\"
}"
```

## GET `/booksy/reconciliation`

Visit list vs sales list per day and person (amounts in grosze)

**Tags:** Booksy

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| month | query | any | Required |

### Responses

**200** – Reconciliation per organization

Content-Type: `application/json`

```json
{
  "month": "string",
  "organizations": [
    {
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "totals": {},
      "divergent": [
        {
          "date": "string",
          "personRef": "string",
          "personId": null,
          "personAliasIds": [
            "00000000-0000-4000-8000-000000000000"
          ],
          "visitsGr": 1,
          "salesGr": 1,
          "diffGr": 1,
          "visitCount": 1,
          "lineCount": 1,
          "divergent": true
        }
      ],
      "unassigned": [
        {
          "date": "string",
          "visitsGr": 1,
          "salesGr": 1,
          "diffGr": 1
        }
      ],
      "cells": [
        {
          "date": "string",
          "personRef": "string",
          "personId": null,
          "personAliasIds": [
            "00000000-0000-4000-8000-000000000000"
          ],
          "visitsGr": 1,
          "salesGr": 1,
          "diffGr": 1,
          "visitCount": 1,
          "lineCount": 1,
          "divergent": true
        }
      ]
    }
  ],
  "aliasNames": {
    "key": "string"
  },
  "identityHolds": true
}
```

**400** – Missing or invalid month

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/booksy/reconciliation?month=string" \
  -H "Accept: application/json"
```

## GET `/booksy/sale-lines`

List imported Booksy sales lines (amounts in grosze)

**Tags:** Booksy

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| from | query | any | Optional |
| to | query | any | Optional |
| kind | query | any | Optional |
| paymentMethod | query | any | Optional |
| personId | query | any | Optional |
| serviceId | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Sales lines

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000"
    }
  ]
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/booksy/sale-lines?page=1&pageSize=50" \
  -H "Accept: application/json"
```

## GET `/booksy/settings`

Settings in force for the selected organization and the defaults

**Tags:** Booksy

### Responses

**200** – Settings

Content-Type: `application/json`

```json
{
  "settings": {},
  "valid": true,
  "state": "default",
  "sourceOrganizationId": null,
  "updatedAt": null,
  "defaults": {}
}
```

**400** – No organization selected

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/booksy/settings" \
  -H "Accept: application/json"
```

## PUT `/booksy/settings`

Change the settings (partial patch merged over the current value); reason required

**Tags:** Booksy

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "settings": {
    "casesFrom": null
  },
  "reason": "string"
}
```

### Responses

**200** – Saved settings

Content-Type: `application/json`

```json
{
  "settings": {},
  "valid": true,
  "state": "default",
  "sourceOrganizationId": null,
  "updatedAt": null,
  "defaults": {}
}
```

**400** – Invalid settings, missing reason or no organization selected

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing salon.decisions.manage

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/booksy/settings" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"settings\": {
    \"casesFrom\": null
  },
  \"reason\": \"string\"
}"
```

## GET `/booksy/visits`

List imported Booksy visits (amounts in grosze); with id + includeClient=1 one visit with aliases and, for booksy.visits.client_view, the client

**Tags:** Booksy

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| id | query | any | Optional |
| from | query | any | Optional |
| to | query | any | Optional |
| month | query | any | Optional |
| status | query | any | Optional |
| unfinalized | query | any | Optional |
| personId | query | any | Optional |
| serviceId | query | any | Optional |
| includeClient | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Visits (list) or one visit (detail)

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000"
    }
  ]
}
```

**400** – Invalid id

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Visit not found or outside the organization scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/booksy/visits?page=1&pageSize=50" \
  -H "Accept: application/json"
```

## GET `/booksy/work-time`

List imported Booksy work time (minutes) per person and month

**Tags:** Booksy

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| month | query | any | Optional |
| monthFrom | query | any | Optional |
| monthTo | query | any | Optional |
| personId | query | any | Optional |
| personAliasId | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Work time rows

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000"
    }
  ]
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/booksy/work-time?page=1&pageSize=50" \
  -H "Accept: application/json"
```

## DELETE `/cash_control/day-closes`

Delete the daily cash report of a day (soft; reason and version required)

**Tags:** Cash control

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Deleted

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "date": "string",
  "updatedAt": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing feature, organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Day close not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, month locked

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, date out of range or outside the legal entity, invalid amount, split above the total, photo not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/cash_control/day-closes" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/cash_control/day-closes`

Daily cash reports of the selected legal entities in a date range (amounts in grosze)

from, to: rrrr-mm-dd (at most 366 days); organizationId optional (must be in scope). The note is returned only to person sessions.

**Tags:** Cash control

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| from | query | any | Required |
| to | query | any | Required |
| organizationId | query | any | Optional |

### Responses

**200** – Day closes

Content-Type: `application/json`

```json
{
  "from": "string",
  "to": "string",
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "date": "string",
      "fiscalGrossGr": 1,
      "fiscalCashGr": null,
      "fiscalCardGr": null,
      "fiscalReportNo": null,
      "terminalGrossGr": null,
      "terminalSource": null,
      "hasPhoto": true,
      "note": null,
      "enteredByUserId": null,
      "enteredAt": "string",
      "updatedAt": "string"
    }
  ]
}
```

**400** – Invalid range

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/cash_control/day-closes?from=string&to=string" \
  -H "Accept: application/json"
```

## POST `/cash_control/day-closes`

Enter the daily cash report of a day (first entry, no reason)

**Tags:** Cash control

### Request Body

Content-Type: `application/json`

```json
{
  "date": "string",
  "fiscalGrossGr": 1,
  "fiscalCashGr": null,
  "fiscalCardGr": null,
  "fiscalReportNo": null,
  "terminalGrossGr": null,
  "note": null,
  "photoAttachmentId": null,
  "updatedAt": null,
  "reason": null
}
```

### Responses

**201** – Created

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "date": "string",
  "updatedAt": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing feature, organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Day close not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, month locked, day close exists

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, date out of range or outside the legal entity, invalid amount, split above the total, photo not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/cash_control/day-closes" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"date\": \"string\",
  \"fiscalGrossGr\": 1,
  \"fiscalCashGr\": null,
  \"fiscalCardGr\": null,
  \"fiscalReportNo\": null,
  \"terminalGrossGr\": null,
  \"note\": null,
  \"photoAttachmentId\": null,
  \"updatedAt\": null,
  \"reason\": null
}"
```

## PUT `/cash_control/day-closes`

Correct the daily cash report of a day (reason and version required)

**Tags:** Cash control

### Request Body

Content-Type: `application/json`

```json
{
  "date": "string",
  "fiscalGrossGr": 1,
  "fiscalCashGr": null,
  "fiscalCardGr": null,
  "fiscalReportNo": null,
  "terminalGrossGr": null,
  "note": null,
  "photoAttachmentId": null,
  "updatedAt": null,
  "reason": "string"
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "date": "string",
  "updatedAt": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing feature, organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Day close not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, month locked

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, date out of range or outside the legal entity, invalid amount, split above the total, photo not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/cash_control/day-closes" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"date\": \"string\",
  \"fiscalGrossGr\": 1,
  \"fiscalCashGr\": null,
  \"fiscalCardGr\": null,
  \"fiscalReportNo\": null,
  \"terminalGrossGr\": null,
  \"note\": null,
  \"photoAttachmentId\": null,
  \"updatedAt\": null,
  \"reason\": \"string\"
}"
```

## GET `/cash_control/days`

Daily fiscal report vs Booksy vs contractors vs terminal, per day of the selected legal entities (amounts in grosze)

from, to: rrrr-mm-dd (at most 62 days); organizationId optional. Status per day: ok, difference, missing_report, incomplete, no_turnover, before_start.

**Tags:** Cash control

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| from | query | any | Required |
| to | query | any | Required |
| organizationId | query | any | Optional |

### Responses

**200** – Reconciled days

Content-Type: `application/json`

```json
{
  "from": "string",
  "to": "string",
  "asOf": "string",
  "items": [
    {
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "date": "string",
      "status": "ok",
      "hasTurnover": true,
      "columns": {
        "booksy": null,
        "workers": {
          "cashGr": 1,
          "cardGr": 1,
          "expectedPersons": 1,
          "confirmedPersons": 1
        },
        "fiscal": null,
        "terminal": null
      },
      "lines": [
        {
          "check": "fiscal_vs_booksy",
          "leftGr": 1,
          "rightGr": 1,
          "diffGr": 1,
          "withinTolerance": true
        }
      ],
      "missing": [
        "booksy"
      ]
    }
  ]
}
```

**400** – Invalid or too long range

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing cash_control.view or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/cash_control/days?from=string&to=string" \
  -H "Accept: application/json"
```

## GET `/cash_control/days/{date}`

The daily cash report of a day and (with cash_control.view) its reconciliation with Booksy and the contractors

Path: rrrr-mm-dd. The legal entity follows the date. Amounts in grosze.

**Tags:** Cash control

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| date | path | any | Required |

### Responses

**200** – The day

Content-Type: `application/json`

```json
{
  "date": "string",
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "dayClose": null,
  "reconciliation": null,
  "monthLocked": true,
  "permissions": {
    "canView": true,
    "canEnter": true,
    "canDelete": true,
    "canOverrideLock": true
  },
  "settings": {
    "toleranceGr": 1,
    "editableDaysBack": 1,
    "startDate": null
  }
}
```

**403** – Neither cash_control.view nor day_close.enter

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Legal entity of the date outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Date outside every legal entity

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/cash_control/days/:date" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/cash_control/photos`

Upload the photo of a daily fiscal report (person sessions only)

multipart/form-data: file (≤ 10 MB; JPEG, PNG, WebP, HEIC or PDF), date (rrrr-mm-dd, optional). Returns the attachment id to put in photoAttachmentId of the day close.

**Tags:** Cash control

### Responses

**201** – Stored

Content-Type: `application/json`

```json
{
  "attachmentId": "00000000-0000-4000-8000-000000000000",
  "organizationId": "00000000-0000-4000-8000-000000000000"
}
```

**403** – API key, missing day_close.enter or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**413** – Photo larger than 10 MB

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Not a photo or a PDF, date outside every legal entity

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/cash_control/photos" \
  -H "Accept: application/json"
```

## GET `/cash_control/photos/{id}`

The photo of the daily fiscal report linked to a day close (person sessions only; API keys get 403)

**Tags:** Cash control

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – The image or PDF

Content-Type: `application/json`

**403** – Missing cash_control.view or an API key

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – No day close with this photo in the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/cash_control/photos/:id" \
  -H "Accept: application/json"
```

## GET `/cash_control/settings`

Day close settings in force for the selected organization (start date, tolerance, payment methods, days back, cases)

**Tags:** Cash control

### Responses

**200** – Settings

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "settings": {
    "settings": {},
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null
  },
  "defaults": {}
}
```

**400** – No organization selected

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/cash_control/settings" \
  -H "Accept: application/json"
```

## PUT `/cash_control/settings`

Change the day close settings (partial patch); reason required

**Tags:** Cash control

### Request Body

Content-Type: `application/json`

```json
{
  "settings": {
    "startDate": null
  },
  "reason": "string"
}
```

### Responses

**200** – Saved settings

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "settings": {
    "settings": {},
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null
  },
  "defaults": {}
}
```

**400** – Invalid settings or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing salon.decisions.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/cash_control/settings" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"settings\": {
    \"startDate\": null
  },
  \"reason\": \"string\"
}"
```

## DELETE `/communication_channels/admin/channels/{id}`

Admin delete (soft-delete) a tenant-wide communication channel

**Tags:** CommunicationChannels

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**204** – Channel deleted

**400** – Invalid channel id

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**404** – Channel not found or not a tenant-wide channel

Content-Type: `application/json`

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/communication_channels/admin/channels/:id" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/communication_channels/channels`

List communication channels for the current tenant

**Tags:** CommunicationChannels

**Requires authentication.**

### Responses

**200** – Channel list (paginated)

Content-Type: `application/json`

**400** – Invalid query parameters

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/communication_channels/channels" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/communication_channels/channels/{id}`

DELETE /communication_channels/channels/{id}

**Tags:** Communication Channels

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**204** – Success

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/communication_channels/channels/:id" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/communication_channels/channels/{id}`

Get a single communication channel by id

**Tags:** CommunicationChannels

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Channel detail

Content-Type: `application/json`

**400** – Invalid channel id

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**404** – Channel not found

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/communication_channels/channels/:id" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/communication_channels/channels/{id}/health`

Snapshot of channel delivery health (last 24h)

**Tags:** CommunicationChannels

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Health snapshot

Content-Type: `application/json`

**400** – Invalid channel id

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**404** – Channel not found

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/communication_channels/channels/:id/health" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/communication_channels/channels/{id}/import-history`

Queue a backlog import for a channel (Spec B § Phase B6)

**Tags:** CommunicationChannels

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Request Body

Content-Type: `application/json`

```json
{
  "sinceDays": 30,
  "maxMessages": 1000
}
```

### Responses

**202** – Import job queued; returns { progressJobId }

Content-Type: `application/json`

**400** – Invalid channel id or unsupported provider

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**404** – Channel not found / not accessible

Content-Type: `application/json`

**409** – Channel is not connected (requires reauth / error)

Content-Type: `application/json`

**429** – Another import is already running for this channel

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/communication_channels/channels/:id/import-history" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"sinceDays\": 30,
  \"maxMessages\": 1000
}"
```

## POST `/communication_channels/channels/{id}/poll-now`

Manually trigger a poll cycle for a channel (demo / operator override)

**Tags:** CommunicationChannels

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**202** – Poll job enqueued

Content-Type: `application/json`

**400** – Invalid channel id

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**404** – Channel not found

Content-Type: `application/json`

**409** – Channel disabled, not connected, or push-driven (never polled)

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/communication_channels/channels/:id/poll-now" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/communication_channels/channels/{id}/push/register`

Force-register push delivery for a channel (Spec C § Phase C5)

**Tags:** CommunicationChannels

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**202** – Push registration attempted; check result.pushStatus

Content-Type: `application/json`

**400** – Invalid id or unsupported provider

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**403** – Missing push.manage feature

Content-Type: `application/json`

**404** – Channel not found

Content-Type: `application/json`

**409** – Provider does not support push (IMAP)

Content-Type: `application/json`

**502** – Provider returned an error during registration

Content-Type: `application/json`

**503** – Webhook base URL or Pub/Sub topic not configured

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/communication_channels/channels/:id/push/register" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/communication_channels/channels/{id}/set-primary`

Mark a per-user channel as primary

**Tags:** CommunicationChannels

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Channel set as primary (or already primary)

Content-Type: `application/json`

**400** – Invalid channel id

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**404** – Channel not found or not owned by current user

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/communication_channels/channels/:id/set-primary" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/communication_channels/channels/{id}/test-send`

Diagnostic — send a test message through the channel without persisting

**Tags:** CommunicationChannels

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Test send result

Content-Type: `application/json`

**400** – Invalid channel id

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**403** – Not allowed to manage this channel

Content-Type: `application/json`

**404** – Channel or adapter not found

Content-Type: `application/json`

**409** – Channel not connected

Content-Type: `application/json`

**422** – Invalid request body

Content-Type: `application/json`

**502** – Provider error

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/communication_channels/channels/:id/test-send" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/communication_channels/channels/connect/credentials`

Connect a credential-based per-user channel (IMAP/SMTP)

**Tags:** CommunicationChannels

**Requires authentication.**

### Responses

**201** – Channel connected

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**403** – Provider is tenant-scoped — use the tenant connect route

Content-Type: `application/json`

**404** – Unknown provider

Content-Type: `application/json`

**409** – Mailbox already connected via another provider

Content-Type: `application/json`

**422** – Invalid body or credential validation failed

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/communication_channels/channels/connect/credentials" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/communication_channels/channels/connect/tenant-credentials`

Connect a tenant-wide credential-based channel (push: FCM/APNs/Expo)

**Tags:** CommunicationChannels

**Requires authentication.**

### Responses

**201** – Channel connected

Content-Type: `application/json`

**400** – Provider is not tenant-scoped

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**404** – Unknown provider

Content-Type: `application/json`

**422** – Invalid body or credential validation failed

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/communication_channels/channels/connect/tenant-credentials" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/communication_channels/me/channels`

List the current user's connected channels

**Tags:** CommunicationChannels

**Requires authentication.**

### Responses

**200** – List of user-owned channels

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/communication_channels/me/channels" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/communication_channels/messages/{messageId}/reactions`

Add a reaction to a channel-linked message

**Tags:** CommunicationChannels

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| messageId | path | any | Required |

### Responses

**201** – Reaction added

Content-Type: `application/json`

**400** – Invalid messageId

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**403** – Channel is owned by another user

Content-Type: `application/json`

**409** – Message not channel-linked or duplicate reaction

Content-Type: `application/json`

**422** – Invalid request body

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/communication_channels/messages/:messageId/reactions" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/communication_channels/messages/{messageId}/reactions/{reactionId}`

Remove a reaction from a channel-linked message

**Tags:** CommunicationChannels

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| messageId | path | any | Required |
| reactionId | path | any | Required |

### Responses

**204** – Reaction removed

**400** – Invalid params

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**403** – Channel is owned by another user

Content-Type: `application/json`

**404** – Reaction not found or not owned by current user

Content-Type: `application/json`

**409** – Message not channel-linked

Content-Type: `application/json`

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/communication_channels/messages/:messageId/reactions/:reactionId" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/communication_channels/oauth/{provider}/callback`

OAuth callback — exchange code, persist credentials, create per-user channel

**Tags:** CommunicationChannels

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| provider | path | any | Required |

### Responses

**200** – Success response

Content-Type: `application/json`

**302** – Redirect back to returnUrl with flash query params

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/communication_channels/oauth/:provider/callback" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/communication_channels/oauth/{provider}/initiate`

Start a per-user channel OAuth flow

**Tags:** CommunicationChannels

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| provider | path | any | Required |

### Responses

**200** – Authorize URL + state cookie set

Content-Type: `application/json`

**400** – Invalid provider or unsupported (no OAuth)

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**422** – Invalid request body

Content-Type: `application/json`

**502** – Adapter failed to build authorize URL

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/communication_channels/oauth/:provider/initiate" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/communication_channels/send-as-user`

Send a message through the current user's own channel

**Tags:** CommunicationChannels

**Requires authentication.**

### Responses

**202** – Message persisted; outbound delivery enqueued

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**403** – Cannot send through a channel you don't own

Content-Type: `application/json`

**404** – Channel not found

Content-Type: `application/json`

**409** – Channel in a non-deliverable transitional status

Content-Type: `application/json`

**422** – Invalid body, or channel requires_reauth / disconnected

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/communication_channels/send-as-user" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/communication_channels/test-seed`

Test-only: seed a connected channel, ingest a real inbound message, or emit a seeded inbound link (env-gated)

**Tags:** CommunicationChannels

**Requires authentication.**

### Responses

**201** – Channel seeded / inbound message emitted

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**404** – Test channel seeding disabled (production default), or the requested channel does not belong to the caller

Content-Type: `application/json`

**422** – Invalid request body

Content-Type: `application/json`

**500** – Seed failed

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/communication_channels/test-seed" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/communication_channels/threads/{threadId}/assign`

Reassign a channel-linked conversation to a different owner

**Tags:** CommunicationChannels

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| threadId | path | any | Required |

### Responses

**200** – Conversation reassigned (or unchanged)

Content-Type: `application/json`

**400** – Invalid threadId

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**404** – Conversation not channel-linked

Content-Type: `application/json`

**422** – Invalid request body

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/communication_channels/threads/:threadId/assign" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/communication_channels/webhook/{provider}`

Process an inbound channel webhook (Slack, WhatsApp, Email, ...)

**Tags:** CommunicationChannels

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| provider | path | any | Required |

### Responses

**202** – Webhook accepted for async processing

Content-Type: `application/json`

**401** – Signature verification failed against every candidate channel

Content-Type: `application/json`

**404** – Unknown provider

Content-Type: `application/json`

**413** – Webhook payload too large

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/communication_channels/webhook/:provider" \
  -H "Accept: application/json"
```

## POST `/communication_channels/webhooks/gmail`

Gmail Pub/Sub push notification webhook (Spec C § Phase C2)

**Tags:** CommunicationChannels

### Responses

**204** – Notification verified + history-sync job enqueued

**400** – Body not a valid Pub/Sub envelope

Content-Type: `application/json`

**401** – Invalid JWT or email claim

Content-Type: `application/json`

**403** – Wrong audience

Content-Type: `application/json`

**413** – Webhook payload too large

Content-Type: `application/json`

**503** – Webhook not configured / Google certs unreachable

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/communication_channels/webhooks/gmail" \
  -H "Accept: application/json"
```

## GET `/configs/cache`

Get cache statistics

Returns detailed cache statistics including total entries and breakdown by cache segments. Requires cache service to be available.

**Tags:** Configs

**Requires authentication.**

### Responses

**200** – Cache statistics

Content-Type: `application/json`

```json
{
  "generatedAt": "string",
  "totalKeys": 1,
  "segments": [
    {
      "segment": "string",
      "resource": null,
      "method": null,
      "path": null,
      "keyCount": 1,
      "keys": [
        "string"
      ]
    }
  ]
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Failed to resolve cache stats

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Cache service unavailable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/configs/cache" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/configs/cache`

Purge cache

Purges cache entries. Supports two actions: purgeAll (clears entire cache) or purgeSegment (clears specific segment). Returns updated cache statistics after purge.

**Tags:** Configs

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "action": "purgeAll"
}
```

### Responses

**200** – Cache segment cleared successfully

Content-Type: `application/json`

```json
{
  "action": "purgeSegment",
  "segment": "string",
  "deleted": 1,
  "stats": {
    "generatedAt": "string",
    "totalKeys": 1,
    "segments": [
      {
        "segment": "string",
        "resource": null,
        "method": null,
        "path": null,
        "keyCount": 1,
        "keys": [
          "string"
        ]
      }
    ]
  }
}
```

**400** – Invalid request - missing segment identifier for purgeSegment action

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Failed to purge cache

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Cache service unavailable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/configs/cache" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"action\": \"purgeAll\"
}"
```

## DELETE `/configs/module-telemetry`

Clear module telemetry data

Development-only endpoint that clears in-memory module telemetry and local process telemetry files.

**Tags:** Configs

**Requires authentication.**

### Responses

**200** – Module telemetry cleared

Content-Type: `application/json`

```json
{
  "cleared": true
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Forbidden outside development mode

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/configs/module-telemetry" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/configs/module-telemetry`

Get module resource usage telemetry

Returns in-process module resource attribution for API routes, event subscribers, and queue workers.

**Tags:** Configs

**Requires authentication.**

### Responses

**200** – Module resource usage report

Content-Type: `application/json`

```json
{
  "generatedAt": "string",
  "startedAt": "string",
  "enabled": true,
  "bucketIntervalMs": 1,
  "totals": {
    "modules": 1,
    "operations": 1,
    "calls": 1,
    "errors": 1,
    "totalDurationMs": 1,
    "totalCpuMs": 1,
    "positiveHeapDeltaBytes": 1,
    "positiveRssDeltaBytes": 1
  },
  "thresholds": {
    "p95DurationMs": 1,
    "cpuMs": 1,
    "positiveHeapDeltaBytes": 1,
    "positiveRssDeltaBytes": 1,
    "errors": 1
  },
  "modules": [
    {
      "moduleId": "string",
      "calls": 1,
      "errors": 1,
      "totalDurationMs": 1,
      "p95DurationMs": 1,
      "totalCpuMs": 1,
      "positiveHeapDeltaBytes": 1,
      "positiveRssDeltaBytes": 1,
      "surfaces": [
        {
          "surface": "api",
          "calls": 1,
          "errors": 1,
          "totalDurationMs": 1,
          "p95DurationMs": 1,
          "totalCpuMs": 1,
          "positiveHeapDeltaBytes": 1,
          "positiveRssDeltaBytes": 1
        }
      ],
      "topOperations": [
        {
          "moduleId": "string",
          "surface": "api",
          "operation": "string",
          "resourceId": null,
          "calls": 1,
          "errors": 1,
          "totalDurationMs": 1,
          "maxDurationMs": 1,
          "p95DurationMs": 1,
          "totalCpuUserMs": 1,
          "totalCpuSystemMs": 1,
          "maxCpuMs": 1,
          "totalHeapDeltaBytes": 1,
          "positiveHeapDeltaBytes": 1,
          "maxHeapDeltaBytes": 1,
          "totalRssDeltaBytes": 1,
          "positiveRssDeltaBytes": 1,
          "maxRssDeltaBytes": 1,
          "firstSeenAt": "string",
          "lastSeenAt": "string"
        }
      ],
      "candidateReasons": [
        "string"
      ]
    }
  ],
  "candidates": [
    {
      "moduleId": "string",
      "calls": 1,
      "errors": 1,
      "totalDurationMs": 1,
      "p95DurationMs": 1,
      "totalCpuMs": 1,
      "positiveHeapDeltaBytes": 1,
      "positiveRssDeltaBytes": 1,
      "surfaces": [
        {
          "surface": "api",
          "calls": 1,
          "errors": 1,
          "totalDurationMs": 1,
          "p95DurationMs": 1,
          "totalCpuMs": 1,
          "positiveHeapDeltaBytes": 1,
          "positiveRssDeltaBytes": 1
        }
      ],
      "topOperations": [
        {
          "moduleId": "string",
          "surface": "api",
          "operation": "string",
          "resourceId": null,
          "calls": 1,
          "errors": 1,
          "totalDurationMs": 1,
          "maxDurationMs": 1,
          "p95DurationMs": 1,
          "totalCpuUserMs": 1,
          "totalCpuSystemMs": 1,
          "maxCpuMs": 1,
          "totalHeapDeltaBytes": 1,
          "positiveHeapDeltaBytes": 1,
          "maxHeapDeltaBytes": 1,
          "totalRssDeltaBytes": 1,
          "positiveRssDeltaBytes": 1,
          "maxRssDeltaBytes": 1,
          "firstSeenAt": "string",
          "lastSeenAt": "string"
        }
      ],
      "candidateReasons": [
        "string"
      ]
    }
  ],
  "buckets": [
    {
      "bucketStart": "string",
      "bucketEnd": "string",
      "bucketIntervalMs": 1,
      "stage": "startup",
      "partial": true,
      "totals": {
        "modules": 1,
        "calls": 1,
        "errors": 1,
        "totalDurationMs": 1,
        "totalCpuMs": 1,
        "positiveHeapDeltaBytes": 1,
        "positiveRssDeltaBytes": 1
      },
      "modules": [
        {
          "moduleId": "string",
          "calls": 1,
          "errors": 1,
          "totalDurationMs": 1,
          "p95DurationMs": 1,
          "totalCpuMs": 1,
          "positiveHeapDeltaBytes": 1,
          "positiveRssDeltaBytes": 1,
          "surfaces": [
            {
              "surface": "api",
              "calls": 1,
              "errors": 1,
              "totalDurationMs": 1,
              "p95DurationMs": 1,
              "totalCpuMs": 1,
              "positiveHeapDeltaBytes": 1,
              "positiveRssDeltaBytes": 1
            }
          ],
          "topOperations": [
            {
              "moduleId": "string",
              "surface": "api",
              "operation": "string",
              "resourceId": null,
              "calls": 1,
              "errors": 1,
              "totalDurationMs": 1,
              "maxDurationMs": 1,
              "p95DurationMs": 1,
              "totalCpuUserMs": 1,
              "totalCpuSystemMs": 1,
              "maxCpuMs": 1,
              "totalHeapDeltaBytes": 1,
              "positiveHeapDeltaBytes": 1,
              "maxHeapDeltaBytes": 1,
              "totalRssDeltaBytes": 1,
              "positiveRssDeltaBytes": 1,
              "maxRssDeltaBytes": 1,
              "firstSeenAt": "string",
              "lastSeenAt": "string"
            }
          ],
          "candidateReasons": [
            "string"
          ]
        }
      ]
    }
  ]
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/configs/module-telemetry" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/configs/system-status`

Get system health status

Returns comprehensive system health information including environment details, version, resource usage, and service connectivity status.

**Tags:** Configs

**Requires authentication.**

### Responses

**200** – System status snapshot

Content-Type: `application/json`

```json
{
  "generatedAt": "string",
  "runtimeMode": "development",
  "categories": [
    {
      "key": "profiling",
      "labelKey": "string",
      "descriptionKey": null,
      "items": [
        {
          "key": "string",
          "category": "profiling",
          "kind": "boolean",
          "labelKey": "string",
          "descriptionKey": "string",
          "docUrl": null,
          "defaultValue": null,
          "state": "enabled",
          "value": null,
          "normalizedValue": null
        }
      ]
    }
  ]
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Failed to load system status

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/configs/system-status" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/configs/system-status`

Clear system cache

Purges the entire cache for the current tenant. Useful for troubleshooting or forcing fresh data loading.

**Tags:** Configs

**Requires authentication.**

### Responses

**200** – Cache cleared successfully

Content-Type: `application/json`

```json
{
  "cleared": true
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Failed to purge cache

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Cache service unavailable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/configs/system-status" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/configs/upgrade-actions`

List pending upgrade actions

Returns a list of pending upgrade actions for the current version. These are one-time setup tasks that need to be executed after upgrading to a new version. Requires organization and tenant context.

**Tags:** Configs

**Requires authentication.**

### Responses

**200** – List of pending upgrade actions

Content-Type: `application/json`

```json
{
  "version": "string",
  "actions": [
    {
      "id": "string",
      "version": "string",
      "message": "string",
      "ctaLabel": "string",
      "successMessage": "string",
      "loadingLabel": "string"
    }
  ]
}
```

**400** – Missing organization or tenant context

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Failed to load upgrade actions

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/configs/upgrade-actions" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/configs/upgrade-actions`

Execute upgrade action

Executes a specific upgrade action by ID. Typically used for one-time setup tasks like seeding example data after version upgrade. Returns execution status and localized success message.

**Tags:** Configs

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "actionId": "string"
}
```

### Responses

**200** – Upgrade action executed successfully

Content-Type: `application/json`

```json
{
  "status": "string",
  "message": "string",
  "version": "string"
}
```

**400** – Invalid request body or missing context

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Upgrade actions are disabled

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Failed to execute upgrade action

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/configs/upgrade-actions" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"actionId\": \"string\"
}"
```

## GET `/costs/occurrences`

Planned, confirmed and skipped costs of the month in the selected organizations

**Tags:** Costs

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| month | query | any | Required |

### Responses

**200** – Occurrences (reference only with costs.manage), totals and canManage

Content-Type: `application/json`

```json
{
  "month": "string",
  "items": [
    {
      "id": null,
      "recurringCostId": "00000000-0000-4000-8000-000000000000",
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "month": "string",
      "status": "planned",
      "name": "string",
      "documentKind": "invoice_ksef",
      "dueDate": "string",
      "lines": [
        {
          "key": "string",
          "label": "string",
          "category": "materials",
          "netGr": 1,
          "vatBps": null,
          "vatGr": 1,
          "grossGr": 1,
          "plannedNetGr": 1,
          "plannedVatGr": 1
        }
      ],
      "netGr": 1,
      "vatGr": 1,
      "grossGr": 1,
      "plannedGrossGr": 1,
      "differsFromPlan": true,
      "paidOn": null,
      "reference": null,
      "confirmedAt": null,
      "confirmedByUserId": null,
      "updatedAt": null
    }
  ],
  "totals": {
    "netGr": 1,
    "vatGr": 1,
    "grossGr": 1,
    "plannedGrossGr": 1,
    "planned": 1,
    "confirmed": 1,
    "skipped": 1
  },
  "canManage": true
}
```

**400** – Invalid month

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/costs/occurrences?month=string" \
  -H "Accept: application/json"
```

## POST `/costs/occurrences/confirm`

Confirm the cost of a month (amounts, payment date, reference)

**Tags:** Costs

### Request Body

Content-Type: `application/json`

```json
{
  "recurringCostId": "00000000-0000-4000-8000-000000000000",
  "month": "string",
  "lines": [
    {
      "key": "string",
      "netGr": 1,
      "vatGr": null
    }
  ],
  "paidOn": null,
  "reference": null,
  "reason": null,
  "updatedAt": null
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null,
  "status": "planned"
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing costs.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Template or decision not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, month already decided (already_decided)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, invalid lines or period, month not due, outside the podmiot

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/costs/occurrences/confirm" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"recurringCostId\": \"00000000-0000-4000-8000-000000000000\",
  \"month\": \"string\",
  \"lines\": [
    {
      \"key\": \"string\",
      \"netGr\": 1,
      \"vatGr\": null
    }
  ],
  \"paidOn\": null,
  \"reference\": null,
  \"reason\": null,
  \"updatedAt\": null
}"
```

## POST `/costs/occurrences/reopen`

Reopen a decided month (back to the plan; reason and version)

**Tags:** Costs

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null,
  "status": "planned"
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing costs.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Template or decision not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, decision changed meanwhile

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, invalid lines or period, month not due, outside the podmiot

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/costs/occurrences/reopen" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## POST `/costs/occurrences/skip`

Skip the cost in a month (reason required)

**Tags:** Costs

### Request Body

Content-Type: `application/json`

```json
{
  "recurringCostId": "00000000-0000-4000-8000-000000000000",
  "month": "string",
  "reason": "string"
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null,
  "status": "planned"
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing costs.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Template or decision not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, month already decided (already_decided)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, invalid lines or period, month not due, outside the podmiot

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/costs/occurrences/skip" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"recurringCostId\": \"00000000-0000-4000-8000-000000000000\",
  \"month\": \"string\",
  \"reason\": \"string\"
}"
```

## DELETE `/costs/recurring-costs`

Delete a template without decided months (id and reason in the body or the query)

**Tags:** Costs

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Deleted

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null,
  "createdId": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing costs.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Template or decision not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, decided months (template_in_use)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, invalid lines or period, month not due, outside the podmiot

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/costs/recurring-costs" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/costs/recurring-costs`

Templates of the selected organizations

**Tags:** Costs

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | query | any | Optional |
| activeIn | query | any | Optional |

### Responses

**200** – Templates, decided months, note (costs.manage only) and canManage

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "name": "string",
      "documentKind": "invoice_ksef",
      "frequency": "monthly",
      "anchorMonth": "string",
      "dueDay": 1,
      "paidInAdvance": true,
      "validFrom": "string",
      "validTo": null,
      "lines": [
        {
          "key": "string",
          "label": "string",
          "category": "materials",
          "netGr": 1,
          "vatBps": null
        }
      ],
      "seedKey": null,
      "updatedAt": "string",
      "note": null,
      "decidedMonths": [
        "string"
      ]
    }
  ],
  "total": 1,
  "canManage": true
}
```

**400** – Invalid filter

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/costs/recurring-costs" \
  -H "Accept: application/json"
```

## POST `/costs/recurring-costs`

Add a template (reason required)

**Tags:** Costs

### Request Body

Content-Type: `application/json`

```json
{
  "name": "string",
  "documentKind": "invoice_ksef",
  "frequency": "monthly",
  "anchorMonth": "string",
  "dueDay": 1,
  "paidInAdvance": true,
  "validFrom": "string",
  "validTo": null,
  "lines": [
    {
      "key": "string",
      "label": "string",
      "category": "materials",
      "netGr": 1,
      "vatBps": null
    }
  ],
  "note": null,
  "reason": "string",
  "organizationId": null,
  "seedKey": null
}
```

### Responses

**201** – Created

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null,
  "createdId": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing costs.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Template or decision not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, seed key already used (already_decided)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, invalid lines or period, month not due, outside the podmiot

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/costs/recurring-costs" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"name\": \"string\",
  \"documentKind\": \"invoice_ksef\",
  \"frequency\": \"monthly\",
  \"anchorMonth\": \"string\",
  \"dueDay\": 1,
  \"paidInAdvance\": true,
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"lines\": [
    {
      \"key\": \"string\",
      \"label\": \"string\",
      \"category\": \"materials\",
      \"netGr\": 1,
      \"vatBps\": null
    }
  ],
  \"note\": null,
  \"reason\": \"string\",
  \"organizationId\": null,
  \"seedKey\": null
}"
```

## PUT `/costs/recurring-costs`

Change a template (id, reason, version); changeFromMonth closes it and starts a new one

**Tags:** Costs

### Request Body

Content-Type: `application/json`

```json
{
  "name": "string",
  "documentKind": "invoice_ksef",
  "frequency": "monthly",
  "anchorMonth": "string",
  "dueDay": 1,
  "paidInAdvance": true,
  "validFrom": "string",
  "validTo": null,
  "lines": [
    {
      "key": "string",
      "label": "string",
      "category": "materials",
      "netGr": 1,
      "vatBps": null
    }
  ],
  "note": null,
  "reason": "string",
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null,
  "changeFromMonth": null
}
```

### Responses

**200** – Saved; createdId = the new template of "change from month"

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null,
  "createdId": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing costs.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Template or decision not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, decided months block the change (template_in_use)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, invalid lines or period, month not due, outside the podmiot

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/costs/recurring-costs" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"name\": \"string\",
  \"documentKind\": \"invoice_ksef\",
  \"frequency\": \"monthly\",
  \"anchorMonth\": \"string\",
  \"dueDay\": 1,
  \"paidInAdvance\": true,
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"lines\": [
    {
      \"key\": \"string\",
      \"label\": \"string\",
      \"category\": \"materials\",
      \"netGr\": 1,
      \"vatBps\": null
    }
  ],
  \"note\": null,
  \"reason\": \"string\",
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"updatedAt\": null,
  \"changeFromMonth\": null
}"
```

## GET `/dashboards/layout`

Load the current dashboard layout

Returns the saved widget layout together with the widgets the current user is allowed to place.

**Tags:** Dashboards

**Requires authentication.**

### Responses

**200** – Current dashboard layout and available widgets.

Content-Type: `application/json`

```json
{
  "layout": {
    "items": [
      {
        "id": "00000000-0000-4000-8000-000000000000",
        "widgetId": "string",
        "order": 1
      }
    ]
  },
  "allowedWidgetIds": [
    "string"
  ],
  "canConfigure": true,
  "context": {
    "userId": "00000000-0000-4000-8000-000000000000",
    "tenantId": null,
    "organizationId": null,
    "userName": null,
    "userEmail": null,
    "userLabel": "string"
  },
  "widgets": [
    {
      "id": "string",
      "title": "string",
      "description": null,
      "defaultSize": "sm",
      "defaultEnabled": true,
      "defaultSettings": null,
      "features": [
        "string"
      ],
      "moduleId": "string",
      "icon": null,
      "loaderKey": "string",
      "supportsRefresh": true
    }
  ]
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/dashboards/layout" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/dashboards/layout`

Persist dashboard layout changes

Saves the provided widget ordering, sizes, and settings for the current user.

**Tags:** Dashboards

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "widgetId": "string",
      "order": 1
    }
  ]
}
```

### Responses

**200** – Layout updated successfully.

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Invalid layout payload

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing dashboards.configure feature

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Widget registry unavailable — the layout was not saved

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/dashboards/layout" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"items\": [
    {
      \"id\": \"00000000-0000-4000-8000-000000000000\",
      \"widgetId\": \"string\",
      \"order\": 1
    }
  ]
}"
```

## PATCH `/dashboards/layout/{itemId}`

Update a dashboard layout item

Adjusts the size or settings for a single widget within the dashboard layout.

**Tags:** Dashboards

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| itemId | path | any | Required |

### Request Body

Content-Type: `application/json`

```json
{}
```

### Responses

**200** – Layout item updated.

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Invalid payload or missing item id

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing dashboards.configure feature

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Item not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PATCH "https://manifaktura.vicoop.com/api/dashboards/layout/00000000-0000-4000-8000-000000000000" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{}"
```

## GET `/dashboards/roles/widgets`

Fetch widget assignments for a role

Returns the widgets explicitly assigned to the given role together with the evaluation scope.

**Tags:** Dashboards

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| roleId | query | any | Required |
| tenantId | query | any | Optional |
| organizationId | query | any | Optional |

### Responses

**200** – Current widget configuration for the role.

Content-Type: `application/json`

```json
{
  "widgetIds": [
    "string"
  ],
  "hasCustom": true,
  "scope": {
    "tenantId": null,
    "organizationId": null
  }
}
```

**400** – Missing role identifier

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Insufficient permissions to manage role widgets

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/dashboards/roles/widgets?roleId=00000000-0000-4000-8000-000000000000" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/dashboards/roles/widgets`

Update widgets assigned to a role

Persists the widget list for a role within the provided tenant and organization scope.

**Tags:** Dashboards

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "roleId": "00000000-0000-4000-8000-000000000000",
  "widgetIds": [
    "string"
  ]
}
```

### Responses

**200** – Widgets updated successfully.

Content-Type: `application/json`

```json
{
  "ok": true,
  "widgetIds": [
    "string"
  ]
}
```

**400** – Invalid payload or unknown widgets

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Insufficient permissions to manage role widgets

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/dashboards/roles/widgets" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"roleId\": \"00000000-0000-4000-8000-000000000000\",
  \"widgetIds\": [
    \"string\"
  ]
}"
```

## GET `/dashboards/users/widgets`

Read widget overrides for a user

Returns the widgets inherited and explicitly configured for the requested user within the current scope.

**Tags:** Dashboards

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| userId | query | any | Required |
| tenantId | query | any | Optional |
| organizationId | query | any | Optional |

### Responses

**200** – Widget settings for the user.

Content-Type: `application/json`

```json
{
  "mode": "inherit",
  "widgetIds": [
    "string"
  ],
  "hasCustom": true,
  "effectiveWidgetIds": [
    "string"
  ],
  "scope": {
    "tenantId": null,
    "organizationId": null
  }
}
```

**400** – Missing user identifier

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Insufficient permissions to manage user widgets

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/dashboards/users/widgets?userId=00000000-0000-4000-8000-000000000000" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/dashboards/users/widgets`

Update user-specific dashboard widgets

Sets the widget override mode and allowed widgets for a user. Passing `mode: inherit` clears overrides.

**Tags:** Dashboards

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "userId": "00000000-0000-4000-8000-000000000000",
  "mode": "inherit",
  "widgetIds": [
    "string"
  ]
}
```

### Responses

**200** – Overrides saved.

Content-Type: `application/json`

```json
{
  "ok": true,
  "mode": "inherit",
  "widgetIds": [
    "string"
  ]
}
```

**400** – Invalid payload or unknown widgets

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Insufficient permissions to manage user widgets

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/dashboards/users/widgets" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"userId\": \"00000000-0000-4000-8000-000000000000\",
  \"mode\": \"inherit\",
  \"widgetIds\": [
    \"string\"
  ]
}"
```

## GET `/dashboards/widgets/catalog`

List available dashboard widgets

Returns the catalog of widgets that modules expose, including defaults and feature requirements.

**Tags:** Dashboards

**Requires authentication.**

### Responses

**200** – Widgets available for assignment.

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "string",
      "title": "string",
      "description": null,
      "defaultSize": "sm",
      "defaultEnabled": true,
      "defaultSettings": null,
      "features": [
        "string"
      ],
      "moduleId": "string",
      "icon": null,
      "loaderKey": "string",
      "supportsRefresh": true
    }
  ]
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Insufficient permissions to view widget catalog

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/dashboards/widgets/catalog" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/dashboards/widgets/data`

Fetch aggregated data for dashboard widgets

Executes an aggregation query against the specified entity type and returns the result. Supports date range filtering, grouping, and period-over-period comparison.

**Tags:** Dashboards

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entityType": "string",
  "metric": {
    "field": "string",
    "aggregate": "count"
  }
}
```

### Responses

**200** – Aggregated data for the widget.

Content-Type: `application/json`

```json
{
  "value": null,
  "data": [
    {
      "value": null
    }
  ],
  "metadata": {
    "fetchedAt": "string",
    "recordCount": 1,
    "currency": null
  }
}
```

**400** – Invalid request payload

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing analytics.view feature

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Too many rows to group an encrypted field in application code

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Internal server error

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Encryption is configured but the group source cannot currently be resolved

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/dashboards/widgets/data" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entityType\": \"string\",
  \"metric\": {
    \"field\": \"string\",
    \"aggregate\": \"count\"
  }
}"
```

## POST `/dashboards/widgets/data/batch`

Fetch aggregated data for multiple dashboard widgets in one request

Resolves a batch of widget data requests with a single authentication, RBAC, organization-scope, and database-context setup. Each request is keyed by an opaque widget id and resolved independently, so a failure in one widget does not fail the batch.

**Tags:** Dashboards

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "requests": [
    {
      "id": "string",
      "request": {
        "entityType": "string",
        "metric": {
          "field": "string",
          "aggregate": "count"
        }
      }
    }
  ]
}
```

### Responses

**200** – Per-widget aggregation results keyed by request id.

Content-Type: `application/json`

```json
{
  "results": [
    {
      "id": "string",
      "ok": true,
      "data": {
        "value": null,
        "data": [
          {
            "value": null
          }
        ],
        "metadata": {
          "fetchedAt": "string",
          "recordCount": 1,
          "currency": null
        }
      }
    }
  ]
}
```

**400** – Invalid request payload

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Internal server error

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/dashboards/widgets/data/batch" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"requests\": [
    {
      \"id\": \"string\",
      \"request\": {
        \"entityType\": \"string\",
        \"metric\": {
          \"field\": \"string\",
          \"aggregate\": \"count\"
        }
      }
    }
  ]
}"
```

## DELETE `/deadlines/marks`

Reopen a marked deadline (reason and version required)

**Tags:** Deadlines

### Request Body

Content-Type: `application/json`

```json
{
  "markId": "00000000-0000-4000-8000-000000000000",
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Reopened

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "key": "string",
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "status": null,
  "updatedAt": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing feature, organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, invalid recurrence, parameter and recurrence together, outside the legal entity

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/deadlines/marks" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"markId\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## POST `/deadlines/marks`

Mark a rule deadline done or skipped (skipped needs a reason; derived deadlines are read-only)

**Tags:** Deadlines

### Request Body

Content-Type: `application/json`

```json
{
  "status": "done",
  "doneOn": null,
  "note": null,
  "reason": null
}
```

### Responses

**201** – Marked

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "key": "string",
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "status": null,
  "updatedAt": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing feature, organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, derived deadline (derived_read_only), already marked

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, invalid recurrence, parameter and recurrence together, outside the legal entity

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/deadlines/marks" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"status\": \"done\",
  \"doneOn\": null,
  \"note\": null,
  \"reason\": null
}"
```

## GET `/deadlines/occurrences`

Deadline occurrences with their due dates and statuses in a date range

from, to, asOf: rrrr-mm-dd (defaults: asOf today, from asOf − 90 days, to asOf + 90 days; at most 400 days); organizationId optional (must be in scope). Statuses: open, overdue, done, skipped. Derived deadlines (cost_payment, accounting_package) are read-only. No amounts.

**Tags:** Deadlines

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| from | query | any | Optional |
| to | query | any | Optional |
| asOf | query | any | Optional |
| organizationId | query | any | Optional |

### Responses

**200** – Deadlines

Content-Type: `application/json`

```json
{
  "from": "string",
  "to": "string",
  "asOf": "string",
  "items": [
    {
      "key": "string",
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "ruleId": null,
      "code": "zus_contributions",
      "label": null,
      "periodKey": "string",
      "nominalDate": "string",
      "dueDate": "string",
      "status": "open",
      "derived": true,
      "doneOn": null,
      "markId": null,
      "link": null,
      "updatedAt": null,
      "warnings": [
        "string"
      ]
    }
  ],
  "organizations": [
    {
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "organizationName": "string"
    }
  ],
  "canManage": true
}
```

**400** – Invalid range or longer than 400 days

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/deadlines/occurrences" \
  -H "Accept: application/json"
```

## DELETE `/deadlines/rules`

Delete a deadline rule (soft; reason and version required)

**Tags:** Deadlines

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Deleted

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing feature, organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, invalid recurrence, parameter and recurrence together, outside the legal entity

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/deadlines/rules" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/deadlines/rules`

Deadline rules with their 3 nearest due dates (or the preview of an unsaved rule)

organizationId and id optional (must be in scope). `preview` = JSON {organizationId, paramKey?, recurrence?, shift, validFrom, validTo?} returns `{ preview, issues }` instead of the list. The note is returned only to person sessions.

**Tags:** Deadlines

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| organizationId | query | any | Optional |
| id | query | any | Optional |
| preview | query | any | Optional |

### Responses

**200** – Rules

Content-Type: `application/json`

```json
{
  "asOf": "string",
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "code": "zus_contributions",
      "label": null,
      "paramKey": null,
      "recurrence": null,
      "shift": "next_business_day",
      "leadDays": [
        1
      ],
      "validFrom": "string",
      "validTo": null,
      "isActive": true,
      "seedKey": null,
      "updatedAt": "string",
      "note": null,
      "next": [
        {
          "periodKey": "string",
          "nominalDate": "string",
          "dueDate": "string",
          "warnings": [
            "string"
          ]
        }
      ],
      "issues": [
        {
          "code": "string",
          "periodKey": null
        }
      ]
    }
  ],
  "organizations": [
    {
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "organizationName": "string",
      "activeFrom": "string",
      "activeTo": null
    }
  ],
  "canManage": true
}
```

**400** – Invalid query

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Rule not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/deadlines/rules" \
  -H "Accept: application/json"
```

## POST `/deadlines/rules`

Add a deadline rule (parameter key or own recurrence)

**Tags:** Deadlines

### Request Body

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "code": "zus_contributions",
  "label": null,
  "paramKey": null,
  "recurrence": null,
  "shift": "next_business_day",
  "leadDays": [
    1
  ],
  "validFrom": "string",
  "validTo": null,
  "isActive": true,
  "note": null,
  "reason": null
}
```

### Responses

**201** – Created

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing feature, organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, invalid recurrence, parameter and recurrence together, outside the legal entity

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/deadlines/rules" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"organizationId\": \"00000000-0000-4000-8000-000000000000\",
  \"code\": \"zus_contributions\",
  \"label\": null,
  \"paramKey\": null,
  \"recurrence\": null,
  \"shift\": \"next_business_day\",
  \"leadDays\": [
    1
  ],
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"isActive\": true,
  \"note\": null,
  \"reason\": null
}"
```

## PUT `/deadlines/rules`

Change a deadline rule (reason and version required)

**Tags:** Deadlines

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "code": "zus_contributions",
  "label": null,
  "paramKey": null,
  "recurrence": null,
  "shift": "next_business_day",
  "leadDays": [
    1
  ],
  "validFrom": "string",
  "validTo": null,
  "isActive": true,
  "note": null,
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing feature, organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, invalid recurrence, parameter and recurrence together, outside the legal entity

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/deadlines/rules" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"code\": \"zus_contributions\",
  \"label\": null,
  \"paramKey\": null,
  \"recurrence\": null,
  \"shift\": \"next_business_day\",
  \"leadDays\": [
    1
  ],
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"isActive\": true,
  \"note\": null,
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/directory/organization-branding`

Read sidebar branding for the selected organization

Returns the logo URL used by the backend sidebar for the currently selected organization.

**Tags:** Directory

**Requires authentication.**

### Responses

**200** – Organization branding

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "organizationName": "string",
  "tenantId": "00000000-0000-4000-8000-000000000000",
  "logoUrl": null,
  "logoPreserveAspectRatio": true,
  "updatedAt": null
}
```

**400** – A concrete organization scope is required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Organization not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/directory/organization-branding" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/directory/organization-branding`

Update sidebar branding for the selected organization

Stores an external image URL or an internal attachment image URL as the selected organization logo.

**Tags:** Directory

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "logoUrl": null
}
```

### Responses

**200** – Updated organization branding

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "organizationName": "string",
  "tenantId": "00000000-0000-4000-8000-000000000000",
  "logoUrl": null,
  "logoPreserveAspectRatio": true,
  "updatedAt": null
}
```

**400** – Save failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Organization branding changed since it was loaded

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Invalid logo URL

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/directory/organization-branding" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"logoUrl\": null
}"
```

## GET `/directory/organization-switcher`

Load organization switcher menu

Returns the hierarchical menu of organizations the current user may switch to within the active tenant.

**Tags:** Directory

**Requires authentication.**

### Responses

**200** – Organization switcher payload.

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "name": "string",
      "depth": 1,
      "selectable": true,
      "children": []
    }
  ],
  "selectedId": null,
  "canManage": true,
  "canViewAllOrganizations": true,
  "tenantId": null,
  "tenants": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "name": "string",
      "isActive": true
    }
  ],
  "isSuperAdmin": true
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/directory/organization-switcher" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/directory/organizations`

Delete organization

Soft deletes an organization identified by id.

**Tags:** Directory

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000"
}
```

### Responses

**200** – Organization deleted.

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Validation failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing directory.organizations.manage feature

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/directory/organizations" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\"
}"
```

## GET `/directory/organizations`

List organizations

Returns organizations using options, tree, or paginated manage view depending on the `view` parameter.

**Tags:** Directory

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| search | query | any | Optional |
| view | query | any | Optional |
| ids | query | any | Optional |
| tenantId | query | any | Optional |
| includeInactive | query | any | Optional |
| status | query | any | Optional |

### Responses

**200** – Organization data for the requested view.

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "name": "string",
      "parentId": null,
      "parentName": null,
      "tenantId": null,
      "tenantName": null,
      "rootId": null,
      "treePath": null
    }
  ]
}
```

**400** – Invalid query or tenant scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/directory/organizations?page=1&pageSize=50&view=options" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/directory/organizations`

Create organization

Creates a new organization within a tenant and optionally assigns hierarchy relationships.

**Tags:** Directory

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "name": "string",
  "slug": null,
  "logoUrl": null,
  "parentId": null
}
```

### Responses

**201** – Organization created.

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000"
}
```

**400** – Validation failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing directory.organizations.manage feature

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/directory/organizations" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"name\": \"string\",
  \"slug\": null,
  \"logoUrl\": null,
  \"parentId\": null
}"
```

## PUT `/directory/organizations`

Update organization

Updates organization details and hierarchy assignments.

**Tags:** Directory

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "slug": null,
  "logoUrl": null,
  "parentId": null
}
```

### Responses

**200** – Organization updated.

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Validation failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing directory.organizations.manage feature

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/directory/organizations" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"slug\": null,
  \"logoUrl\": null,
  \"parentId\": null
}"
```

## GET `/directory/organizations/lookup`

Public organization lookup by slug

**Tags:** Directory (Tenants & Organizations)

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/directory/organizations/lookup" \
  -H "Accept: application/json"
```

## DELETE `/directory/tenants`

Delete tenant

Soft deletes the tenant identified by id.

**Tags:** Directory

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000"
}
```

### Responses

**200** – Tenant removed.

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Validation failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing directory.tenants.manage feature

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/directory/tenants" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\"
}"
```

## GET `/directory/tenants`

List tenants

Returns tenants visible to the current user with optional search and pagination.

**Tags:** Directory

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | query | any | Optional |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| search | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |
| isActive | query | any | Optional |

### Responses

**200** – Paged list of tenants.

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "name": "string",
      "isActive": true,
      "createdAt": null,
      "updatedAt": null
    }
  ],
  "total": 1,
  "page": 1,
  "pageSize": 1,
  "totalPages": 1
}
```

**400** – Invalid query parameters

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Requires super-admin

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/directory/tenants?page=1&pageSize=50" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/directory/tenants`

Create tenant

Creates a new tenant and returns its identifier.

**Tags:** Directory

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "name": "string"
}
```

### Responses

**201** – Tenant created.

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000"
}
```

**400** – Validation failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing directory.tenants.manage feature

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/directory/tenants" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"name\": \"string\"
}"
```

## PUT `/directory/tenants`

Update tenant

Updates tenant properties such as name or activation state.

**Tags:** Directory

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000"
}
```

### Responses

**200** – Tenant updated.

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Validation failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing directory.tenants.manage feature

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/directory/tenants" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\"
}"
```

## GET `/directory/tenants/lookup`

Public tenant lookup

**Tags:** Directory (Tenants & Organizations)

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/directory/tenants/lookup" \
  -H "Accept: application/json"
```

## DELETE `/entities/definitions`

Soft delete custom field definition

Marks the specified definition inactive and tombstones it for the current scope.

**Tags:** Entities

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entityId": "string",
  "key": "string"
}
```

### Responses

**200** – Definition deleted

Content-Type: `application/json`

```json
{
  "ok": true,
  "version": null
}
```

**400** – Missing entity id or key

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Definition not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/entities/definitions" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entityId\": \"string\",
  \"key\": \"string\"
}"
```

## GET `/entities/definitions`

List active custom field definitions

Returns active custom field definitions for the supplied entity ids, respecting tenant scope and tombstones.

**Tags:** Entities

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| entityId | query | any | Optional |
| entityIds | query | any | Optional |
| fieldset | query | any | Optional |

### Responses

**200** – Definition list

Content-Type: `application/json`

```json
{
  "items": [
    {
      "key": "string",
      "kind": "string",
      "label": "string",
      "entityId": "string"
    }
  ]
}
```

**400** – Missing entity id

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/entities/definitions" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/entities/definitions`

Upsert custom field definition

Creates or updates a custom field definition for the current tenant/org scope.

**Tags:** Entities

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entityId": "string",
  "key": "string",
  "kind": "text"
}
```

### Responses

**200** – Definition saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "item": {
    "id": "00000000-0000-4000-8000-000000000000",
    "key": "string",
    "kind": "string",
    "configJson": {}
  }
}
```

**400** – Validation failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/entities/definitions" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entityId\": \"string\",
  \"key\": \"string\",
  \"kind\": \"text\"
}"
```

## POST `/entities/definitions.batch`

Save multiple custom field definitions

Creates or updates multiple definitions for a single entity in one transaction.

**Tags:** Entities

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entityId": "string",
  "definitions": [
    {
      "key": "string",
      "kind": "text"
    }
  ]
}
```

### Responses

**200** – Definitions saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "version": null
}
```

**400** – Validation error

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Unexpected failure

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/entities/definitions.batch" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entityId\": \"string\",
  \"definitions\": [
    {
      \"key\": \"string\",
      \"kind\": \"text\"
    }
  ]
}"
```

## GET `/entities/definitions.manage`

Get management snapshot

Returns scoped custom field definitions (including inactive tombstones) for administration interfaces.

**Tags:** Entities

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| entityId | query | any | Required |

### Responses

**200** – Scoped definitions and deleted keys

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "key": "string",
      "kind": "string",
      "configJson": null,
      "organizationId": null,
      "tenantId": null
    }
  ],
  "deletedKeys": [
    "string"
  ],
  "version": null
}
```

**400** – Missing entity id

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Missing authentication or feature

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/entities/definitions.manage?entityId=string" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/entities/definitions.restore`

Restore definition

Reactivates a previously soft-deleted definition within the current tenant/org scope.

**Tags:** Entities

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entityId": "string",
  "key": "string"
}
```

### Responses

**200** – Definition restored

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Missing entity id or key

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Definition not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/entities/definitions.restore" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entityId\": \"string\",
  \"key\": \"string\"
}"
```

## GET `/entities/encryption`

Fetch encryption map

Returns the encrypted field map for the current tenant/organization scope.

**Tags:** Entities

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| entityId | query | any | Required |

### Responses

**200** – Map

Content-Type: `application/json`

```json
{
  "entityId": "string",
  "fields": [
    {
      "field": "string",
      "hashField": null
    }
  ],
  "updatedAt": null
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/entities/encryption?entityId=string" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/entities/encryption`

Upsert encryption map

Creates or updates the encryption map for the current tenant/organization scope. Enforces optimistic locking when the caller sends the expected version header.

**Tags:** Entities

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entityId": "string",
  "tenantId": null,
  "organizationId": null,
  "fields": [
    {
      "field": "string",
      "hashField": null
    }
  ]
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "updatedAt": null
}
```

**409** – Optimistic-lock conflict (stale write)

Content-Type: `application/json`

```json
{
  "error": "string",
  "code": "string",
  "currentUpdatedAt": "string",
  "expectedUpdatedAt": "string"
}
```

**422** – Selected organization is unavailable

Content-Type: `application/json`

```json
{
  "error": "string",
  "code": "organization_selection_invalid"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/entities/encryption" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entityId\": \"string\",
  \"tenantId\": null,
  \"organizationId\": null,
  \"fields\": [
    {
      \"field\": \"string\",
      \"hashField\": null
    }
  ]
}"
```

## DELETE `/entities/entities`

Soft delete custom entity

Marks the specified custom entity inactive within the current scope.

**Tags:** Entities

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entityId": "string"
}
```

### Responses

**200** – Entity deleted

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Missing entity id

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Entity not found in scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/entities/entities" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entityId\": \"string\"
}"
```

## GET `/entities/entities`

List available entities

Returns generated and custom entities scoped to the caller with field counts per entity.

**Tags:** Entities

**Requires authentication.**

### Responses

**200** – List of entities

Content-Type: `application/json`

```json
{
  "items": [
    {
      "entityId": "string",
      "source": "code",
      "label": "string",
      "count": 1
    }
  ]
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/entities/entities" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/entities/entities`

Upsert custom entity

Creates or updates a tenant/org scoped custom entity definition.

**Tags:** Entities

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entityId": "string",
  "label": "string",
  "description": null,
  "showInSidebar": false,
  "accessRestricted": false
}
```

### Responses

**200** – Entity saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "item": {
    "id": "00000000-0000-4000-8000-000000000000",
    "entityId": "string",
    "label": "string"
  }
}
```

**400** – Validation error

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/entities/entities" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entityId\": \"string\",
  \"label\": \"string\",
  \"description\": null,
  \"showInSidebar\": false,
  \"accessRestricted\": false
}"
```

## GET `/entities/entity-settings`

Get custom entity settings

Returns the tenant-scoped default-restricted policy for new custom entities.

**Tags:** Entities

**Requires authentication.**

### Responses

**200** – Current settings

Content-Type: `application/json`

```json
{
  "newEntitiesRestrictedByDefault": true,
  "updatedAt": null
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/entities/entity-settings" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/entities/entity-settings`

Update custom entity settings

Sets the tenant-scoped default-restricted policy for new custom entities.

**Tags:** Entities

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "newEntitiesRestrictedByDefault": true
}
```

### Responses

**200** – Updated settings

Content-Type: `application/json`

```json
{
  "ok": true,
  "newEntitiesRestrictedByDefault": true,
  "updatedAt": null
}
```

**400** – Invalid payload

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Optimistic lock conflict

Content-Type: `application/json`

```json
{
  "code": "string",
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/entities/entity-settings" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"newEntitiesRestrictedByDefault\": true
}"
```

## DELETE `/entities/records`

Delete record

Soft deletes the specified record within the current tenant/org scope.

**Tags:** Entities

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entityId": "string",
  "recordId": "string"
}
```

### Responses

**200** – Record deleted

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Missing entity id or record id

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Record not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Unexpected failure

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/entities/records" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entityId\": \"string\",
  \"recordId\": \"string\"
}"
```

## GET `/entities/records`

List records

Returns paginated records for the supplied entity. Supports custom field filters, exports, and soft-delete toggles.

**Tags:** Entities

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| entityId | query | any | Required |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |
| search | query | any | Optional |
| searchFields | query | any | Optional |
| withDeleted | query | any | Optional |
| format | query | any | Optional |
| exportScope | query | any | Optional |
| export_scope | query | any | Optional |
| all | query | any | Optional |
| full | query | any | Optional |

### Responses

**200** – Paginated records

Content-Type: `application/json`

```json
{
  "items": [
    {}
  ],
  "total": 1,
  "page": 1,
  "pageSize": 1,
  "totalPages": 1
}
```

**400** – Missing entity id

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Unexpected failure

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/entities/records?entityId=string" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/entities/records`

Create record

Creates a record for the given entity. When `recordId` is omitted or not a UUID the data engine will generate one automatically.

**Tags:** Entities

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entityId": "string",
  "values": {}
}
```

### Responses

**200** – Record created

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Validation failure

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Unexpected failure

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/entities/records" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entityId\": \"string\",
  \"values\": {}
}"
```

## PUT `/entities/records`

Update record

Updates an existing record. If the provided recordId is not a UUID the record will be created instead to support optimistic flows.

**Tags:** Entities

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entityId": "string",
  "recordId": "string",
  "values": {}
}
```

### Responses

**200** – Record updated

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Validation failure

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Unexpected failure

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/entities/records" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entityId\": \"string\",
  \"recordId\": \"string\",
  \"values\": {}
}"
```

## GET `/entities/relations/options`

List relation options

Returns up to 200 option entries for populating relation dropdowns, automatically resolving label fields when omitted. An entityId that matches neither an active custom entity nor a registered ORM entity yields an empty option list.

**Tags:** Entities

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| entityId | query | any | Required |
| labelField | query | any | Optional |
| q | query | any | Optional |
| ids | query | any | Optional |
| routeContextFields | query | any | Optional |

### Responses

**200** – Option list

Content-Type: `application/json`

```json
{
  "items": [
    {
      "value": "string",
      "label": "string"
    }
  ]
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/entities/relations/options?entityId=string" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/entities/sidebar-entities`

Get sidebar entities

Returns custom entities flagged with `showInSidebar` for the current tenant/org scope.

**Tags:** Entities

**Requires authentication.**

### Responses

**200** – Sidebar entities for navigation

Content-Type: `application/json`

```json
{
  "items": [
    {
      "entityId": "string",
      "label": "string",
      "href": "string"
    }
  ]
}
```

**401** – Missing authentication

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/entities/sidebar-entities" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/events`

List declared events

Returns every declared event, including its declared payloadSchema when the module (or the generated CRUD default) provides one. Filters: category, module, excludeTriggerExcluded (default true).

**Tags:** Events

**Requires authentication.**

### Responses

**200** – Declared events

Content-Type: `application/json`

```json
{
  "data": [
    {
      "id": "string",
      "label": "string"
    }
  ],
  "total": 1
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/events" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/events/stream`

GET /events/stream

**Tags:** Events

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/events/stream" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/insights/costs-by-category`

Costs of a legal entity per month and category (at most 24 months)

Ready read of Manifaktura (the same numbers as the screens). Amounts in grosze (divide by 100), shares in basis points (divide by 100 for %). Always quote `completeness.text`. Rows: recurring costs (confirmed, or planned until confirmed) and the cost of the persons as one amount (category payroll, gross + employer cost estimate). The entity is VAT exempt, so gross is the cost. KSeF invoices are not connected yet.

**Tags:** Insights

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| monthFrom | query | any | Required |
| monthTo | query | any | Required |
| organizationId | query | any | Optional |

### Responses

**200** – Costs by category

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "monthFrom": "string",
  "monthTo": "string",
  "rows": [
    {
      "month": "string",
      "category": "materials",
      "grossGr": 1,
      "netGr": 1,
      "source": "recurring",
      "confirmed": true
    }
  ],
  "totals": {
    "key": 1
  },
  "ksef": "not_connected",
  "completeness": {
    "through": null,
    "partial": true,
    "sources": [
      {
        "source": "string",
        "through": null,
        "state": "ok"
      }
    ],
    "text": "string"
  }
}
```

**400** – Invalid query, period or no legal entity for the period (`organization_required`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing insights.view or organization outside the scope (`organization_not_allowed`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/insights/costs-by-category?monthFrom=string&monthTo=string" \
  -H "Accept: application/json"
```

## GET `/insights/data-status`

How complete the data of every source is, per legal entity

Ready read of Manifaktura (the same numbers as the screens). Amounts in grosze (divide by 100), shares in basis points (divide by 100 for %). Always quote `completeness.text`. Per legal entity and source (Booksy visits and sales, work days of the persons, cash reports, recurring costs, settlements, accountant package, KSeF, accounting office): state (ok, lagging, missing, not_connected, not_applicable), last complete day or month, last import, lag in days and gaps. `dailyThrough` = the day up to which every daily source is complete.

**Tags:** Insights

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| organizationId | query | any | Optional |
| asOf | query | any | Optional |

### Responses

**200** – Data status

Content-Type: `application/json`

```json
{
  "asOf": "string",
  "completeness": {
    "through": null,
    "partial": true,
    "sources": [
      {
        "source": "string",
        "through": null,
        "state": "ok"
      }
    ],
    "text": "string"
  },
  "entities": [
    {
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "organizationName": "string",
      "activeFrom": "string",
      "activeTo": null,
      "sources": [
        {
          "source": "booksy_visits",
          "state": "ok",
          "granularity": "day",
          "lastCompleteDay": null,
          "lastCompleteMonth": null,
          "lastUpdateAt": null,
          "lagDays": null,
          "gaps": [
            {
              "from": "string",
              "to": "string",
              "days": 1,
              "code": "string"
            }
          ],
          "noteKey": null
        }
      ],
      "dailyThrough": null
    }
  ]
}
```

**400** – Invalid query, period or no legal entity for the period (`organization_required`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing insights.view or organization outside the scope (`organization_not_allowed`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/insights/data-status" \
  -H "Accept: application/json"
```

## GET `/insights/month-result`

Revenue, cost of the persons (one sum), fixed costs, result and indicators of a month

Ready read of Manifaktura (the same numbers as the screens). Amounts in grosze (divide by 100), shares in basis points (divide by 100 for %). Always quote `completeness.text`. resultGr = revenue.realGr − payroll.grossGr − payroll.employerCostGr − fixedCosts.grossGr − otherCosts.grossGr. Revenue = VAT limit counter, real basis (fiscal report where entered, Booksy otherwise). No amounts per person. `commentHints` are facts (codes and params) for a short comment.

**Tags:** Insights

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| month | query | any | Required |
| organizationId | query | any | Optional |

### Responses

**200** – Month result

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "organizationName": "string",
  "month": "string",
  "status": "open",
  "revenue": {
    "realGr": 1,
    "booksyGr": 1,
    "fiscalReportDays": 1
  },
  "payroll": {
    "grossGr": 1,
    "employerCostGr": 1,
    "persons": 1,
    "acceptedPersons": 1,
    "anyDraft": true,
    "coverageBps": null
  },
  "fixedCosts": {
    "grossGr": 1,
    "confirmedGr": 1,
    "plannedGr": 1
  },
  "otherCosts": {
    "state": "not_connected",
    "grossGr": 1,
    "source": null
  },
  "resultGr": 1,
  "indicators": {
    "payrollShareBps": null,
    "completedVisits": 1,
    "revenuePerVisitGr": null,
    "newClients": 1,
    "unfinalizedVisits": 1,
    "vatUsedBps": null
  },
  "commentHints": [
    {
      "code": "string",
      "params": {
        "key": "string"
      }
    }
  ],
  "completeness": {
    "through": null,
    "partial": true,
    "sources": [
      {
        "source": "string",
        "through": null,
        "state": "ok"
      }
    ],
    "text": "string"
  },
  "warnings": [
    "string"
  ]
}
```

**400** – Invalid query, period or no legal entity for the period (`organization_required`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing insights.view or organization outside the scope (`organization_not_allowed`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/insights/month-result?month=string" \
  -H "Accept: application/json"
```

## GET `/insights/overview`

Data status, VAT limit and the results of the current and the previous month at once

Ready read of Manifaktura (the same numbers as the screens). Amounts in grosze (divide by 100), shares in basis points (divide by 100 for %). Always quote `completeness.text`. Start here: the data status of every legal entity in scope, the VAT limit brief of the entity active today and the month results (current and previous month), each with its own completeness.

**Tags:** Insights

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| asOf | query | any | Optional |

### Responses

**200** – Overview

Content-Type: `application/json`

```json
{
  "asOf": "string",
  "completeness": {
    "through": null,
    "partial": true,
    "sources": [
      {
        "source": "string",
        "through": null,
        "state": "ok"
      }
    ],
    "text": "string"
  },
  "dataStatus": {
    "asOf": "string",
    "entities": [
      {
        "organizationId": "00000000-0000-4000-8000-000000000000",
        "organizationName": "string",
        "activeFrom": "string",
        "activeTo": null,
        "sources": [
          {
            "source": "booksy_visits",
            "state": "ok",
            "granularity": "day",
            "lastCompleteDay": null,
            "lastCompleteMonth": null,
            "lastUpdateAt": null,
            "lagDays": null,
            "gaps": [
              {
                "from": "string",
                "to": "string",
                "days": 1,
                "code": "string"
              }
            ],
            "noteKey": null
          }
        ],
        "dailyThrough": null
      }
    ]
  },
  "vat": [
    {
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "year": 1,
      "limitGr": 1,
      "countedGr": 1,
      "usedBps": null,
      "basis": "booksy",
      "variant": "main",
      "dataThrough": null,
      "crossingDate": null,
      "fiscalReportDays": 1,
      "level": "string",
      "warnings": [
        "string"
      ],
      "completeness": {
        "through": null,
        "partial": true,
        "sources": [
          {
            "source": "string",
            "through": null,
            "state": "ok"
          }
        ],
        "text": "string"
      }
    }
  ],
  "currentMonth": [
    {
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "organizationName": "string",
      "month": "string",
      "status": "open",
      "revenue": {
        "realGr": 1,
        "booksyGr": 1,
        "fiscalReportDays": 1
      },
      "payroll": {
        "grossGr": 1,
        "employerCostGr": 1,
        "persons": 1,
        "acceptedPersons": 1,
        "anyDraft": true,
        "coverageBps": null
      },
      "fixedCosts": {
        "grossGr": 1,
        "confirmedGr": 1,
        "plannedGr": 1
      },
      "otherCosts": {
        "state": "not_connected",
        "grossGr": 1,
        "source": null
      },
      "resultGr": 1,
      "indicators": {
        "payrollShareBps": null,
        "completedVisits": 1,
        "revenuePerVisitGr": null,
        "newClients": 1,
        "unfinalizedVisits": 1,
        "vatUsedBps": null
      },
      "commentHints": [
        {
          "code": "string",
          "params": {
            "key": "string"
          }
        }
      ],
      "completeness": {
        "through": null,
        "partial": true,
        "sources": [
          {
            "source": "string",
            "through": null,
            "state": "ok"
          }
        ],
        "text": "string"
      },
      "warnings": [
        "string"
      ]
    }
  ],
  "previousMonth": [
    {
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "organizationName": "string",
      "month": "string",
      "status": "open",
      "revenue": {
        "realGr": 1,
        "booksyGr": 1,
        "fiscalReportDays": 1
      },
      "payroll": {
        "grossGr": 1,
        "employerCostGr": 1,
        "persons": 1,
        "acceptedPersons": 1,
        "anyDraft": true,
        "coverageBps": null
      },
      "fixedCosts": {
        "grossGr": 1,
        "confirmedGr": 1,
        "plannedGr": 1
      },
      "otherCosts": {
        "state": "not_connected",
        "grossGr": 1,
        "source": null
      },
      "resultGr": 1,
      "indicators": {
        "payrollShareBps": null,
        "completedVisits": 1,
        "revenuePerVisitGr": null,
        "newClients": 1,
        "unfinalizedVisits": 1,
        "vatUsedBps": null
      },
      "commentHints": [
        {
          "code": "string",
          "params": {
            "key": "string"
          }
        }
      ],
      "completeness": {
        "through": null,
        "partial": true,
        "sources": [
          {
            "source": "string",
            "through": null,
            "state": "ok"
          }
        ],
        "text": "string"
      },
      "warnings": [
        "string"
      ]
    }
  ]
}
```

**400** – Invalid query, period or no legal entity for the period (`organization_required`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing insights.view or organization outside the scope (`organization_not_allowed`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/insights/overview" \
  -H "Accept: application/json"
```

## GET `/insights/reports`

Reports of the legal entities of the organization switcher, without the data

Ready reports of Manifaktura: weekly (KOK-02, ISO week) and monthly (KOK-03, after the live delivery of the accountant package). No report data here - the detail is /api/insights/reports/{id}. Amounts in grosze.

**Tags:** Insights

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| kind | query | any | Optional |
| from | query | any | Optional |
| to | query | any | Optional |

### Responses

**200** – Reports

Content-Type: `application/json`

```json
{
  "from": "string",
  "to": "string",
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "kind": "weekly",
      "periodKey": "string",
      "status": "generated",
      "contentHash": "string",
      "completenessThrough": null,
      "generatedAt": "string",
      "notifiedAt": null,
      "data": null,
      "updatedAt": "string"
    }
  ]
}
```

**400** – Invalid or too long period

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing insights.view

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/insights/reports" \
  -H "Accept: application/json"
```

## GET `/insights/reports/{id}`

Report detail (data of the legal entity, amounts in grosze)

Weekly report: revenue (real basis), completed visits, new clients, open cases, cash days, data status and completeness. Monthly report: the month result against the previous month of the same legal entity and the template comment. Always quote completeness.text.

**Tags:** Insights

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Report

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "kind": "weekly",
  "periodKey": "string",
  "status": "generated",
  "contentHash": "string",
  "completenessThrough": null,
  "generatedAt": "string",
  "notifiedAt": null,
  "data": null,
  "updatedAt": "string"
}
```

**403** – Missing insights.view

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Report not found in the caller scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/insights/reports/:id" \
  -H "Accept: application/json"
```

## POST `/insights/reports/generate`

Regenerate (same data = no write) or resend (notify on a notified report, reason required)

Writes go through the command insights.reports.generate (audit log with the reason). The answer has no report data.

**Tags:** Insights

### Request Body

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "kind": "weekly",
  "periodKey": "string",
  "reason": null,
  "updatedAt": null
}
```

### Responses

**200** – Result of the command

Content-Type: `application/json`

```json
{
  "reportId": "00000000-0000-4000-8000-000000000000",
  "kind": "weekly",
  "periodKey": "string",
  "created": true,
  "changed": true,
  "notifyOutcome": "not_requested",
  "recipients": 1,
  "report": {
    "id": "00000000-0000-4000-8000-000000000000",
    "organizationId": "00000000-0000-4000-8000-000000000000",
    "kind": "weekly",
    "periodKey": "string",
    "status": "generated",
    "contentHash": "string",
    "completenessThrough": null,
    "generatedAt": "string",
    "notifiedAt": null,
    "data": null,
    "updatedAt": "string"
  }
}
```

**400** – Invalid period

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing insights.manage or organization not allowed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – The report changed since it was shown

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Resend without a reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/insights/reports/generate" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"organizationId\": \"00000000-0000-4000-8000-000000000000\",
  \"kind\": \"weekly\",
  \"periodKey\": \"string\",
  \"reason\": null,
  \"updatedAt\": null
}"
```

## GET `/insights/revenue`

Revenue of a legal entity by day, week, month, service category or service (at most 366 days)

Ready read of Manifaktura (the same numbers as the screens). Amounts in grosze (divide by 100), shares in basis points (divide by 100 for %). Always quote `completeness.text`. Booksy sale lines by visit date, total minus tips, never per person. Note: this is Booksy revenue; the month result and the VAT limit use the real basis (fiscal reports where entered).

**Tags:** Insights

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| from | query | any | Required |
| to | query | any | Required |
| groupBy | query | any | Required |
| organizationId | query | any | Optional |

### Responses

**200** – Revenue breakdown

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "from": "string",
  "to": "string",
  "groupBy": "day",
  "rows": [
    {
      "key": "string",
      "label": "string",
      "revenueGr": 1,
      "lines": 1
    }
  ],
  "totalGr": 1,
  "completeness": {
    "through": null,
    "partial": true,
    "sources": [
      {
        "source": "string",
        "through": null,
        "state": "ok"
      }
    ],
    "text": "string"
  }
}
```

**400** – Invalid query, period or no legal entity for the period (`organization_required`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing insights.view or organization outside the scope (`organization_not_allowed`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/insights/revenue?from=string&to=string&groupBy=day" \
  -H "Accept: application/json"
```

## GET `/insights/settings`

Settings of the data status and the reports for the selected organization

Lag thresholds per source (days), data-gap reminders, weekly and monthly report switches.

**Tags:** Insights

### Responses

**200** – Settings

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "settings": {
    "settings": {},
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null
  },
  "defaults": {}
}
```

**400** – No organization selected

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/insights/settings" \
  -H "Accept: application/json"
```

## PUT `/insights/settings`

Change the settings (partial patch); reason required

**Tags:** Insights

### Request Body

Content-Type: `application/json`

```json
{
  "settings": {},
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Saved settings

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "settings": {
    "settings": {},
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null
  },
  "defaults": {}
}
```

**400** – Invalid settings or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing salon.decisions.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – The stored setting changed in the meantime

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/insights/settings" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"settings\": {},
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/insights/vat-limit`

Headline VAT limit counter of a legal entity: counted, limit, usage, forecast crossing

Ready read of Manifaktura (the same numbers as the screens). Amounts in grosze (divide by 100), shares in basis points (divide by 100 for %). Always quote `completeness.text`. The headline counter of the VAT exemption limit (basis and variant from the settings), proportional limit of the entity, usage in bps, forecast crossing date, days with a fiscal report and the level (ok, notice, warning, danger, exceeded, unknown).

**Tags:** Insights

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| organizationId | query | any | Optional |
| asOf | query | any | Optional |

### Responses

**200** – VAT limit brief

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "year": 1,
  "limitGr": 1,
  "countedGr": 1,
  "usedBps": null,
  "basis": "booksy",
  "variant": "main",
  "dataThrough": null,
  "crossingDate": null,
  "fiscalReportDays": 1,
  "level": "string",
  "warnings": [
    "string"
  ],
  "completeness": {
    "through": null,
    "partial": true,
    "sources": [
      {
        "source": "string",
        "through": null,
        "state": "ok"
      }
    ],
    "text": "string"
  }
}
```

**400** – Invalid query, period or no legal entity for the period (`organization_required`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing insights.view or organization outside the scope (`organization_not_allowed`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – VAT limit module not available

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/insights/vat-limit" \
  -H "Accept: application/json"
```

## GET `/integrations`

List integrations

Returns a paginated collection of integrations.

**Tags:** Integrations

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| q | query | any | Optional |
| category | query | any | Optional |
| bundleId | query | any | Optional |
| isEnabled | query | any | Optional |
| healthStatus | query | any | Optional |
| sort | query | any | Optional |
| order | query | any | Optional |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| ids | query | any | Optional. Comma-separated list of record UUIDs to filter by (max 200). |

### Responses

**200** – Paginated integrations

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "string",
      "title": "string",
      "description": null,
      "category": null,
      "tags": [
        "string"
      ],
      "hub": null,
      "providerKey": null,
      "bundleId": null,
      "author": null,
      "company": null,
      "version": null,
      "hasCredentials": true,
      "isEnabled": true,
      "apiVersion": null,
      "healthStatus": "healthy",
      "lastHealthCheckedAt": null,
      "lastHealthLatencyMs": null,
      "enabledAt": null,
      "analytics": {
        "lastActivityAt": null,
        "totalCount": 1,
        "errorCount": 1,
        "errorRate": 1,
        "dailyCounts": [
          1
        ]
      }
    }
  ],
  "total": 1,
  "totalPages": 1,
  "bundles": [
    {
      "id": "string",
      "title": "string",
      "description": "string",
      "icon": null,
      "integrationCount": 1,
      "enabledCount": 1
    }
  ]
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/integrations?order=asc&page=1&pageSize=100" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/integrations/{id}`

Get integration detail

**Tags:** Integrations

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/integrations/:id" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/integrations/{id}/credentials`

Get or save integration credentials

**Tags:** Integrations

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/integrations/:id/credentials" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/integrations/{id}/credentials`

Get or save integration credentials

**Tags:** Integrations

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/integrations/:id/credentials" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/integrations/{id}/health`

Run health check for an integration

**Tags:** Integrations

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**201** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/integrations/:id/health" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/integrations/{id}/state`

Update integration state

**Tags:** Integrations

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/integrations/:id/state" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/integrations/{id}/version`

Change integration API version

**Tags:** Integrations

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/integrations/:id/version" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/integrations/logs`

List integration logs

**Tags:** Integrations

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/integrations/logs" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/mcp_gateway/connections`

Disconnects (command mcp_gateway.grants.revoke): tokens end, the API key is deleted

**Tags:** MCP gateway

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000"
}
```

### Responses

**200** – Disconnected

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "string",
  "status": "string",
  "updatedAt": "string"
}
```

**403** – Connection of another person without mcp_gateway.manage, or an API key

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Unknown connection

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Changed meanwhile (stale_version)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/mcp_gateway/connections" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\"
}"
```

## GET `/mcp_gateway/connections`

Own connections, or all of the tenant with scope=all (mcp_gateway.manage)

**Tags:** MCP gateway

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| scope | query | any | Optional |
| includeEnded | query | any | Optional |

### Responses

**200** – Connections

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "userId": "00000000-0000-4000-8000-000000000000",
      "userEmail": null,
      "own": true,
      "clientId": "string",
      "clientName": null,
      "scope": "string",
      "status": "pending",
      "createdAt": "string",
      "expiresAt": "string",
      "lastUsedAt": null,
      "revokedAt": null,
      "revokedReason": null,
      "updatedAt": "string"
    }
  ],
  "canManage": true
}
```

**403** – API key, or scope=all without mcp_gateway.manage

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/mcp_gateway/connections" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/mcp_gateway/mcp`

Not supported (405)

**Tags:** MCP gateway

### Responses

**204** – Success

**405** – Use POST

Content-Type: `application/json`

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/mcp_gateway/mcp" \
  -H "Accept: application/json"
```

## GET `/mcp_gateway/mcp`

Not supported (405)

**Tags:** MCP gateway

### Responses

**200** – Success response

Content-Type: `application/json`

**405** – Use POST

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/mcp_gateway/mcp" \
  -H "Accept: application/json"
```

## POST `/mcp_gateway/mcp`

Forwards a JSON-RPC message or batch to the OM MCP server; requires the x-api-key header, or (OAuth switched on) Authorization: Bearer with a connector access token

**Tags:** MCP gateway

### Request Body

Content-Type: `application/json`

```json
{
  "jsonrpc": "2.0"
}
```

### Responses

**200** – JSON-RPC response from the MCP server

Content-Type: `application/json`

```json
{
  "jsonrpc": "2.0"
}
```

**401** – Missing or invalid API key or access token (OAuth: WWW-Authenticate with resource_metadata)

Content-Type: `application/json`

**403** – OAuth: client IP outside MCP_GATEWAY_ALLOWED_CIDRS

Content-Type: `application/json`

**404** – Gateway disabled

Content-Type: `application/json`

**413** – Body larger than 1 MB

Content-Type: `application/json`

**429** – Too many requests (per IP, or per OAuth connection)

Content-Type: `application/json`

**502** – MCP server unavailable

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/mcp_gateway/mcp" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"jsonrpc\": \"2.0\"
}"
```

## GET `/mcp_gateway/oauth/authorize`

Starts an authorization: redirects to the consent page, or back to the client with an OAuth error

**Tags:** MCP gateway

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| response_type | query | any | Required |
| client_id | query | any | Required. CIMD URL on an allowed host, or a DCR client id |
| redirect_uri | query | any | Required |
| code_challenge | query | any | Required. BASE64URL(SHA-256(code_verifier)), 43 characters |
| code_challenge_method | query | any | Required |
| state | query | any | Optional |
| scope | query | any | Optional. mcp:read (default) |
| resource | query | any | Optional. URL of the MCP endpoint (RFC 8707) |

### Responses

**200** – Success response

Content-Type: `application/json`

**302** – To the consent page, or to the redirect URI with error, state and iss

Content-Type: `application/json`

**400** – Unknown client or redirect URI (not redirected)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – OAuth switched off

Content-Type: `application/json`

**429** – Too many requests

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/mcp_gateway/oauth/authorize?response_type=code&client_id=string&redirect_uri=string&code_challenge=string&code_challenge_method=S256" \
  -H "Accept: application/json"
```

## GET `/mcp_gateway/oauth/consent`

What the consent screen shows, with a fresh nonce (binds the request to the signed-in person)

**Tags:** MCP gateway

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| requestId | query | any | Required |

### Responses

**200** – Consent view

Content-Type: `application/json`

```json
{
  "requestId": "00000000-0000-4000-8000-000000000000",
  "nonce": "string",
  "clientName": null,
  "clientId": "string",
  "redirectHost": "string",
  "scope": "string",
  "role": "ai_summary",
  "requestExpiresAt": "string",
  "connectionExpiresAt": "string",
  "accountEmail": null
}
```

**403** – API key, missing mcp_gateway.connect, restricted organizations, or another person

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Unknown request or OAuth switched off

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Request already decided

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**410** – Request expired (10 minutes)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/mcp_gateway/oauth/consent?requestId=00000000-0000-4000-8000-000000000000" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/mcp_gateway/oauth/consent`

Approve (command mcp_gateway.grants.approve) or deny; answers where the browser goes next

**Tags:** MCP gateway

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "requestId": "00000000-0000-4000-8000-000000000000",
  "nonce": "string",
  "decision": "approve"
}
```

### Responses

**200** – Redirect target with the code (or access_denied)

Content-Type: `application/json`

```json
{
  "ok": true,
  "redirectTo": "string"
}
```

**400** – Invalid body

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Origin, nonce, API key, permission or organizations refused

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Already decided, connection role missing or not read-only, too many connections

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**410** – Request expired

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Tenant encryption unavailable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/mcp_gateway/oauth/consent" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"requestId\": \"00000000-0000-4000-8000-000000000000\",
  \"nonce\": \"string\",
  \"decision\": \"approve\"
}"
```

## POST `/mcp_gateway/oauth/register`

Registers a public client (token_endpoint_auth_method none)

**Tags:** MCP gateway

### Request Body

Content-Type: `application/json`

```json
{
  "redirect_uris": [
    "string"
  ]
}
```

### Responses

**201** – Registered client

Content-Type: `application/json`

**400** – invalid_redirect_uri or invalid_client_metadata

Content-Type: `application/json`

**404** – Registration switched off

Content-Type: `application/json`

**429** – Too many registrations

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/mcp_gateway/oauth/register" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"redirect_uris\": [
    \"string\"
  ]
}"
```

## POST `/mcp_gateway/oauth/revoke`

Revokes a refresh token (whole connection) or an access token

**Tags:** MCP gateway

### Request Body

Content-Type: `application/x-www-form-urlencoded`

```text
token=string&client_id=string
```

### Responses

**200** – Done (also for unknown tokens)

Content-Type: `application/json`

**400** – Missing token

Content-Type: `application/json`

```json
{
  "error": "string",
  "error_description": "string"
}
```

**404** – OAuth switched off

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/mcp_gateway/oauth/revoke" \
  -H "Accept: application/json" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "token=string&client_id=string"
```

## POST `/mcp_gateway/oauth/token`

Exchanges a code (PKCE S256) or rotates a refresh token

**Tags:** MCP gateway

### Request Body

Content-Type: `application/x-www-form-urlencoded`

```text
grant_type=authorization_code&client_id=string
```

### Responses

**200** – Token pair

Content-Type: `application/json`

```json
{
  "access_token": "string",
  "token_type": "Bearer",
  "expires_in": 1,
  "refresh_token": "string",
  "scope": "string"
}
```

**400** – RFC 6749 error (invalid_grant, invalid_request, …)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – OAuth switched off

Content-Type: `application/json`

**429** – Too many requests

Content-Type: `application/json`

**500** – server_error

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/mcp_gateway/oauth/token" \
  -H "Accept: application/json" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=authorization_code&client_id=string"
```

## GET `/notifications`

List notifications

Returns a paginated collection of notifications.

**Tags:** Notifications

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| status | query | any | Optional |
| type | query | any | Optional |
| severity | query | any | Optional |
| sourceEntityType | query | any | Optional |
| sourceEntityId | query | any | Optional |
| since | query | any | Optional |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| ids | query | any | Optional. Comma-separated list of record UUIDs to filter by (max 200). |

### Responses

**200** – Paginated notifications

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "type": "string",
      "title": "string",
      "body": null,
      "titleKey": null,
      "bodyKey": null,
      "titleVariables": null,
      "bodyVariables": null,
      "icon": null,
      "severity": "string",
      "status": "string",
      "actions": [
        {
          "id": "string",
          "label": "string"
        }
      ],
      "sourceModule": null,
      "sourceEntityType": null,
      "sourceEntityId": null,
      "linkHref": null,
      "createdAt": "string",
      "readAt": null,
      "actionTaken": null
    }
  ],
  "total": 1,
  "page": 1,
  "pageSize": 1,
  "totalPages": 1
}
```

**403** – Request could not be resolved to a tenant scope (code: tenant_scope_required)

Content-Type: `application/json`

```json
{
  "error": "string",
  "code": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/notifications?page=1&pageSize=20" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/notifications`

Create notification

Creates a notification for a user.

**Tags:** Notifications

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "type": "string",
  "severity": "info",
  "recipientUserId": "00000000-0000-4000-8000-000000000000"
}
```

### Responses

**201** – Notification created

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/notifications" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"type\": \"string\",
  \"severity\": \"info\",
  \"recipientUserId\": \"00000000-0000-4000-8000-000000000000\"
}"
```

## POST `/notifications/{id}/action`

POST /notifications/{id}/action

**Tags:** Notifications

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**201** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/notifications/:id/action" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/notifications/{id}/dismiss`

PUT /notifications/{id}/dismiss

**Tags:** Notifications

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/notifications/:id/dismiss" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/notifications/{id}/read`

PUT /notifications/{id}/read

**Tags:** Notifications

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/notifications/:id/read" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/notifications/{id}/restore`

PUT /notifications/{id}/restore

**Tags:** Notifications

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/notifications/:id/restore" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/notifications/admin/preferences`

GET /notifications/admin/preferences

**Tags:** Notifications

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/notifications/admin/preferences" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/notifications/admin/preferences`

PUT /notifications/admin/preferences

**Tags:** Notifications

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/notifications/admin/preferences" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/notifications/batch`

POST /notifications/batch

**Tags:** Notifications

**Requires authentication.**

### Responses

**201** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/notifications/batch" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/notifications/channels`

GET /notifications/channels

**Tags:** Notifications

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/notifications/channels" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/notifications/feature`

POST /notifications/feature

**Tags:** Notifications

**Requires authentication.**

### Responses

**201** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/notifications/feature" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/notifications/mark-all-read`

PUT /notifications/mark-all-read

**Tags:** Notifications

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/notifications/mark-all-read" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/notifications/preferences`

GET /notifications/preferences

**Tags:** Notifications

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/notifications/preferences" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/notifications/preferences`

PUT /notifications/preferences

**Tags:** Notifications

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/notifications/preferences" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/notifications/role`

POST /notifications/role

**Tags:** Notifications

**Requires authentication.**

### Responses

**201** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/notifications/role" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/notifications/settings`

GET /notifications/settings

**Tags:** Notifications

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/notifications/settings" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/notifications/settings`

POST /notifications/settings

**Tags:** Notifications

**Requires authentication.**

### Responses

**201** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/notifications/settings" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/notifications/types`

GET /notifications/types

**Tags:** Notifications

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/notifications/types" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PATCH `/notifications/types`

PATCH /notifications/types

**Tags:** Notifications

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X PATCH "https://manifaktura.vicoop.com/api/notifications/types" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/notifications/types/{id}/channels/{channel}`

DELETE /notifications/types/{id}/channels/{channel}

**Tags:** Notifications

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |
| channel | path | any | Required |

### Responses

**204** – Success

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/notifications/types/:id/channels/:channel" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/notifications/types/{id}/channels/{channel}`

PUT /notifications/types/{id}/channels/{channel}

**Tags:** Notifications

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |
| channel | path | any | Required |

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/notifications/types/:id/channels/:channel" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/notifications/unread-count`

GET /notifications/unread-count

**Tags:** Notifications

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/notifications/unread-count" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/payroll_history/anomalies`

List migration anomalies of the payroll sheets

**Tags:** Payroll history

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| personKey | query | any | Optional |
| code | query | any | Optional |
| status | query | any | Optional |
| severity | query | any | Optional |
| month | query | any | Optional |
| monthId | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Anomalies

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "personKey": null,
      "month": null,
      "code": null,
      "severity": null,
      "params": {},
      "status": null,
      "explanation": null,
      "updatedAt": null
    }
  ]
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/payroll_history/anomalies?page=1&pageSize=50" \
  -H "Accept: application/json"
```

## PUT `/payroll_history/anomalies`

Explain or reopen an anomaly; reason required (audit log)

**Tags:** Payroll history

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "status": "explained",
  "explanation": null,
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Invalid input, missing explanation or reason

Content-Type: `application/json`

**403** – Organization not allowed

Content-Type: `application/json`

**404** – Anomaly not found

Content-Type: `application/json`

**409** – Changed by someone else, or no longer in the sheets

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/payroll_history/anomalies" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"status\": \"explained\",
  \"explanation\": null,
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/payroll_history/days`

List the days of one month (monthId required; amounts in grosze, time in minutes)

**Tags:** Payroll history

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| monthId | query | any | Required |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Days

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "day": null,
      "hoursMin": null
    }
  ]
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/payroll_history/days?page=1&pageSize=31&monthId=00000000-0000-4000-8000-000000000000" \
  -H "Accept: application/json"
```

## GET `/payroll_history/imports`

List applied payroll import batches

**Tags:** Payroll history

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| personKey | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Import batches

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "personKey": null,
      "monthFrom": null,
      "monthTo": null,
      "counts": null
    }
  ]
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/payroll_history/imports?page=1&pageSize=50" \
  -H "Accept: application/json"
```

## POST `/payroll_history/imports`

Preview or apply a payroll workbook (ODS)

**Tags:** Payroll history

### Request Body

Content-Type: `multipart/form-data`

```text
file=string
```

### Responses

**200** – Preview (dryRun) or applied import; counts only

Content-Type: `application/json`

```json
{
  "dryRun": true,
  "summary": {
    "person": {
      "personKey": "string",
      "personLabel": "string"
    },
    "startYear": 1,
    "sheets": 1,
    "skipped": 1,
    "layouts": {
      "U1": 1,
      "U2": 1,
      "U3": 1
    },
    "monthFrom": null,
    "monthTo": null,
    "months": [
      {
        "month": "string",
        "sheetName": "string",
        "layout": "U1",
        "days": 1,
        "anomalies": 1,
        "verification": "match"
      }
    ],
    "anomaliesByCode": {
      "key": 1
    },
    "verification": {
      "match": 1,
      "matchWithNotes": 1,
      "mismatch": 1,
      "notApplicable": 1
    },
    "errors": {
      "total": 1,
      "byCode": {
        "key": 1
      },
      "sample": [
        {
          "code": "string",
          "sheet": null,
          "address": null
        }
      ]
    },
    "warnings": {
      "total": 1,
      "byCode": {
        "key": 1
      },
      "sample": [
        {
          "code": "string",
          "sheet": null,
          "address": null
        }
      ]
    }
  }
}
```

**400** – Missing or invalid file or field

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization not allowed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**413** – File larger than 10 MB

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**415** – Not multipart/form-data

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Unreadable workbook, blocking sheet errors or months outside the legal entities

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Import failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/payroll_history/imports" \
  -H "Accept: application/json" \
  -H "Content-Type: multipart/form-data" \
  -d "{
  \"file\": \"string\"
}"
```

## GET `/payroll_history/months`

List imported payroll months (amounts in grosze, time in minutes, read-only)

**Tags:** Payroll history

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| id | query | any | Optional |
| personKey | query | any | Optional |
| monthFrom | query | any | Optional |
| monthTo | query | any | Optional |
| layout | query | any | Optional |
| verificationStatus | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Months with the number of open anomalies

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "personKey": null,
      "month": null,
      "layout": null,
      "verificationStatus": null,
      "openAnomalies": 1
    }
  ]
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/payroll_history/months?page=1&pageSize=50" \
  -H "Accept: application/json"
```

## GET `/payroll_history/notes`

List the text cells of one month (monthId required)

**Tags:** Payroll history

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| monthId | query | any | Required |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Notes (decrypted)

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "address": null,
      "text": null
    }
  ]
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/payroll_history/notes?page=1&pageSize=100&monthId=00000000-0000-4000-8000-000000000000" \
  -H "Accept: application/json"
```

## GET `/payroll_history/person-links`

Person keys of the payroll sheets with their link to a salon person

**Tags:** Payroll history

**Requires authentication.**

### Responses

**200** – Keys, links, canManage and (only with canManage) the salon persons to choose from

Content-Type: `application/json`

```json
{
  "items": [
    {
      "personKey": "string",
      "personLabel": "string",
      "monthFrom": "string",
      "monthTo": "string",
      "months": 1,
      "link": null
    }
  ],
  "total": 1,
  "canManage": true,
  "persons": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "displayName": "string",
      "kind": "string",
      "userId": null,
      "isActive": true
    }
  ]
}
```

**401** – Not signed in

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/payroll_history/person-links" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/payroll_history/person-links`

Link, change or remove (personId null) the link of a sheet person key; reason required (audit log)

**Tags:** Payroll history

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "personKey": "string",
  "personId": null,
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": null,
  "personKey": "string",
  "personId": null,
  "updatedAt": null,
  "changed": true
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing payroll_history.import or a role limited to some organizations

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – No sheet months for this person key

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – The link was changed by someone else

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required or the salon person does not exist

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/payroll_history/person-links" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"personKey\": \"string\",
  \"personId\": null,
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/progress/active`

GET /progress/active

**Tags:** Progress

**Requires authentication.**

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/progress/active" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/progress/jobs`

List progressjobs

Returns a paginated collection of progressjobs scoped to the authenticated tenant.

**Tags:** Progress

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| status | query | any | Optional |
| jobType | query | any | Optional |
| parentJobId | query | any | Optional |
| includeCompleted | query | any | Optional |
| completedSince | query | any | Optional |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| search | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |
| ids | query | any | Optional. Comma-separated list of record UUIDs to filter by (max 200). |

### Responses

**200** – Paginated progressjobs

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "jobType": "string",
      "name": "string",
      "description": null,
      "status": "string",
      "progressPercent": 1,
      "processedCount": 1,
      "totalCount": null,
      "etaSeconds": null,
      "cancellable": true,
      "startedAt": null,
      "finishedAt": null,
      "errorMessage": null,
      "createdAt": null,
      "tenantId": "00000000-0000-4000-8000-000000000000",
      "organizationId": null
    }
  ],
  "total": 1,
  "totalPages": 1
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/progress/jobs?page=1&pageSize=20" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/progress/jobs`

Create progressjob

Creates a new progress job for tracking a long-running operation.

**Tags:** Progress

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "jobType": "string",
  "name": "string",
  "cancellable": false
}
```

### Responses

**201** – ProgressJob created

Content-Type: `application/json`

```json
{
  "id": null
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/progress/jobs" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"jobType\": \"string\",
  \"name\": \"string\",
  \"cancellable\": false
}"
```

## DELETE `/progress/jobs/{id}`

DELETE /progress/jobs/{id}

**Tags:** Progress

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**204** – Success

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/progress/jobs/:id" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/progress/jobs/{id}`

GET /progress/jobs/{id}

**Tags:** Progress

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/progress/jobs/:id" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/progress/jobs/{id}`

PUT /progress/jobs/{id}

**Tags:** Progress

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/progress/jobs/:id" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/query_index/purge`

Purge query index records

Queues a purge job to remove indexed records for an entity type within the active scope.

**Tags:** Query Index

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entityType": "string"
}
```

### Responses

**200** – Purge job accepted.

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Missing entity type

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/query_index/purge" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entityType\": \"string\"
}"
```

## POST `/query_index/reindex`

Trigger query index rebuild

Queues a reindex job for the specified entity type within the current tenant scope.

**Tags:** Query Index

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entityType": "string"
}
```

### Responses

**200** – Reindex job accepted.

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Missing entity type

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/query_index/reindex" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entityType\": \"string\"
}"
```

## GET `/query_index/status`

Inspect query index coverage

Returns entity counts comparing base tables with the query index along with the latest job status.

**Tags:** Query Index

**Requires authentication.**

### Responses

**200** – Current query index status.

Content-Type: `application/json`

```json
{
  "items": [
    {
      "entityId": "string",
      "label": "string",
      "baseCount": null,
      "indexCount": null,
      "vectorCount": null,
      "fulltextCount": null,
      "ok": true,
      "job": {
        "status": "idle",
        "startedAt": null,
        "finishedAt": null,
        "heartbeatAt": null,
        "processedCount": null,
        "totalCount": null,
        "scope": null
      },
      "refreshedAt": null
    }
  ],
  "errors": [
    {
      "id": "string",
      "source": "string",
      "handler": "string",
      "entityType": null,
      "recordId": null,
      "tenantId": null,
      "organizationId": null,
      "message": "string",
      "stack": null,
      "payload": null,
      "occurredAt": "string"
    }
  ],
  "logs": [
    {
      "id": "string",
      "source": "string",
      "handler": "string",
      "level": "info",
      "entityType": null,
      "recordId": null,
      "tenantId": null,
      "organizationId": null,
      "message": "string",
      "details": null,
      "occurredAt": "string"
    }
  ]
}
```

**400** – Tenant or organization context required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Authentication required

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/query_index/status" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/results/books`

Delete the totals of a month (version and reason required)

**Tags:** Results

### Request Body

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "month": "string",
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Deleted

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing results.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Month not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version (`stale_version`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, invalid amounts, month outside the legal entity

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/results/books" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"organizationId\": \"00000000-0000-4000-8000-000000000000\",
  \"month\": \"string\",
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/results/books`

Monthly KPiR totals of the legal entities of the scope (at most 72 months)

Revenue, payroll and other expenses per month as booked by the accounting office (payroll in the month of payment); income = revenue − payroll − other. Amounts in grosze. Shown next to the result, never added to it.

**Tags:** Results

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| organizationId | query | any | Optional |
| from | query | any | Required |
| to | query | any | Required |

### Responses

**200** – Months

Content-Type: `application/json`

```json
{
  "monthFrom": "string",
  "monthTo": "string",
  "organizations": [
    {
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "organizationName": "string",
      "activeFrom": "string",
      "activeTo": null
    }
  ],
  "months": [
    {
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "month": "string",
      "revenueGr": 1,
      "payrollGr": 1,
      "otherCostsGr": 1,
      "incomeGr": 1,
      "source": "manual",
      "note": null,
      "updatedAt": "string"
    }
  ]
}
```

**400** – Invalid query or period, no legal entity for the period (`organization_required`), period too long

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing feature or organization outside the scope (`organization_not_allowed`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/results/books?from=string&to=string" \
  -H "Accept: application/json"
```

## POST `/results/books`

Enter the totals of a new month

**Tags:** Results

### Request Body

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "month": "string",
  "revenueGr": 1,
  "payrollGr": 1,
  "otherCostsGr": 1,
  "note": null,
  "reason": null,
  "updatedAt": null
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing results.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Month not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version (`stale_version`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, invalid amounts, month outside the legal entity

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/results/books" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"organizationId\": \"00000000-0000-4000-8000-000000000000\",
  \"month\": \"string\",
  \"revenueGr\": 1,
  \"payrollGr\": 1,
  \"otherCostsGr\": 1,
  \"note\": null,
  \"reason\": null,
  \"updatedAt\": null
}"
```

## PUT `/results/books`

Change the totals of a month (version and reason required)

**Tags:** Results

### Request Body

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "month": "string",
  "revenueGr": 1,
  "payrollGr": 1,
  "otherCostsGr": 1,
  "note": null,
  "reason": null,
  "updatedAt": null
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing results.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Month not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version (`stale_version`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Reason required, invalid amounts, month outside the legal entity

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/results/books" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"organizationId\": \"00000000-0000-4000-8000-000000000000\",
  \"month\": \"string\",
  \"revenueGr\": 1,
  \"payrollGr\": 1,
  \"otherCostsGr\": 1,
  \"note\": null,
  \"reason\": null,
  \"updatedAt\": null
}"
```

## GET `/results/break-even`

Monthly revenue needed to cover the fixed costs: F / (1 − variable share)

Ready read of Manifaktura (the same numbers as the screens). Amounts in grosze (divide by 100), shares in basis points (divide by 100 for %). Always quote `completeness.text`; when `isEstimate` is true say it is an estimate (management estimate, not accounting or tax advice). Always an estimate. Variable share = payroll with employer cost over revenue of the last completed months + other variable costs (setting or KPiR totals); fixed = recurring costs per month + minimal health contribution (owner on the scale) + other fixed costs. `breakEvenRevenueGr` null when the variable share reaches 100%.

**Tags:** Results

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| organizationId | query | any | Optional |
| asOf | query | any | Optional |

### Responses

**200** – Break-even

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "asOf": "string",
  "windowMonths": [
    "string"
  ],
  "basis": "entity",
  "revenueAvgGr": 1,
  "variableShareBps": {
    "payroll": 1,
    "other": 1,
    "total": 1
  },
  "otherShareSource": "setting",
  "fixedMonthlyGr": {
    "recurring": 1,
    "ownerHealthMin": 1,
    "otherFixed": 1,
    "total": 1
  },
  "breakEvenRevenueGr": null,
  "marginOverBreakEvenGr": null,
  "isEstimate": true,
  "completeness": {
    "through": null,
    "partial": true,
    "sources": [
      {
        "source": "string",
        "through": null,
        "state": "ok"
      }
    ],
    "text": "string"
  },
  "warnings": [
    "string"
  ]
}
```

**400** – Invalid query or period, no legal entity for the period (`organization_required`), period too long

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing feature or organization outside the scope (`organization_not_allowed`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/results/break-even" \
  -H "Accept: application/json"
```

## GET `/results/family`

Rent after the lump sum + the manager mandate net + the owner net result of a month

Ready read of Manifaktura (the same numbers as the screens). Amounts in grosze (divide by 100), shares in basis points (divide by 100 for %). Always quote `completeness.text`; when `isEstimate` is true say it is an estimate (management estimate, not accounting or tax advice). Management estimate, not accounting: always say "szacunek". Needs results.family.view (family_finance role only). 409 family_disabled when the family result is off for the entity or the month is before its first month.

**Tags:** Results

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| month | query | any | Required |
| organizationId | query | any | Optional |

### Responses

**200** – Family result

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "month": "string",
  "isEstimate": true,
  "rent": {
    "grossGr": 1,
    "lumpSumTaxGr": 1,
    "netGr": 1
  },
  "manager": {
    "personId": null,
    "grossGr": 1,
    "socialGr": 1,
    "healthGr": 1,
    "pitGr": 1,
    "netGr": 1,
    "insuranceStatus": null
  },
  "ownerNetGr": null,
  "totalGr": null,
  "ytdTotalGr": null,
  "completeness": {
    "through": null,
    "partial": true,
    "sources": [
      {
        "source": "string",
        "through": null,
        "state": "ok"
      }
    ],
    "text": "string"
  },
  "warnings": [
    "string"
  ]
}
```

**400** – Invalid month or no legal entity for the month (`organization_required`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing results.family.view or organization outside the scope (`organization_not_allowed`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Family result disabled for the entity or month before its first month (`family_disabled`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/results/family?month=string" \
  -H "Accept: application/json"
```

## GET `/results/family/settings`

Family result switches of the legal entity (no amounts)

Enabled, first month, managing person, voluntary sickness insurance. Needs results.family.view.

**Tags:** Results

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| organizationId | query | any | Optional |

### Responses

**200** – Settings

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "settings": {
    "settings": {
      "enabled": true,
      "fromMonth": "string",
      "managerPersonId": null,
      "managerIncludeSickness": true
    },
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null
  },
  "defaults": {
    "enabled": true,
    "fromMonth": "string",
    "managerPersonId": null,
    "managerIncludeSickness": true
  },
  "managers": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "displayName": "string",
      "isActive": true
    }
  ]
}
```

**400** – No organization selected (`organization_required`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing results.family.view or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/results/family/settings" \
  -H "Accept: application/json"
```

## PUT `/results/family/settings`

Change the family result settings (partial patch); reason required

**Tags:** Results

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| organizationId | query | any | Optional |

### Request Body

Content-Type: `application/json`

```json
{
  "settings": {
    "managerPersonId": null
  },
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Saved settings

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "settings": {
    "settings": {
      "enabled": true,
      "fromMonth": "string",
      "managerPersonId": null,
      "managerIncludeSickness": true
    },
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null
  },
  "defaults": {
    "enabled": true,
    "fromMonth": "string",
    "managerPersonId": null,
    "managerIncludeSickness": true
  },
  "managers": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "displayName": "string",
      "isActive": true
    }
  ]
}
```

**400** – Invalid settings, managing person not a manager or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing results.family.manage (or salon.decisions.manage) or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – The stored setting changed in the meantime

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/results/family/settings" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"settings\": {
    \"managerPersonId\": null
  },
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/results/pnl`

Lines × columns (month, previous month, same month last year, year to date), comparisons, KPiR totals

Ready read of Manifaktura (the same numbers as the screens). Amounts in grosze (divide by 100), shares in basis points (divide by 100 for %). Always quote `completeness.text`; when `isEstimate` is true say it is an estimate (management estimate, not accounting or tax advice). Lines: revenue (VAT counter), payroll gross and employer cost, fixed costs (by category), other costs, result before tax; for an owner taxed on the scale also health contribution, PIT advance and net result (estimates). `books` = KPiR totals typed in from the office, shown next to the result, never in it.

**Tags:** Results

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| month | query | any | Required |
| organizationId | query | any | Optional |
| asOf | query | any | Optional |

### Responses

**200** – Profit and loss

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "organizationName": "string",
  "month": "string",
  "ownerTaxForm": "scale",
  "columns": [
    {
      "key": "month",
      "monthFrom": "string",
      "monthTo": "string",
      "organizationIds": [
        "00000000-0000-4000-8000-000000000000"
      ],
      "lines": [
        {
          "code": "revenue",
          "amountGr": null,
          "source": null,
          "quality": "actual",
          "noteCodes": [
            "string"
          ]
        }
      ],
      "booksyGr": 1,
      "fixedByCategory": {
        "key": 1
      }
    }
  ],
  "comparisons": [
    {
      "against": "previous_month",
      "scope": "entity",
      "available": true,
      "reasonCode": null,
      "deltas": {
        "key": {
          "deltaGr": 1,
          "deltaBps": null
        }
      }
    }
  ],
  "books": {
    "month": null,
    "ytd": null
  },
  "isEstimate": true,
  "estimateReasons": [
    "string"
  ],
  "completeness": {
    "through": null,
    "partial": true,
    "sources": [
      {
        "source": "string",
        "through": null,
        "state": "ok"
      }
    ],
    "text": "string"
  },
  "warnings": [
    "string"
  ]
}
```

**400** – Invalid query or period, no legal entity for the period (`organization_required`), period too long

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing feature or organization outside the scope (`organization_not_allowed`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/results/pnl?month=string" \
  -H "Accept: application/json"
```

## GET `/results/salon-trend`

Monthly revenue, Booksy sales, payroll, fixed costs and result before tax of the salon (at most 72 months)

Ready read of Manifaktura (the same numbers as the screens). Amounts in grosze (divide by 100), shares in basis points (divide by 100 for %). Always quote `completeness.text`; when `isEstimate` is true say it is an estimate (management estimate, not accounting or tax advice). Sum of the legal entities of your scope per month, without the owner's taxes. Each point has a quality (actual, estimate, partial, missing) and the KPiR totals when entered. `groupBy=person` (needs results.persons.view) adds the Booksy service revenue per person and month; former staff have `isActive: false`.

**Tags:** Results

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| from | query | any | Optional |
| to | query | any | Optional |
| groupBy | query | any | Optional |
| asOf | query | any | Optional |

### Responses

**200** – Salon trend

Content-Type: `application/json`

```json
{
  "monthFrom": "string",
  "monthTo": "string",
  "organizations": [
    {
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "organizationName": "string",
      "activeFrom": "string",
      "activeTo": null
    }
  ],
  "points": [
    {
      "month": "string",
      "organizationIds": [
        "00000000-0000-4000-8000-000000000000"
      ],
      "revenueGr": 1,
      "booksyGr": 1,
      "completedVisits": 1,
      "newClients": 1,
      "payrollGr": null,
      "employerCostGr": null,
      "payrollSource": "payroll_office",
      "payrollCoverageBps": null,
      "fixedCostsGr": 1,
      "resultBeforeTaxGr": null,
      "quality": "actual",
      "books": null
    }
  ],
  "byPerson": null,
  "completeness": {
    "through": null,
    "partial": true,
    "sources": [
      {
        "source": "string",
        "through": null,
        "state": "ok"
      }
    ],
    "text": "string"
  },
  "warnings": [
    "string"
  ]
}
```

**400** – Invalid query or period, no legal entity for the period (`organization_required`), period too long

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing feature or organization outside the scope (`organization_not_allowed`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/results/salon-trend" \
  -H "Accept: application/json"
```

## GET `/results/settings`

Settings of the results for a legal entity

Owner tax form (none or scale) and other yearly income of the owner, break-even assumptions, first month of the trend. No amounts of persons.

**Tags:** Results

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| organizationId | query | any | Optional |

### Responses

**200** – Settings

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "settings": {
    "settings": {},
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null
  },
  "defaults": {}
}
```

**400** – No organization selected

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/results/settings" \
  -H "Accept: application/json"
```

## PUT `/results/settings`

Change the settings (partial patch); reason required

**Tags:** Results

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| organizationId | query | any | Optional |

### Request Body

Content-Type: `application/json`

```json
{
  "settings": {},
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Saved settings

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "settings": {
    "settings": {},
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null
  },
  "defaults": {}
}
```

**400** – Invalid settings or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing results.manage / salon.decisions.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – The stored setting changed in the meantime

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/results/settings" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"settings\": {},
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/salon/decision-settings`

List decision settings

Tenant-wide settings and settings of the organizations in scope. With `key` and `organizationId`, `effective` is the setting in force (organization row first, then the tenant row).

**Tags:** Salon

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| key | query | any | Optional |
| organizationId | query | any | Optional |

### Responses

**200** – Settings

Content-Type: `application/json`

```json
{
  "items": [
    {
      "key": "string",
      "organizationId": null,
      "value": null,
      "defaultValue": null,
      "state": "default",
      "decidedAt": null,
      "decidedByUserId": null,
      "note": null,
      "updatedAt": "string"
    }
  ],
  "effective": null
}
```

**400** – Invalid query

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/salon/decision-settings" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/salon/exception-cases`

List exception cases

Returns a paginated collection of exception cases.

**Tags:** Salon

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| ids | query | any | Optional. Comma-separated list of record UUIDs to filter by (max 200). |
| personId | query | any | Optional |
| period | query | any | Optional |
| periodFrom | query | any | Optional |
| periodTo | query | any | Optional |
| source | query | any | Optional |
| type | query | any | Optional |
| severity | query | any | Optional |
| status | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Paginated exception cases

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "organizationId": null,
      "source": "booksy",
      "type": "string",
      "severity": "blocking",
      "period": "string",
      "personId": null,
      "subjectType": "string",
      "subjectId": null,
      "subjectDate": null,
      "subjectLink": null,
      "amountGr": null,
      "params": {
        "key": "string"
      },
      "allowedDecisions": [
        "accept_catalog_amount"
      ],
      "status": "open",
      "decision": null,
      "decisionAmountGr": null,
      "decisionPersonId": null,
      "comment": null,
      "resolutionSource": null,
      "resolvedByUserId": null,
      "resolvedAt": null,
      "previousDecision": null,
      "previousComment": null,
      "reopenCount": 1,
      "firstSeenAt": null,
      "lastChangedAt": null,
      "obsoleteAt": null,
      "updatedAt": null
    }
  ],
  "total": 1,
  "totalPages": 1
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/salon/exception-cases?page=1&pageSize=50" \
  -H "Accept: application/json"
```

## POST `/salon/exception-cases/reopen`

Open a resolved case again

The decision moves to the previous decision and the case is open again. Requires `reason`.

**Tags:** Salon

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string"
}
```

### Responses

**200** – Reopened

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "status": "open"
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Case not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Case not resolved, obsolete or stale version

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/salon/exception-cases/reopen" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\"
}"
```

## POST `/salon/exception-cases/resolve`

Decide one exception case

Stores the decision of a case (allowed by the case, ROZ-05). `accept_worker_amount` needs `amountGr` (grosze ≥ 0), `assign_person` needs `personId`; the comment is required and is the reason in the audit log. A resolved case may get another decision.

**Tags:** Salon

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "decision": "accept_catalog_amount",
  "amountGr": null,
  "personId": null,
  "comment": "string"
}
```

### Responses

**200** – Resolved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "status": "open"
}
```

**400** – Invalid input or decision not allowed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Case not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Obsolete case or stale version

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/salon/exception-cases/resolve" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"decision\": \"accept_catalog_amount\",
  \"amountGr\": null,
  \"personId\": null,
  \"comment\": \"string\"
}"
```

## POST `/salon/exception-cases/resolve-bulk`

Decide up to 200 open cases at once

One decision and one comment for every listed case. Every case must be open and allow the decision; `acknowledge` and `ignore` only for informational cases.

**Tags:** Salon

### Request Body

Content-Type: `application/json`

```json
{
  "ids": [
    "00000000-0000-4000-8000-000000000000"
  ],
  "decision": "acknowledge",
  "comment": "string"
}
```

### Responses

**200** – Resolved

Content-Type: `application/json`

```json
{
  "ok": true,
  "ids": [
    "00000000-0000-4000-8000-000000000000"
  ],
  "count": 1
}
```

**400** – Invalid input, too many cases or decision not allowed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Case not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – A case is not open any more

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/salon/exception-cases/resolve-bulk" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"ids\": [
    \"00000000-0000-4000-8000-000000000000\"
  ],
  \"decision\": \"acknowledge\",
  \"comment\": \"string\"
}"
```

## GET `/salon/exception-cases/summary`

Count open exception cases

Open blocking and informational cases of the organizations in the current scope, the sum of blocking amounts (grosze) and the oldest open month (KOK-01).

**Tags:** Salon

### Responses

**200** – Counts

Content-Type: `application/json`

```json
{
  "blocking": 1,
  "info": 1,
  "blockingAmountGr": 1,
  "oldestOpenPeriod": null,
  "byPeriod": [
    {
      "period": "string",
      "blocking": 1,
      "info": 1
    }
  ]
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/salon/exception-cases/summary" \
  -H "Accept: application/json"
```

## GET `/salon/exception-cases/types`

List the (source, type) pairs of exception cases

Distinct source and type of the exception cases of the organizations in the current scope, with the number of open cases. Feeds the source and type filter of the case list.

**Tags:** Salon

### Responses

**200** – Types

Content-Type: `application/json`

```json
{
  "items": [
    {
      "source": "string",
      "type": "string",
      "open": 1
    }
  ]
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/salon/exception-cases/types" \
  -H "Accept: application/json"
```

## GET `/salon/legal-entities`

List legal entities

Organizations of the tenant visible in the current organization scope, with their legal profile.

**Tags:** Salon

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| organizationId | query | any | Optional |

### Responses

**200** – Organizations with profiles

Content-Type: `application/json`

```json
{
  "items": [
    {
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "organizationName": "string",
      "hasProfile": true,
      "id": null,
      "legalName": null,
      "nip": null,
      "activeFrom": null,
      "activeTo": null,
      "taxForm": null,
      "vatStatus": "exempt",
      "vatExemptFrom": null,
      "accountingEmail": null,
      "note": null,
      "updatedAt": null
    }
  ]
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/salon/legal-entities" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/salon/legal-entities`

Create or update the legal profile of an organization

Upserts the legal profile of `organizationId`. Requires `reason`. Active periods of the tenant's entities must not overlap (409).

**Tags:** Salon

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "tenantId": "00000000-0000-4000-8000-000000000000",
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "legalName": null,
  "nip": null,
  "activeTo": null,
  "taxForm": null,
  "vatExemptFrom": null,
  "accountingEmail": null,
  "note": null,
  "reason": "string"
}
```

### Responses

**200** – Saved (or unchanged)

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "created": true,
  "changed": true
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Forbidden

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Organization not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Overlapping period or stale version

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/salon/legal-entities" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"tenantId\": \"00000000-0000-4000-8000-000000000000\",
  \"organizationId\": \"00000000-0000-4000-8000-000000000000\",
  \"legalName\": null,
  \"nip\": null,
  \"activeTo\": null,
  \"taxForm\": null,
  \"vatExemptFrom\": null,
  \"accountingEmail\": null,
  \"note\": null,
  \"reason\": \"string\"
}"
```

## DELETE `/salon/legal-parameters`

Delete legal parameter

Soft-deletes a legal parameter value. Requires `reason` (body or query).

**Tags:** Salon

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string"
}
```

### Responses

**200** – Legal parameter deleted

Content-Type: `application/json`

```json
{
  "ok": true
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/salon/legal-parameters" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\"
}"
```

## GET `/salon/legal-parameters`

List legal parameters

Returns a paginated collection of legal parameters.

**Tags:** Salon

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| search | query | any | Optional |
| ids | query | any | Optional. Comma-separated list of record UUIDs to filter by (max 200). |
| key | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Paginated legal parameters

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "key": "string",
      "valueInt": null,
      "valueJson": null,
      "unit": "gr",
      "validFrom": null,
      "validTo": null,
      "confirmation": "to_confirm",
      "sourceNote": null,
      "createdAt": null,
      "updatedAt": null
    }
  ],
  "total": 1,
  "totalPages": 1
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/salon/legal-parameters?page=1&pageSize=50" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/salon/legal-parameters`

Create legal parameter

Adds a legal parameter value valid from a date (LIM-02). Requires `reason`; periods of one key must not overlap (409).

**Tags:** Salon

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "tenantId": "00000000-0000-4000-8000-000000000000",
  "key": "string",
  "valueInt": null,
  "unit": "gr",
  "validFrom": "string",
  "validTo": null,
  "confirmation": "to_confirm",
  "sourceNote": null,
  "reason": "string"
}
```

### Responses

**201** – Legal parameter created

Content-Type: `application/json`

```json
{
  "id": null
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/salon/legal-parameters" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"tenantId\": \"00000000-0000-4000-8000-000000000000\",
  \"key\": \"string\",
  \"valueInt\": null,
  \"unit\": \"gr\",
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"confirmation\": \"to_confirm\",
  \"sourceNote\": null,
  \"reason\": \"string\"
}"
```

## PUT `/salon/legal-parameters`

Update legal parameter

Changes a legal parameter value or its validity. Requires `reason`; honors the optimistic lock.

**Tags:** Salon

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "valueInt": null,
  "validTo": null,
  "sourceNote": null,
  "reason": "string"
}
```

### Responses

**200** – Legal parameter updated

Content-Type: `application/json`

```json
{
  "ok": true
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/salon/legal-parameters" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"valueInt\": null,
  \"validTo\": null,
  \"sourceNote\": null,
  \"reason\": \"string\"
}"
```

## GET `/salon/persons`

List persons

Returns a paginated collection of persons.

**Tags:** Salon

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| search | query | any | Optional |
| ids | query | any | Optional. Comma-separated list of record UUIDs to filter by (max 200). |
| kind | query | any | Optional |
| isActive | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Paginated persons

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "displayName": "string",
      "kind": "contractor",
      "userId": null,
      "isActive": true,
      "note": null,
      "updatedAt": null
    }
  ],
  "total": 1,
  "totalPages": 1
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/salon/persons?page=1&pageSize=50" \
  -H "Accept: application/json"
```

## POST `/salon/persons`

Create person

Adds a person (staff, owner, accountant). Requires `reason`; a login account belongs to at most one person (409).

**Tags:** Salon

### Request Body

Content-Type: `application/json`

```json
{
  "displayName": "string",
  "kind": "contractor",
  "userId": null,
  "note": null,
  "reason": "string"
}
```

### Responses

**201** – Person created

Content-Type: `application/json`

```json
{
  "id": null
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/salon/persons" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"displayName\": \"string\",
  \"kind\": \"contractor\",
  \"userId\": null,
  \"note\": null,
  \"reason\": \"string\"
}"
```

## PUT `/salon/persons`

Update person

Changes a person. Requires `reason`; honors the optimistic lock.

**Tags:** Salon

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "userId": null,
  "note": null,
  "reason": "string"
}
```

### Responses

**200** – Person updated

Content-Type: `application/json`

```json
{
  "ok": true
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/salon/persons" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"userId\": null,
  \"note\": null,
  \"reason\": \"string\"
}"
```

## GET `/salon/persons/user-options`

List the login accounts of the tenant

Accounts of the tenant (AI agents excluded) with e-mail, name and the person each account is already linked to. Requires salon.persons.manage. One account belongs to at most one person; the person update command enforces it.

**Tags:** Salon

### Responses

**200** – Accounts

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "email": "string",
      "name": null,
      "linkedPersonId": null,
      "linkedPersonName": null
    }
  ]
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing salon.persons.manage

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/salon/persons/user-options" \
  -H "Accept: application/json"
```

## GET `/salon/service-categories`

List service categories

Returns a paginated collection of service categories.

**Tags:** Salon

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| search | query | any | Optional |
| ids | query | any | Optional. Comma-separated list of record UUIDs to filter by (max 200). |
| isActive | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Paginated service categories

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "name": "string",
      "nameKey": "string",
      "isActive": true,
      "sortOrder": 1,
      "updatedAt": null
    }
  ],
  "total": 1,
  "totalPages": 1
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/salon/service-categories?page=1&pageSize=100" \
  -H "Accept: application/json"
```

## POST `/salon/service-categories`

Create service category

Adds a service category. Requires `reason`; the name (case and spacing aside) is unique (409).

**Tags:** Salon

### Request Body

Content-Type: `application/json`

```json
{
  "name": "string",
  "reason": "string"
}
```

### Responses

**201** – Service category created

Content-Type: `application/json`

```json
{
  "id": null
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/salon/service-categories" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"name\": \"string\",
  \"reason\": \"string\"
}"
```

## PUT `/salon/service-categories`

Update service category

Renames a category or changes its activity and order. Requires `reason`; honors the optimistic lock.

**Tags:** Salon

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string"
}
```

### Responses

**200** – Service category updated

Content-Type: `application/json`

```json
{
  "ok": true
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/salon/service-categories" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\"
}"
```

## GET `/salon/services`

List services

Returns a paginated collection of services.

**Tags:** Salon

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| search | query | any | Optional |
| ids | query | any | Optional. Comma-separated list of record UUIDs to filter by (max 200). |
| categoryId | query | any | Optional |
| reviewStatus | query | any | Optional |
| isActive | query | any | Optional |
| origin | query | any | Optional |
| sortField | query | any | Optional |
| sortDir | query | any | Optional |

### Responses

**200** – Paginated services

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "name": "string",
      "nameKey": "string",
      "categoryId": null,
      "listPriceGr": null,
      "durationMin": null,
      "isActive": true,
      "origin": "booksy",
      "reviewStatus": "new",
      "firstSeenDate": null,
      "note": null,
      "updatedAt": null
    }
  ],
  "total": 1,
  "totalPages": 1
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/salon/services?page=1&pageSize=50" \
  -H "Accept: application/json"
```

## PUT `/salon/services`

Update service

Changes the category, list price (grosze), duration (minutes), activity or review status of a service. Requires `reason`; honors the optimistic lock.

**Tags:** Salon

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "categoryId": null,
  "listPriceGr": null,
  "durationMin": null,
  "note": null,
  "reason": "string"
}
```

### Responses

**200** – Service updated

Content-Type: `application/json`

```json
{
  "ok": true
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/salon/services" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"categoryId\": null,
  \"listPriceGr\": null,
  \"durationMin\": null,
  \"note\": null,
  \"reason\": \"string\"
}"
```

## DELETE `/scheduler/jobs`

Delete scheduledjob

Deletes a scheduled job by ID.

**Tags:** Scheduler

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "id": "string"
}
```

### Responses

**200** – ScheduledJob deleted

Content-Type: `application/json`

```json
{
  "ok": true
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/scheduler/jobs" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"string\"
}"
```

## GET `/scheduler/jobs`

List scheduledjobs

Returns a paginated collection of scheduledjobs scoped to the authenticated organization.

**Tags:** Scheduler

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| page | query | any | Optional |
| pageSize | query | any | Optional |
| id | query | any | Optional |
| search | query | any | Optional |
| scopeType | query | any | Optional |
| isEnabled | query | any | Required |
| sourceType | query | any | Optional |
| sourceModule | query | any | Optional |
| sort | query | any | Optional |
| order | query | any | Optional |
| ids | query | any | Optional. Comma-separated list of record UUIDs to filter by (max 200). |

### Responses

**200** – Paginated scheduledjobs

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "name": "string",
      "description": null,
      "scopeType": "system",
      "organizationId": null,
      "tenantId": null,
      "scheduleType": "cron",
      "scheduleValue": "string",
      "timezone": "string",
      "targetType": "queue",
      "targetQueue": null,
      "targetCommand": null,
      "targetPayload": null,
      "requireFeature": null,
      "isEnabled": true,
      "lastRunAt": null,
      "nextRunAt": null,
      "sourceType": "user",
      "sourceModule": null,
      "createdAt": "string",
      "updatedAt": "string"
    }
  ],
  "total": 1,
  "totalPages": 1
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/scheduler/jobs?page=1&pageSize=20" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/scheduler/jobs`

Create scheduledjob

Creates a new scheduled job with cron or interval-based scheduling.

**Tags:** Scheduler

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "name": "string",
  "description": null,
  "scopeType": "system",
  "organizationId": null,
  "tenantId": null,
  "scheduleType": "cron",
  "scheduleValue": "string",
  "timezone": "UTC",
  "targetType": "queue",
  "targetQueue": null,
  "targetCommand": null,
  "targetPayload": null,
  "requireFeature": null,
  "isEnabled": true
}
```

### Responses

**201** – ScheduledJob created

Content-Type: `application/json`

```json
{
  "id": null
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/scheduler/jobs" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"name\": \"string\",
  \"description\": null,
  \"scopeType\": \"system\",
  \"organizationId\": null,
  \"tenantId\": null,
  \"scheduleType\": \"cron\",
  \"scheduleValue\": \"string\",
  \"timezone\": \"UTC\",
  \"targetType\": \"queue\",
  \"targetQueue\": null,
  \"targetCommand\": null,
  \"targetPayload\": null,
  \"requireFeature\": null,
  \"isEnabled\": true
}"
```

## PUT `/scheduler/jobs`

Update scheduledjob

Updates an existing scheduled job by ID.

**Tags:** Scheduler

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "id": "string",
  "description": null,
  "targetQueue": null,
  "targetCommand": null,
  "targetPayload": null,
  "requireFeature": null
}
```

### Responses

**200** – ScheduledJob updated

Content-Type: `application/json`

```json
{
  "ok": true
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/scheduler/jobs" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"string\",
  \"description\": null,
  \"targetQueue\": null,
  \"targetCommand\": null,
  \"targetPayload\": null,
  \"requireFeature\": null
}"
```

## GET `/scheduler/jobs/{id}/executions`

Get execution history for a schedule

Fetch recent executions from BullMQ for a scheduled job. Requires QUEUE_STRATEGY=async.

**Tags:** Scheduler

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |
| pageSize | query | any | Optional |

### Responses

**200** – Execution history

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "string",
      "scheduleId": "00000000-0000-4000-8000-000000000000",
      "startedAt": "string",
      "finishedAt": null,
      "status": "running",
      "triggerType": "scheduled",
      "triggeredByUserId": null,
      "errorMessage": null,
      "errorStack": null,
      "durationMs": null,
      "queueJobId": "string",
      "queueName": "string",
      "attemptsMade": 1,
      "result": null
    }
  ],
  "total": 1,
  "page": 1,
  "pageSize": 1
}
```

**400** – Local strategy not supported

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Access denied

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Schedule not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/scheduler/jobs/:id/executions?pageSize=20" \
  -H "Accept: application/json"
```

## GET `/scheduler/queue-jobs/{jobId}`

Get BullMQ job details and logs

Fetch detailed information and logs for a queue job. Requires QUEUE_STRATEGY=async.

**Tags:** Scheduler

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| jobId | path | any | Required |
| queue | query | any | Required |

### Responses

**200** – Job details and logs

Content-Type: `application/json`

```json
{
  "id": "string",
  "name": "string",
  "state": "waiting",
  "progress": null,
  "returnvalue": null,
  "failedReason": null,
  "stacktrace": null,
  "attemptsMade": 1,
  "processedOn": null,
  "finishedOn": null,
  "logs": [
    "string"
  ]
}
```

**400** – Invalid request or local strategy not supported

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Access denied

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Job not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Internal server error

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/scheduler/queue-jobs/:jobId?queue=string" \
  -H "Accept: application/json"
```

## GET `/scheduler/targets`

List available queues and commands

Returns available queue names and scheduler-safe command IDs for schedule target selection.

**Tags:** Scheduler

### Responses

**200** – Available targets

Content-Type: `application/json`

```json
{
  "queues": [
    {
      "value": "string",
      "label": "string"
    }
  ],
  "commands": [
    {
      "value": "string",
      "label": "string"
    }
  ]
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/scheduler/targets" \
  -H "Accept: application/json"
```

## POST `/scheduler/trigger`

Manually trigger a schedule

Executes a scheduled job immediately, bypassing the scheduled time. Only works with async queue strategy. The attempt is audited against the calling user whether it succeeds, is refused, or fails, except when a before command interceptor blocks it before the command runs.

**Tags:** Scheduler

### Request Body

Content-Type: `application/json`

```json
{
  "id": "string"
}
```

### Responses

**200** – Schedule triggered successfully

Content-Type: `application/json`

```json
{
  "ok": true,
  "jobId": "string",
  "message": "string"
}
```

**400** – Invalid request or local strategy not supported

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Access denied

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Schedule not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Trigger deliberately blocked by a before command interceptor. The interceptor chooses the status (any 4xx/5xx) and may replace the body.

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/scheduler/trigger" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"string\"
}"
```

## GET `/search/embeddings`

Get embeddings configuration

Returns current embedding provider and model configuration.

**Tags:** Search

**Requires authentication.**

### Responses

**200** – Embeddings settings

Content-Type: `application/json`

```json
{
  "settings": {
    "openaiConfigured": true,
    "autoIndexingEnabled": true,
    "autoIndexingLocked": true,
    "lockReason": null,
    "embeddingConfig": null,
    "configuredProviders": [
      "openai"
    ],
    "indexedDimension": null,
    "reindexRequired": true,
    "documentCount": null
  }
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/search/embeddings" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/search/embeddings`

Update embeddings configuration

Updates the embedding provider and model settings.

**Tags:** Search

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{}
```

### Responses

**200** – Updated settings

Content-Type: `application/json`

```json
{
  "settings": {
    "openaiConfigured": true,
    "autoIndexingEnabled": true,
    "autoIndexingLocked": true,
    "lockReason": null,
    "embeddingConfig": null,
    "configuredProviders": [
      "openai"
    ],
    "indexedDimension": null,
    "reindexRequired": true,
    "documentCount": null
  }
}
```

**400** – Invalid request

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Auto-indexing disabled via environment

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Update failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Configuration service unavailable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/search/embeddings" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{}"
```

## POST `/search/embeddings/reindex`

Trigger vector reindex

Starts a vector embedding reindex operation.

**Tags:** Search

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{}
```

### Responses

**200** – Reindex result

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Reindex already in progress

Content-Type: `application/json`

```json
{
  "error": "string",
  "lock": {
    "type": "fulltext",
    "action": "string",
    "startedAt": "string",
    "elapsedMinutes": 1,
    "processedCount": null,
    "totalCount": null
  }
}
```

**500** – Reindex failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Search indexer unavailable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/search/embeddings/reindex" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{}"
```

## POST `/search/embeddings/reindex/cancel`

Cancel vector reindex

Cancels an in-progress vector reindex operation.

**Tags:** Search

**Requires authentication.**

### Responses

**200** – Cancel result

Content-Type: `application/json`

```json
{
  "ok": true,
  "jobsRemoved": 1
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/search/embeddings/reindex/cancel" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/search/index`

Purge vector index

Purges entries from the vector search index. Requires confirmAll=true when purging all entities.

**Tags:** Search

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| entityId | query | any | Optional. Specific entity ID to purge (e.g., "customers:customer_person_profile", "catalog:catalog_product") |
| confirmAll | query | any | Optional. Required when purging all entities |

### Responses

**200** – Purge result

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**400** – Missing confirmAll parameter

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Purge failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Search indexer unavailable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/search/index" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/search/index`

List vector index entries

Returns paginated list of entries in the vector search index.

**Tags:** Search

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| entityId | query | any | Optional. Filter by entity ID (e.g., "customers:customer_person_profile", "catalog:catalog_product") |
| limit | query | any | Optional. Maximum entries to return (default: 50, max: 200) |
| offset | query | any | Optional. Offset for pagination (default: 0) |

### Responses

**200** – Index entries

Content-Type: `application/json`

```json
{
  "entries": [
    {
      "id": "string",
      "entityId": "string",
      "recordId": "string",
      "tenantId": "string",
      "organizationId": null
    }
  ],
  "limit": 1,
  "offset": 1
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Failed to fetch index

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Vector strategy unavailable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/search/index" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/search/reindex`

Trigger fulltext reindex

Starts a fulltext (Meilisearch) reindex operation. Can clear, recreate, or fully reindex.

**Tags:** Search

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{}
```

### Responses

**200** – Reindex result

Content-Type: `application/json`

```json
{
  "ok": true,
  "action": "clear",
  "entityId": null
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Reindex already in progress

Content-Type: `application/json`

```json
{
  "error": "string",
  "lock": {
    "type": "fulltext",
    "action": "string",
    "startedAt": "string",
    "elapsedMinutes": 1,
    "processedCount": null,
    "totalCount": null
  }
}
```

**500** – Reindex failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Search service unavailable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/search/reindex" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{}"
```

## POST `/search/reindex/cancel`

Cancel fulltext reindex

Cancels an in-progress fulltext reindex operation.

**Tags:** Search

**Requires authentication.**

### Responses

**200** – Cancel result

Content-Type: `application/json`

```json
{
  "ok": true,
  "jobsRemoved": 1
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/search/reindex/cancel" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/search/search`

Search across all indexed entities

Performs a search using configured strategies (fulltext, vector, tokens). Use for search playground. Results are limited to the entity types the caller holds the declared view features for; superadmins are exempt.

**Tags:** Search

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| q | query | any | Required. Search query (required) |
| limit | query | any | Optional. Maximum results to return (default: 50, max: 100) |
| strategies | query | any | Optional. Comma-separated strategies to use: fulltext, vector, tokens (e.g., "fulltext,vector") |
| entityTypes | query | any | Optional. Comma-separated entity types to filter results (e.g., "customers:customer_person_profile,catalog:catalog_product,sales:sales_order") |

### Responses

**200** – Search results

Content-Type: `application/json`

```json
{
  "results": [
    {
      "entityId": "string",
      "recordId": "string",
      "score": 1,
      "source": "fulltext"
    }
  ],
  "strategiesUsed": [
    "fulltext"
  ],
  "timing": 1,
  "query": "string",
  "limit": 1
}
```

**400** – Missing query parameter

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Search failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Search service unavailable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/search/search?q=string" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/search/search/global`

Global search (Cmd+K)

Performs a global search using saved tenant strategies. Does NOT accept strategies from URL.

**Tags:** Search

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| q | query | any | Required. Search query (required) |
| limit | query | any | Optional. Maximum results to return (default: 50, max: 100) |
| entityTypes | query | any | Optional. Comma-separated entity types to filter results (e.g., "customers:customer_person_profile,catalog:catalog_product,sales:sales_order") |

### Responses

**200** – Search results

Content-Type: `application/json`

```json
{
  "results": [
    {
      "entityId": "string",
      "recordId": "string",
      "score": 1,
      "source": "fulltext"
    }
  ],
  "strategiesUsed": [
    "fulltext"
  ],
  "strategiesEnabled": [
    "fulltext"
  ],
  "timing": 1,
  "query": "string",
  "limit": 1
}
```

**400** – Missing query parameter

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Search failed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Search service unavailable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/search/search/global?q=string" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/search/settings`

Get search settings and status

Returns search module configuration, available strategies, and reindex lock status.

**Tags:** Search

**Requires authentication.**

### Responses

**200** – Search settings

Content-Type: `application/json`

```json
{
  "settings": {
    "strategies": [
      {
        "id": "string",
        "name": "string",
        "priority": 1,
        "available": true
      }
    ],
    "fulltextConfigured": true,
    "fulltextStats": null,
    "vectorConfigured": true,
    "tokensEnabled": true,
    "defaultStrategies": [
      "string"
    ],
    "reindexLock": null,
    "fulltextReindexLock": null,
    "vectorReindexLock": null
  }
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/search/settings" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/search/settings/fulltext`

Get fulltext search configuration

Returns Meilisearch configuration status and index statistics.

**Tags:** Search

**Requires authentication.**

### Responses

**200** – Fulltext settings

Content-Type: `application/json`

```json
{
  "driver": null,
  "configured": true,
  "envVars": {
    "MEILISEARCH_HOST": {
      "set": true,
      "hint": "string"
    },
    "MEILISEARCH_API_KEY": {
      "set": true,
      "hint": "string"
    }
  },
  "optionalEnvVars": {
    "MEILISEARCH_INDEX_PREFIX": {
      "set": true,
      "hint": "string"
    },
    "SEARCH_EXCLUDE_ENCRYPTED_FIELDS": {
      "set": true,
      "hint": "string"
    }
  }
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/search/settings/fulltext" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/search/settings/global-search`

Get global search strategies

Returns the enabled strategies for Cmd+K global search.

**Tags:** Search

**Requires authentication.**

### Responses

**200** – Global search settings

Content-Type: `application/json`

```json
{
  "enabledStrategies": [
    "fulltext"
  ]
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/search/settings/global-search" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/search/settings/global-search`

Update global search strategies

Sets which strategies are enabled for Cmd+K global search.

**Tags:** Search

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "enabledStrategies": [
    "fulltext"
  ]
}
```

### Responses

**200** – Updated settings

Content-Type: `application/json`

```json
{
  "ok": true,
  "enabledStrategies": [
    "fulltext"
  ]
}
```

**400** – Invalid request

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Internal error

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/search/settings/global-search" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"enabledStrategies\": [
    \"fulltext\"
  ]
}"
```

## GET `/search/settings/vector-store`

Get vector store configuration

Returns vector store configuration status.

**Tags:** Search

**Requires authentication.**

### Responses

**200** – Vector store settings

Content-Type: `application/json`

```json
{
  "currentDriver": "pgvector",
  "configured": true,
  "drivers": [
    {
      "id": "pgvector",
      "name": "string",
      "configured": true,
      "implemented": true,
      "available": null,
      "unavailableReason": null,
      "envVars": [
        {
          "name": "string",
          "set": true,
          "hint": "string"
        }
      ]
    }
  ]
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/search/settings/vector-store" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/settlements/adjustments`

Delete an adjustment (id and reason in the body or the query)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Deleted

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.adjustments.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Person or adjustment not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Wrong sign, invalid correction target or month before the start month

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/settlements/adjustments" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/settlements/adjustments`

Adjustments of the selected organizations

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| month | query | any | Optional |
| personId | query | any | Optional |
| kind | query | any | Optional |
| targets | query | any | Optional |
| page | query | any | Optional |
| pageSize | query | any | Optional |

### Responses

**200** – Adjustments (or `{ targets }` with targets=1)

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "personId": "00000000-0000-4000-8000-000000000000",
      "month": "string",
      "kind": "bonus",
      "amountGr": 1,
      "description": null,
      "correctsSettlementId": null,
      "correctsMonth": null,
      "locked": true,
      "updatedAt": "string"
    }
  ],
  "total": 1,
  "page": 1,
  "pageSize": 1,
  "totalPages": 1
}
```

**400** – Invalid filter

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/settlements/adjustments" \
  -H "Accept: application/json"
```

## POST `/settlements/adjustments`

Add an adjustment (positive amount + kind; reason required)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "personId": "00000000-0000-4000-8000-000000000000",
  "month": "string",
  "kind": "bonus",
  "amountGr": 1,
  "description": "string",
  "correctsSettlementId": null,
  "organizationId": null,
  "reason": "string"
}
```

### Responses

**201** – Created

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.adjustments.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Person or adjustment not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Wrong sign, invalid correction target or month before the start month

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/adjustments" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"personId\": \"00000000-0000-4000-8000-000000000000\",
  \"month\": \"string\",
  \"kind\": \"bonus\",
  \"amountGr\": 1,
  \"description\": \"string\",
  \"correctsSettlementId\": null,
  \"organizationId\": null,
  \"reason\": \"string\"
}"
```

## PUT `/settlements/adjustments`

Change an adjustment (id, reason and version in the body)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "personId": "00000000-0000-4000-8000-000000000000",
  "month": "string",
  "kind": "bonus",
  "amountGr": 1,
  "description": "string",
  "correctsSettlementId": null,
  "organizationId": null,
  "reason": "string",
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.adjustments.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Person or adjustment not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Wrong sign, invalid correction target or month before the start month

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/settlements/adjustments" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"personId\": \"00000000-0000-4000-8000-000000000000\",
  \"month\": \"string\",
  \"kind\": \"bonus\",
  \"amountGr\": 1,
  \"description\": \"string\",
  \"correctsSettlementId\": null,
  \"organizationId\": null,
  \"reason\": \"string\",
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"updatedAt\": null
}"
```

## DELETE `/settlements/allowances`

Allowances: delete (id and reason in the body or the query)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Deleted

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.contracts.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Contract or record not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, overlap or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Outside the contract, per-piece allowance not supported

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/settlements/allowances" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## POST `/settlements/allowances`

Allowances: create (reason required)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "contractId": "00000000-0000-4000-8000-000000000000",
  "kind": "social_media_monthly",
  "amountGr": 1,
  "inSettlement": true,
  "validFrom": "string",
  "validTo": null,
  "reason": "string"
}
```

### Responses

**201** – Created

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.contracts.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Contract or record not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, overlap or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Outside the contract, per-piece allowance not supported

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/allowances" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"contractId\": \"00000000-0000-4000-8000-000000000000\",
  \"kind\": \"social_media_monthly\",
  \"amountGr\": 1,
  \"inSettlement\": true,
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"reason\": \"string\"
}"
```

## PUT `/settlements/allowances`

Allowances: update (id, reason and version in the body)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "contractId": "00000000-0000-4000-8000-000000000000",
  "kind": "social_media_monthly",
  "amountGr": 1,
  "inSettlement": true,
  "validFrom": "string",
  "validTo": null,
  "reason": "string",
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.contracts.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Contract or record not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, overlap or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Outside the contract, per-piece allowance not supported

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/settlements/allowances" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"contractId\": \"00000000-0000-4000-8000-000000000000\",
  \"kind\": \"social_media_monthly\",
  \"amountGr\": 1,
  \"inSettlement\": true,
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"reason\": \"string\",
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"updatedAt\": null
}"
```

## POST `/settlements/cases/rebuild`

Recompute the settlements cases of whole months (all organizations with a legal entity in them)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "monthFrom": "string",
  "monthTo": "string"
}
```

### Responses

**200** – Counters of the rebuild

Content-Type: `application/json`

```json
{
  "ok": true,
  "result": {
    "monthFrom": "string",
    "monthTo": "string",
    "asOf": "string",
    "organizationIds": [
      "00000000-0000-4000-8000-000000000000"
    ],
    "detected": 1,
    "detectedByType": {
      "key": 1
    },
    "shadows": 1,
    "deltas": 1,
    "sync": {
      "inserted": 1,
      "updated": 1,
      "reopened": 1,
      "autoResolved": 1,
      "unchanged": 1,
      "obsoleted": 1,
      "byType": {
        "key": 1
      }
    }
  }
}
```

**400** – Invalid months

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.accept

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/cases/rebuild" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"monthFrom\": \"string\",
  \"monthTo\": \"string\"
}"
```

## DELETE `/settlements/commission-rules`

Commission rules: delete (id and reason in the body or the query)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Deleted

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.contracts.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Contract or record not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, overlap or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Outside the contract, scope reference missing or unknown, tiers not supported

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/settlements/commission-rules" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## POST `/settlements/commission-rules`

Commission rules: create (reason required)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "contractId": "00000000-0000-4000-8000-000000000000",
  "scope": "default",
  "scopeRefId": null,
  "rateBps": 1,
  "validFrom": "string",
  "validTo": null,
  "isConfirmed": true,
  "reason": "string"
}
```

### Responses

**201** – Created

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.contracts.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Contract or record not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, overlap or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Outside the contract, scope reference missing or unknown, tiers not supported

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/commission-rules" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"contractId\": \"00000000-0000-4000-8000-000000000000\",
  \"scope\": \"default\",
  \"scopeRefId\": null,
  \"rateBps\": 1,
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"isConfirmed\": true,
  \"reason\": \"string\"
}"
```

## PUT `/settlements/commission-rules`

Commission rules: update (id, reason and version in the body)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "contractId": "00000000-0000-4000-8000-000000000000",
  "scope": "default",
  "scopeRefId": null,
  "rateBps": 1,
  "validFrom": "string",
  "validTo": null,
  "isConfirmed": true,
  "reason": "string",
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.contracts.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Contract or record not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, overlap or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Outside the contract, scope reference missing or unknown, tiers not supported

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/settlements/commission-rules" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"contractId\": \"00000000-0000-4000-8000-000000000000\",
  \"scope\": \"default\",
  \"scopeRefId\": null,
  \"rateBps\": 1,
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"isConfirmed\": true,
  \"reason\": \"string\",
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"updatedAt\": null
}"
```

## POST `/settlements/commission-rules/confirm`

Confirm a commission rule (PR-9); reason required

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Confirmed

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Rule not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version or accepted month

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/commission-rules/confirm" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## DELETE `/settlements/contract-insurance`

Insurance status periods: delete (id and reason in the body or the query)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Deleted

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.contracts.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Contract or record not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, overlap or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Outside the contract

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/settlements/contract-insurance" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## POST `/settlements/contract-insurance`

Insurance status periods: create (reason required)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "contractId": "00000000-0000-4000-8000-000000000000",
  "validFrom": "string",
  "validTo": null,
  "status": "full",
  "fpFgspExempt": true,
  "ppkParticipant": true,
  "reason": "string"
}
```

### Responses

**201** – Created

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.contracts.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Contract or record not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, overlap or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Outside the contract

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/contract-insurance" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"contractId\": \"00000000-0000-4000-8000-000000000000\",
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"status\": \"full\",
  \"fpFgspExempt\": true,
  \"ppkParticipant\": true,
  \"reason\": \"string\"
}"
```

## PUT `/settlements/contract-insurance`

Insurance status periods: update (id, reason and version in the body)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "contractId": "00000000-0000-4000-8000-000000000000",
  "validFrom": "string",
  "validTo": null,
  "status": "full",
  "fpFgspExempt": true,
  "ppkParticipant": true,
  "reason": "string",
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.contracts.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Contract or record not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, overlap or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Outside the contract

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/settlements/contract-insurance" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"contractId\": \"00000000-0000-4000-8000-000000000000\",
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"status\": \"full\",
  \"fpFgspExempt\": true,
  \"ppkParticipant\": true,
  \"reason\": \"string\",
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"updatedAt\": null
}"
```

## DELETE `/settlements/contract-rates`

Hourly rates: delete (id and reason in the body or the query)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Deleted

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.contracts.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Contract or record not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, overlap or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Outside the contract, below the minimum hourly rate (ROZ-02) or no minimum rate for a period

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/settlements/contract-rates" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## POST `/settlements/contract-rates`

Hourly rates: create (reason required)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "contractId": "00000000-0000-4000-8000-000000000000",
  "validFrom": "string",
  "validTo": null,
  "hourlyRateGr": 1,
  "reason": "string"
}
```

### Responses

**201** – Created

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.contracts.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Contract or record not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, overlap or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Outside the contract, below the minimum hourly rate (ROZ-02) or no minimum rate for a period

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/contract-rates" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"contractId\": \"00000000-0000-4000-8000-000000000000\",
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"hourlyRateGr\": 1,
  \"reason\": \"string\"
}"
```

## PUT `/settlements/contract-rates`

Hourly rates: update (id, reason and version in the body)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "contractId": "00000000-0000-4000-8000-000000000000",
  "validFrom": "string",
  "validTo": null,
  "hourlyRateGr": 1,
  "reason": "string",
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.contracts.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Contract or record not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, overlap or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Outside the contract, below the minimum hourly rate (ROZ-02) or no minimum rate for a period

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/settlements/contract-rates" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"contractId\": \"00000000-0000-4000-8000-000000000000\",
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"hourlyRateGr\": 1,
  \"reason\": \"string\",
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"updatedAt\": null
}"
```

## GET `/settlements/contracts`

Contracts of the selected organizations

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| personId | query | any | Optional |
| activeOn | query | any | Optional |
| page | query | any | Optional |
| pageSize | query | any | Optional |

### Responses

**200** – Contracts

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "personId": "00000000-0000-4000-8000-000000000000",
      "hoursModel": "A",
      "hoursConfirmationMethod": "app",
      "validFrom": "string",
      "validTo": null,
      "updatedAt": "string",
      "currentRateGr": null,
      "currentDefaultRateBps": null,
      "hasUnconfirmedRule": true
    }
  ],
  "total": 1,
  "page": 1,
  "pageSize": 1,
  "totalPages": 1
}
```

**400** – Invalid filter

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/settlements/contracts" \
  -H "Accept: application/json"
```

## POST `/settlements/contracts`

Create a contract (reason required)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "personId": "00000000-0000-4000-8000-000000000000",
  "validFrom": "string",
  "validTo": null,
  "hoursModel": "A",
  "hoursConfirmationMethod": "app",
  "note": null,
  "reason": "string"
}
```

### Responses

**201** – Created

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Person not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Overlapping contract or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Contract outside the legal entity

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/contracts" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"personId\": \"00000000-0000-4000-8000-000000000000\",
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"hoursModel\": \"A\",
  \"hoursConfirmationMethod\": \"app\",
  \"note\": null,
  \"reason\": \"string\"
}"
```

## DELETE `/settlements/contracts/{id}`

Delete the contract (reason required; not with an accepted month)

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Request Body

Content-Type: `application/json`

```json
{
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Deleted

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**404** – Not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/settlements/contracts/:id" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/settlements/contracts/{id}`

Contract with rates, commission rules, allowances and (with contracts.manage) insurance periods

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Contract

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "personId": "00000000-0000-4000-8000-000000000000",
  "hoursModel": "A",
  "hoursConfirmationMethod": "app",
  "validFrom": "string",
  "validTo": null,
  "updatedAt": "string",
  "rates": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "contractId": "00000000-0000-4000-8000-000000000000",
      "hourlyRateGr": 1,
      "validFrom": "string",
      "validTo": null,
      "updatedAt": "string"
    }
  ],
  "rules": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "contractId": "00000000-0000-4000-8000-000000000000",
      "scope": "default",
      "scopeRefId": null,
      "rateBps": 1,
      "isConfirmed": true,
      "confirmedAt": null,
      "confirmedByUserId": null,
      "validFrom": "string",
      "validTo": null,
      "updatedAt": "string"
    }
  ],
  "allowances": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "contractId": "00000000-0000-4000-8000-000000000000",
      "kind": "social_media_monthly",
      "amountGr": 1,
      "inSettlement": true,
      "validFrom": "string",
      "validTo": null,
      "updatedAt": "string"
    }
  ],
  "insurance": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "contractId": "00000000-0000-4000-8000-000000000000",
      "status": "full",
      "fpFgspExempt": true,
      "ppkParticipant": true,
      "validFrom": "string",
      "validTo": null,
      "updatedAt": "string"
    }
  ],
  "canSeeInsurance": true,
  "note": null,
  "lockedMonths": [
    "string"
  ]
}
```

**404** – Not found or outside the selected organization

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/settlements/contracts/:id" \
  -H "Accept: application/json"
```

## PUT `/settlements/contracts/{id}`

Change the contract header (reason and version required)

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "validFrom": "string",
  "validTo": null,
  "hoursModel": "A",
  "hoursConfirmationMethod": "app",
  "note": null,
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Saved

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "updatedAt": null
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, overlap or accepted month (period_locked)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Outside the legal entity, or terms outside the new period

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/settlements/contracts/:id" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"validFrom\": \"string\",
  \"validTo\": null,
  \"hoursModel\": \"A\",
  \"hoursConfirmationMethod\": \"app\",
  \"note\": null,
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## POST `/settlements/my/confirm`

Confirm the caller's own settlement

Confirms exactly the numbers the person saw (`inputsHash`) when the settlement is ready (month ended, no blocking cases, no open days, no hard issues). A personId in the body is ignored; another person's settlement gives 403 `not_own_settlement`.

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "settlementId": "00000000-0000-4000-8000-000000000000",
  "inputsHash": "string",
  "updatedAt": null
}
```

### Responses

**200** – The confirmed settlement

Content-Type: `application/json`

```json
{
  "settlementId": null,
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "month": "string",
  "status": "draft",
  "updatedAt": null,
  "inputsHash": null,
  "hoursMin": 1,
  "turnoverGr": 1,
  "components": [
    {
      "kind": "hourly",
      "amountGr": 1,
      "inGross": true,
      "baseMin": null,
      "baseGr": null,
      "rateGr": null,
      "rateBps": null,
      "correctsMonth": null,
      "description": null
    }
  ],
  "grossGr": null,
  "pending": {
    "unfinalizedCount": 1,
    "unfinalizedCatalogGr": 1,
    "unconfirmedDays": 1,
    "blockingCases": 1
  },
  "readiness": {
    "ready": true,
    "gates": [
      "month_not_ended"
    ]
  },
  "canConfirm": true,
  "canRemark": true,
  "remark": null,
  "remarkAnswer": null,
  "dataThrough": null,
  "calculatedAt": null
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – No person for the account or not the caller's settlement

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Settlement not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Changed settlement, stale version, not ready or wrong status (current state in `item`)

Content-Type: `application/json`

```json
{
  "error": "string",
  "item": null
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/my/confirm" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"settlementId\": \"00000000-0000-4000-8000-000000000000\",
  \"inputsHash\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/settlements/my/months`

Months of the caller's own person

Status, gross and hours of the caller's own settlements in at most 24 months (default: the last 12). No components and no employer cost.

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| from | query | any | Optional |
| to | query | any | Optional |

### Responses

**200** – My months

Content-Type: `application/json`

```json
{
  "person": null,
  "issue": null,
  "from": "string",
  "to": "string",
  "items": [
    {
      "settlementId": "00000000-0000-4000-8000-000000000000",
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "month": "string",
      "status": "draft",
      "grossGr": null,
      "hoursMin": 1,
      "updatedAt": null
    }
  ]
}
```

**400** – Invalid or too long range

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/settlements/my/months" \
  -H "Accept: application/json"
```

## POST `/settlements/my/remark`

Report a remark on the caller's own settlement

Moves a draft or confirmed settlement of the caller's own person to "remarked" with a text of at least 3 characters (encrypted). A personId in the body is ignored; another person's settlement gives 403 `not_own_settlement`.

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "settlementId": "00000000-0000-4000-8000-000000000000",
  "text": "string",
  "updatedAt": null
}
```

### Responses

**200** – The settlement with the remark

Content-Type: `application/json`

```json
{
  "settlementId": null,
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "month": "string",
  "status": "draft",
  "updatedAt": null,
  "inputsHash": null,
  "hoursMin": 1,
  "turnoverGr": 1,
  "components": [
    {
      "kind": "hourly",
      "amountGr": 1,
      "inGross": true,
      "baseMin": null,
      "baseGr": null,
      "rateGr": null,
      "rateBps": null,
      "correctsMonth": null,
      "description": null
    }
  ],
  "grossGr": null,
  "pending": {
    "unfinalizedCount": 1,
    "unfinalizedCatalogGr": 1,
    "unconfirmedDays": 1,
    "blockingCases": 1
  },
  "readiness": {
    "ready": true,
    "gates": [
      "month_not_ended"
    ]
  },
  "canConfirm": true,
  "canRemark": true,
  "remark": null,
  "remarkAnswer": null,
  "dataThrough": null,
  "calculatedAt": null
}
```

**400** – Invalid input or text too short

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – No person for the account or not the caller's settlement

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Settlement not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version or wrong status (current state in `item`)

Content-Type: `application/json`

```json
{
  "error": "string",
  "item": null
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/my/remark" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"settlementId\": \"00000000-0000-4000-8000-000000000000\",
  \"text\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/settlements/my/summary`

Draft settlements of the caller's own person

The stored draft of the caller's own person: hours, commission base, components in simple words, gross (draft), what is still pending and whether it can be confirmed. Without `month`: the current month and the previous one while not accepted. Never contains the employer cost estimate; a personId in the query is ignored.

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| month | query | any | Optional |

### Responses

**200** – My settlements

Content-Type: `application/json`

```json
{
  "person": null,
  "issue": null,
  "month": "string",
  "items": [
    {
      "settlementId": null,
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "month": "string",
      "status": "draft",
      "updatedAt": null,
      "inputsHash": null,
      "hoursMin": 1,
      "turnoverGr": 1,
      "components": [
        {
          "kind": "hourly",
          "amountGr": 1,
          "inGross": true,
          "baseMin": null,
          "baseGr": null,
          "rateGr": null,
          "rateBps": null,
          "correctsMonth": null,
          "description": null
        }
      ],
      "grossGr": null,
      "pending": {
        "unfinalizedCount": 1,
        "unfinalizedCatalogGr": 1,
        "unconfirmedDays": 1,
        "blockingCases": 1
      },
      "readiness": {
        "ready": true,
        "gates": [
          "month_not_ended"
        ]
      },
      "canConfirm": true,
      "canRemark": true,
      "remark": null,
      "remarkAnswer": null,
      "dataThrough": null,
      "calculatedAt": null
    }
  ]
}
```

**400** – Invalid month

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/settlements/my/summary" \
  -H "Accept: application/json"
```

## GET `/settlements/package-settings`

Package setting in force for the selected organization

**Tags:** Settlements

### Responses

**200** – Setting

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "settings": {
    "settings": {},
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null
  },
  "defaults": {}
}
```

**400** – No organization selected

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.package.view or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/settlements/package-settings" \
  -H "Accept: application/json"
```

## PUT `/settlements/package-settings`

Change the package setting (partial or whole value); reason required

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "settings": {},
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Saved setting

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "settings": {
    "settings": {},
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null
  },
  "defaults": {}
}
```

**400** – Invalid setting or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing salon.decisions.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Saved by someone else in the meantime

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/settlements/package-settings" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"settings\": {},
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/settlements/packages`

Packages per organization and month (status, due date, version, live delivery)

Months from the settlements start month with settlements or a package. Organizations of the switcher only. No package content.

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| monthFrom | query | any | Optional |
| monthTo | query | any | Optional |

### Responses

**200** – Packages

Content-Type: `application/json`

```json
{
  "monthFrom": "string",
  "monthTo": "string",
  "items": [
    {
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "organizationName": "string",
      "month": "string",
      "status": "not_ready",
      "dueDate": "string",
      "currentVersionNo": null,
      "liveSentAt": null,
      "settlementsTotal": 1,
      "settlementsAccepted": 1
    }
  ]
}
```

**400** – Invalid month

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.package.view

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/settlements/packages" \
  -H "Accept: application/json"
```

## GET `/settlements/packages/{organizationId}/{month}`

Status, freshness, warnings, versions and deliveries of one package

Freshness: the hash of today's data compared with the current version (status stale). No package content and no insurance data; the office address only for settlements.package.send.

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| organizationId | path | any | Required |
| month | path | any | Required |

### Responses

**200** – Package

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "organizationName": "string",
  "month": "string",
  "status": "not_ready",
  "dueDate": "string",
  "currentVersionNo": null,
  "liveSentAt": null,
  "settlementsTotal": 1,
  "settlementsAccepted": 1,
  "persons": [
    {
      "personId": "00000000-0000-4000-8000-000000000000",
      "displayName": "string",
      "settlementId": null,
      "status": null
    }
  ],
  "previewHash": null,
  "previewWarnings": [
    {
      "code": "settlement_not_accepted",
      "personId": null,
      "count": 1
    }
  ],
  "versions": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "versionNo": 1,
      "status": "current",
      "contentHash": "string",
      "generatedAt": "string",
      "generatedByUserId": null,
      "trigger": "auto",
      "warnings": [
        {
          "code": "settlement_not_accepted",
          "personId": null,
          "count": 1
        }
      ],
      "totals": {
        "persons": 1,
        "registerMin": 1,
        "grossGr": 1,
        "employerCostGr": 1,
        "employerCostComplete": true,
        "costsNetGr": 1,
        "costsVatGr": 1,
        "costsGrossGr": 1
      },
      "files": [
        {
          "kind": "pdf",
          "filename": "string",
          "size": 1,
          "sha256": "string"
        }
      ],
      "liveSentAt": null
    }
  ],
  "deliveries": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "versionNo": 1,
      "mode": "live",
      "status": "sending",
      "recipientMasked": "string",
      "requestedAt": "string",
      "requestedByUserId": null,
      "sentAt": null,
      "errorCode": null,
      "isResend": true
    }
  ],
  "accountingEmail": null,
  "mode": "live"
}
```

**403** – Missing settlements.package.view

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Not found or outside the organization scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Month before the settlements start month

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/settlements/packages/:organizationId/:month" \
  -H "Accept: application/json"
```

## POST `/settlements/packages/generate`

Generate a new version when the data changed (PDF + XLSX, encrypted at rest)

Same data as the current version: returns it (created false). Warnings are written into the version and the first page of the PDF. Not undoable; older versions stay downloadable.

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "month": "string",
  "reason": null
}
```

### Responses

**200** – Current version

Content-Type: `application/json`

```json
{
  "ok": true,
  "created": true,
  "packageId": "00000000-0000-4000-8000-000000000000",
  "versionId": "00000000-0000-4000-8000-000000000000",
  "versionNo": 1,
  "contentHash": "string",
  "version": {
    "id": "00000000-0000-4000-8000-000000000000",
    "versionNo": 1,
    "status": "current",
    "contentHash": "string",
    "generatedAt": "string",
    "generatedByUserId": null,
    "trigger": "auto",
    "warnings": [
      {
        "code": "settlement_not_accepted",
        "personId": null,
        "count": 1
      }
    ],
    "totals": {
      "persons": 1,
      "registerMin": 1,
      "grossGr": 1,
      "employerCostGr": 1,
      "employerCostComplete": true,
      "costsNetGr": 1,
      "costsVatGr": 1,
      "costsGrossGr": 1
    },
    "files": [
      {
        "kind": "pdf",
        "filename": "string",
        "size": 1,
        "sha256": "string"
      }
    ],
    "liveSentAt": null
  }
}
```

**400** – Invalid input

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.package.send or organization outside RBAC

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Month before the settlements start month

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Package components do not sum to the settlement gross (package_amount_mismatch)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Encryption or package data unavailable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/packages/generate" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"organizationId\": \"00000000-0000-4000-8000-000000000000\",
  \"month\": \"string\",
  \"reason\": null
}"
```

## GET `/settlements/packages/versions/{id}/files/{kind}`

PDF or XLSX of a version (decrypted, sha256 checked); human accounts only

kind: pdf | xlsx. API keys are refused (403). Every download is recorded. Content-Disposition attachment, no-store.

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |
| kind | path | any | Required |

### Responses

**200** – The file (application/pdf or XLSX)

Content-Type: `application/json`

**403** – Missing settlements.package.view or an API key

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Not found or outside the organization scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Stored file corrupted

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – Encryption key unavailable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/settlements/packages/versions/:id/files/:kind" \
  -H "Accept: application/json"
```

## POST `/settlements/packages/versions/{id}/send`

E-mail the PDF and XLSX to the office (live) or to the caller (test); dryRun previews

Gates: current and fresh version, no other delivery in progress, office address (live), e-mail delivery configured, a reason for hard warnings and for a repeated live delivery. The same idempotency key never sends a second e-mail. Live: the accepted settlements of the version are closed.

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Request Body

Content-Type: `application/json`

```json
{
  "mode": "live",
  "idempotencyKey": "00000000-0000-4000-8000-000000000000",
  "warningsReason": null,
  "resendReason": null
}
```

### Responses

**200** – Delivery result or preview

Content-Type: `application/json`

```json
{
  "deliveryId": null,
  "status": "sending",
  "preview": null,
  "closedSettlementIds": [
    "00000000-0000-4000-8000-000000000000"
  ]
}
```

**400** – Invalid input or missing idempotency key

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.package.send

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Version not found or outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Gates: not current, stale, in progress, reasons; live mode disabled

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – No office address (live) or no address of the caller (test)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**500** – Stored file corrupted (package_file_corrupted)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**503** – E-mail delivery not configured or encryption unavailable

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/packages/versions/:id/send" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"mode\": \"live\",
  \"idempotencyKey\": \"00000000-0000-4000-8000-000000000000\",
  \"warningsReason\": null,
  \"resendReason\": null
}"
```

## GET `/settlements/settings`

Settings in force for the selected organization

**Tags:** Settlements

### Responses

**200** – Settings

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "settings": {
    "settings": {},
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null
  },
  "defaults": {},
  "requireApprovalFor": "all"
}
```

**400** – No organization selected

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/settlements/settings" \
  -H "Accept: application/json"
```

## PUT `/settlements/settings`

Change the settings (partial patch); reason required

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "settings": {
    "startMonth": null
  },
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Saved settings

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "settings": {
    "settings": {},
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null
  },
  "defaults": {},
  "requireApprovalFor": "all"
}
```

**400** – Invalid settings or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing salon.decisions.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/settlements/settings" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"settings\": {
    \"startMonth\": null
  },
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## GET `/settlements/settlements`

Monthly settlements of the organizations in scope, with gates and totals

One row per person and organization: hours, turnover, components, gross, employer cost estimate, status, gates (blocking cases, open and unapproved days, remark) and whether the caller may accept. Never returns remark texts or ZUS status periods.

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| month | query | any | Required |
| personId | query | any | Optional |
| status | query | any | Required |

### Responses

**200** – Month list

Content-Type: `application/json`

```json
{
  "month": "string",
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "personId": "00000000-0000-4000-8000-000000000000",
      "month": "string",
      "status": "draft",
      "hoursModel": "A",
      "workedMin": 1,
      "registerMin": 1,
      "turnoverGr": 1,
      "totals": {
        "hourlyGr": 1,
        "commissionGr": 1,
        "allowancesGr": 1,
        "tipsGr": 1,
        "adjustmentsGr": 1,
        "topUpGr": 1,
        "outsideGr": 1
      },
      "grossGr": null,
      "employerCostGr": null,
      "employerCostBps": null,
      "employerCostApprox": true,
      "inputsHash": "string",
      "updatedAt": "string",
      "acceptedAt": null,
      "acceptedWithoutConfirmation": true,
      "remarkOpen": true,
      "readiness": null,
      "acceptance": null,
      "counts": null,
      "acceptor": {
        "canAccept": true,
        "denial": null
      }
    }
  ],
  "totals": {
    "count": 1,
    "grossGr": 1,
    "employerCostGr": 1,
    "employerCostMissing": 1,
    "workersCostGr": 1
  }
}
```

**400** – Invalid query

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/settlements/settlements?month=string" \
  -H "Accept: application/json"
```

## GET `/settlements/settlements/{id}`

One settlement with components, base breakdown, gates, events and correction proposals

Texts of the remark, the answer and the event comments are returned only to callers with settlements.accept; ZUS status periods are never returned. Outside the organization scope: 404.

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Responses

**200** – Settlement card

Content-Type: `application/json`

```json
{
  "settlement": {
    "id": "00000000-0000-4000-8000-000000000000",
    "organizationId": "00000000-0000-4000-8000-000000000000",
    "personId": "00000000-0000-4000-8000-000000000000",
    "month": "string",
    "contractIds": [
      "string"
    ],
    "status": "draft",
    "hoursModel": "A",
    "workedMin": 1,
    "registerMin": 1,
    "grossGr": null,
    "computedGr": null,
    "employerCostGr": null,
    "employerCostBps": null,
    "inputsHash": "string",
    "calculatedAt": null,
    "issues": [
      {
        "code": "calculation_error",
        "params": {
          "key": "string"
        }
      }
    ],
    "base": null,
    "confirmedAt": null,
    "confirmedByUserId": null,
    "acceptedAt": null,
    "acceptedByUserId": null,
    "acceptedByPersonId": null,
    "acceptedWithoutConfirmation": true,
    "closedAt": null,
    "updatedAt": "string"
  },
  "components": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "settlementId": "00000000-0000-4000-8000-000000000000",
      "position": 1,
      "kind": "hourly",
      "key": "string",
      "baseMin": null,
      "baseGr": null,
      "rateGr": null,
      "rateBps": null,
      "amountGr": 1,
      "inGross": true,
      "sourceId": null,
      "correctsSettlementId": null,
      "correctsMonth": null
    }
  ],
  "totals": {
    "hourlyGr": 1,
    "commissionGr": 1,
    "allowancesGr": 1,
    "tipsGr": 1,
    "adjustmentsGr": 1,
    "topUpGr": 1,
    "outsideGr": 1
  },
  "turnoverGr": 1,
  "employerCostApprox": true,
  "readiness": null,
  "acceptance": null,
  "counts": null,
  "days": null,
  "events": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "type": "created",
      "from": null,
      "to": "draft",
      "grossGr": null,
      "inputsHash": null,
      "actorUserId": null,
      "actorPersonId": null,
      "systemActor": null,
      "createdAt": null,
      "comment": null
    }
  ],
  "remark": {
    "text": null,
    "at": null,
    "answer": null,
    "answeredAt": null
  },
  "corrections": [
    {
      "caseId": "00000000-0000-4000-8000-000000000000",
      "correctsSettlementId": null,
      "correctedMonth": null,
      "deltaGr": 1
    }
  ],
  "permissions": {
    "acceptor": {
      "canAccept": true,
      "denial": null
    },
    "canSeeTexts": true,
    "canAnswerRemark": true,
    "canManageAdjustments": true,
    "canRecalculate": true
  }
}
```

**404** – Not found or outside the organization scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/settlements/settlements/:id" \
  -H "Accept: application/json"
```

## POST `/settlements/settlements/{id}/accept`

Accept exactly the settlement the caller saw (hash), lock the work days of the month

Recalculates the draft first and compares the hash (409 settlement_changed with the current view). Gates: month ended, no hard issue, no open blocking case of the person or without a person, no open day, days approved (PR-23), confirmed by the person or a reason for accepting without confirmation (PR-34). Nobody accepts their own settlement; settlements of people restricted by D6 only by the D6 approver. Not undoable.

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Request Body

Content-Type: `application/json`

```json
{
  "inputsHash": "string",
  "withoutConfirmationReason": null,
  "updatedAt": null
}
```

### Responses

**200** – Accepted

Content-Type: `application/json`

```json
{
  "ok": true,
  "settlement": {
    "id": "00000000-0000-4000-8000-000000000000",
    "organizationId": "00000000-0000-4000-8000-000000000000",
    "personId": "00000000-0000-4000-8000-000000000000",
    "month": "string",
    "contractIds": [
      "string"
    ],
    "status": "draft",
    "hoursModel": "A",
    "workedMin": 1,
    "registerMin": 1,
    "grossGr": null,
    "computedGr": null,
    "employerCostGr": null,
    "employerCostBps": null,
    "inputsHash": "string",
    "calculatedAt": null,
    "issues": [
      {
        "code": "calculation_error",
        "params": {
          "key": "string"
        }
      }
    ],
    "base": null,
    "confirmedAt": null,
    "confirmedByUserId": null,
    "acceptedAt": null,
    "acceptedByUserId": null,
    "acceptedByPersonId": null,
    "acceptedWithoutConfirmation": true,
    "closedAt": null,
    "updatedAt": "string"
  }
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing feature or organization outside RBAC

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Not found or outside the organization scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Changed, stale version, not ready, remark open, invalid transition, days not locked

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Acceptance rule (decision 22, D6) not met

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/settlements/:id/accept" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"inputsHash\": \"string\",
  \"withoutConfirmationReason\": null,
  \"updatedAt\": null
}"
```

## POST `/settlements/settlements/{id}/answer-remark`

Answer the person's remark; the settlement goes back to draft

Only for a remarked settlement; the same acceptor rule as the acceptance (not one's own; D6 for restricted people). The comment is encrypted and visible to the person and to callers with settlements.accept.

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | path | any | Required |

### Request Body

Content-Type: `application/json`

```json
{
  "comment": "string",
  "updatedAt": null
}
```

### Responses

**200** – Answered

Content-Type: `application/json`

```json
{
  "ok": true,
  "settlement": {
    "id": "00000000-0000-4000-8000-000000000000",
    "organizationId": "00000000-0000-4000-8000-000000000000",
    "personId": "00000000-0000-4000-8000-000000000000",
    "month": "string",
    "contractIds": [
      "string"
    ],
    "status": "draft",
    "hoursModel": "A",
    "workedMin": 1,
    "registerMin": 1,
    "grossGr": null,
    "computedGr": null,
    "employerCostGr": null,
    "employerCostBps": null,
    "inputsHash": "string",
    "calculatedAt": null,
    "issues": [
      {
        "code": "calculation_error",
        "params": {
          "key": "string"
        }
      }
    ],
    "base": null,
    "confirmedAt": null,
    "confirmedByUserId": null,
    "acceptedAt": null,
    "acceptedByUserId": null,
    "acceptedByPersonId": null,
    "acceptedWithoutConfirmation": true,
    "closedAt": null,
    "updatedAt": "string"
  }
}
```

**400** – Invalid input or text too short

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing feature or organization outside RBAC

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Not found or outside the organization scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Invalid transition or stale version

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Acceptor rule (decision 22, D6) not met

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/settlements/:id/answer-remark" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"comment\": \"string\",
  \"updatedAt\": null
}"
```

## POST `/settlements/settlements/recalculate`

Recalculate the drafts of a month (accepted settlements are never changed)

**Tags:** Settlements

### Request Body

Content-Type: `application/json`

```json
{
  "month": "string",
  "personId": null
}
```

### Responses

**200** – Counters and outcomes of the recalculation

Content-Type: `application/json`

```json
{
  "ok": true,
  "result": {
    "monthFrom": "string",
    "monthTo": "string",
    "counts": {
      "key": 1
    },
    "notified": 1,
    "outcomes": [
      {
        "settlementId": null,
        "organizationId": "00000000-0000-4000-8000-000000000000",
        "personId": "00000000-0000-4000-8000-000000000000",
        "month": "string",
        "created": true,
        "changed": true,
        "statusBefore": null,
        "statusAfter": null,
        "grossGr": null,
        "inputsHash": null,
        "skipped": null
      }
    ]
  }
}
```

**400** – Invalid month or person

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing settlements.accept

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/settlements/settlements/recalculate" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"month\": \"string\",
  \"personId\": null
}"
```

## GET `/settlements/summary`

Counts and sums of the settlements of a month (dashboard tile)

Default month: the previous month up to the 10th day, then the current one. To accept N of M, confirmed, remarks, blocked, sums of gross and employer cost estimate. Organizations of the switcher only. `package`: status, due date, version and live send of the accountant package of the month (most urgent organization), only for callers with settlements.package.view; null otherwise.

**Tags:** Settlements

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| month | query | any | Optional |

### Responses

**200** – Tile data

Content-Type: `application/json`

```json
{
  "month": "string",
  "total": 1,
  "toAccept": 1,
  "accepted": 1,
  "confirmed": 1,
  "remarked": 1,
  "blocked": 1,
  "readyToAccept": 1,
  "grossGr": 1,
  "employerCostGr": 1,
  "employerCostMissing": 1,
  "href": "string",
  "package": null
}
```

**400** – Invalid query

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/settlements/summary" \
  -H "Accept: application/json"
```

## GET `/timesheets/approvals/summary`

Count of confirmed days the caller may approve

**Tags:** Timesheets

### Responses

**200** – Summary

Content-Type: `application/json`

```json
{
  "approvableCount": 1,
  "oldestDate": null
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/timesheets/approvals/summary" \
  -H "Accept: application/json"
```

## POST `/timesheets/cases/rebuild`

Recompute the work-day cases of whole months (all organizations with a legal entity in them)

**Tags:** Timesheets

### Request Body

Content-Type: `application/json`

```json
{
  "monthFrom": "string",
  "monthTo": "string"
}
```

### Responses

**200** – Counters of the rebuild

Content-Type: `application/json`

```json
{
  "ok": true,
  "result": {
    "monthFrom": "string",
    "monthTo": "string",
    "asOf": "string",
    "organizationIds": [
      "00000000-0000-4000-8000-000000000000"
    ],
    "detected": 1,
    "detectedByType": {
      "key": 1
    },
    "sync": {
      "inserted": 1,
      "updated": 1,
      "reopened": 1,
      "autoResolved": 1,
      "unchanged": 1,
      "obsoleted": 1,
      "byType": {
        "key": 1
      }
    }
  }
}
```

**400** – Invalid months

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing timesheets.manage

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/timesheets/cases/rebuild" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"monthFrom\": \"string\",
  \"monthTo\": \"string\"
}"
```

## GET `/timesheets/month`

Work days of one person in a month with Booksy suggestions and totals

**Tags:** Timesheets

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| personId | query | any | Required |
| month | query | any | Required |

### Responses

**200** – Month view

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "personId": "00000000-0000-4000-8000-000000000000",
  "month": "string",
  "locked": true,
  "days": [
    {
      "date": "string",
      "workDay": null,
      "suggestion": null,
      "diffMin": null
    }
  ],
  "totals": {
    "registerMin": 1,
    "visitsSumMin": 1,
    "diffMin": 1,
    "diffBps": null
  },
  "schedule": null
}
```

**400** – Invalid query

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization of the month outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Person not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – No legal entity in the month

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/timesheets/month?personId=00000000-0000-4000-8000-000000000000&month=string" \
  -H "Accept: application/json"
```

## GET `/timesheets/my/days`

Work days of the person linked to the caller

Days of the caller's own person only (the person is never a request parameter): today, days with a row and past days with Booksy activity, with the server-side suggestion (numbers only). Without a linked person: `issue: no_person_for_user` and an empty list.

**Tags:** Timesheets

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| from | query | any | Optional |
| to | query | any | Optional |

### Responses

**200** – Days

Content-Type: `application/json`

```json
{
  "person": null,
  "issue": null,
  "today": "string",
  "from": "string",
  "to": "string",
  "days": [
    {
      "date": "string",
      "organizationId": null,
      "id": null,
      "status": "missing",
      "updatedAt": null,
      "hoursMin": null,
      "startMin": null,
      "endMin": null,
      "cashGr": null,
      "cardGr": null,
      "comment": null,
      "managerComment": null,
      "confirmationMethod": null,
      "confirmedAt": null,
      "approvedAt": null,
      "hasActivity": true,
      "editable": true,
      "requiresStartEnd": true,
      "suggestion": null,
      "warnings": [
        {
          "code": "no_booksy_data",
          "params": {
            "key": 1
          }
        }
      ]
    }
  ],
  "unconfirmedCount": 1,
  "rules": {
    "stepMin": 1,
    "maxDayMin": 1,
    "amountDiffThresholdGr": 1,
    "requireCommentOnHoursChange": true,
    "requireCommentOnAmountDiff": true,
    "editableFrom": "string"
  }
}
```

**400** – Invalid range

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/timesheets/my/days" \
  -H "Accept: application/json"
```

## POST `/timesheets/my/days/confirm`

Confirm a work day of the caller's own person

Hours on the 15-minute grid, cash and card in grosze, optional start/end (required for some kinds of people), a comment when the values differ from the Booksy suggestion. The server recomputes the suggestion; `acceptedSuggestion: true` with a changed suggestion gives 409 `suggestion_changed`. A personId in the body is ignored.

**Tags:** Timesheets

### Request Body

Content-Type: `application/json`

```json
{
  "date": "string",
  "hoursMin": 1,
  "startMin": null,
  "endMin": null,
  "cashGr": 1,
  "cardGr": 1,
  "comment": null,
  "acceptedSuggestion": true,
  "updatedAt": null
}
```

### Responses

**200** – The confirmed day

Content-Type: `application/json`

```json
{
  "date": "string",
  "organizationId": null,
  "id": null,
  "status": "missing",
  "updatedAt": null,
  "hoursMin": null,
  "startMin": null,
  "endMin": null,
  "cashGr": null,
  "cardGr": null,
  "comment": null,
  "managerComment": null,
  "confirmationMethod": null,
  "confirmedAt": null,
  "approvedAt": null,
  "hasActivity": true,
  "editable": true,
  "requiresStartEnd": true,
  "suggestion": null,
  "warnings": [
    {
      "code": "no_booksy_data",
      "params": {
        "key": 1
      }
    }
  ]
}
```

**400** – Invalid entry (code in `code`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – No person for the account, inactive person or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, changed suggestion, closed period or day not editable (current day in `day`)

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – No legal entity for the date

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/timesheets/my/days/confirm" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"date\": \"string\",
  \"hoursMin\": 1,
  \"startMin\": null,
  \"endMin\": null,
  \"cashGr\": 1,
  \"cardGr\": 1,
  \"comment\": null,
  \"acceptedSuggestion\": true,
  \"updatedAt\": null
}"
```

## GET `/timesheets/my/register`

Download the caller’s own work register (PDF, CSV or XLSX)

The register of the person linked to the caller’s account (a personId in the query is ignored). Legal entity from the month, within the organizations RBAC allows; `organizationId` when the month has two. Totals count only confirmed, approved and locked days (ECP-05).

**Tags:** Timesheets

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| month | query | any | Required |
| format | query | any | Optional |
| organizationId | query | any | Optional |

### Responses

**200** – The register file (application/pdf, text/csv or XLSX)

Content-Type: `application/json`

**400** – Invalid query, or the month has two legal entities and no organizationId

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing timesheets.own.view, or the legal entity is not allowed

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – No person linked to the account (no_person_for_user) or no legal entity

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/timesheets/my/register?month=string&format=pdf" \
  -H "Accept: application/json"
```

## GET `/timesheets/my/summary`

Count of the caller's own unconfirmed work days

**Tags:** Timesheets

### Responses

**200** – Summary

Content-Type: `application/json`

```json
{
  "unconfirmedCount": 1,
  "oldestDate": null,
  "issue": null
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/timesheets/my/summary" \
  -H "Accept: application/json"
```

## GET `/timesheets/register`

Download the work register (PDF, CSV or XLSX)

Work days of one person in one month and one legal entity (from the month; `organizationId` when the month has two). Totals count only confirmed, approved and locked days; open days are listed as unconfirmed. Header: legal name and NIP, person, month, draft or closed state; no amounts and no comments (ECP-05). The legal entity must be inside the current organization scope.

**Tags:** Timesheets

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| personId | query | any | Required |
| month | query | any | Required |
| format | query | any | Optional |
| organizationId | query | any | Optional |

### Responses

**200** – The register file (application/pdf, text/csv or XLSX)

Content-Type: `application/json`

**400** – Invalid query, or the month has two legal entities and no organizationId

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing timesheets.all.view, or the legal entity is outside the organization scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Person or legal entity not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/timesheets/register?personId=00000000-0000-4000-8000-000000000000&month=string&format=pdf" \
  -H "Accept: application/json"
```

## GET `/timesheets/settings`

Settings and approval rule (D6) in force for the selected organization

**Tags:** Timesheets

### Responses

**200** – Settings

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "settings": {
    "settings": {},
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null
  },
  "approval": {
    "settings": {},
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null,
    "approverPersonId": null
  },
  "defaults": {
    "settings": {},
    "approval": {}
  }
}
```

**400** – No organization selected

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/timesheets/settings" \
  -H "Accept: application/json"
```

## PUT `/timesheets/settings`

Change the settings and/or the approval rule (partial patches); reason required

**Tags:** Timesheets

### Request Body

Content-Type: `application/json`

```json
{
  "reason": "string"
}
```

### Responses

**200** – Saved settings

Content-Type: `application/json`

```json
{
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "settings": {
    "settings": {},
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null
  },
  "approval": {
    "settings": {},
    "valid": true,
    "state": "default",
    "sourceOrganizationId": null,
    "updatedAt": null,
    "approverPersonId": null
  },
  "defaults": {
    "settings": {},
    "approval": {}
  }
}
```

**400** – Invalid settings, missing reason or nothing to change

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Missing salon.decisions.manage or organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/timesheets/settings" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"reason\": \"string\"
}"
```

## GET `/timesheets/work-days`

Work days of the organizations in scope

Days of every person in the selected organizations, with decrypted comments and whether the caller may approve them (D6). `approvable=1` lists only confirmed days the caller may approve.

**Tags:** Timesheets

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| personId | query | any | Optional |
| month | query | any | Optional |
| from | query | any | Optional |
| to | query | any | Optional |
| status | query | any | Required |
| approvable | query | any | Optional |
| page | query | any | Optional |
| pageSize | query | any | Optional |

### Responses

**200** – Work days

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "personId": "00000000-0000-4000-8000-000000000000",
      "date": "string",
      "hoursMin": 1,
      "startMin": null,
      "endMin": null,
      "cashGr": 1,
      "cardGr": 1,
      "status": "open",
      "confirmationMethod": null,
      "confirmedAt": null,
      "confirmedByUserId": null,
      "approvedAt": null,
      "approvedByUserId": null,
      "approvedByPersonId": null,
      "lockedAt": null,
      "suggestedHoursMin": null,
      "suggestedCashGr": null,
      "suggestedCardGr": null,
      "warnings": [
        {
          "code": "no_booksy_data",
          "params": {
            "key": 1
          }
        }
      ],
      "updatedAt": "string",
      "comment": null,
      "managerComment": null,
      "canApprove": true
    }
  ],
  "total": 1,
  "page": 1,
  "pageSize": 1,
  "totalPages": 1
}
```

**400** – Invalid filters

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**401** – Unauthorized

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/timesheets/work-days" \
  -H "Accept: application/json"
```

## POST `/timesheets/work-days/approve`

Approve confirmed work days (all or nothing)

Approves up to 200 confirmed days. Nobody approves their own day; days of people restricted by setting D6 are approved only by the configured approver. On any failing day nothing is approved and `items` lists the code per id.

**Tags:** Timesheets

### Request Body

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "updatedAt": null
    }
  ],
  "comment": null
}
```

### Responses

**200** – Approved

Content-Type: `application/json`

```json
{
  "ok": true,
  "count": 1,
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "status": "open",
      "updatedAt": null
    }
  ]
}
```

**400** – Invalid input or too many days

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Day not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Invalid transition, stale version or closed period

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Approval rule (D6) not met

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/timesheets/work-days/approve" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"items\": [
    {
      \"id\": \"00000000-0000-4000-8000-000000000000\",
      \"updatedAt\": null
    }
  ],
  \"comment\": null
}"
```

## POST `/timesheets/work-days/correct`

Correct the work day of another person

Writes hours, start/end and amounts of another person's day with a required comment (the reason). A person with an account confirms the day again (status open); for a person without an account the entry is the confirmation (entered_by_manager).

**Tags:** Timesheets

### Request Body

Content-Type: `application/json`

```json
{
  "personId": "00000000-0000-4000-8000-000000000000",
  "date": "string",
  "hoursMin": 1,
  "startMin": null,
  "endMin": null,
  "cashGr": 1,
  "cardGr": 1,
  "comment": "string",
  "updatedAt": null
}
```

### Responses

**200** – Corrected

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "personId": "00000000-0000-4000-8000-000000000000",
  "date": "string",
  "status": "open",
  "previousStatus": "missing",
  "updatedAt": null
}
```

**400** – Invalid entry or missing comment

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**403** – Organization outside the scope

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Person not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Stale version, invalid transition or closed period

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Own day or no legal entity for the date

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/timesheets/work-days/correct" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"personId\": \"00000000-0000-4000-8000-000000000000\",
  \"date\": \"string\",
  \"hoursMin\": 1,
  \"startMin\": null,
  \"endMin\": null,
  \"cashGr\": 1,
  \"cardGr\": 1,
  \"comment\": \"string\",
  \"updatedAt\": null
}"
```

## POST `/timesheets/work-days/reopen`

Approved → confirmed, with a reason

**Tags:** Timesheets

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string",
  "updatedAt": null
}
```

### Responses

**200** – Reopened

Content-Type: `application/json`

```json
{
  "ok": true,
  "id": "00000000-0000-4000-8000-000000000000",
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "personId": "00000000-0000-4000-8000-000000000000",
  "date": "string",
  "status": "open",
  "previousStatus": "missing",
  "updatedAt": null
}
```

**400** – Missing reason

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**404** – Day not found

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**409** – Invalid transition, stale version or closed period

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

**422** – Approval rule (D6) not met

Content-Type: `application/json`

```json
{
  "error": "string"
}
```

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/timesheets/work-days/reopen" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\",
  \"updatedAt\": null
}"
```

## DELETE `/translations/{entityType}/{entityId}`

Delete entity translations

Removes all translations for an entity.

**Tags:** Translations

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| entityType | path | any | Required |
| entityId | path | any | Required |

### Responses

**204** – Translations deleted.

**401** – Authentication required

Content-Type: `application/json`

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/translations/string/string" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/translations/{entityType}/{entityId}`

Get entity translations

Returns the full translation record for a single entity.

**Tags:** Translations

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| entityType | path | any | Required |
| entityId | path | any | Required |

### Responses

**200** – Translation record found.

Content-Type: `application/json`

**401** – Authentication required

Content-Type: `application/json`

**404** – No translations found for this entity

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/translations/string/string" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/translations/{entityType}/{entityId}`

Create or update entity translations

Full replacement of translations JSONB for an entity.

**Tags:** Translations

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| entityType | path | any | Required |
| entityId | path | any | Required |

### Responses

**200** – Translations saved.

Content-Type: `application/json`

**400** – Validation failed

Content-Type: `application/json`

**401** – Authentication required

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/translations/string/string" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/translations/locales`

List supported translation locales

**Tags:** Entity Translations

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/translations/locales" \
  -H "Accept: application/json"
```

## PUT `/translations/locales`

Update supported translation locales

**Tags:** Entity Translations

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/translations/locales" \
  -H "Accept: application/json"
```

## GET `/vat_limit/alerts`

Recorded VAT limit alerts of the selected legal entity, newest first

**Tags:** VAT limit

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| year | query | any | Optional |
| limit | query | any | Optional |

### Responses

**200** – Alerts

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "year": 1,
      "kind": "threshold",
      "thresholdBps": 1,
      "basis": "string",
      "variant": "string",
      "usedBps": 1,
      "countedGr": 1,
      "limitGr": 1,
      "forecastDate": null,
      "asOf": "string",
      "suppressed": true,
      "notifiedAt": null,
      "recipientsCount": null,
      "createdAt": null
    }
  ]
}
```

**400** – No organization selected or invalid query

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/vat_limit/alerts?limit=20" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/vat_limit/monthly`

Twelve months of the four counters (Booksy/real × main/cautious) and sums per kind

**Tags:** VAT limit

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| year | query | any | Optional |

### Responses

**200** – Months

Content-Type: `application/json`

```json
{
  "year": 1,
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "months": [
    {
      "month": "string",
      "booksyMainGr": 1,
      "booksyCautiousGr": 1,
      "realMainGr": 1,
      "realCautiousGr": 1,
      "fiscalReportDays": 1,
      "byKind": {
        "key": 1
      }
    }
  ],
  "warnings": [
    "string"
  ]
}
```

**400** – No organization selected or invalid query

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/vat_limit/monthly" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## DELETE `/vat_limit/revenue-entries`

Soft-delete a manual entry; Booksy rows are read-only; reason required

**Tags:** VAT limit

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "reason": "string"
}
```

### Responses

**200** – Deleted

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**404** – Entry not found

Content-Type: `application/json`

**409** – Booksy row

Content-Type: `application/json`

### Example

```bash
curl -X DELETE "https://manifaktura.vicoop.com/api/vat_limit/revenue-entries" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"reason\": \"string\"
}"
```

## GET `/vat_limit/revenue-entries`

Revenue rows (manual and Booksy) of the selected legal entity

**Tags:** VAT limit

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| id | query | any | Optional |
| from | query | any | Optional |
| to | query | any | Optional |
| kind | query | any | Optional |
| origin | query | any | Optional |
| page | query | any | Optional |
| pageSize | query | any | Optional |

### Responses

**200** – Page of rows

Content-Type: `application/json`

```json
{
  "items": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "organizationId": "00000000-0000-4000-8000-000000000000",
      "tenantId": "00000000-0000-4000-8000-000000000000",
      "entryDate": "string",
      "kind": "string",
      "origin": "booksy",
      "amountGr": 1,
      "countedOverride": null,
      "documentRef": null,
      "note": null,
      "sourceCount": null,
      "createdAt": null,
      "updatedAt": null
    }
  ],
  "total": 1,
  "page": 1,
  "pageSize": 1,
  "totalPages": 1
}
```

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/vat_limit/revenue-entries?page=1&pageSize=50" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## POST `/vat_limit/revenue-entries`

Create a manual entry (fiscal daily report, sublease, voucher sale, product sale, other); reason required

**Tags:** VAT limit

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "entryDate": "string",
  "kind": "fiscal_daily_report",
  "amountGr": 1,
  "countedOverride": null,
  "reason": "string"
}
```

### Responses

**201** – Created

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000"
}
```

**400** – Invalid input or missing reason

Content-Type: `application/json`

**409** – A fiscal daily report already exists for the day

Content-Type: `application/json`

### Example

```bash
curl -X POST "https://manifaktura.vicoop.com/api/vat_limit/revenue-entries" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"entryDate\": \"string\",
  \"kind\": \"fiscal_daily_report\",
  \"amountGr\": 1,
  \"countedOverride\": null,
  \"reason\": \"string\"
}"
```

## PUT `/vat_limit/revenue-entries`

Update a manual entry; Booksy rows are read-only; reason required

**Tags:** VAT limit

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "countedOverride": null,
  "reason": "string"
}
```

### Responses

**200** – Updated

Content-Type: `application/json`

```json
{
  "ok": true
}
```

**404** – Entry not found

Content-Type: `application/json`

**409** – Booksy row or conflicting fiscal report

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/vat_limit/revenue-entries" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"id\": \"00000000-0000-4000-8000-000000000000\",
  \"countedOverride\": null,
  \"reason\": \"string\"
}"
```

## GET `/vat_limit/settings`

Effective settings (counting rules, forecast, alerts) and their defaults

**Tags:** VAT limit

**Requires authentication.**

### Responses

**200** – Settings

Content-Type: `application/json`

```json
{
  "settings": {},
  "valid": true,
  "state": "default",
  "updatedAt": null,
  "defaults": {}
}
```

**401** – Unauthorized

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/vat_limit/settings" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## PUT `/vat_limit/settings`

Change the settings (partial patch merged over the current value); reason required

**Tags:** VAT limit

**Requires authentication.**

### Request Body

Content-Type: `application/json`

```json
{
  "settings": {},
  "reason": "string"
}
```

### Responses

**200** – Saved settings

Content-Type: `application/json`

```json
{
  "settings": {},
  "valid": true,
  "state": "default",
  "updatedAt": null,
  "defaults": {}
}
```

**400** – Invalid settings or missing reason

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

**403** – Missing salon.decisions.manage

Content-Type: `application/json`

### Example

```bash
curl -X PUT "https://manifaktura.vicoop.com/api/vat_limit/settings" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d "{
  \"settings\": {},
  \"reason\": \"string\"
}"
```

## GET `/vat_limit/summary`

Counters, proportional limit, forecasts and warnings of the selected legal entity

**Tags:** VAT limit

**Requires authentication.**

### Parameters
| Name | Location | Type | Description |
| --- | --- | --- | --- |
| asOf | query | any | Optional |
| year | query | any | Optional |

### Responses

**200** – Summary

Content-Type: `application/json`

```json
{
  "asOf": "string",
  "year": 1,
  "organizationId": "00000000-0000-4000-8000-000000000000",
  "periodStart": "string",
  "dataThrough": null,
  "counters": [
    {
      "basis": "booksy",
      "variant": "main",
      "dataThrough": null,
      "countedGr": 1,
      "usedBps": null,
      "exceeded": true,
      "forecast": null
    }
  ],
  "headlineCounter": null,
  "level": "unknown",
  "warnings": [
    "string"
  ]
}
```

**400** – No organization selected or invalid query

Content-Type: `application/json`

**401** – Unauthorized

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/vat_limit/summary" \
  -H "Accept: application/json" \
  -H "authorization: Bearer <token>"
```

## GET `/version`

Deployed Open Mercato version

**Tags:** API Documentation

### Responses

**200** – Success response

Content-Type: `application/json`

### Example

```bash
curl -X GET "https://manifaktura.vicoop.com/api/version" \
  -H "Accept: application/json"
```