{
  "openapi": "3.1.0",
  "info": {
    "title": "Fixra API",
    "version": "2026-10-01",
    "description": "Fixras öppna REST-API. Alla svar har formen `{ ok, data, warnings, errors }`. Belopp i öre som heltal, tider i ISO 8601 med offset. Svarshuvudet `Fixra-Version` anger versionen."
  },
  "servers": [
    {
      "url": "https://api.fixra.se",
      "description": "Production"
    },
    {
      "url": "https://app.fixra.se/api/public",
      "description": "Direct (fallback)"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Konto"
    },
    {
      "name": "Specifikation"
    },
    {
      "name": "Kunder"
    },
    {
      "name": "Platser"
    },
    {
      "name": "Kontakter"
    },
    {
      "name": "Arbetsorder"
    },
    {
      "name": "Pass"
    },
    {
      "name": "Avtal"
    },
    {
      "name": "Offerter"
    },
    {
      "name": "Tjänster"
    },
    {
      "name": "Personal"
    },
    {
      "name": "Tid"
    },
    {
      "name": "Fakturaunderlag"
    },
    {
      "name": "Avvikelser"
    },
    {
      "name": "Förfrågningar"
    },
    {
      "name": "Webhooks"
    },
    {
      "name": "Bilagor"
    },
    {
      "name": "Uppgifter"
    },
    {
      "name": "Ärenden"
    },
    {
      "name": "Material"
    },
    {
      "name": "Leverantörer"
    },
    {
      "name": "Inköpsorder"
    },
    {
      "name": "Leverantörsfakturor"
    },
    {
      "name": "Projekt"
    },
    {
      "name": "Partner-API",
      "description": "För återförsäljare. Nyckeln (`fx_ptnr_…`) skapas i partnerportalen och gäller en partner. Samma regler som portalen; MFA gäller inte nycklar men scopes gör."
    }
  ],
  "paths": {
    "/v1/me": {
      "get": {
        "operationId": "getMe",
        "tags": [
          "Konto"
        ],
        "summary": "Vem är jag",
        "description": "Returnerar bolaget nyckeln hör till, nyckelns namn, prefix, läge (live eller test) och scopes. Kräver inget scope — bra som första anrop.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "tenant": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "name": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "name"
                              ],
                              "additionalProperties": false
                            },
                            "key": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "prefix": {
                                  "type": "string",
                                  "description": "De första 16 tecknen i nyckeln, t.ex. fx_live_AbCd1234."
                                },
                                "mode": {
                                  "type": "string",
                                  "enum": [
                                    "live",
                                    "test"
                                  ]
                                },
                                "scopes": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                },
                                "expires_at": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "created_at": {
                                  "type": "string",
                                  "format": "date-time"
                                }
                              },
                              "required": [
                                "name",
                                "prefix",
                                "mode",
                                "scopes",
                                "expires_at",
                                "created_at"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "tenant",
                            "key"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "tenant": {
                      "id": "3f1c2a9e-7b1d-4c55-9a0e-2d6f1b7c8e90",
                      "name": "Städbolaget AB"
                    },
                    "key": {
                      "name": "Min integration",
                      "prefix": "fx_live_AbCd1234",
                      "mode": "live",
                      "scopes": [
                        "customers:read",
                        "work_orders:read"
                      ],
                      "expires_at": "2026-12-30T09:00:00+01:00",
                      "created_at": "2026-10-01T09:00:00+02:00"
                    }
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": null,
        "x-fixra-rpc": "api_me_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/me\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/openapi.json": {
      "get": {
        "operationId": "getOpenApi",
        "tags": [
          "Specifikation"
        ],
        "summary": "OpenAPI-specifikationen",
        "description": "Hela API:t som OpenAPI 3.1. Publik, ingen nyckel.",
        "security": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "openapi": {
                      "type": "string",
                      "const": "3.1.0"
                    }
                  },
                  "required": [
                    "openapi"
                  ],
                  "additionalProperties": true
                },
                "example": {
                  "openapi": "3.1.0",
                  "info": {
                    "title": "Fixra API",
                    "version": "2026-10-01"
                  }
                }
              }
            }
          },
          "500": {
            "description": "`SERVERFEL` — Specen kunde inte byggas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SERVERFEL": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SERVERFEL"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": null,
        "x-fixra-rpc": null,
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/openapi.json\""
          }
        ]
      }
    },
    "/v1/customers": {
      "get": {
        "operationId": "listCustomers",
        "tags": [
          "Kunder"
        ],
        "summary": "Lista kunder",
        "description": "Kunder i bolaget, sorterade på senast ändrad. Filtrera på fritext (`q`), `type` eller ert `external_id`. Privatkunders personnummer visas bara som ÅÅMMDD-****.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ]
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "enum": [
                    "company",
                    "private"
                  ]
                }
              ]
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                }
              ],
              "description": "Slå upp på ert eget id (external_id)."
            },
            "description": "Slå upp på ert eget id (external_id)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "customer_number": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "company",
                                      "private"
                                    ]
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "org_number": {
                                    "type": [
                                      "string",
                                      "null"
                                    ],
                                    "description": "Organisationsnummer. För privatkunder personnummer maskerat ÅÅMMDD-****."
                                  },
                                  "vat_number": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "email": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "phone": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "payment_terms_days": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_active": {
                                    "type": "boolean"
                                  },
                                  "tags": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "billing_address": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "line1": {
                                            "type": [
                                              "string",
                                              "null"
                                            ]
                                          },
                                          "line2": {
                                            "type": [
                                              "string",
                                              "null"
                                            ]
                                          },
                                          "postal_code": {
                                            "type": [
                                              "string",
                                              "null"
                                            ]
                                          },
                                          "city": {
                                            "type": [
                                              "string",
                                              "null"
                                            ]
                                          },
                                          "country": {
                                            "type": [
                                              "string",
                                              "null"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "line1",
                                          "line2",
                                          "postal_code",
                                          "city",
                                          "country"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "external_id": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "customer_number",
                                  "type",
                                  "name",
                                  "org_number",
                                  "vat_number",
                                  "email",
                                  "phone",
                                  "payment_terms_days",
                                  "is_active",
                                  "tags",
                                  "billing_address",
                                  "external_id",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "customer_number": "K-1042",
                        "type": "company",
                        "name": "Brf Solgläntan",
                        "org_number": "769612-3456",
                        "vat_number": null,
                        "email": "styrelsen@solglantan.se",
                        "phone": "+46701234567",
                        "payment_terms_days": 30,
                        "is_active": true,
                        "tags": [],
                        "billing_address": {
                          "line1": "Solvägen 4",
                          "line2": null,
                          "postal_code": "11122",
                          "city": "Stockholm",
                          "country": "SE"
                        },
                        "external_id": "crm-881",
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`OKAND_KUNDTYP` — Okänd kundtyp.\n\n`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OKAND_KUNDTYP": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OKAND_KUNDTYP"
                      ]
                    }
                  },
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "customers:read",
        "x-fixra-rpc": "api_customers_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/customers\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createCustomer",
        "tags": [
          "Kunder"
        ],
        "summary": "Skapa kund",
        "description": "Skapar en kund med samma regler som i appen. Märks med källa API i aktivitetsloggen. Testnycklar kör torrt (`dry_run: true`).",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "company",
                      "private"
                    ]
                  },
                  "org_number": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "vat_number": {
                    "type": "string",
                    "maxLength": 30
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 200
                  },
                  "phone": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "payment_terms_days": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 365
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 50
                    },
                    "maxItems": 50
                  },
                  "address": {
                    "type": "object",
                    "properties": {
                      "line1": {
                        "type": "string",
                        "maxLength": 200
                      },
                      "line2": {
                        "type": "string",
                        "maxLength": 200
                      },
                      "postal_code": {
                        "type": "string",
                        "maxLength": 20
                      },
                      "city": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "country": {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 2
                      }
                    },
                    "additionalProperties": false
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "name"
                ],
                "additionalProperties": false
              },
              "example": {
                "name": "Brf Solgläntan",
                "type": "company",
                "org_number": "769612-3456",
                "external_id": "crm-881"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "customer_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "company",
                                "private"
                              ]
                            },
                            "name": {
                              "type": "string"
                            },
                            "org_number": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "description": "Organisationsnummer. För privatkunder personnummer maskerat ÅÅMMDD-****."
                            },
                            "vat_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "email": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "phone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "payment_terms_days": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "is_active": {
                              "type": "boolean"
                            },
                            "tags": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "billing_address": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "line1": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "line2": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "postal_code": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "city": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "country": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "line1",
                                    "line2",
                                    "postal_code",
                                    "city",
                                    "country"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "customer_number",
                            "type",
                            "name",
                            "org_number",
                            "vat_number",
                            "email",
                            "phone",
                            "payment_terms_days",
                            "is_active",
                            "tags",
                            "billing_address",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "customer_number": "K-1042",
                    "type": "company",
                    "name": "Brf Solgläntan",
                    "org_number": "769612-3456",
                    "vat_number": null,
                    "email": "styrelsen@solglantan.se",
                    "phone": "+46701234567",
                    "payment_terms_days": 30,
                    "is_active": true,
                    "tags": [],
                    "billing_address": {
                      "line1": "Solvägen 4",
                      "line2": null,
                      "postal_code": "11122",
                      "city": "Stockholm",
                      "country": "SE"
                    },
                    "external_id": "crm-881",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`NAMN_SAKNAS` — Namn saknas.\n\n`OGILTIG_KUNDTYP` — Ogiltig kundtyp.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NAMN_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NAMN_SAKNAS"
                      ]
                    }
                  },
                  "OGILTIG_KUNDTYP": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIG_KUNDTYP"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "customers:write",
        "x-fixra-rpc": "api_customers_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/customers\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Brf Solgläntan\",\"type\":\"company\",\"org_number\":\"769612-3456\",\"external_id\":\"crm-881\"}'"
          }
        ]
      }
    },
    "/v1/customers/{id}": {
      "get": {
        "operationId": "getCustomer",
        "tags": [
          "Kunder"
        ],
        "summary": "Hämta kund",
        "description": "En kund. Kund i ett annat bolag ger 404.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "customer_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "company",
                                "private"
                              ]
                            },
                            "name": {
                              "type": "string"
                            },
                            "org_number": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "description": "Organisationsnummer. För privatkunder personnummer maskerat ÅÅMMDD-****."
                            },
                            "vat_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "email": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "phone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "payment_terms_days": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "is_active": {
                              "type": "boolean"
                            },
                            "tags": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "billing_address": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "line1": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "line2": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "postal_code": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "city": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "country": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "line1",
                                    "line2",
                                    "postal_code",
                                    "city",
                                    "country"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "customer_number",
                            "type",
                            "name",
                            "org_number",
                            "vat_number",
                            "email",
                            "phone",
                            "payment_terms_days",
                            "is_active",
                            "tags",
                            "billing_address",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "customer_number": "K-1042",
                    "type": "company",
                    "name": "Brf Solgläntan",
                    "org_number": "769612-3456",
                    "vat_number": null,
                    "email": "styrelsen@solglantan.se",
                    "phone": "+46701234567",
                    "payment_terms_days": 30,
                    "is_active": true,
                    "tags": [],
                    "billing_address": {
                      "line1": "Solvägen 4",
                      "line2": null,
                      "postal_code": "11122",
                      "city": "Stockholm",
                      "country": "SE"
                    },
                    "external_id": "crm-881",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`KUND_SAKNAS` — Kunden finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "KUND_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KUND_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "customers:read",
        "x-fixra-rpc": "api_customers_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/customers/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "patch": {
        "operationId": "updateCustomer",
        "tags": [
          "Kunder"
        ],
        "summary": "Ändra kund",
        "description": "Ändrar bara fälten som skickas.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "company",
                      "private"
                    ]
                  },
                  "org_number": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "vat_number": {
                    "type": "string",
                    "maxLength": 30
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 200
                  },
                  "phone": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "payment_terms_days": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 365
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 50
                    },
                    "maxItems": 50
                  },
                  "address": {
                    "type": "object",
                    "properties": {
                      "line1": {
                        "type": "string",
                        "maxLength": 200
                      },
                      "line2": {
                        "type": "string",
                        "maxLength": 200
                      },
                      "postal_code": {
                        "type": "string",
                        "maxLength": 20
                      },
                      "city": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "country": {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 2
                      }
                    },
                    "additionalProperties": false
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "phone": "+46709998877"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "customer_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "company",
                                "private"
                              ]
                            },
                            "name": {
                              "type": "string"
                            },
                            "org_number": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "description": "Organisationsnummer. För privatkunder personnummer maskerat ÅÅMMDD-****."
                            },
                            "vat_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "email": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "phone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "payment_terms_days": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "is_active": {
                              "type": "boolean"
                            },
                            "tags": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "billing_address": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "line1": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "line2": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "postal_code": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "city": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "country": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "line1",
                                    "line2",
                                    "postal_code",
                                    "city",
                                    "country"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "customer_number",
                            "type",
                            "name",
                            "org_number",
                            "vat_number",
                            "email",
                            "phone",
                            "payment_terms_days",
                            "is_active",
                            "tags",
                            "billing_address",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "customer_number": "K-1042",
                    "type": "company",
                    "name": "Brf Solgläntan",
                    "org_number": "769612-3456",
                    "vat_number": null,
                    "email": "styrelsen@solglantan.se",
                    "phone": "+46701234567",
                    "payment_terms_days": 30,
                    "is_active": true,
                    "tags": [],
                    "billing_address": {
                      "line1": "Solvägen 4",
                      "line2": null,
                      "postal_code": "11122",
                      "city": "Stockholm",
                      "country": "SE"
                    },
                    "external_id": "crm-881",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`KUND_SAKNAS` — Kunden finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "KUND_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KUND_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`NAMN_SAKNAS` — Namnet får inte vara tomt.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NAMN_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NAMN_SAKNAS"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "customers:write",
        "x-fixra-rpc": "api_customers_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/customers/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"phone\":\"+46709998877\"}'"
          }
        ]
      }
    },
    "/v1/sites": {
      "get": {
        "operationId": "listSites",
        "tags": [
          "Platser"
        ],
        "summary": "Lista platser",
        "description": "Platser (städobjekt). Portkod, larmkod, nyckelinformation och tillträdesinstruktioner returneras aldrig.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                }
              ],
              "description": "Slå upp på ert eget id (external_id)."
            },
            "description": "Slå upp på ert eget id (external_id)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "customer_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "address": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "line1": {
                                            "type": [
                                              "string",
                                              "null"
                                            ]
                                          },
                                          "line2": {
                                            "type": [
                                              "string",
                                              "null"
                                            ]
                                          },
                                          "postal_code": {
                                            "type": [
                                              "string",
                                              "null"
                                            ]
                                          },
                                          "city": {
                                            "type": [
                                              "string",
                                              "null"
                                            ]
                                          },
                                          "country": {
                                            "type": [
                                              "string",
                                              "null"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "line1",
                                          "line2",
                                          "postal_code",
                                          "city",
                                          "country"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "property_designation": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "service_area": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "area_sqm": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "external_id": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "customer_id",
                                  "name",
                                  "address",
                                  "property_designation",
                                  "service_area",
                                  "area_sqm",
                                  "external_id",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "name": "Trapphus A",
                        "address": {
                          "line1": "Solvägen 4",
                          "line2": null,
                          "postal_code": "11122",
                          "city": "Stockholm",
                          "country": "SE"
                        },
                        "property_designation": "Solen 1:4",
                        "service_area": "Innerstan",
                        "area_sqm": 420,
                        "external_id": null,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "sites:read",
        "x-fixra-rpc": "api_sites_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/sites\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createSite",
        "tags": [
          "Platser"
        ],
        "summary": "Skapa plats",
        "description": "Skapar en plats hos en kund. Portkod och nyckelinformation kan skrivas men läses aldrig tillbaka.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "address": {
                    "type": "object",
                    "properties": {
                      "line1": {
                        "type": "string",
                        "maxLength": 200
                      },
                      "line2": {
                        "type": "string",
                        "maxLength": 200
                      },
                      "postal_code": {
                        "type": "string",
                        "maxLength": 20
                      },
                      "city": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "country": {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 2
                      }
                    },
                    "additionalProperties": false
                  },
                  "property_designation": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "service_area": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "area_sqm": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10000000
                  },
                  "access_info": {
                    "type": "string",
                    "maxLength": 2000,
                    "description": "Skrivs men returneras aldrig."
                  },
                  "gate_code": {
                    "type": "string",
                    "maxLength": 50,
                    "description": "Portkod. Skrivs men returneras aldrig."
                  },
                  "alarm_code": {
                    "type": "string",
                    "maxLength": 50,
                    "description": "Larmkod. Skrivs men returneras aldrig."
                  },
                  "key_info": {
                    "type": "string",
                    "maxLength": 500,
                    "description": "Nyckelinformation. Skrivs men returneras aldrig."
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "customer_id",
                  "name"
                ],
                "additionalProperties": false
              },
              "example": {
                "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "name": "Trapphus A",
                "gate_code": "1234",
                "address": {
                  "line1": "Solvägen 4",
                  "postal_code": "11122",
                  "city": "Stockholm"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "customer_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "address": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "line1": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "line2": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "postal_code": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "city": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "country": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "line1",
                                    "line2",
                                    "postal_code",
                                    "city",
                                    "country"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "property_designation": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "service_area": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "area_sqm": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "customer_id",
                            "name",
                            "address",
                            "property_designation",
                            "service_area",
                            "area_sqm",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "name": "Trapphus A",
                    "address": {
                      "line1": "Solvägen 4",
                      "line2": null,
                      "postal_code": "11122",
                      "city": "Stockholm",
                      "country": "SE"
                    },
                    "property_designation": "Solen 1:4",
                    "service_area": "Innerstan",
                    "area_sqm": 420,
                    "external_id": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`NAMN_SAKNAS` — Namn saknas.\n\n`KUND_SAKNAS` — Kunden finns inte i bolaget.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NAMN_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NAMN_SAKNAS"
                      ]
                    }
                  },
                  "KUND_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KUND_SAKNAS"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "sites:write",
        "x-fixra-rpc": "api_sites_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/sites\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"customer_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"name\":\"Trapphus A\",\"gate_code\":\"1234\",\"address\":{\"line1\":\"Solvägen 4\",\"postal_code\":\"11122\",\"city\":\"Stockholm\"}}'"
          }
        ]
      }
    },
    "/v1/sites/{id}": {
      "get": {
        "operationId": "getSite",
        "tags": [
          "Platser"
        ],
        "summary": "Hämta plats",
        "description": "En plats. Plats i ett annat bolag ger 404.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "customer_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "address": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "line1": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "line2": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "postal_code": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "city": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "country": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "line1",
                                    "line2",
                                    "postal_code",
                                    "city",
                                    "country"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "property_designation": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "service_area": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "area_sqm": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "customer_id",
                            "name",
                            "address",
                            "property_designation",
                            "service_area",
                            "area_sqm",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "name": "Trapphus A",
                    "address": {
                      "line1": "Solvägen 4",
                      "line2": null,
                      "postal_code": "11122",
                      "city": "Stockholm",
                      "country": "SE"
                    },
                    "property_designation": "Solen 1:4",
                    "service_area": "Innerstan",
                    "area_sqm": 420,
                    "external_id": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`OBJEKT_SAKNAS` — Platsen finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OBJEKT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OBJEKT_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "sites:read",
        "x-fixra-rpc": "api_sites_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/sites/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "patch": {
        "operationId": "updateSite",
        "tags": [
          "Platser"
        ],
        "summary": "Ändra plats",
        "description": "Ändrar bara fälten som skickas.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "address": {
                    "type": "object",
                    "properties": {
                      "line1": {
                        "type": "string",
                        "maxLength": 200
                      },
                      "line2": {
                        "type": "string",
                        "maxLength": 200
                      },
                      "postal_code": {
                        "type": "string",
                        "maxLength": 20
                      },
                      "city": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "country": {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 2
                      }
                    },
                    "additionalProperties": false
                  },
                  "property_designation": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "service_area": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "area_sqm": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10000000
                  },
                  "access_info": {
                    "type": "string",
                    "maxLength": 2000,
                    "description": "Skrivs men returneras aldrig."
                  },
                  "gate_code": {
                    "type": "string",
                    "maxLength": 50,
                    "description": "Portkod. Skrivs men returneras aldrig."
                  },
                  "alarm_code": {
                    "type": "string",
                    "maxLength": 50,
                    "description": "Larmkod. Skrivs men returneras aldrig."
                  },
                  "key_info": {
                    "type": "string",
                    "maxLength": 500,
                    "description": "Nyckelinformation. Skrivs men returneras aldrig."
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "area_sqm": 450
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "customer_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "address": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "line1": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "line2": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "postal_code": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "city": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "country": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "line1",
                                    "line2",
                                    "postal_code",
                                    "city",
                                    "country"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "property_designation": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "service_area": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "area_sqm": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "customer_id",
                            "name",
                            "address",
                            "property_designation",
                            "service_area",
                            "area_sqm",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "name": "Trapphus A",
                    "address": {
                      "line1": "Solvägen 4",
                      "line2": null,
                      "postal_code": "11122",
                      "city": "Stockholm",
                      "country": "SE"
                    },
                    "property_designation": "Solen 1:4",
                    "service_area": "Innerstan",
                    "area_sqm": 420,
                    "external_id": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`OBJEKT_SAKNAS` — Platsen finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OBJEKT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OBJEKT_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "sites:write",
        "x-fixra-rpc": "api_sites_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/sites/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"area_sqm\":450}'"
          }
        ]
      }
    },
    "/v1/contacts": {
      "get": {
        "operationId": "listContacts",
        "tags": [
          "Kontakter"
        ],
        "summary": "Lista kontakter",
        "description": "Kontaktpersoner, valfritt för en kund.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "customer_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "site_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "first_name": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "last_name": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "title": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "email": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "phone": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "is_primary": {
                                    "type": "boolean"
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "customer_id",
                                  "site_id",
                                  "first_name",
                                  "last_name",
                                  "title",
                                  "email",
                                  "phone",
                                  "is_primary",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "site_id": null,
                        "first_name": "Anna",
                        "last_name": "Berg",
                        "title": "Ordförande",
                        "email": "anna@solglantan.se",
                        "phone": "+46701234567",
                        "is_primary": true,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "contacts:read",
        "x-fixra-rpc": "api_contacts_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/contacts\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createContact",
        "tags": [
          "Kontakter"
        ],
        "summary": "Skapa kontakt",
        "description": "Skapar en kontaktperson hos en kund.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "site_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "first_name": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "last_name": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 200
                  },
                  "phone": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "is_primary": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "customer_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "first_name": "Anna",
                "last_name": "Berg",
                "email": "anna@solglantan.se"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "customer_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "first_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "last_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "title": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "email": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "phone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "is_primary": {
                              "type": "boolean"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "customer_id",
                            "site_id",
                            "first_name",
                            "last_name",
                            "title",
                            "email",
                            "phone",
                            "is_primary",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": null,
                    "first_name": "Anna",
                    "last_name": "Berg",
                    "title": "Ordförande",
                    "email": "anna@solglantan.se",
                    "phone": "+46701234567",
                    "is_primary": true,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`NAMN_SAKNAS` — För- eller efternamn krävs.\n\n`KUND_SAKNAS` — Kunden finns inte i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NAMN_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NAMN_SAKNAS"
                      ]
                    }
                  },
                  "KUND_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KUND_SAKNAS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "contacts:write",
        "x-fixra-rpc": "api_contacts_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/contacts\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"customer_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"first_name\":\"Anna\",\"last_name\":\"Berg\",\"email\":\"anna@solglantan.se\"}'"
          }
        ]
      }
    },
    "/v1/contacts/{id}": {
      "patch": {
        "operationId": "updateContact",
        "tags": [
          "Kontakter"
        ],
        "summary": "Ändra kontakt",
        "description": "Ändrar bara fälten som skickas.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "site_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "first_name": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "last_name": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 200
                  },
                  "phone": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "is_primary": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "phone": "+46701234567"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "customer_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "first_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "last_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "title": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "email": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "phone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "is_primary": {
                              "type": "boolean"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "customer_id",
                            "site_id",
                            "first_name",
                            "last_name",
                            "title",
                            "email",
                            "phone",
                            "is_primary",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": null,
                    "first_name": "Anna",
                    "last_name": "Berg",
                    "title": "Ordförande",
                    "email": "anna@solglantan.se",
                    "phone": "+46701234567",
                    "is_primary": true,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`KONTAKT_SAKNAS` — Kontakten finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "KONTAKT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KONTAKT_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "contacts:write",
        "x-fixra-rpc": "api_contacts_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/contacts/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"phone\":\"+46701234567\"}'"
          }
        ]
      }
    },
    "/v1/work-orders": {
      "get": {
        "operationId": "listWorkOrders",
        "tags": [
          "Arbetsorder"
        ],
        "summary": "Lista arbetsorder",
        "description": "Arbetsorder utan priser. Filtrera på `status` (kanoniskt tillstånd), period (`from`/`to`), kund, plats eller `external_id`.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 40
                }
              ]
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ]
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ]
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "site_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                }
              ],
              "description": "Slå upp på ert eget id (external_id)."
            },
            "description": "Slå upp på ert eget id (external_id)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "work_order_no": {
                                    "type": "string"
                                  },
                                  "customer_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "site_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "contact_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "agreement_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "title": {
                                    "type": "string"
                                  },
                                  "description": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "description": "Kanoniskt tillstånd: unplanned, planned, in_progress, completed, cancelled …"
                                  },
                                  "status_label": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "priority": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "planned_start": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "planned_end": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "estimated_minutes": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "source": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "external_id": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "work_order_no",
                                  "customer_id",
                                  "site_id",
                                  "contact_id",
                                  "agreement_id",
                                  "title",
                                  "description",
                                  "status",
                                  "status_label",
                                  "priority",
                                  "planned_start",
                                  "planned_end",
                                  "estimated_minutes",
                                  "source",
                                  "external_id",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "work_order_no": "AO-2031",
                        "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "contact_id": null,
                        "agreement_id": null,
                        "title": "Fönsterputs",
                        "description": "Alla fönster plan 1–3",
                        "status": "unplanned",
                        "status_label": null,
                        "priority": "normal",
                        "planned_start": "2026-10-05T08:00:00+02:00",
                        "planned_end": "2026-10-05T10:00:00+02:00",
                        "estimated_minutes": 120,
                        "source": "api",
                        "external_id": "crm-wo-19",
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "work_orders:read",
        "x-fixra-rpc": "api_work_orders_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/work-orders\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createWorkOrder",
        "tags": [
          "Arbetsorder"
        ],
        "summary": "Skapa arbetsorder",
        "description": "Skapar en oplanerad arbetsorder genom samma funktion som appen (`work_order_create`). Källa `api`. Testnycklar kör torrt.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "site_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "agreement_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "product_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "occurrence_date": {
                    "type": "string",
                    "format": "date",
                    "description": "Dagen ordern gäller. Standard i dag."
                  },
                  "preferred_time": {
                    "type": "string",
                    "pattern": "^\\d{2}:\\d{2}$",
                    "description": "Starttid HH:MM (Europe/Stockholm). Standard 08:00."
                  },
                  "estimated_minutes": {
                    "type": "integer",
                    "minimum": 15,
                    "maximum": 1440
                  },
                  "billing_type": {
                    "type": "string",
                    "enum": [
                      "fixed_price",
                      "time_material"
                    ]
                  },
                  "fixed_price": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "description": "Fast pris i öre. Krävs för fixed_price. Returneras aldrig."
                  },
                  "vat_rate": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "tax_reduction": {
                    "type": "string",
                    "enum": [
                      "rut",
                      "none"
                    ]
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "title"
                ],
                "additionalProperties": false
              },
              "example": {
                "title": "Fönsterputs",
                "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "billing_type": "time_material",
                "occurrence_date": "2026-10-05",
                "external_id": "crm-wo-19"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_no": {
                              "type": "string"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "agreement_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "description": "Kanoniskt tillstånd: unplanned, planned, in_progress, completed, cancelled …"
                            },
                            "status_label": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "priority": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "planned_start": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "planned_end": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "estimated_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "work_order_no",
                            "customer_id",
                            "site_id",
                            "contact_id",
                            "agreement_id",
                            "title",
                            "description",
                            "status",
                            "status_label",
                            "priority",
                            "planned_start",
                            "planned_end",
                            "estimated_minutes",
                            "source",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_no": "AO-2031",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "contact_id": null,
                    "agreement_id": null,
                    "title": "Fönsterputs",
                    "description": "Alla fönster plan 1–3",
                    "status": "unplanned",
                    "status_label": null,
                    "priority": "normal",
                    "planned_start": "2026-10-05T08:00:00+02:00",
                    "planned_end": "2026-10-05T10:00:00+02:00",
                    "estimated_minutes": 120,
                    "source": "api",
                    "external_id": "crm-wo-19",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`TITEL_SAKNAS` — Titel saknas.\n\n`KUND_SAKNAS` — Kunden finns inte i bolaget.\n\n`OBJEKT_SAKNAS` — Platsen finns inte i bolaget.\n\n`PRIS_SAKNAS` — Fast pris krävs för fixed_price.\n\n`ROT_EJ_STOTT` — ROT stöds inte.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "TITEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "TITEL_SAKNAS"
                      ]
                    }
                  },
                  "KUND_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KUND_SAKNAS"
                      ]
                    }
                  },
                  "OBJEKT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OBJEKT_SAKNAS"
                      ]
                    }
                  },
                  "PRIS_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PRIS_SAKNAS"
                      ]
                    }
                  },
                  "ROT_EJ_STOTT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ROT_EJ_STOTT"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "work_orders:write",
        "x-fixra-rpc": "api_work_orders_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/work-orders\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"title\":\"Fönsterputs\",\"customer_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"site_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"billing_type\":\"time_material\",\"occurrence_date\":\"2026-10-05\",\"external_id\":\"crm-wo-19\"}'"
          }
        ]
      }
    },
    "/v1/work-orders/{id}": {
      "get": {
        "operationId": "getWorkOrder",
        "tags": [
          "Arbetsorder"
        ],
        "summary": "Hämta arbetsorder",
        "description": "En arbetsorder med rader och pass.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_no": {
                              "type": "string"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "agreement_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "description": "Kanoniskt tillstånd: unplanned, planned, in_progress, completed, cancelled …"
                            },
                            "status_label": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "priority": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "planned_start": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "planned_end": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "estimated_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "label": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "service_slug": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "label",
                                  "service_slug",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "shifts": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "user_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "title": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "starts_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "ends_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "is_tentative": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "work_order_id",
                                  "user_id",
                                  "title",
                                  "starts_at",
                                  "ends_at",
                                  "is_tentative",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "work_order_no",
                            "customer_id",
                            "site_id",
                            "contact_id",
                            "agreement_id",
                            "title",
                            "description",
                            "status",
                            "status_label",
                            "priority",
                            "planned_start",
                            "planned_end",
                            "estimated_minutes",
                            "source",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines",
                            "shifts"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_no": "AO-2031",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "contact_id": null,
                    "agreement_id": null,
                    "title": "Fönsterputs",
                    "description": "Alla fönster plan 1–3",
                    "status": "unplanned",
                    "status_label": null,
                    "priority": "normal",
                    "planned_start": "2026-10-05T08:00:00+02:00",
                    "planned_end": "2026-10-05T10:00:00+02:00",
                    "estimated_minutes": 120,
                    "source": "api",
                    "external_id": "crm-wo-19",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [],
                    "shifts": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "title": "Trappstädning",
                        "starts_at": "2026-10-05T08:00:00+02:00",
                        "ends_at": "2026-10-05T10:00:00+02:00",
                        "is_tentative": false,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ]
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARBETSORDER_SAKNAS` — Arbetsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARBETSORDER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "work_orders:read",
        "x-fixra-rpc": "api_work_orders_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/work-orders/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "patch": {
        "operationId": "updateWorkOrder",
        "tags": [
          "Arbetsorder"
        ],
        "summary": "Ändra arbetsorder",
        "description": "Ändrar titel, beskrivning, beräknad tid, avtal eller external_id.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "estimated_minutes": {
                    "type": "integer",
                    "minimum": 15,
                    "maximum": 1440
                  },
                  "agreement_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "description": "Även källarfönster"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_no": {
                              "type": "string"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "agreement_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "description": "Kanoniskt tillstånd: unplanned, planned, in_progress, completed, cancelled …"
                            },
                            "status_label": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "priority": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "planned_start": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "planned_end": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "estimated_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "work_order_no",
                            "customer_id",
                            "site_id",
                            "contact_id",
                            "agreement_id",
                            "title",
                            "description",
                            "status",
                            "status_label",
                            "priority",
                            "planned_start",
                            "planned_end",
                            "estimated_minutes",
                            "source",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_no": "AO-2031",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "contact_id": null,
                    "agreement_id": null,
                    "title": "Fönsterputs",
                    "description": "Alla fönster plan 1–3",
                    "status": "unplanned",
                    "status_label": null,
                    "priority": "normal",
                    "planned_start": "2026-10-05T08:00:00+02:00",
                    "planned_end": "2026-10-05T10:00:00+02:00",
                    "estimated_minutes": 120,
                    "source": "api",
                    "external_id": "crm-wo-19",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARBETSORDER_SAKNAS` — Arbetsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARBETSORDER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`TITEL_SAKNAS` — Titeln får inte vara tom.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "TITEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "TITEL_SAKNAS"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "work_orders:write",
        "x-fixra-rpc": "api_work_orders_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/work-orders/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"description\":\"Även källarfönster\"}'"
          }
        ]
      }
    },
    "/v1/work-orders/{id}/cancel": {
      "post": {
        "operationId": "cancelWorkOrder",
        "tags": [
          "Arbetsorder"
        ],
        "summary": "Avboka arbetsorder",
        "description": "Sätter tillståndet `cancelled` genom `work_order_set_state`. Orsak krävs.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  }
                },
                "required": [
                  "reason"
                ],
                "additionalProperties": false
              },
              "example": {
                "reason": "Kunden avbokade"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_no": {
                              "type": "string"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "agreement_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "description": "Kanoniskt tillstånd: unplanned, planned, in_progress, completed, cancelled …"
                            },
                            "status_label": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "priority": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "planned_start": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "planned_end": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "estimated_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "work_order_no",
                            "customer_id",
                            "site_id",
                            "contact_id",
                            "agreement_id",
                            "title",
                            "description",
                            "status",
                            "status_label",
                            "priority",
                            "planned_start",
                            "planned_end",
                            "estimated_minutes",
                            "source",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_no": "AO-2031",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "contact_id": null,
                    "agreement_id": null,
                    "title": "Fönsterputs",
                    "description": "Alla fönster plan 1–3",
                    "status": "cancelled",
                    "status_label": null,
                    "priority": "normal",
                    "planned_start": "2026-10-05T08:00:00+02:00",
                    "planned_end": "2026-10-05T10:00:00+02:00",
                    "estimated_minutes": 120,
                    "source": "api",
                    "external_id": "crm-wo-19",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARBETSORDER_SAKNAS` — Arbetsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARBETSORDER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`OGILTIG_OVERGANG` — Ordern kan inte avbokas i sitt nuvarande tillstånd.\n\n`ORSAK_KRAVS` — Orsak krävs.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OGILTIG_OVERGANG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIG_OVERGANG"
                      ]
                    }
                  },
                  "ORSAK_KRAVS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ORSAK_KRAVS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "work_orders:write",
        "x-fixra-rpc": "api_work_orders_cancel",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/work-orders/{id}/cancel\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"reason\":\"Kunden avbokade\"}'"
          }
        ]
      }
    },
    "/v1/shifts": {
      "get": {
        "operationId": "listShifts",
        "tags": [
          "Pass"
        ],
        "summary": "Lista pass",
        "description": "Jobbpass i schemat mellan `from` och `to` (högst 31 dagar).",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "user_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "work_order_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "user_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "title": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "starts_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "ends_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "is_tentative": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "work_order_id",
                                  "user_id",
                                  "title",
                                  "starts_at",
                                  "ends_at",
                                  "is_tentative",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "title": "Trappstädning",
                        "starts_at": "2026-10-05T08:00:00+02:00",
                        "ends_at": "2026-10-05T10:00:00+02:00",
                        "is_tentative": false,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PERIOD_OGILTIG` — Perioden saknas, är baklänges eller längre än 31 dagar. Ny felkod i v1.\n\n`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PERIOD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PERIOD_OGILTIG"
                      ]
                    }
                  },
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "schedule:read",
        "x-fixra-rpc": "api_shifts_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/shifts\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createShift",
        "tags": [
          "Pass"
        ],
        "summary": "Skapa pass",
        "description": "Tilldelar en person en arbetsorder genom `work_order_assign`. Dubbelbokning hindras av schemat.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "user_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "starts_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "ends_at": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "required": [
                  "work_order_id",
                  "user_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "starts_at": "2026-10-05T08:00:00+02:00",
                "ends_at": "2026-10-05T10:00:00+02:00"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "user_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "starts_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "ends_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "is_tentative": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "work_order_id",
                            "user_id",
                            "title",
                            "starts_at",
                            "ends_at",
                            "is_tentative",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "title": "Trappstädning",
                    "starts_at": "2026-10-05T08:00:00+02:00",
                    "ends_at": "2026-10-05T10:00:00+02:00",
                    "is_tentative": false,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARBETSORDER_SAKNAS` — Arbetsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARBETSORDER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`MEDLEM_SAKNAS` — Personen finns inte i bolaget.\n\n`ARBETSORDER_AVSLUTAD` — Arbetsordern är avslutad.\n\n`OGILTIG_TID` — Sluttid före starttid.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "MEDLEM_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MEDLEM_SAKNAS"
                      ]
                    }
                  },
                  "ARBETSORDER_AVSLUTAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_AVSLUTAD"
                      ]
                    }
                  },
                  "OGILTIG_TID": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIG_TID"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "schedule:write",
        "x-fixra-rpc": "api_shifts_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/shifts\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"work_order_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"user_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"starts_at\":\"2026-10-05T08:00:00+02:00\",\"ends_at\":\"2026-10-05T10:00:00+02:00\"}'"
          }
        ]
      }
    },
    "/v1/shifts/{id}": {
      "delete": {
        "operationId": "deleteShift",
        "tags": [
          "Pass"
        ],
        "summary": "Ta bort pass",
        "description": "Tar bort ett jobbpass genom `schedule_block_delete`. Låst period vägras.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "deleted": {
                              "type": "boolean"
                            },
                            "dry_run": {
                              "type": "boolean"
                            },
                            "idempotent": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "deleted",
                            "dry_run",
                            "idempotent"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "deleted": true,
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PASS_SAKNAS` — Passet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PASS_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PASS_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`RADERINGSNOTERING_KRAVS` — Bolaget kräver orsak vid borttagning.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "RADERINGSNOTERING_KRAVS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RADERINGSNOTERING_KRAVS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "schedule:write",
        "x-fixra-rpc": "api_shifts_delete",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.fixra.se/v1/shifts/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "get": {
        "operationId": "getShift",
        "tags": [
          "Pass"
        ],
        "summary": "Hämta pass",
        "description": "Ett jobbpass med raster, låsning och fordon.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "user_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "starts_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "ends_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "is_tentative": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "is_locked": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "vehicle_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "break_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "breaks": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "shift_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "starts_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "minutes": {
                                    "type": "integer"
                                  },
                                  "note": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "shift_id",
                                  "starts_at",
                                  "minutes",
                                  "note",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "work_order_id",
                            "user_id",
                            "title",
                            "starts_at",
                            "ends_at",
                            "is_tentative",
                            "created_at",
                            "updated_at",
                            "is_locked",
                            "vehicle_id",
                            "break_minutes",
                            "breaks"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "title": "Trappstädning",
                    "starts_at": "2026-10-05T08:00:00+02:00",
                    "ends_at": "2026-10-05T10:00:00+02:00",
                    "is_tentative": false,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "is_locked": false,
                    "vehicle_id": null,
                    "break_minutes": 15,
                    "breaks": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "shift_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "starts_at": "2026-10-05T09:00:00+02:00",
                        "minutes": 15,
                        "note": null,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ]
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PASS_SAKNAS` — Passet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PASS_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PASS_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "schedule:read",
        "x-fixra-rpc": "api_shifts_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/shifts/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "patch": {
        "operationId": "moveShift",
        "tags": [
          "Pass"
        ],
        "summary": "Flytta pass",
        "description": "Flyttar passet till annan person och/eller starttid genom `schedule_move_block`. Dubbelbokning och tillgänglighet prövas som i appen.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "starts_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "override": {
                    "type": "boolean"
                  },
                  "override_reason": {
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "starts_at": "2026-10-05T09:00:00+02:00"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "user_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "starts_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "ends_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "is_tentative": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "is_locked": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "vehicle_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "break_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "breaks": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "shift_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "starts_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "minutes": {
                                    "type": "integer"
                                  },
                                  "note": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "shift_id",
                                  "starts_at",
                                  "minutes",
                                  "note",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "work_order_id",
                            "user_id",
                            "title",
                            "starts_at",
                            "ends_at",
                            "is_tentative",
                            "created_at",
                            "updated_at",
                            "is_locked",
                            "vehicle_id",
                            "break_minutes",
                            "breaks"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "title": "Trappstädning",
                    "starts_at": "2026-10-05T08:00:00+02:00",
                    "ends_at": "2026-10-05T10:00:00+02:00",
                    "is_tentative": false,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "is_locked": false,
                    "vehicle_id": null,
                    "break_minutes": 15,
                    "breaks": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "shift_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "starts_at": "2026-10-05T09:00:00+02:00",
                        "minutes": 15,
                        "note": null,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PASS_SAKNAS` — Passet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PASS_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PASS_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`DUBBELBOKNING` — Personen är redan bokad.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "DUBBELBOKNING": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "DUBBELBOKNING"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "schedule:write",
        "x-fixra-rpc": "api_shifts_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/shifts/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"starts_at\":\"2026-10-05T09:00:00+02:00\"}'"
          }
        ]
      }
    },
    "/v1/agreements": {
      "get": {
        "operationId": "listAgreements",
        "tags": [
          "Avtal"
        ],
        "summary": "Lista avtal",
        "description": "Avtal med månadsbelopp i öre.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 40
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "agreement_number": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "customer_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "site_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "name": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string"
                                  },
                                  "starts_on": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "ends_on": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "notice_months": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "billing_interval": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "monthly_amount": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Öre."
                                  },
                                  "currency": {
                                    "type": "string",
                                    "const": "SEK"
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "agreement_number",
                                  "customer_id",
                                  "site_id",
                                  "name",
                                  "status",
                                  "starts_on",
                                  "ends_on",
                                  "notice_months",
                                  "billing_interval",
                                  "monthly_amount",
                                  "currency",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "agreement_number": "AV-12",
                        "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "name": "Trappstädning varje vecka",
                        "status": "active",
                        "starts_on": "2026-01-01",
                        "ends_on": null,
                        "notice_months": 3,
                        "billing_interval": "month",
                        "monthly_amount": 450000,
                        "currency": "SEK",
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "agreements:read",
        "x-fixra-rpc": "api_agreements_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/agreements\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/agreements/{id}": {
      "get": {
        "operationId": "getAgreement",
        "tags": [
          "Avtal"
        ],
        "summary": "Hämta avtal",
        "description": "Ett avtal.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "agreement_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "customer_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "starts_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "ends_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "notice_months": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "billing_interval": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "monthly_amount": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Öre."
                            },
                            "currency": {
                              "type": "string",
                              "const": "SEK"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "agreement_number",
                            "customer_id",
                            "site_id",
                            "name",
                            "status",
                            "starts_on",
                            "ends_on",
                            "notice_months",
                            "billing_interval",
                            "monthly_amount",
                            "currency",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "agreement_number": "AV-12",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "name": "Trappstädning varje vecka",
                    "status": "active",
                    "starts_on": "2026-01-01",
                    "ends_on": null,
                    "notice_months": 3,
                    "billing_interval": "month",
                    "monthly_amount": 450000,
                    "currency": "SEK",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`AVTAL_SAKNAS` — Avtalet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "AVTAL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "AVTAL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "agreements:read",
        "x-fixra-rpc": "api_agreements_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/agreements/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/quotes": {
      "get": {
        "operationId": "listQuotes",
        "tags": [
          "Offerter"
        ],
        "summary": "Lista offerter",
        "description": "Offerter (bara läsning). Personnummer för RUT returneras aldrig.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 40
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "quote_number": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "customer_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "site_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "title": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string"
                                  },
                                  "version": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "valid_until": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "sent_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "accepted_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "declined_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "created_agreement_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "quote_number",
                                  "customer_id",
                                  "site_id",
                                  "title",
                                  "status",
                                  "version",
                                  "valid_until",
                                  "sent_at",
                                  "accepted_at",
                                  "declined_at",
                                  "created_agreement_id",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "quote_number": "OF-88",
                        "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "site_id": null,
                        "title": "Kontorsstädning",
                        "status": "sent",
                        "version": 1,
                        "valid_until": "2026-10-31",
                        "sent_at": "2026-10-01T09:00:00+02:00",
                        "accepted_at": null,
                        "declined_at": null,
                        "created_agreement_id": null,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "quotes:read",
        "x-fixra-rpc": "api_quotes_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/quotes\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/quotes/{id}": {
      "get": {
        "operationId": "getQuote",
        "tags": [
          "Offerter"
        ],
        "summary": "Hämta offert",
        "description": "En offert.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "quote_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "version": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "valid_until": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sent_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "accepted_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "declined_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_agreement_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "quote_number",
                            "customer_id",
                            "site_id",
                            "title",
                            "status",
                            "version",
                            "valid_until",
                            "sent_at",
                            "accepted_at",
                            "declined_at",
                            "created_agreement_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "quote_number": "OF-88",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": null,
                    "title": "Kontorsstädning",
                    "status": "sent",
                    "version": 1,
                    "valid_until": "2026-10-31",
                    "sent_at": "2026-10-01T09:00:00+02:00",
                    "accepted_at": null,
                    "declined_at": null,
                    "created_agreement_id": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`OFFERT_SAKNAS` — Offerten finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OFFERT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OFFERT_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "quotes:read",
        "x-fixra-rpc": "api_quotes_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/quotes/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/products": {
      "get": {
        "operationId": "listProducts",
        "tags": [
          "Tjänster"
        ],
        "summary": "Lista tjänster",
        "description": "Tjänster och artiklar med försäljningspris i öre. Inköpspris returneras aldrig.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "article_number": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "description": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "unit": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "sales_price": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Öre."
                                  },
                                  "currency": {
                                    "type": "string",
                                    "const": "SEK"
                                  },
                                  "vat_rate": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "tax_reduction": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "estimated_minutes": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_active": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "article_number",
                                  "name",
                                  "description",
                                  "unit",
                                  "sales_price",
                                  "currency",
                                  "vat_rate",
                                  "tax_reduction",
                                  "estimated_minutes",
                                  "is_active",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "article_number": "T-10",
                        "name": "Fönsterputs",
                        "description": null,
                        "unit": "tim",
                        "sales_price": 59500,
                        "currency": "SEK",
                        "vat_rate": 25,
                        "tax_reduction": "rut",
                        "estimated_minutes": 60,
                        "is_active": true,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "products:read",
        "x-fixra-rpc": "api_products_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/products\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createProduct",
        "tags": [
          "Tjänster"
        ],
        "summary": "Skapa tjänst",
        "description": "Skapar en tjänst genom `product_save`.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "article_number": {
                    "type": "string",
                    "maxLength": 50
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "unit": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "sales_price": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "Öre."
                  },
                  "vat_rate": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "tax_reduction": {
                    "type": "string",
                    "enum": [
                      "rut",
                      "none"
                    ]
                  },
                  "estimated_minutes": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1440
                  }
                },
                "required": [
                  "name"
                ],
                "additionalProperties": false
              },
              "example": {
                "name": "Fönsterputs",
                "unit": "tim",
                "sales_price": 59500,
                "tax_reduction": "rut"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "article_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "name": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "unit": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sales_price": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Öre."
                            },
                            "currency": {
                              "type": "string",
                              "const": "SEK"
                            },
                            "vat_rate": {
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "tax_reduction": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "estimated_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "is_active": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "article_number",
                            "name",
                            "description",
                            "unit",
                            "sales_price",
                            "currency",
                            "vat_rate",
                            "tax_reduction",
                            "estimated_minutes",
                            "is_active",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "article_number": "T-10",
                    "name": "Fönsterputs",
                    "description": null,
                    "unit": "tim",
                    "sales_price": 59500,
                    "currency": "SEK",
                    "vat_rate": 25,
                    "tax_reduction": "rut",
                    "estimated_minutes": 60,
                    "is_active": true,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`NAMN_SAKNAS` — Namn saknas.\n\n`ROT_EJ_STOTT` — ROT stöds inte.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NAMN_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NAMN_SAKNAS"
                      ]
                    }
                  },
                  "ROT_EJ_STOTT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ROT_EJ_STOTT"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "products:write",
        "x-fixra-rpc": "api_products_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/products\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Fönsterputs\",\"unit\":\"tim\",\"sales_price\":59500,\"tax_reduction\":\"rut\"}'"
          }
        ]
      }
    },
    "/v1/products/{id}": {
      "patch": {
        "operationId": "updateProduct",
        "tags": [
          "Tjänster"
        ],
        "summary": "Ändra tjänst",
        "description": "Ändrar bara fälten som skickas.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "article_number": {
                    "type": "string",
                    "maxLength": 50
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "unit": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "sales_price": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "Öre."
                  },
                  "vat_rate": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "tax_reduction": {
                    "type": "string",
                    "enum": [
                      "rut",
                      "none"
                    ]
                  },
                  "estimated_minutes": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1440
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "sales_price": 62500
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "article_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "name": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "unit": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sales_price": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Öre."
                            },
                            "currency": {
                              "type": "string",
                              "const": "SEK"
                            },
                            "vat_rate": {
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "tax_reduction": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "estimated_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "is_active": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "article_number",
                            "name",
                            "description",
                            "unit",
                            "sales_price",
                            "currency",
                            "vat_rate",
                            "tax_reduction",
                            "estimated_minutes",
                            "is_active",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "article_number": "T-10",
                    "name": "Fönsterputs",
                    "description": null,
                    "unit": "tim",
                    "sales_price": 59500,
                    "currency": "SEK",
                    "vat_rate": 25,
                    "tax_reduction": "rut",
                    "estimated_minutes": 60,
                    "is_active": true,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`TJANST_SAKNAS` — Tjänsten finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "TJANST_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "TJANST_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "products:write",
        "x-fixra-rpc": "api_products_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/products/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"sales_price\":62500}'"
          }
        ]
      }
    },
    "/v1/staff": {
      "get": {
        "operationId": "listStaff",
        "tags": [
          "Personal"
        ],
        "summary": "Lista personal",
        "description": "Förnamn, efternamn, roll, e-post, telefon och aktiv. Inget annat — aldrig lön, personnummer eller bankuppgifter.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "first_name": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "last_name": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "role": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "email": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "phone": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "active": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "id",
                                  "first_name",
                                  "last_name",
                                  "role",
                                  "email",
                                  "phone",
                                  "active"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "first_name": "Sara",
                        "last_name": "Lind",
                        "role": "Personal",
                        "email": "sara@bolaget.se",
                        "phone": "+46701112233",
                        "active": true
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "staff:read",
        "x-fixra-rpc": "api_staff_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/staff\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/time-entries": {
      "get": {
        "operationId": "listTimeEntries",
        "tags": [
          "Tid"
        ],
        "summary": "Lista tidrader",
        "description": "Rapporterad tid i minuter, utan timlön eller kostnadssats. Filtrera på datum (`from`/`to`) och `status`.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date"
                }
              ]
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date"
                }
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 40
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "user_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "shift_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "worked_on": {
                                    "type": "string"
                                  },
                                  "started_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "ended_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "break_minutes": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "worked_minutes": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "billable_minutes": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "status": {
                                    "type": "string"
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "user_id",
                                  "work_order_id",
                                  "shift_id",
                                  "worked_on",
                                  "started_at",
                                  "ended_at",
                                  "break_minutes",
                                  "worked_minutes",
                                  "billable_minutes",
                                  "status",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "shift_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "worked_on": "2026-10-05",
                        "started_at": "2026-10-05T08:02:00+02:00",
                        "ended_at": "2026-10-05T10:01:00+02:00",
                        "break_minutes": 0,
                        "worked_minutes": 119,
                        "billable_minutes": 120,
                        "status": "approved",
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "time_entries:read",
        "x-fixra-rpc": "api_time_entries_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/time-entries\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/invoice-basis": {
      "get": {
        "operationId": "listInvoiceBasis",
        "tags": [
          "Fakturaunderlag"
        ],
        "summary": "Lista fakturaunderlag",
        "description": "Fakturaunderlag med belopp i öre.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 40
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "basis_number": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "customer_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "agreement_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "period_start": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "period_end": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string"
                                  },
                                  "currency": {
                                    "type": "string"
                                  },
                                  "net_amount": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "vat_amount": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "tax_reduction_amount": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "total_amount": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "basis_number",
                                  "customer_id",
                                  "agreement_id",
                                  "period_start",
                                  "period_end",
                                  "status",
                                  "currency",
                                  "net_amount",
                                  "vat_amount",
                                  "tax_reduction_amount",
                                  "total_amount",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "basis_number": "FU-301",
                        "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "agreement_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "period_start": "2026-09-01",
                        "period_end": "2026-09-30",
                        "status": "draft",
                        "currency": "SEK",
                        "net_amount": 450000,
                        "vat_amount": 112500,
                        "tax_reduction_amount": 0,
                        "total_amount": 562500,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "invoice_basis:read",
        "x-fixra-rpc": "api_invoice_basis_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/invoice-basis\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/invoice-basis/{id}": {
      "get": {
        "operationId": "getInvoiceBasis",
        "tags": [
          "Fakturaunderlag"
        ],
        "summary": "Hämta fakturaunderlag",
        "description": "Ett underlag med dess frysta rader.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "basis_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "customer_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "agreement_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "period_start": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "period_end": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "currency": {
                              "type": "string"
                            },
                            "net_amount": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "vat_amount": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "tax_reduction_amount": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "total_amount": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "line_type": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "product_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "description": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "unit": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "unit_price": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "discount_pct": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "vat_rate": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "net_amount": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "tax_reduction": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "house_work_hours": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "line_type",
                                  "work_order_id",
                                  "product_id",
                                  "description",
                                  "quantity",
                                  "unit",
                                  "unit_price",
                                  "discount_pct",
                                  "vat_rate",
                                  "net_amount",
                                  "tax_reduction",
                                  "house_work_hours"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "basis_number",
                            "customer_id",
                            "agreement_id",
                            "period_start",
                            "period_end",
                            "status",
                            "currency",
                            "net_amount",
                            "vat_amount",
                            "tax_reduction_amount",
                            "total_amount",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "basis_number": "FU-301",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "agreement_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "period_start": "2026-09-01",
                    "period_end": "2026-09-30",
                    "status": "draft",
                    "currency": "SEK",
                    "net_amount": 450000,
                    "vat_amount": 112500,
                    "tax_reduction_amount": 0,
                    "total_amount": 562500,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": []
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`UNDERLAG_SAKNAS` — Underlaget finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "UNDERLAG_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "UNDERLAG_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "invoice_basis:read",
        "x-fixra-rpc": "api_invoice_basis_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/invoice-basis/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/deviations": {
      "get": {
        "operationId": "listDeviations",
        "tags": [
          "Avvikelser"
        ],
        "summary": "Lista avvikelser",
        "description": "Avvikelser, valfritt per plats eller status.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 40
                }
              ]
            }
          },
          {
            "name": "site_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "deviation_number": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "site_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "title": {
                                    "type": "string"
                                  },
                                  "description": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "severity": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string"
                                  },
                                  "resolved_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "deviation_number",
                                  "work_order_id",
                                  "site_id",
                                  "title",
                                  "description",
                                  "severity",
                                  "status",
                                  "resolved_at",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "deviation_number": "AV-0042",
                        "work_order_id": null,
                        "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "title": "Trasig lampa i trapphus",
                        "description": null,
                        "severity": "normal",
                        "status": "open",
                        "resolved_at": null,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "deviations:read",
        "x-fixra-rpc": "api_deviations_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/deviations\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createDeviation",
        "tags": [
          "Avvikelser"
        ],
        "summary": "Rapportera avvikelse",
        "description": "Rapporterar en avvikelse genom `deviation_report`. Kräver modulen Kvalitet.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "site_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "work_order_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "severity": {
                    "type": "string",
                    "enum": [
                      "low",
                      "normal",
                      "high",
                      "critical"
                    ]
                  },
                  "reporter_name": {
                    "type": "string",
                    "maxLength": 200
                  }
                },
                "required": [
                  "title"
                ],
                "additionalProperties": false
              },
              "example": {
                "title": "Trasig lampa i trapphus",
                "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "deviation_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "severity": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "resolved_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "deviation_number",
                            "work_order_id",
                            "site_id",
                            "title",
                            "description",
                            "severity",
                            "status",
                            "resolved_at",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "deviation_number": "AV-0042",
                    "work_order_id": null,
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "title": "Trasig lampa i trapphus",
                    "description": null,
                    "severity": "normal",
                    "status": "open",
                    "resolved_at": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`BESKRIVNING_SAKNAS` — Titel saknas.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESKRIVNING_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESKRIVNING_SAKNAS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "deviations:write",
        "x-fixra-rpc": "api_deviations_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/deviations\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"title\":\"Trasig lampa i trapphus\",\"site_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\"}'"
          }
        ]
      }
    },
    "/v1/requests": {
      "get": {
        "operationId": "listRequests",
        "tags": [
          "Förfrågningar"
        ],
        "summary": "Lista förfrågningar",
        "description": "Kundförfrågningar. Interna anteckningar returneras aldrig.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 40
                }
              ]
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "customer_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "site_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "contact_name": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "contact_phone": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "contact_email": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "channel": {
                                    "type": "string"
                                  },
                                  "body": {
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string"
                                  },
                                  "source": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "customer_id",
                                  "site_id",
                                  "contact_name",
                                  "contact_phone",
                                  "contact_email",
                                  "channel",
                                  "body",
                                  "status",
                                  "source",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "site_id": null,
                        "contact_name": "Anna Berg",
                        "contact_phone": "+46701234567",
                        "contact_email": null,
                        "channel": "api",
                        "body": "Vill ha offert på storstädning i november.",
                        "status": "new",
                        "source": "api",
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "requests:read",
        "x-fixra-rpc": "api_requests_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/requests\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createRequest",
        "tags": [
          "Förfrågningar"
        ],
        "summary": "Skapa förfrågan",
        "description": "Skapar en kundförfrågan med kanal `api` genom `customer_request_create`.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4000
                  },
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "site_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "contact_name": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "contact_phone": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "contact_email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 200
                  }
                },
                "required": [
                  "body"
                ],
                "additionalProperties": false
              },
              "example": {
                "body": "Vill ha offert på storstädning i november.",
                "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "contact_name": "Anna Berg"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "contact_phone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "contact_email": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "channel": {
                              "type": "string"
                            },
                            "body": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "customer_id",
                            "site_id",
                            "contact_name",
                            "contact_phone",
                            "contact_email",
                            "channel",
                            "body",
                            "status",
                            "source",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": null,
                    "contact_name": "Anna Berg",
                    "contact_phone": "+46701234567",
                    "contact_email": null,
                    "channel": "api",
                    "body": "Vill ha offert på storstädning i november.",
                    "status": "new",
                    "source": "api",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`BESKRIVNING_SAKNAS` — Texten saknas.\n\n`KUND_SAKNAS` — Kunden finns inte i bolaget.\n\n`OBJEKT_SAKNAS` — Platsen finns inte hos kunden.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESKRIVNING_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESKRIVNING_SAKNAS"
                      ]
                    }
                  },
                  "KUND_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KUND_SAKNAS"
                      ]
                    }
                  },
                  "OBJEKT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OBJEKT_SAKNAS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "requests:write",
        "x-fixra-rpc": "api_requests_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/requests\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"body\":\"Vill ha offert på storstädning i november.\",\"customer_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"contact_name\":\"Anna Berg\"}'"
          }
        ]
      }
    },
    "/v1/webhook-endpoints": {
      "get": {
        "operationId": "listWebhookEndpoints",
        "tags": [
          "Webhooks"
        ],
        "summary": "Lista webhookmottagare",
        "description": "Bolagets mottagare (högst 10, plus 100 på hooks.zapier.com). Hemligheten visas aldrig här. Varje leverans är en POST med kroppen `{ id, type, created_at, api_version, data: { object } }` där `object` har samma form som motsvarande GET (samma maskning). Huvudet `X-Fixra-Signature: t=<unix>,v1=<hex>` är HMAC-SHA256 med mottagarens hemlighet över `t + \".\" + rå kropp`; avvisa om `t` avviker mer än 5 minuter. Svara 2xx inom 10 s. Annars nytt försök efter 30 s med dubblering upp till 1 h; efter 10 misslyckade försök stängs mottagaren av (`GAV_UPP`) och bolagets administratörer får en notis. Svarar mottagaren 410 Gone tas den bort direkt, utan notis (så beter sig Zapier när en Zap stängs av). Tak: 10 mottagare per bolag, plus 100 separata för mottagare vars värd är exakt `hooks.zapier.com`. Händelser: customer.created, customer.updated, work_order.created, work_order.updated, work_order.status_changed, shift.created, shift.deleted, request.created, deviation.created, quote.accepted, invoice_basis.created, work_order.state_changed, shift.started, shift.completed, task.created, task.updated, ticket.created, ticket.updated, attachment.created samt test.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "url": {
                                    "type": "string"
                                  },
                                  "description": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "events": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "active": {
                                    "type": "boolean"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "active",
                                      "inactive",
                                      "GAV_UPP"
                                    ]
                                  },
                                  "last_status": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "last_error": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "last_delivery_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "url",
                                  "description",
                                  "events",
                                  "active",
                                  "status",
                                  "last_status",
                                  "last_error",
                                  "last_delivery_at",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "url": "https://example.com/fixra/webhook",
                        "description": "Affärssystemet",
                        "events": [
                          "customer.created",
                          "work_order.status_changed"
                        ],
                        "active": true,
                        "status": "active",
                        "last_status": 200,
                        "last_error": null,
                        "last_delivery_at": "2026-10-01T09:00:00+02:00",
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "webhooks:read",
        "x-fixra-rpc": "api_webhooks_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/webhook-endpoints\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          },
          {
            "lang": "javascript",
            "label": "Node.js",
            "source": "import crypto from \"node:crypto\";\n\n// rawBody: exakt de mottagna byten (inte omserialiserad JSON).\nexport function verifyFixra(rawBody, header, secret, toleranceSec = 300) {\n  const parts = Object.fromEntries(header.split(\",\").map((p) => p.split(\"=\")));\n  const t = Number(parts.t);\n  if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSec) return false;\n  const expected = crypto.createHmac(\"sha256\", secret).update(`${t}.${rawBody}`).digest(\"hex\");\n  const a = Buffer.from(expected), b = Buffer.from(parts.v1 ?? \"\");\n  return a.length === b.length && crypto.timingSafeEqual(a, b);\n}"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import hmac, hashlib, time\n\ndef verify_fixra(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:\n    parts = dict(p.split(\"=\", 1) for p in header.split(\",\"))\n    t = int(parts.get(\"t\", \"0\"))\n    if not t or abs(time.time() - t) > tolerance:\n        return False\n    expected = hmac.new(secret.encode(), f\"{t}.\".encode() + raw_body, hashlib.sha256).hexdigest()\n    return hmac.compare_digest(expected, parts.get(\"v1\", \"\"))"
          },
          {
            "lang": "php",
            "label": "PHP",
            "source": "<?php\nfunction verify_fixra(string $rawBody, string $header, string $secret, int $tolerance = 300): bool {\n    $parts = [];\n    foreach (explode(',', $header) as $p) { [$k, $v] = array_pad(explode('=', $p, 2), 2, ''); $parts[$k] = $v; }\n    $t = (int)($parts['t'] ?? 0);\n    if (!$t || abs(time() - $t) > $tolerance) return false;\n    $expected = hash_hmac('sha256', $t . '.' . $rawBody, $secret);\n    return hash_equals($expected, $parts['v1'] ?? '');\n}\n// verify_fixra(file_get_contents('php://input'), $_SERVER['HTTP_X_FIXRA_SIGNATURE'], getenv('FIXRA_WHSEC'));"
          }
        ]
      },
      "post": {
        "operationId": "createWebhookEndpoint",
        "tags": [
          "Webhooks"
        ],
        "summary": "Skapa webhookmottagare",
        "description": "Skapar en mottagare. Svaret innehåller `secret` (whsec_…) en enda gång — spara den. Varje leverans är en POST med kroppen `{ id, type, created_at, api_version, data: { object } }` där `object` har samma form som motsvarande GET (samma maskning). Huvudet `X-Fixra-Signature: t=<unix>,v1=<hex>` är HMAC-SHA256 med mottagarens hemlighet över `t + \".\" + rå kropp`; avvisa om `t` avviker mer än 5 minuter. Svara 2xx inom 10 s. Annars nytt försök efter 30 s med dubblering upp till 1 h; efter 10 misslyckade försök stängs mottagaren av (`GAV_UPP`) och bolagets administratörer får en notis. Svarar mottagaren 410 Gone tas den bort direkt, utan notis (så beter sig Zapier när en Zap stängs av). Tak: 10 mottagare per bolag, plus 100 separata för mottagare vars värd är exakt `hooks.zapier.com`. Händelser: customer.created, customer.updated, work_order.created, work_order.updated, work_order.status_changed, shift.created, shift.deleted, request.created, deviation.created, quote.accepted, invoice_basis.created, work_order.state_changed, shift.started, shift.completed, task.created, task.updated, ticket.created, ticket.updated, attachment.created samt test.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2000,
                    "description": "Bara https. Interna adresser vägras."
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "customer.created",
                        "customer.updated",
                        "work_order.created",
                        "work_order.updated",
                        "work_order.status_changed",
                        "shift.created",
                        "shift.deleted",
                        "request.created",
                        "deviation.created",
                        "quote.accepted",
                        "invoice_basis.created",
                        "work_order.state_changed",
                        "shift.started",
                        "shift.completed",
                        "task.created",
                        "task.updated",
                        "ticket.created",
                        "ticket.updated",
                        "attachment.created"
                      ]
                    },
                    "minItems": 1,
                    "maxItems": 19
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 200
                  }
                },
                "required": [
                  "url",
                  "events"
                ],
                "additionalProperties": false
              },
              "example": {
                "url": "https://example.com/fixra/webhook",
                "events": [
                  "customer.created",
                  "work_order.status_changed"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "url": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "events": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "active": {
                              "type": "boolean"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "inactive",
                                "GAV_UPP"
                              ]
                            },
                            "last_status": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "last_error": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "last_delivery_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "secret": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "url",
                            "description",
                            "events",
                            "active",
                            "status",
                            "last_status",
                            "last_error",
                            "last_delivery_at",
                            "created_at",
                            "updated_at",
                            "secret"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "url": "https://example.com/fixra/webhook",
                    "description": "Affärssystemet",
                    "events": [
                      "customer.created",
                      "work_order.status_changed"
                    ],
                    "active": true,
                    "status": "active",
                    "last_status": 200,
                    "last_error": null,
                    "last_delivery_at": "2026-10-01T09:00:00+02:00",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "secret": "whsec_AbCdEfGhIjKlMnOpQrStUvWxYz012345",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`WEBHOOK_URL_OGILTIG` — URL:en är inte https eller pekar på localhost, ett privat/länklokalt intervall, *.fixra.se eller *.supabase.co. Ny felkod i v1.\n\n`HANDELSER_SAKNAS` — Minst en händelse krävs. Ny felkod i v1.\n\n`HANDELSE_OKAND` — Okänd händelsetyp. Ny felkod i v1.\n\n`WEBHOOK_GRANS_NADD` — Taket är nått: 10 vanliga mottagare, eller 100 på värden hooks.zapier.com. Ny felkod i v1.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "WEBHOOK_URL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "WEBHOOK_URL_OGILTIG"
                      ]
                    }
                  },
                  "HANDELSER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "HANDELSER_SAKNAS"
                      ]
                    }
                  },
                  "HANDELSE_OKAND": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "HANDELSE_OKAND"
                      ]
                    }
                  },
                  "WEBHOOK_GRANS_NADD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "WEBHOOK_GRANS_NADD"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "webhooks:write",
        "x-fixra-rpc": "api_webhooks_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/webhook-endpoints\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"url\":\"https://example.com/fixra/webhook\",\"events\":[\"customer.created\",\"work_order.status_changed\"]}'"
          },
          {
            "lang": "javascript",
            "label": "Node.js",
            "source": "import crypto from \"node:crypto\";\n\n// rawBody: exakt de mottagna byten (inte omserialiserad JSON).\nexport function verifyFixra(rawBody, header, secret, toleranceSec = 300) {\n  const parts = Object.fromEntries(header.split(\",\").map((p) => p.split(\"=\")));\n  const t = Number(parts.t);\n  if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSec) return false;\n  const expected = crypto.createHmac(\"sha256\", secret).update(`${t}.${rawBody}`).digest(\"hex\");\n  const a = Buffer.from(expected), b = Buffer.from(parts.v1 ?? \"\");\n  return a.length === b.length && crypto.timingSafeEqual(a, b);\n}"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import hmac, hashlib, time\n\ndef verify_fixra(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:\n    parts = dict(p.split(\"=\", 1) for p in header.split(\",\"))\n    t = int(parts.get(\"t\", \"0\"))\n    if not t or abs(time.time() - t) > tolerance:\n        return False\n    expected = hmac.new(secret.encode(), f\"{t}.\".encode() + raw_body, hashlib.sha256).hexdigest()\n    return hmac.compare_digest(expected, parts.get(\"v1\", \"\"))"
          },
          {
            "lang": "php",
            "label": "PHP",
            "source": "<?php\nfunction verify_fixra(string $rawBody, string $header, string $secret, int $tolerance = 300): bool {\n    $parts = [];\n    foreach (explode(',', $header) as $p) { [$k, $v] = array_pad(explode('=', $p, 2), 2, ''); $parts[$k] = $v; }\n    $t = (int)($parts['t'] ?? 0);\n    if (!$t || abs(time() - $t) > $tolerance) return false;\n    $expected = hash_hmac('sha256', $t . '.' . $rawBody, $secret);\n    return hash_equals($expected, $parts['v1'] ?? '');\n}\n// verify_fixra(file_get_contents('php://input'), $_SERVER['HTTP_X_FIXRA_SIGNATURE'], getenv('FIXRA_WHSEC'));"
          }
        ]
      }
    },
    "/v1/webhook-endpoints/{id}": {
      "patch": {
        "operationId": "updateWebhookEndpoint",
        "tags": [
          "Webhooks"
        ],
        "summary": "Ändra webhookmottagare",
        "description": "Ändrar url, händelser, beskrivning eller aktiv. `active: true` återaktiverar en mottagare som gav upp.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2000
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "customer.created",
                        "customer.updated",
                        "work_order.created",
                        "work_order.updated",
                        "work_order.status_changed",
                        "shift.created",
                        "shift.deleted",
                        "request.created",
                        "deviation.created",
                        "quote.accepted",
                        "invoice_basis.created",
                        "work_order.state_changed",
                        "shift.started",
                        "shift.completed",
                        "task.created",
                        "task.updated",
                        "ticket.created",
                        "ticket.updated",
                        "attachment.created"
                      ]
                    },
                    "minItems": 1,
                    "maxItems": 19
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "active": {
                    "type": "boolean",
                    "description": "true slår på igen efter GAV_UPP."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "active": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "url": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "events": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "active": {
                              "type": "boolean"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "inactive",
                                "GAV_UPP"
                              ]
                            },
                            "last_status": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "last_error": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "last_delivery_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "url",
                            "description",
                            "events",
                            "active",
                            "status",
                            "last_status",
                            "last_error",
                            "last_delivery_at",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "url": "https://example.com/fixra/webhook",
                    "description": "Affärssystemet",
                    "events": [
                      "customer.created",
                      "work_order.status_changed"
                    ],
                    "active": true,
                    "status": "active",
                    "last_status": 200,
                    "last_error": null,
                    "last_delivery_at": "2026-10-01T09:00:00+02:00",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`WEBHOOK_SAKNAS` — Mottagaren finns inte i nyckelns bolag. Ny felkod i v1.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "WEBHOOK_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "WEBHOOK_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`WEBHOOK_URL_OGILTIG` — URL:en är inte https eller pekar på localhost, ett privat/länklokalt intervall, *.fixra.se eller *.supabase.co. Ny felkod i v1.\n\n`HANDELSER_SAKNAS` — Minst en händelse krävs. Ny felkod i v1.\n\n`HANDELSE_OKAND` — Okänd händelsetyp. Ny felkod i v1.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "WEBHOOK_URL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "WEBHOOK_URL_OGILTIG"
                      ]
                    }
                  },
                  "HANDELSER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "HANDELSER_SAKNAS"
                      ]
                    }
                  },
                  "HANDELSE_OKAND": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "HANDELSE_OKAND"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "webhooks:write",
        "x-fixra-rpc": "api_webhooks_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/webhook-endpoints/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"active\":true}'"
          }
        ]
      },
      "delete": {
        "operationId": "deleteWebhookEndpoint",
        "tags": [
          "Webhooks"
        ],
        "summary": "Ta bort webhookmottagare",
        "description": "Tar bort mottagaren, dess hemlighet och leveranslogg.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "deleted": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "id",
                            "deleted"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "deleted": true,
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`WEBHOOK_SAKNAS` — Mottagaren finns inte i nyckelns bolag. Ny felkod i v1.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "WEBHOOK_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "WEBHOOK_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "webhooks:write",
        "x-fixra-rpc": "api_webhooks_delete",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.fixra.se/v1/webhook-endpoints/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/webhook-endpoints/{id}/test": {
      "post": {
        "operationId": "testWebhookEndpoint",
        "tags": [
          "Webhooks"
        ],
        "summary": "Skicka testhändelse",
        "description": "Köar en händelse av typen `test` till just denna mottagare, signerad som alla andra. Verifieringskod i curl, JavaScript, Python och PHP.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "event_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "delivery_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "status": {
                              "type": "string",
                              "const": "pending"
                            }
                          },
                          "required": [
                            "event_id",
                            "delivery_id",
                            "status"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "event_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "delivery_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "status": "pending",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`WEBHOOK_SAKNAS` — Mottagaren finns inte i nyckelns bolag. Ny felkod i v1.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "WEBHOOK_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "WEBHOOK_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`WEBHOOK_INAKTIV` — Mottagaren är avstängd. Ny felkod i v1.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "WEBHOOK_INAKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "WEBHOOK_INAKTIV"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "webhooks:write",
        "x-fixra-rpc": "api_webhooks_test",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/webhook-endpoints/{id}/test\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\""
          },
          {
            "lang": "curl",
            "label": "curl + openssl",
            "source": "# Skicka en testhändelse till mottagaren:\ncurl -X POST \"https://api.fixra.se/v1/webhook-endpoints/{id}/test\" \\\n  -H \"Authorization: Bearer fx_live_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\"\n\n# Verifiera en mottagen kropp (body.json = exakt de mottagna byten):\nSIG=\"t=1759302000,v1=...\"\nT=\"${SIG#t=}\"; T=\"${T%%,*}\"; V1=\"${SIG##*v1=}\"\nEXP=$(printf \"%s.\" \"$T\" | cat - body.json | openssl dgst -sha256 -hmac \"$FIXRA_WHSEC\" -hex | sed \"s/^.* //\")\n[ \"$EXP\" = \"$V1\" ] && [ $(( $(date +%s) - T )) -le 300 ] && echo OK"
          },
          {
            "lang": "javascript",
            "label": "Node.js",
            "source": "import crypto from \"node:crypto\";\n\n// rawBody: exakt de mottagna byten (inte omserialiserad JSON).\nexport function verifyFixra(rawBody, header, secret, toleranceSec = 300) {\n  const parts = Object.fromEntries(header.split(\",\").map((p) => p.split(\"=\")));\n  const t = Number(parts.t);\n  if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSec) return false;\n  const expected = crypto.createHmac(\"sha256\", secret).update(`${t}.${rawBody}`).digest(\"hex\");\n  const a = Buffer.from(expected), b = Buffer.from(parts.v1 ?? \"\");\n  return a.length === b.length && crypto.timingSafeEqual(a, b);\n}"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import hmac, hashlib, time\n\ndef verify_fixra(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:\n    parts = dict(p.split(\"=\", 1) for p in header.split(\",\"))\n    t = int(parts.get(\"t\", \"0\"))\n    if not t or abs(time.time() - t) > tolerance:\n        return False\n    expected = hmac.new(secret.encode(), f\"{t}.\".encode() + raw_body, hashlib.sha256).hexdigest()\n    return hmac.compare_digest(expected, parts.get(\"v1\", \"\"))"
          },
          {
            "lang": "php",
            "label": "PHP",
            "source": "<?php\nfunction verify_fixra(string $rawBody, string $header, string $secret, int $tolerance = 300): bool {\n    $parts = [];\n    foreach (explode(',', $header) as $p) { [$k, $v] = array_pad(explode('=', $p, 2), 2, ''); $parts[$k] = $v; }\n    $t = (int)($parts['t'] ?? 0);\n    if (!$t || abs(time() - $t) > $tolerance) return false;\n    $expected = hash_hmac('sha256', $t . '.' . $rawBody, $secret);\n    return hash_equals($expected, $parts['v1'] ?? '');\n}\n// verify_fixra(file_get_contents('php://input'), $_SERVER['HTTP_X_FIXRA_SIGNATURE'], getenv('FIXRA_WHSEC'));"
          }
        ]
      }
    },
    "/v1/work-orders/{id}/checklist": {
      "get": {
        "operationId": "getWorkOrderChecklist",
        "tags": [
          "Arbetsorder"
        ],
        "summary": "Hämta checklista",
        "description": "Checklistan för arbetsordern — samma mall som passkortet visar i appen — med varje punkts `key` och om den är avbockad. Kräver modulen Kvalitet.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "work_order_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "template_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "template_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "response_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "status": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "completed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "key": {
                                    "type": "string"
                                  },
                                  "label": {
                                    "type": "string"
                                  },
                                  "done": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "key",
                                  "label",
                                  "done"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "updated_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "work_order_id",
                            "template_id",
                            "template_name",
                            "response_id",
                            "status",
                            "completed_at",
                            "items",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "template_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "template_name": "Trappstädning",
                    "response_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "status": "draft",
                    "completed_at": null,
                    "items": [
                      {
                        "key": "p0",
                        "label": "Moppa trappor",
                        "done": true
                      },
                      {
                        "key": "p1",
                        "label": "Torka räcken",
                        "done": false
                      }
                    ],
                    "updated_at": "2026-10-01T09:00:00+02:00"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARBETSORDER_SAKNAS` — Arbetsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARBETSORDER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "checklists:read",
        "x-fixra-rpc": "api_work_orders_checklist",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/work-orders/{id}/checklist\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/work-orders/{id}/checklist/{item_id}": {
      "put": {
        "operationId": "setWorkOrderChecklistItem",
        "tags": [
          "Arbetsorder"
        ],
        "summary": "Bocka checklistpunkt",
        "description": "Sätter en punkt (`item_id` = punktens `key`) genom `checklist_response_save`. `status: completed` slutför checklistan. Idempotent utan Idempotency-Key.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "item_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "done": {
                    "type": "boolean"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "draft",
                      "completed"
                    ]
                  }
                },
                "required": [
                  "done"
                ],
                "additionalProperties": false
              },
              "example": {
                "done": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "work_order_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "template_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "template_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "response_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "status": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "completed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "key": {
                                    "type": "string"
                                  },
                                  "label": {
                                    "type": "string"
                                  },
                                  "done": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "key",
                                  "label",
                                  "done"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "updated_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "work_order_id",
                            "template_id",
                            "template_name",
                            "response_id",
                            "status",
                            "completed_at",
                            "items",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "template_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "template_name": "Trappstädning",
                    "response_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "status": "draft",
                    "completed_at": null,
                    "items": [
                      {
                        "key": "p0",
                        "label": "Moppa trappor",
                        "done": true
                      },
                      {
                        "key": "p1",
                        "label": "Torka räcken",
                        "done": false
                      }
                    ],
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARBETSORDER_SAKNAS` — Arbetsordern finns inte i nyckelns bolag.\n\n`PUNKT_SAKNAS` — Punkten finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARBETSORDER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_SAKNAS"
                      ]
                    }
                  },
                  "PUNKT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PUNKT_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`MALL_SAKNAS` — Bolaget har ingen aktiv checklistmall.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "MALL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MALL_SAKNAS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "checklists:write",
        "x-fixra-rpc": "api_work_orders_checklist_set",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PUT \"https://api.fixra.se/v1/work-orders/{id}/checklist/{item_id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"done\":true}'"
          }
        ]
      }
    },
    "/v1/work-orders/{id}/state": {
      "post": {
        "operationId": "setWorkOrderState",
        "tags": [
          "Arbetsorder"
        ],
        "summary": "Byt tillstånd",
        "description": "Byter kanoniskt tillstånd genom `work_order_set_state` — samma övergångsregler som appen. Orsak krävs för `cancelled`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "state": {
                    "type": "string",
                    "enum": [
                      "unplanned",
                      "planned",
                      "in_progress",
                      "paused",
                      "completed",
                      "cancelled"
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "required": [
                  "state"
                ],
                "additionalProperties": false
              },
              "example": {
                "state": "paused",
                "reason": "Väntar på kund"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_no": {
                              "type": "string"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "agreement_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "description": "Kanoniskt tillstånd: unplanned, planned, in_progress, completed, cancelled …"
                            },
                            "status_label": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "priority": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "planned_start": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "planned_end": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "estimated_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "work_order_no",
                            "customer_id",
                            "site_id",
                            "contact_id",
                            "agreement_id",
                            "title",
                            "description",
                            "status",
                            "status_label",
                            "priority",
                            "planned_start",
                            "planned_end",
                            "estimated_minutes",
                            "source",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_no": "AO-2031",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "contact_id": null,
                    "agreement_id": null,
                    "title": "Fönsterputs",
                    "description": "Alla fönster plan 1–3",
                    "status": "paused",
                    "status_label": null,
                    "priority": "normal",
                    "planned_start": "2026-10-05T08:00:00+02:00",
                    "planned_end": "2026-10-05T10:00:00+02:00",
                    "estimated_minutes": 120,
                    "source": "api",
                    "external_id": "crm-wo-19",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARBETSORDER_SAKNAS` — Arbetsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARBETSORDER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`OGILTIG_OVERGANG` — Övergången är inte tillåten från nuvarande tillstånd.\n\n`ORSAK_KRAVS` — Orsak krävs.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OGILTIG_OVERGANG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIG_OVERGANG"
                      ]
                    }
                  },
                  "ORSAK_KRAVS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ORSAK_KRAVS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "work_orders:write",
        "x-fixra-rpc": "api_work_orders_set_state",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/work-orders/{id}/state\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"state\":\"paused\",\"reason\":\"Väntar på kund\"}'"
          }
        ]
      }
    },
    "/v1/work-orders/{id}/rework": {
      "post": {
        "operationId": "createReworkWorkOrder",
        "tags": [
          "Arbetsorder"
        ],
        "summary": "Skapa omstädning",
        "description": "Skapar en omstädningsorder för en avvikelse på arbetsordern genom `work_order_rework_create`. Svaret är den nya ordern.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deviation_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "occurrence_date": {
                    "type": "string",
                    "format": "date"
                  },
                  "preferred_time": {
                    "type": "string",
                    "pattern": "^\\d{2}:\\d{2}$"
                  },
                  "estimated_minutes": {
                    "type": "integer",
                    "minimum": 15,
                    "maximum": 1440
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Slå upp på ert eget id (external_id)."
                  }
                },
                "required": [
                  "deviation_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "deviation_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "occurrence_date": "2026-10-06"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_no": {
                              "type": "string"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "agreement_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "description": "Kanoniskt tillstånd: unplanned, planned, in_progress, completed, cancelled …"
                            },
                            "status_label": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "priority": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "planned_start": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "planned_end": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "estimated_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "work_order_no",
                            "customer_id",
                            "site_id",
                            "contact_id",
                            "agreement_id",
                            "title",
                            "description",
                            "status",
                            "status_label",
                            "priority",
                            "planned_start",
                            "planned_end",
                            "estimated_minutes",
                            "source",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_no": "AO-2031",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "contact_id": null,
                    "agreement_id": null,
                    "title": "Fönsterputs",
                    "description": "Alla fönster plan 1–3",
                    "status": "unplanned",
                    "status_label": null,
                    "priority": "normal",
                    "planned_start": "2026-10-05T08:00:00+02:00",
                    "planned_end": "2026-10-05T10:00:00+02:00",
                    "estimated_minutes": 120,
                    "source": "api",
                    "external_id": "crm-wo-19",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARBETSORDER_SAKNAS` — Arbetsordern finns inte i nyckelns bolag.\n\n`AVVIKELSE_SAKNAS` — Avvikelsen på arbetsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARBETSORDER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_SAKNAS"
                      ]
                    }
                  },
                  "AVVIKELSE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "AVVIKELSE_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "work_orders:write",
        "x-fixra-rpc": "api_work_orders_rework",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/work-orders/{id}/rework\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"deviation_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"occurrence_date\":\"2026-10-06\"}'"
          }
        ]
      }
    },
    "/v1/work-orders/adhoc": {
      "post": {
        "operationId": "createAdhocWorkOrder",
        "tags": [
          "Arbetsorder"
        ],
        "summary": "Skapa akutorder",
        "description": "Skapar en tillfällig order utanför avtal genom `work_order_adhoc_create`. Fast pris i öre skrivs men returneras aldrig.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "site_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "occurrence_date": {
                    "type": "string",
                    "format": "date"
                  },
                  "preferred_time": {
                    "type": "string",
                    "pattern": "^\\d{2}:\\d{2}$"
                  },
                  "estimated_minutes": {
                    "type": "integer",
                    "minimum": 15,
                    "maximum": 1440
                  },
                  "billing_type": {
                    "type": "string",
                    "enum": [
                      "fixed_price",
                      "time_material"
                    ]
                  },
                  "fixed_price": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  },
                  "vat_rate": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "tax_reduction": {
                    "type": "string",
                    "enum": [
                      "rut",
                      "none"
                    ]
                  },
                  "supervisor_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Slå upp på ert eget id (external_id)."
                  }
                },
                "required": [
                  "title",
                  "customer_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "title": "Akut sanering",
                "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "billing_type": "time_material"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_no": {
                              "type": "string"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "agreement_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "description": "Kanoniskt tillstånd: unplanned, planned, in_progress, completed, cancelled …"
                            },
                            "status_label": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "priority": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "planned_start": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "planned_end": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "estimated_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "work_order_no",
                            "customer_id",
                            "site_id",
                            "contact_id",
                            "agreement_id",
                            "title",
                            "description",
                            "status",
                            "status_label",
                            "priority",
                            "planned_start",
                            "planned_end",
                            "estimated_minutes",
                            "source",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_no": "AO-2031",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "contact_id": null,
                    "agreement_id": null,
                    "title": "Fönsterputs",
                    "description": "Alla fönster plan 1–3",
                    "status": "unplanned",
                    "status_label": null,
                    "priority": "normal",
                    "planned_start": "2026-10-05T08:00:00+02:00",
                    "planned_end": "2026-10-05T10:00:00+02:00",
                    "estimated_minutes": 120,
                    "source": "api",
                    "external_id": "crm-wo-19",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`KUND_SAKNAS` — Kunden finns inte i bolaget.\n\n`TITEL_SAKNAS` — Titel saknas.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "KUND_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KUND_SAKNAS"
                      ]
                    }
                  },
                  "TITEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "TITEL_SAKNAS"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "work_orders:write",
        "x-fixra-rpc": "api_work_orders_adhoc",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/work-orders/adhoc\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"title\":\"Akut sanering\",\"customer_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"billing_type\":\"time_material\"}'"
          }
        ]
      }
    },
    "/v1/work-orders/{id}/subcontract": {
      "post": {
        "operationId": "setWorkOrderSubcontractor",
        "tags": [
          "Arbetsorder"
        ],
        "summary": "Sätt underentreprenör",
        "description": "Lägger ut ordern på en underentreprenör genom `work_order_subcontract_set`. Kostnad och pris i öre skrivs men returneras aldrig. `subcontractor_id: null` tar bort.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "subcontractor_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "subcontractor_cost_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "subcontractor_price_ore": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "required": [
                  "subcontractor_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "subcontractor_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "subcontractor_cost_ore": 150000
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_no": {
                              "type": "string"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "agreement_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "description": "Kanoniskt tillstånd: unplanned, planned, in_progress, completed, cancelled …"
                            },
                            "status_label": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "priority": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "planned_start": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "planned_end": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "estimated_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "work_order_no",
                            "customer_id",
                            "site_id",
                            "contact_id",
                            "agreement_id",
                            "title",
                            "description",
                            "status",
                            "status_label",
                            "priority",
                            "planned_start",
                            "planned_end",
                            "estimated_minutes",
                            "source",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_no": "AO-2031",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "contact_id": null,
                    "agreement_id": null,
                    "title": "Fönsterputs",
                    "description": "Alla fönster plan 1–3",
                    "status": "unplanned",
                    "status_label": null,
                    "priority": "normal",
                    "planned_start": "2026-10-05T08:00:00+02:00",
                    "planned_end": "2026-10-05T10:00:00+02:00",
                    "estimated_minutes": 120,
                    "source": "api",
                    "external_id": "crm-wo-19",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARBETSORDER_SAKNAS` — Arbetsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARBETSORDER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`UNDERENTREPRENOR_SAKNAS` — Underentreprenören finns inte.\n\n`ARBETSORDER_FAKTURERAD` — Ordern är redan fakturerad.\n\n`OGILTIGT_PRIS` — Ogiltigt belopp.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "UNDERENTREPRENOR_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "UNDERENTREPRENOR_SAKNAS"
                      ]
                    }
                  },
                  "ARBETSORDER_FAKTURERAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_FAKTURERAD"
                      ]
                    }
                  },
                  "OGILTIGT_PRIS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIGT_PRIS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "work_orders:write",
        "x-fixra-rpc": "api_work_orders_subcontract",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/work-orders/{id}/subcontract\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"subcontractor_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"subcontractor_cost_ore\":150000}'"
          }
        ]
      }
    },
    "/v1/work-orders/{id}/extra-time": {
      "post": {
        "operationId": "createWorkOrderExtraTime",
        "tags": [
          "Arbetsorder"
        ],
        "summary": "Lägg till extra tid",
        "description": "Registrerar extra tid genom `extra_time_create`. `pending` = personalen ska svara, `ordered` = beordrad. Kräver att nyckelns skapare får attestera tid.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "minutes": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1440
                  },
                  "worked_on": {
                    "type": "string",
                    "format": "date"
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "shift_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "ordered"
                    ]
                  }
                },
                "required": [
                  "user_id",
                  "minutes",
                  "worked_on"
                ],
                "additionalProperties": false
              },
              "example": {
                "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "minutes": 30,
                "worked_on": "2026-10-05",
                "note": "Extra fönster"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "user_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "shift_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "worked_on": {
                              "type": "string"
                            },
                            "minutes": {
                              "type": "integer"
                            },
                            "note": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "user_id",
                            "shift_id",
                            "work_order_id",
                            "worked_on",
                            "minutes",
                            "note",
                            "status",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "shift_id": null,
                    "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "worked_on": "2026-10-05",
                    "minutes": 30,
                    "note": "Extra fönster",
                    "status": "pending",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARBETSORDER_SAKNAS` — Arbetsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARBETSORDER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`OGILTIG_STATUS` — Status måste vara pending eller ordered.\n\n`OGILTIGT_DATUM` — Datum saknas eller är ogiltigt.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OGILTIG_STATUS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIG_STATUS"
                      ]
                    }
                  },
                  "OGILTIGT_DATUM": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIGT_DATUM"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "work_orders:write",
        "x-fixra-rpc": "api_work_orders_extra_time",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/work-orders/{id}/extra-time\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"user_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"minutes\":30,\"worked_on\":\"2026-10-05\",\"note\":\"Extra fönster\"}'"
          }
        ]
      }
    },
    "/v1/shifts/{id}/flags": {
      "post": {
        "operationId": "setShiftFlags",
        "tags": [
          "Pass"
        ],
        "summary": "Lås eller markera preliminärt",
        "description": "Sätter `is_locked` och/eller `is_tentative` genom `schedule_block_set_flags`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "is_locked": {
                    "type": "boolean"
                  },
                  "is_tentative": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "is_locked": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "user_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "starts_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "ends_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "is_tentative": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "is_locked": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "vehicle_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "break_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "breaks": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "shift_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "starts_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "minutes": {
                                    "type": "integer"
                                  },
                                  "note": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "shift_id",
                                  "starts_at",
                                  "minutes",
                                  "note",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "work_order_id",
                            "user_id",
                            "title",
                            "starts_at",
                            "ends_at",
                            "is_tentative",
                            "created_at",
                            "updated_at",
                            "is_locked",
                            "vehicle_id",
                            "break_minutes",
                            "breaks"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "title": "Trappstädning",
                    "starts_at": "2026-10-05T08:00:00+02:00",
                    "ends_at": "2026-10-05T10:00:00+02:00",
                    "is_tentative": false,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "is_locked": false,
                    "vehicle_id": null,
                    "break_minutes": 15,
                    "breaks": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "shift_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "starts_at": "2026-10-05T09:00:00+02:00",
                        "minutes": 15,
                        "note": null,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PASS_SAKNAS` — Passet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PASS_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PASS_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "schedule:write",
        "x-fixra-rpc": "api_shifts_flags",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/shifts/{id}/flags\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"is_locked\":true}'"
          }
        ]
      }
    },
    "/v1/shifts/{id}/vehicle": {
      "post": {
        "operationId": "setShiftVehicle",
        "tags": [
          "Pass"
        ],
        "summary": "Koppla fordon",
        "description": "Kopplar ett fordon (eller `null`) genom `schedule_block_set_vehicle`. Krockar returneras i `conflicts`. Kräver modulen Fordon.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "vehicle_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "vehicle_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "vehicle_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "user_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "starts_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "ends_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "is_tentative": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "is_locked": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "vehicle_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "break_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "breaks": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "shift_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "starts_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "minutes": {
                                    "type": "integer"
                                  },
                                  "note": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "shift_id",
                                  "starts_at",
                                  "minutes",
                                  "note",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "conflicts": {
                              "type": "array",
                              "items": {}
                            }
                          },
                          "required": [
                            "id",
                            "work_order_id",
                            "user_id",
                            "title",
                            "starts_at",
                            "ends_at",
                            "is_tentative",
                            "created_at",
                            "updated_at",
                            "is_locked",
                            "vehicle_id",
                            "break_minutes",
                            "breaks",
                            "conflicts"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "title": "Trappstädning",
                    "starts_at": "2026-10-05T08:00:00+02:00",
                    "ends_at": "2026-10-05T10:00:00+02:00",
                    "is_tentative": false,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "is_locked": false,
                    "vehicle_id": null,
                    "break_minutes": 15,
                    "breaks": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "shift_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "starts_at": "2026-10-05T09:00:00+02:00",
                        "minutes": 15,
                        "note": null,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "conflicts": [],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PASS_SAKNAS` — Passet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PASS_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PASS_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`FORDON_SAKNAS` — Fordonet finns inte.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FORDON_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FORDON_SAKNAS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "schedule:write",
        "x-fixra-rpc": "api_shifts_vehicle",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/shifts/{id}/vehicle\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"vehicle_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\"}'"
          }
        ]
      }
    },
    "/v1/shifts/{id}/start": {
      "post": {
        "operationId": "startShift",
        "tags": [
          "Pass"
        ],
        "summary": "Starta pass",
        "description": "Stämplar in genom `shift_start` (samma som Mina pass). Ger händelsen `shift.started`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "user_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "starts_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "ends_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "is_tentative": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "is_locked": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "vehicle_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "break_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "breaks": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "shift_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "starts_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "minutes": {
                                    "type": "integer"
                                  },
                                  "note": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "shift_id",
                                  "starts_at",
                                  "minutes",
                                  "note",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "time_entry_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "started_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "work_order_id",
                            "user_id",
                            "title",
                            "starts_at",
                            "ends_at",
                            "is_tentative",
                            "created_at",
                            "updated_at",
                            "is_locked",
                            "vehicle_id",
                            "break_minutes",
                            "breaks",
                            "time_entry_id",
                            "started_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "title": "Trappstädning",
                    "starts_at": "2026-10-05T08:00:00+02:00",
                    "ends_at": "2026-10-05T10:00:00+02:00",
                    "is_tentative": false,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "is_locked": false,
                    "vehicle_id": null,
                    "break_minutes": 15,
                    "breaks": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "shift_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "starts_at": "2026-10-05T09:00:00+02:00",
                        "minutes": 15,
                        "note": null,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "time_entry_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "started_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PASS_SAKNAS` — Passet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PASS_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PASS_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`ANNAT_PASS_PAGAR` — Personen har redan ett pass igång; data innehåller pagaende_time_entry_id och pagaende_block_id.\n\n`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ANNAT_PASS_PAGAR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ANNAT_PASS_PAGAR"
                      ]
                    }
                  },
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PASS_PRELIMINART` — Passet är preliminärt.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PASS_PRELIMINART": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PASS_PRELIMINART"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "schedule:write",
        "x-fixra-rpc": "api_shifts_start",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/shifts/{id}/start\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\""
          }
        ]
      }
    },
    "/v1/shifts/{id}/complete": {
      "post": {
        "operationId": "completeShift",
        "tags": [
          "Pass"
        ],
        "summary": "Slutför pass",
        "description": "Stämplar ut genom `shift_complete` och lämnar tiden till attest. Ger händelsen `shift.completed`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "summary": {
                    "type": "string",
                    "maxLength": 2000
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "summary": "Klart"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "user_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "starts_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "ends_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "is_tentative": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "is_locked": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "vehicle_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "break_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "breaks": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "shift_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "starts_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "minutes": {
                                    "type": "integer"
                                  },
                                  "note": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "shift_id",
                                  "starts_at",
                                  "minutes",
                                  "note",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "time_entry_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "worked_minutes": {
                              "type": "integer"
                            },
                            "billable_minutes": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "id",
                            "work_order_id",
                            "user_id",
                            "title",
                            "starts_at",
                            "ends_at",
                            "is_tentative",
                            "created_at",
                            "updated_at",
                            "is_locked",
                            "vehicle_id",
                            "break_minutes",
                            "breaks",
                            "time_entry_id",
                            "worked_minutes",
                            "billable_minutes"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "title": "Trappstädning",
                    "starts_at": "2026-10-05T08:00:00+02:00",
                    "ends_at": "2026-10-05T10:00:00+02:00",
                    "is_tentative": false,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "is_locked": false,
                    "vehicle_id": null,
                    "break_minutes": 15,
                    "breaks": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "shift_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "starts_at": "2026-10-05T09:00:00+02:00",
                        "minutes": 15,
                        "note": null,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "time_entry_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "worked_minutes": 119,
                    "billable_minutes": 119,
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PASS_SAKNAS` — Passet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PASS_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PASS_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "schedule:write",
        "x-fixra-rpc": "api_shifts_complete",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/shifts/{id}/complete\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"summary\":\"Klart\"}'"
          }
        ]
      }
    },
    "/v1/shifts/{id}/breaks": {
      "get": {
        "operationId": "listShiftBreaks",
        "tags": [
          "Pass"
        ],
        "summary": "Lista raster",
        "description": "Rasterna på ett pass.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "shift_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "starts_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "minutes": {
                                    "type": "integer"
                                  },
                                  "note": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "shift_id",
                                  "starts_at",
                                  "minutes",
                                  "note",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "shift_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "starts_at": "2026-10-05T09:00:00+02:00",
                        "minutes": 15,
                        "note": null,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PASS_SAKNAS` — Passet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PASS_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PASS_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "schedule:read",
        "x-fixra-rpc": "api_shifts_breaks",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/shifts/{id}/breaks\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createShiftBreak",
        "tags": [
          "Pass"
        ],
        "summary": "Lägg till rast",
        "description": "Lägger en rast genom `schedule_block_break_save`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "starts_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "minutes": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 480
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "required": [
                  "starts_at",
                  "minutes"
                ],
                "additionalProperties": false
              },
              "example": {
                "starts_at": "2026-10-05T09:00:00+02:00",
                "minutes": 15
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "shift_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "starts_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "minutes": {
                              "type": "integer"
                            },
                            "note": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "shift_id",
                            "starts_at",
                            "minutes",
                            "note",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "shift_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "starts_at": "2026-10-05T09:00:00+02:00",
                    "minutes": 15,
                    "note": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PASS_SAKNAS` — Passet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PASS_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PASS_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "schedule:write",
        "x-fixra-rpc": "api_shifts_break_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/shifts/{id}/breaks\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"starts_at\":\"2026-10-05T09:00:00+02:00\",\"minutes\":15}'"
          }
        ]
      }
    },
    "/v1/shifts/{id}/breaks/{break_id}": {
      "delete": {
        "operationId": "deleteShiftBreak",
        "tags": [
          "Pass"
        ],
        "summary": "Ta bort rast",
        "description": "Tar bort en rast genom `schedule_block_break_delete`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "break_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "deleted": {
                              "type": "boolean",
                              "const": true
                            },
                            "dry_run": {
                              "type": "boolean"
                            },
                            "idempotent": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "deleted",
                            "dry_run",
                            "idempotent"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "deleted": true,
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PASS_SAKNAS` — Passet finns inte i nyckelns bolag.\n\n`RAST_SAKNAS` — Rasten finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PASS_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PASS_SAKNAS"
                      ]
                    }
                  },
                  "RAST_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RAST_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "schedule:write",
        "x-fixra-rpc": "api_shifts_break_delete",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.fixra.se/v1/shifts/{id}/breaks/{break_id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/shifts/bulk-rebook": {
      "post": {
        "operationId": "bulkRebookShifts",
        "tags": [
          "Pass"
        ],
        "summary": "Massombokning",
        "description": "Bokar om en persons pass i en period genom `schedule_bulk_rebook`. `preview: true` visar utfallet utan att ändra.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "date_from": {
                    "type": "string",
                    "format": "date"
                  },
                  "date_to": {
                    "type": "string",
                    "format": "date"
                  },
                  "outcome": {
                    "type": "string",
                    "enum": [
                      "unstaff",
                      "replace",
                      "copy",
                      "delete"
                    ]
                  },
                  "target_user_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "weekdays": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 7
                    }
                  },
                  "week_parity": {
                    "type": "string",
                    "enum": [
                      "all",
                      "even",
                      "odd"
                    ]
                  },
                  "interval_weeks": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 52
                  },
                  "reason": {
                    "type": "string",
                    "maxLength": 500
                  },
                  "preview": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "user_id",
                  "date_from",
                  "date_to",
                  "outcome"
                ],
                "additionalProperties": false
              },
              "example": {
                "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "date_from": "2026-10-05",
                "date_to": "2026-10-09",
                "outcome": "replace",
                "target_user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "preview": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "affected": 4,
                    "preview": true,
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`OGILTIG_PERIOD` — Perioden är ogiltig.\n\n`PERIOD_FOR_LANG` — Högst 366 dagar.\n\n`OKANT_UTFALL` — Okänt utfall.\n\n`ERSATTARE_SAKNAS` — Ersättare krävs.\n\n`MEDLEM_SAKNAS` — Personen finns inte i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OGILTIG_PERIOD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIG_PERIOD"
                      ]
                    }
                  },
                  "PERIOD_FOR_LANG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PERIOD_FOR_LANG"
                      ]
                    }
                  },
                  "OKANT_UTFALL": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OKANT_UTFALL"
                      ]
                    }
                  },
                  "ERSATTARE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ERSATTARE_SAKNAS"
                      ]
                    }
                  },
                  "MEDLEM_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MEDLEM_SAKNAS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "schedule:write",
        "x-fixra-rpc": "api_shifts_bulk_rebook",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/shifts/bulk-rebook\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"user_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"date_from\":\"2026-10-05\",\"date_to\":\"2026-10-09\",\"outcome\":\"replace\",\"target_user_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"preview\":true}'"
          }
        ]
      }
    },
    "/v1/attachments": {
      "get": {
        "operationId": "listAttachments",
        "tags": [
          "Bilagor"
        ],
        "summary": "Lista bilagor",
        "description": "Bilagor på ett objekt. `updated_since` filtrerar på skapandetid (bilagor ändras inte).",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "object_type",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "customer",
                "site",
                "agreement",
                "work_order",
                "deviation",
                "quote",
                "schedule_block",
                "expense"
              ]
            }
          },
          {
            "name": "object_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "object_type": {
                                    "type": "string"
                                  },
                                  "object_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "role": {
                                    "type": "string"
                                  },
                                  "is_customer_visible": {
                                    "type": "boolean"
                                  },
                                  "file_name": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "mime_type": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "size_bytes": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "download_url": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uri"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Signerad nedladdningslänk, giltig 60 minuter. Skapas vid varje läsning och leverans, lagras aldrig. null om filen saknas."
                                  },
                                  "download_expires_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "object_type",
                                  "object_id",
                                  "role",
                                  "is_customer_visible",
                                  "file_name",
                                  "mime_type",
                                  "size_bytes",
                                  "created_at",
                                  "download_url",
                                  "download_expires_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "object_type": "work_order",
                        "object_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "role": "after",
                        "is_customer_visible": false,
                        "file_name": "efter.jpg",
                        "mime_type": "image/jpeg",
                        "size_bytes": 482113,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "download_url": "https://app.fixra.se/api/public/fil/3f1c2b7e-8d4a-4c1e-9b2f-6a7d5e4c3b21?exp=1790000000&sig=9c1e…",
                        "download_expires_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`OBJEKT_SAKNAS_ELLER_OGILTIGT` — Objektet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OBJEKT_SAKNAS_ELLER_OGILTIGT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OBJEKT_SAKNAS_ELLER_OGILTIGT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "attachments:read",
        "x-fixra-rpc": "api_attachments_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/attachments\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createAttachment",
        "tags": [
          "Bilagor"
        ],
        "summary": "Registrera bilaga",
        "description": "Steg 2 av 2. Kopplar den uppladdade filen till objektet genom `attachment_register`. Storlek och filtyp kontrolleras mot den faktiska filen.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "upload_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "before",
                      "after",
                      "damage",
                      "document",
                      "drawing",
                      "receipt",
                      "image"
                    ]
                  },
                  "is_customer_visible": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "upload_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "upload_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "role": "after"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "object_type": {
                              "type": "string"
                            },
                            "object_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "role": {
                              "type": "string"
                            },
                            "is_customer_visible": {
                              "type": "boolean"
                            },
                            "file_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "mime_type": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "size_bytes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "download_url": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uri"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Signerad nedladdningslänk, giltig 60 minuter. Skapas vid varje läsning och leverans, lagras aldrig. null om filen saknas."
                            },
                            "download_expires_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "object_type",
                            "object_id",
                            "role",
                            "is_customer_visible",
                            "file_name",
                            "mime_type",
                            "size_bytes",
                            "created_at",
                            "download_url",
                            "download_expires_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "object_type": "work_order",
                    "object_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "role": "after",
                    "is_customer_visible": false,
                    "file_name": "efter.jpg",
                    "mime_type": "image/jpeg",
                    "size_bytes": 482113,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "download_url": "https://app.fixra.se/api/public/fil/3f1c2b7e-8d4a-4c1e-9b2f-6a7d5e4c3b21?exp=1790000000&sig=9c1e…",
                    "download_expires_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`UPPLADDNING_SAKNAS` — Uppladdningen finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "UPPLADDNING_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "UPPLADDNING_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`UPPLADDNING_UTGANGEN` — Mer än 10 minuter har gått.\n\n`UPPLADDNING_ANVAND` — Redan registrerad.\n\n`FIL_SAKNAS` — Filen är inte uppladdad.\n\n`FIL_FOR_STOR` — Filen är större än angivet.\n\n`FILTYP_EJ_TILLATEN` — Filtypen stämmer inte.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "UPPLADDNING_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "UPPLADDNING_UTGANGEN"
                      ]
                    }
                  },
                  "UPPLADDNING_ANVAND": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "UPPLADDNING_ANVAND"
                      ]
                    }
                  },
                  "FIL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FIL_SAKNAS"
                      ]
                    }
                  },
                  "FIL_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FIL_FOR_STOR"
                      ]
                    }
                  },
                  "FILTYP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FILTYP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "attachments:write",
        "x-fixra-rpc": "api_attachments_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/attachments\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"upload_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"role\":\"after\"}'"
          }
        ]
      }
    },
    "/v1/attachments/upload-url": {
      "post": {
        "operationId": "createAttachmentUploadUrl",
        "tags": [
          "Bilagor"
        ],
        "summary": "Hämta uppladdnings-URL",
        "description": "Steg 1 av 2. Ger en signerad URL för `PUT` av filen (max 25 MB, tillåtna filtyper: JPEG, PNG, WebP, HEIC, PDF, text, CSV, Word, Excel). Registrera med `POST /v1/attachments` inom 10 minuter. Testnycklar får ingen URL.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "object_type": {
                    "type": "string",
                    "enum": [
                      "customer",
                      "site",
                      "agreement",
                      "work_order",
                      "deviation",
                      "quote",
                      "schedule_block",
                      "expense"
                    ]
                  },
                  "object_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "file_name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "mime_type": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "size_bytes": {
                    "type": "integer",
                    "minimum": 1
                  }
                },
                "required": [
                  "object_type",
                  "object_id",
                  "file_name",
                  "mime_type",
                  "size_bytes"
                ],
                "additionalProperties": false
              },
              "example": {
                "object_type": "work_order",
                "object_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "file_name": "efter.jpg",
                "mime_type": "image/jpeg",
                "size_bytes": 482113
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "upload_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "bucket": {
                              "type": "string"
                            },
                            "storage_path": {
                              "type": "string"
                            },
                            "mime_type": {
                              "type": "string"
                            },
                            "max_bytes": {
                              "type": "integer"
                            },
                            "expires_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "upload_url": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "upload_id",
                            "bucket",
                            "storage_path",
                            "mime_type",
                            "max_bytes",
                            "expires_at",
                            "upload_url"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "upload_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "bucket": "fixra-filer",
                    "storage_path": "…/efter.jpg",
                    "mime_type": "image/jpeg",
                    "max_bytes": 482113,
                    "expires_at": "2026-10-01T09:00:00+02:00",
                    "upload_url": "https://…",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`OBJEKT_SAKNAS_ELLER_OGILTIGT` — Objektet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OBJEKT_SAKNAS_ELLER_OGILTIGT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OBJEKT_SAKNAS_ELLER_OGILTIGT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`FILTYP_EJ_TILLATEN` — Filtypen är inte tillåten.\n\n`FIL_FOR_STOR` — Filen är större än 25 MB.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FILTYP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FILTYP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "FIL_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FIL_FOR_STOR"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "attachments:write",
        "x-fixra-rpc": "api_attachments_upload_url",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/attachments/upload-url\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"object_type\":\"work_order\",\"object_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"file_name\":\"efter.jpg\",\"mime_type\":\"image/jpeg\",\"size_bytes\":482113}'"
          }
        ]
      }
    },
    "/v1/attachments/{id}": {
      "patch": {
        "operationId": "updateAttachment",
        "tags": [
          "Bilagor"
        ],
        "summary": "Visa för kund",
        "description": "Sätter om bilagan syns i kundportalen genom `attachment_set_customer_visible`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "is_customer_visible": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "is_customer_visible"
                ],
                "additionalProperties": false
              },
              "example": {
                "is_customer_visible": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "object_type": {
                              "type": "string"
                            },
                            "object_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "role": {
                              "type": "string"
                            },
                            "is_customer_visible": {
                              "type": "boolean"
                            },
                            "file_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "mime_type": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "size_bytes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "download_url": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uri"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Signerad nedladdningslänk, giltig 60 minuter. Skapas vid varje läsning och leverans, lagras aldrig. null om filen saknas."
                            },
                            "download_expires_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "object_type",
                            "object_id",
                            "role",
                            "is_customer_visible",
                            "file_name",
                            "mime_type",
                            "size_bytes",
                            "created_at",
                            "download_url",
                            "download_expires_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "object_type": "work_order",
                    "object_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "role": "after",
                    "is_customer_visible": true,
                    "file_name": "efter.jpg",
                    "mime_type": "image/jpeg",
                    "size_bytes": 482113,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "download_url": "https://app.fixra.se/api/public/fil/3f1c2b7e-8d4a-4c1e-9b2f-6a7d5e4c3b21?exp=1790000000&sig=9c1e…",
                    "download_expires_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`BILAGA_SAKNAS` — Bilagan finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BILAGA_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BILAGA_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "attachments:write",
        "x-fixra-rpc": "api_attachments_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/attachments/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"is_customer_visible\":true}'"
          }
        ]
      }
    },
    "/v1/tasks": {
      "get": {
        "operationId": "listTasks",
        "tags": [
          "Uppgifter"
        ],
        "summary": "Lista uppgifter",
        "description": "Uppgifter. Kräver modulen Uppgifter.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 40
                }
              ]
            }
          },
          {
            "name": "assignee_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "work_order_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                }
              ],
              "description": "Slå upp på ert eget id (external_id)."
            },
            "description": "Slå upp på ert eget id (external_id)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "title": {
                                    "type": "string"
                                  },
                                  "description": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "assignee_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "due_on": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string"
                                  },
                                  "priority": {
                                    "type": "string"
                                  },
                                  "customer_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "site_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "agreement_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "completed_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "external_id": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "title",
                                  "description",
                                  "assignee_id",
                                  "due_on",
                                  "status",
                                  "priority",
                                  "customer_id",
                                  "site_id",
                                  "work_order_id",
                                  "agreement_id",
                                  "completed_at",
                                  "external_id",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "title": "Ring kunden om nyckel",
                        "description": null,
                        "assignee_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "due_on": "2026-10-06",
                        "status": "open",
                        "priority": "normal",
                        "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "site_id": null,
                        "work_order_id": null,
                        "agreement_id": null,
                        "completed_at": null,
                        "external_id": "crm-t-4",
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "tasks:read",
        "x-fixra-rpc": "api_tasks_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/tasks\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createTask",
        "tags": [
          "Uppgifter"
        ],
        "summary": "Skapa uppgift",
        "description": "Skapar en uppgift genom `task_save`.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "assignee_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "due_on": {
                    "type": "string",
                    "format": "date"
                  },
                  "priority": {
                    "type": "string",
                    "enum": [
                      "low",
                      "normal",
                      "high"
                    ]
                  },
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "site_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "work_order_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "agreement_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "title"
                ],
                "additionalProperties": false
              },
              "example": {
                "title": "Ring kunden om nyckel",
                "assignee_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "due_on": "2026-10-06",
                "external_id": "crm-t-4"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "assignee_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "due_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "priority": {
                              "type": "string"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "agreement_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "completed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "title",
                            "description",
                            "assignee_id",
                            "due_on",
                            "status",
                            "priority",
                            "customer_id",
                            "site_id",
                            "work_order_id",
                            "agreement_id",
                            "completed_at",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "title": "Ring kunden om nyckel",
                    "description": null,
                    "assignee_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "due_on": "2026-10-06",
                    "status": "open",
                    "priority": "normal",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": null,
                    "work_order_id": null,
                    "agreement_id": null,
                    "completed_at": null,
                    "external_id": "crm-t-4",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`RUBRIK_SAKNAS` — Rubrik saknas.\n\n`ANSVARIG_EJ_MEDLEM` — Ansvarig finns inte i bolaget.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "RUBRIK_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RUBRIK_SAKNAS"
                      ]
                    }
                  },
                  "ANSVARIG_EJ_MEDLEM": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ANSVARIG_EJ_MEDLEM"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "tasks:write",
        "x-fixra-rpc": "api_tasks_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/tasks\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"title\":\"Ring kunden om nyckel\",\"assignee_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"due_on\":\"2026-10-06\",\"external_id\":\"crm-t-4\"}'"
          }
        ]
      }
    },
    "/v1/tasks/{id}": {
      "get": {
        "operationId": "getTask",
        "tags": [
          "Uppgifter"
        ],
        "summary": "Hämta uppgift",
        "description": "En uppgift.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "assignee_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "due_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "priority": {
                              "type": "string"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "agreement_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "completed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "title",
                            "description",
                            "assignee_id",
                            "due_on",
                            "status",
                            "priority",
                            "customer_id",
                            "site_id",
                            "work_order_id",
                            "agreement_id",
                            "completed_at",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "title": "Ring kunden om nyckel",
                    "description": null,
                    "assignee_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "due_on": "2026-10-06",
                    "status": "open",
                    "priority": "normal",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": null,
                    "work_order_id": null,
                    "agreement_id": null,
                    "completed_at": null,
                    "external_id": "crm-t-4",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`UPPGIFT_SAKNAS` — Uppgiften finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "UPPGIFT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "UPPGIFT_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "tasks:read",
        "x-fixra-rpc": "api_tasks_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/tasks/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "patch": {
        "operationId": "updateTask",
        "tags": [
          "Uppgifter"
        ],
        "summary": "Ändra uppgift",
        "description": "Ändrar bara fälten som skickas, genom `task_save`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 4000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "assignee_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "due_on": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "priority": {
                    "type": "string",
                    "enum": [
                      "low",
                      "normal",
                      "high"
                    ]
                  },
                  "customer_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "site_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "work_order_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "agreement_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "due_on": "2026-10-07"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "assignee_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "due_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "priority": {
                              "type": "string"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "agreement_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "completed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "title",
                            "description",
                            "assignee_id",
                            "due_on",
                            "status",
                            "priority",
                            "customer_id",
                            "site_id",
                            "work_order_id",
                            "agreement_id",
                            "completed_at",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "title": "Ring kunden om nyckel",
                    "description": null,
                    "assignee_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "due_on": "2026-10-06",
                    "status": "open",
                    "priority": "normal",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": null,
                    "work_order_id": null,
                    "agreement_id": null,
                    "completed_at": null,
                    "external_id": "crm-t-4",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`UPPGIFT_SAKNAS` — Uppgiften finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "UPPGIFT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "UPPGIFT_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "tasks:write",
        "x-fixra-rpc": "api_tasks_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/tasks/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"due_on\":\"2026-10-07\"}'"
          }
        ]
      }
    },
    "/v1/tasks/{id}/status": {
      "post": {
        "operationId": "setTaskStatus",
        "tags": [
          "Uppgifter"
        ],
        "summary": "Byt status",
        "description": "Sätter status genom `task_set_status`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "open",
                      "done",
                      "cancelled"
                    ]
                  }
                },
                "required": [
                  "status"
                ],
                "additionalProperties": false
              },
              "example": {
                "status": "done"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "assignee_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "due_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "priority": {
                              "type": "string"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "agreement_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "completed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "title",
                            "description",
                            "assignee_id",
                            "due_on",
                            "status",
                            "priority",
                            "customer_id",
                            "site_id",
                            "work_order_id",
                            "agreement_id",
                            "completed_at",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "title": "Ring kunden om nyckel",
                    "description": null,
                    "assignee_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "due_on": "2026-10-06",
                    "status": "done",
                    "priority": "normal",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": null,
                    "work_order_id": null,
                    "agreement_id": null,
                    "completed_at": null,
                    "external_id": "crm-t-4",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`UPPGIFT_SAKNAS` — Uppgiften finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "UPPGIFT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "UPPGIFT_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "tasks:write",
        "x-fixra-rpc": "api_tasks_status",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/tasks/{id}/status\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"status\":\"done\"}'"
          }
        ]
      }
    },
    "/v1/tickets": {
      "get": {
        "operationId": "listTickets",
        "tags": [
          "Ärenden"
        ],
        "summary": "Lista ärenden",
        "description": "Ärenden utan meddelandetext. Sammanslagna ärenden visas inte. Kräver modulen Ärenden.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 40
                }
              ]
            }
          },
          {
            "name": "priority",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 20
                }
              ]
            }
          },
          {
            "name": "assigned_to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                }
              ],
              "description": "Slå upp på ert eget id (external_id)."
            },
            "description": "Slå upp på ert eget id (external_id)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "number": {
                                    "type": "integer"
                                  },
                                  "subject": {
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string"
                                  },
                                  "priority": {
                                    "type": "string"
                                  },
                                  "category": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "source": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "customer_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "contact_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "site_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "assigned_to": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "due_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "first_response_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "closed_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "last_message_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "external_id": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "number",
                                  "subject",
                                  "status",
                                  "priority",
                                  "category",
                                  "source",
                                  "customer_id",
                                  "contact_id",
                                  "site_id",
                                  "assigned_to",
                                  "due_at",
                                  "first_response_at",
                                  "closed_at",
                                  "work_order_id",
                                  "last_message_at",
                                  "external_id",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "number": 1042,
                        "subject": "Trasig port",
                        "status": "open",
                        "priority": "normal",
                        "category": null,
                        "source": "manual",
                        "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "contact_id": null,
                        "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "assigned_to": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "due_at": null,
                        "first_response_at": null,
                        "closed_at": null,
                        "work_order_id": null,
                        "last_message_at": "2026-10-01T09:00:00+02:00",
                        "external_id": null,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "tickets:read",
        "x-fixra-rpc": "api_tickets_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/tickets\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createTicket",
        "tags": [
          "Ärenden"
        ],
        "summary": "Skapa ärende",
        "description": "Skapar ett manuellt ärende genom `ticket_create` (samma nummerserie och SLA som appen).",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "subject": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 300
                  },
                  "body": {
                    "type": "string",
                    "maxLength": 20000,
                    "description": "Sparas som intern anteckning, eller skickas som mejl med notify_customer."
                  },
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "contact_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "site_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "priority": {
                    "type": "string",
                    "enum": [
                      "low",
                      "normal",
                      "high",
                      "urgent"
                    ]
                  },
                  "category": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "mailbox_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "assigned_to": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "due_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "notify_customer": {
                    "type": "boolean"
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "subject"
                ],
                "additionalProperties": false
              },
              "example": {
                "subject": "Trasig port",
                "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "body": "Porten går inte att låsa."
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "number": {
                              "type": "integer"
                            },
                            "subject": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "priority": {
                              "type": "string"
                            },
                            "category": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "assigned_to": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "due_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "first_response_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "closed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "last_message_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "number",
                            "subject",
                            "status",
                            "priority",
                            "category",
                            "source",
                            "customer_id",
                            "contact_id",
                            "site_id",
                            "assigned_to",
                            "due_at",
                            "first_response_at",
                            "closed_at",
                            "work_order_id",
                            "last_message_at",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "number": 1042,
                    "subject": "Trasig port",
                    "status": "open",
                    "priority": "normal",
                    "category": null,
                    "source": "manual",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "contact_id": null,
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "assigned_to": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "due_at": null,
                    "first_response_at": null,
                    "closed_at": null,
                    "work_order_id": null,
                    "last_message_at": "2026-10-01T09:00:00+02:00",
                    "external_id": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`AMNE_SAKNAS` — Ämne saknas.\n\n`ANVANDARE_OGILTIG` — Handläggaren saknar behörighet.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "AMNE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "AMNE_SAKNAS"
                      ]
                    }
                  },
                  "ANVANDARE_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ANVANDARE_OGILTIG"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "tickets:write",
        "x-fixra-rpc": "api_tickets_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/tickets\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"subject\":\"Trasig port\",\"customer_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"body\":\"Porten går inte att låsa.\"}'"
          }
        ]
      }
    },
    "/v1/tickets/{id}": {
      "get": {
        "operationId": "getTicket",
        "tags": [
          "Ärenden"
        ],
        "summary": "Hämta ärende",
        "description": "Ett ärende. Interna anteckningar och meddelanden returneras inte.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "number": {
                              "type": "integer"
                            },
                            "subject": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "priority": {
                              "type": "string"
                            },
                            "category": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "assigned_to": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "due_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "first_response_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "closed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "last_message_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "number",
                            "subject",
                            "status",
                            "priority",
                            "category",
                            "source",
                            "customer_id",
                            "contact_id",
                            "site_id",
                            "assigned_to",
                            "due_at",
                            "first_response_at",
                            "closed_at",
                            "work_order_id",
                            "last_message_at",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "number": 1042,
                    "subject": "Trasig port",
                    "status": "open",
                    "priority": "normal",
                    "category": null,
                    "source": "manual",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "contact_id": null,
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "assigned_to": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "due_at": null,
                    "first_response_at": null,
                    "closed_at": null,
                    "work_order_id": null,
                    "last_message_at": "2026-10-01T09:00:00+02:00",
                    "external_id": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARENDE_SAKNAS` — Ärendet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARENDE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARENDE_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "tickets:read",
        "x-fixra-rpc": "api_tickets_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/tickets/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/tickets/{id}/assign": {
      "post": {
        "operationId": "assignTicket",
        "tags": [
          "Ärenden"
        ],
        "summary": "Tilldela ärende",
        "description": "Tilldelar genom `ticket_assign`. `user_id: null` tar bort tilldelningen.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "user_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "user_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "number": {
                              "type": "integer"
                            },
                            "subject": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "priority": {
                              "type": "string"
                            },
                            "category": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "assigned_to": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "due_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "first_response_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "closed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "last_message_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "number",
                            "subject",
                            "status",
                            "priority",
                            "category",
                            "source",
                            "customer_id",
                            "contact_id",
                            "site_id",
                            "assigned_to",
                            "due_at",
                            "first_response_at",
                            "closed_at",
                            "work_order_id",
                            "last_message_at",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "number": 1042,
                    "subject": "Trasig port",
                    "status": "open",
                    "priority": "normal",
                    "category": null,
                    "source": "manual",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "contact_id": null,
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "assigned_to": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "due_at": null,
                    "first_response_at": null,
                    "closed_at": null,
                    "work_order_id": null,
                    "last_message_at": "2026-10-01T09:00:00+02:00",
                    "external_id": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARENDE_SAKNAS` — Ärendet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARENDE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARENDE_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`HANDLAGGARE_SAKNAR_BEHORIGHET` — Personen kan inte läsa ärenden.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "HANDLAGGARE_SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "HANDLAGGARE_SAKNAR_BEHORIGHET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "tickets:write",
        "x-fixra-rpc": "api_tickets_assign",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/tickets/{id}/assign\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"user_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\"}'"
          }
        ]
      }
    },
    "/v1/tickets/{id}/status": {
      "post": {
        "operationId": "setTicketStatus",
        "tags": [
          "Ärenden"
        ],
        "summary": "Byt status",
        "description": "Sätter status genom `ticket_set_status`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "new",
                      "open",
                      "pending",
                      "closed"
                    ]
                  }
                },
                "required": [
                  "status"
                ],
                "additionalProperties": false
              },
              "example": {
                "status": "closed"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "number": {
                              "type": "integer"
                            },
                            "subject": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "priority": {
                              "type": "string"
                            },
                            "category": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "assigned_to": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "due_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "first_response_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "closed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "last_message_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "number",
                            "subject",
                            "status",
                            "priority",
                            "category",
                            "source",
                            "customer_id",
                            "contact_id",
                            "site_id",
                            "assigned_to",
                            "due_at",
                            "first_response_at",
                            "closed_at",
                            "work_order_id",
                            "last_message_at",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "number": 1042,
                    "subject": "Trasig port",
                    "status": "closed",
                    "priority": "normal",
                    "category": null,
                    "source": "manual",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "contact_id": null,
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "assigned_to": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "due_at": null,
                    "first_response_at": null,
                    "closed_at": null,
                    "work_order_id": null,
                    "last_message_at": "2026-10-01T09:00:00+02:00",
                    "external_id": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARENDE_SAKNAS` — Ärendet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARENDE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARENDE_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "tickets:write",
        "x-fixra-rpc": "api_tickets_status",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/tickets/{id}/status\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"status\":\"closed\"}'"
          }
        ]
      }
    },
    "/v1/tickets/{id}/priority": {
      "post": {
        "operationId": "setTicketPriority",
        "tags": [
          "Ärenden"
        ],
        "summary": "Byt prioritet",
        "description": "Sätter prioritet genom `ticket_set_priority`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "priority": {
                    "type": "string",
                    "enum": [
                      "low",
                      "normal",
                      "high",
                      "urgent"
                    ]
                  }
                },
                "required": [
                  "priority"
                ],
                "additionalProperties": false
              },
              "example": {
                "priority": "high"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "number": {
                              "type": "integer"
                            },
                            "subject": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "priority": {
                              "type": "string"
                            },
                            "category": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "assigned_to": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "due_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "first_response_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "closed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "last_message_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "number",
                            "subject",
                            "status",
                            "priority",
                            "category",
                            "source",
                            "customer_id",
                            "contact_id",
                            "site_id",
                            "assigned_to",
                            "due_at",
                            "first_response_at",
                            "closed_at",
                            "work_order_id",
                            "last_message_at",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "number": 1042,
                    "subject": "Trasig port",
                    "status": "open",
                    "priority": "high",
                    "category": null,
                    "source": "manual",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "contact_id": null,
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "assigned_to": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "due_at": null,
                    "first_response_at": null,
                    "closed_at": null,
                    "work_order_id": null,
                    "last_message_at": "2026-10-01T09:00:00+02:00",
                    "external_id": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARENDE_SAKNAS` — Ärendet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARENDE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARENDE_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "tickets:write",
        "x-fixra-rpc": "api_tickets_priority",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/tickets/{id}/priority\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"priority\":\"high\"}'"
          }
        ]
      }
    },
    "/v1/tickets/{id}/work-order": {
      "post": {
        "operationId": "createTicketWorkOrder",
        "tags": [
          "Ärenden"
        ],
        "summary": "Skapa arbetsorder från ärende",
        "description": "Skapar en arbetsorder från ärendet genom `ticket_create_work_order`. Svaret är ärendet med `work_order_id`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "site_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "product_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "occurrence_date": {
                    "type": "string",
                    "format": "date"
                  },
                  "preferred_time": {
                    "type": "string",
                    "pattern": "^\\d{2}:\\d{2}$"
                  },
                  "estimated_minutes": {
                    "type": "integer",
                    "minimum": 15,
                    "maximum": 1440
                  },
                  "billing_type": {
                    "type": "string",
                    "enum": [
                      "fixed_price",
                      "time_material"
                    ]
                  },
                  "fixed_price": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  },
                  "non_billable": {
                    "type": "boolean"
                  },
                  "assignee_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "maxItems": 20
                  },
                  "close_on_done": {
                    "type": "boolean"
                  },
                  "confirm_to_customer": {
                    "type": "boolean"
                  },
                  "confirm_text": {
                    "type": "string",
                    "maxLength": 4000
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "title": "Laga port",
                "occurrence_date": "2026-10-06"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "number": {
                              "type": "integer"
                            },
                            "subject": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "priority": {
                              "type": "string"
                            },
                            "category": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "assigned_to": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "due_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "first_response_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "closed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "last_message_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "number",
                            "subject",
                            "status",
                            "priority",
                            "category",
                            "source",
                            "customer_id",
                            "contact_id",
                            "site_id",
                            "assigned_to",
                            "due_at",
                            "first_response_at",
                            "closed_at",
                            "work_order_id",
                            "last_message_at",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "number": 1042,
                    "subject": "Trasig port",
                    "status": "open",
                    "priority": "normal",
                    "category": null,
                    "source": "manual",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "contact_id": null,
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "assigned_to": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "due_at": null,
                    "first_response_at": null,
                    "closed_at": null,
                    "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "last_message_at": "2026-10-01T09:00:00+02:00",
                    "external_id": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARENDE_SAKNAS` — Ärendet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARENDE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARENDE_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`ARBETSORDER_FINNS` — Ärendet har redan en arbetsorder.\n\n`KUND_SAKNAS` — Ärendet saknar kund.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARBETSORDER_FINNS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_FINNS"
                      ]
                    }
                  },
                  "KUND_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KUND_SAKNAS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "tickets:write",
        "x-fixra-rpc": "api_tickets_work_order",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/tickets/{id}/work-order\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"title\":\"Laga port\",\"occurrence_date\":\"2026-10-06\"}'"
          }
        ]
      }
    },
    "/v1/requests/{id}": {
      "get": {
        "operationId": "getRequest",
        "tags": [
          "Förfrågningar"
        ],
        "summary": "Hämta förfrågan",
        "description": "En förfrågan. Interna anteckningar returneras aldrig.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "contact_phone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "contact_email": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "channel": {
                              "type": "string"
                            },
                            "body": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "customer_id",
                            "site_id",
                            "contact_name",
                            "contact_phone",
                            "contact_email",
                            "channel",
                            "body",
                            "status",
                            "source",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": null,
                    "contact_name": "Anna Berg",
                    "contact_phone": "+46701234567",
                    "contact_email": null,
                    "channel": "api",
                    "body": "Vill ha offert på storstädning i november.",
                    "status": "new",
                    "source": "api",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`FORFRAGAN_SAKNAS` — Förfrågan finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FORFRAGAN_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FORFRAGAN_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "requests:read",
        "x-fixra-rpc": "api_requests_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/requests/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "patch": {
        "operationId": "updateRequest",
        "tags": [
          "Förfrågningar"
        ],
        "summary": "Ändra förfrågan",
        "description": "Ändrar status, handläggare, kund, plats eller tagg genom `customer_request_update`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "assigned_to": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "customer_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "site_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "tag_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "status": "handled"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "contact_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "contact_phone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "contact_email": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "channel": {
                              "type": "string"
                            },
                            "body": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "source": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "customer_id",
                            "site_id",
                            "contact_name",
                            "contact_phone",
                            "contact_email",
                            "channel",
                            "body",
                            "status",
                            "source",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": null,
                    "contact_name": "Anna Berg",
                    "contact_phone": "+46701234567",
                    "contact_email": null,
                    "channel": "api",
                    "body": "Vill ha offert på storstädning i november.",
                    "status": "handled",
                    "source": "api",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`FORFRAGAN_SAKNAS` — Förfrågan finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FORFRAGAN_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FORFRAGAN_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`OGILTIG_STATUS` — Okänd status.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OGILTIG_STATUS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIG_STATUS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "requests:write",
        "x-fixra-rpc": "api_requests_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/requests/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"status\":\"handled\"}'"
          }
        ]
      }
    },
    "/v1/customers/{id}/notes": {
      "get": {
        "operationId": "listCustomerNotes",
        "tags": [
          "Kunder"
        ],
        "summary": "Lista kundanteckningar",
        "description": "Anteckningarna på kundkortet.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "customer_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "body": {
                                    "type": "string"
                                  },
                                  "is_pinned": {
                                    "type": "boolean"
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "customer_id",
                                  "body",
                                  "is_pinned",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "body": "Föredrar mejl före telefon.",
                        "is_pinned": false,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`KUND_SAKNAS` — Kunden finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "KUND_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KUND_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "customer_notes:read",
        "x-fixra-rpc": "api_customer_notes_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/customers/{id}/notes\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createCustomerNote",
        "tags": [
          "Kunder"
        ],
        "summary": "Skapa kundanteckning",
        "description": "Skapar en anteckning genom `customer_note_save`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4000
                  },
                  "is_pinned": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "body"
                ],
                "additionalProperties": false
              },
              "example": {
                "body": "Föredrar mejl före telefon."
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "customer_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "body": {
                              "type": "string"
                            },
                            "is_pinned": {
                              "type": "boolean"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "customer_id",
                            "body",
                            "is_pinned",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "body": "Föredrar mejl före telefon.",
                    "is_pinned": false,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`KUND_SAKNAS` — Kunden finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "KUND_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KUND_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`ANTECKNING_TOM` — Texten är tom.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ANTECKNING_TOM": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ANTECKNING_TOM"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "customer_notes:write",
        "x-fixra-rpc": "api_customer_notes_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/customers/{id}/notes\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"body\":\"Föredrar mejl före telefon.\"}'"
          }
        ]
      }
    },
    "/v1/customer-notes/{id}": {
      "patch": {
        "operationId": "updateCustomerNote",
        "tags": [
          "Kunder"
        ],
        "summary": "Ändra kundanteckning",
        "description": "Ändrar text eller fastnålning.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4000
                  },
                  "is_pinned": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "is_pinned": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "customer_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "body": {
                              "type": "string"
                            },
                            "is_pinned": {
                              "type": "boolean"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "customer_id",
                            "body",
                            "is_pinned",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "body": "Föredrar mejl före telefon.",
                    "is_pinned": true,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ANTECKNING_SAKNAS` — Anteckningen finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ANTECKNING_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ANTECKNING_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "customer_notes:write",
        "x-fixra-rpc": "api_customer_notes_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/customer-notes/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"is_pinned\":true}'"
          }
        ]
      },
      "delete": {
        "operationId": "deleteCustomerNote",
        "tags": [
          "Kunder"
        ],
        "summary": "Ta bort kundanteckning",
        "description": "Tar bort genom `customer_note_delete`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "deleted": {
                              "type": "boolean",
                              "const": true
                            },
                            "dry_run": {
                              "type": "boolean"
                            },
                            "idempotent": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "deleted",
                            "dry_run",
                            "idempotent"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "deleted": true,
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ANTECKNING_SAKNAS` — Anteckningen finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ANTECKNING_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ANTECKNING_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "customer_notes:write",
        "x-fixra-rpc": "api_customer_notes_delete",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.fixra.se/v1/customer-notes/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/deviations/{id}": {
      "get": {
        "operationId": "getDeviation",
        "tags": [
          "Avvikelser"
        ],
        "summary": "Hämta avvikelse",
        "description": "En avvikelse.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "deviation_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "severity": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "resolved_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "deviation_number",
                            "work_order_id",
                            "site_id",
                            "title",
                            "description",
                            "severity",
                            "status",
                            "resolved_at",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "deviation_number": "AV-0042",
                    "work_order_id": null,
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "title": "Trasig lampa i trapphus",
                    "description": null,
                    "severity": "normal",
                    "status": "open",
                    "resolved_at": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`AVVIKELSE_SAKNAS` — Avvikelsen finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "AVVIKELSE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "AVVIKELSE_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "deviations:read",
        "x-fixra-rpc": "api_deviations_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/deviations/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "patch": {
        "operationId": "updateDeviation",
        "tags": [
          "Avvikelser"
        ],
        "summary": "Ändra avvikelse",
        "description": "Ändrar genom `deviation_update`. Kräver att nyckelns skapare får hantera kvalitet.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "open",
                      "in_progress",
                      "resolved",
                      "closed"
                    ]
                  },
                  "severity": {
                    "type": "string",
                    "enum": [
                      "low",
                      "normal",
                      "high",
                      "critical"
                    ]
                  },
                  "assigned_to": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "due_at": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "type_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "subtype_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "root_cause": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "immediate_action": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "improvement_suggestion": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "resolution_note": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "is_customer_visible": {
                    "type": "boolean"
                  },
                  "work_order_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "status": "resolved",
                "resolution_note": "Lampan bytt"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "deviation_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "severity": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "resolved_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "deviation_number",
                            "work_order_id",
                            "site_id",
                            "title",
                            "description",
                            "severity",
                            "status",
                            "resolved_at",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "deviation_number": "AV-0042",
                    "work_order_id": null,
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "title": "Trasig lampa i trapphus",
                    "description": null,
                    "severity": "normal",
                    "status": "resolved",
                    "resolved_at": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`AVVIKELSE_SAKNAS` — Avvikelsen finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "AVVIKELSE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "AVVIKELSE_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`OGILTIG_STATUS` — Okänd status.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OGILTIG_STATUS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIG_STATUS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "deviations:write",
        "x-fixra-rpc": "api_deviations_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/deviations/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"status\":\"resolved\",\"resolution_note\":\"Lampan bytt\"}'"
          }
        ]
      }
    },
    "/v1/deviations/{id}/actions": {
      "get": {
        "operationId": "listDeviationActions",
        "tags": [
          "Avvikelser"
        ],
        "summary": "Lista åtgärder",
        "description": "Åtgärdsstegen på en avvikelse.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "deviation_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "step_no": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "supervisor_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "worker_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "due_date": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "proposed_action": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string"
                                  },
                                  "done_date": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "outcome_note": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "deviation_id",
                                  "step_no",
                                  "supervisor_id",
                                  "worker_id",
                                  "due_date",
                                  "proposed_action",
                                  "status",
                                  "done_date",
                                  "outcome_note",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "deviation_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "step_no": 1,
                        "supervisor_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "worker_id": null,
                        "due_date": "2026-10-08",
                        "proposed_action": "Byt lampa",
                        "status": "planned",
                        "done_date": null,
                        "outcome_note": null,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`AVVIKELSE_SAKNAS` — Avvikelsen finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "AVVIKELSE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "AVVIKELSE_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "deviations:read",
        "x-fixra-rpc": "api_deviation_actions_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/deviations/{id}/actions\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createDeviationAction",
        "tags": [
          "Avvikelser"
        ],
        "summary": "Lägg till åtgärd",
        "description": "Lägger ett åtgärdssteg genom `deviation_action_save`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "proposed_action": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "supervisor_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "worker_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "due_date": {
                    "type": "string",
                    "format": "date"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "planned",
                      "in_progress",
                      "done",
                      "cancelled"
                    ]
                  },
                  "step_no": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 99
                  },
                  "outcome_note": {
                    "type": "string",
                    "maxLength": 2000
                  }
                },
                "required": [
                  "proposed_action"
                ],
                "additionalProperties": false
              },
              "example": {
                "proposed_action": "Byt lampa",
                "due_date": "2026-10-08"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "deviation_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "step_no": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "supervisor_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "worker_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "due_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "proposed_action": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "done_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "outcome_note": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "deviation_id",
                            "step_no",
                            "supervisor_id",
                            "worker_id",
                            "due_date",
                            "proposed_action",
                            "status",
                            "done_date",
                            "outcome_note",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "deviation_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "step_no": 1,
                    "supervisor_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "worker_id": null,
                    "due_date": "2026-10-08",
                    "proposed_action": "Byt lampa",
                    "status": "planned",
                    "done_date": null,
                    "outcome_note": null,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`AVVIKELSE_SAKNAS` — Avvikelsen finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "AVVIKELSE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "AVVIKELSE_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "deviations:write",
        "x-fixra-rpc": "api_deviation_actions_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/deviations/{id}/actions\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"proposed_action\":\"Byt lampa\",\"due_date\":\"2026-10-08\"}'"
          }
        ]
      }
    },
    "/v1/deviations/{id}/actions/{action_id}": {
      "delete": {
        "operationId": "deleteDeviationAction",
        "tags": [
          "Avvikelser"
        ],
        "summary": "Ta bort åtgärd",
        "description": "Tar bort ett åtgärdssteg genom `deviation_action_delete`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "action_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "deleted": {
                              "type": "boolean",
                              "const": true
                            },
                            "dry_run": {
                              "type": "boolean"
                            },
                            "idempotent": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "deleted",
                            "dry_run",
                            "idempotent"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "deleted": true,
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`AVVIKELSE_SAKNAS` — Avvikelsen finns inte i nyckelns bolag.\n\n`STEG_SAKNAS` — Åtgärden finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "AVVIKELSE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "AVVIKELSE_SAKNAS"
                      ]
                    }
                  },
                  "STEG_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STEG_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "deviations:write",
        "x-fixra-rpc": "api_deviation_actions_delete",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.fixra.se/v1/deviations/{id}/actions/{action_id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/deviation-types": {
      "get": {
        "operationId": "listDeviationTypes",
        "tags": [
          "Avvikelser"
        ],
        "summary": "Lista avvikelsetyper",
        "description": "Bolagets avvikelsetyper och undertyper (`parent_id`).",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "parent_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "label": {
                                    "type": "string"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_active": {
                                    "type": "boolean"
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "parent_id",
                                  "label",
                                  "sort_order",
                                  "is_active",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "parent_id": null,
                        "label": "Missad städning",
                        "sort_order": 1,
                        "is_active": true,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till är inte aktiv i bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "deviations:read",
        "x-fixra-rpc": "api_deviation_types_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/deviation-types\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/materials": {
      "get": {
        "operationId": "listMaterials",
        "tags": [
          "Material"
        ],
        "summary": "Lista artiklar",
        "description": "Materialregistret. Inköpspriset returneras aldrig. Kräver modulen Material.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "active",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "enum": [
                    "true",
                    "false"
                  ]
                }
              ]
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                }
              ],
              "description": "Slå upp på ert eget id (external_id)."
            },
            "description": "Slå upp på ert eget id (external_id)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "unit": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "sales_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_rebillable": {
                                    "type": "boolean"
                                  },
                                  "is_active": {
                                    "type": "boolean"
                                  },
                                  "external_id": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "unit",
                                  "sales_price_ore",
                                  "is_rebillable",
                                  "is_active",
                                  "external_id",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "name": "Allrengöring 5 l",
                        "unit": "st",
                        "sales_price_ore": 24900,
                        "is_rebillable": true,
                        "is_active": true,
                        "external_id": "ART-77",
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Material är inte aktiv i bolaget (`module: material`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "materials:read",
        "x-fixra-rpc": "api_materials_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/materials\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createMaterial",
        "tags": [
          "Material"
        ],
        "summary": "Skapa artikel",
        "description": "Skapar en artikel genom `material_item_save`. `purchase_price_ore` sparas men returneras aldrig.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "unit": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "purchase_price_ore": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "Skrivs men returneras aldrig."
                  },
                  "sales_price_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "is_rebillable": {
                    "type": "boolean"
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Slå upp på ert eget id (external_id)."
                  }
                },
                "required": [
                  "name"
                ],
                "additionalProperties": false
              },
              "example": {
                "name": "Allrengöring 5 l",
                "unit": "st",
                "purchase_price_ore": 12000,
                "sales_price_ore": 24900,
                "external_id": "ART-77"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "unit": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sales_price_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "is_rebillable": {
                              "type": "boolean"
                            },
                            "is_active": {
                              "type": "boolean"
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "unit",
                            "sales_price_ore",
                            "is_rebillable",
                            "is_active",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "name": "Allrengöring 5 l",
                    "unit": "st",
                    "sales_price_ore": 24900,
                    "is_rebillable": true,
                    "is_active": true,
                    "external_id": "ART-77",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Material är inte aktiv i bolaget (`module: material`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`ARTIKEL_FINNS_REDAN` — En artikel med samma namn finns.\n\n`OGILTIGT_PRIS` — Priset är ogiltigt.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARTIKEL_FINNS_REDAN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARTIKEL_FINNS_REDAN"
                      ]
                    }
                  },
                  "OGILTIGT_PRIS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIGT_PRIS"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "materials:write",
        "x-fixra-rpc": "api_materials_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/materials\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Allrengöring 5 l\",\"unit\":\"st\",\"purchase_price_ore\":12000,\"sales_price_ore\":24900,\"external_id\":\"ART-77\"}'"
          }
        ]
      }
    },
    "/v1/materials/{id}": {
      "patch": {
        "operationId": "updateMaterial",
        "tags": [
          "Material"
        ],
        "summary": "Ändra artikel",
        "description": "Ändrar skickade fält; övriga behåller sitt värde.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "unit": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "purchase_price_ore": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "Skrivs men returneras aldrig."
                  },
                  "sales_price_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "is_rebillable": {
                    "type": "boolean"
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Slå upp på ert eget id (external_id)."
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "sales_price_ore": 25900
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "unit": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sales_price_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "is_rebillable": {
                              "type": "boolean"
                            },
                            "is_active": {
                              "type": "boolean"
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "unit",
                            "sales_price_ore",
                            "is_rebillable",
                            "is_active",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "name": "Allrengöring 5 l",
                    "unit": "st",
                    "sales_price_ore": 25900,
                    "is_rebillable": true,
                    "is_active": true,
                    "external_id": "ART-77",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Material är inte aktiv i bolaget (`module: material`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARTIKEL_SAKNAS` — Artikeln finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARTIKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARTIKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`OGILTIGT_PRIS` — Priset är ogiltigt.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OGILTIGT_PRIS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIGT_PRIS"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "materials:write",
        "x-fixra-rpc": "api_materials_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/materials/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"sales_price_ore\":25900}'"
          }
        ]
      }
    },
    "/v1/material-usage": {
      "get": {
        "operationId": "listMaterialUsage",
        "tags": [
          "Material"
        ],
        "summary": "Lista materialåtgång",
        "description": "Registrerad åtgång per arbetsorder eller plats. Inköpspriset returneras aldrig.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "work_order_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "site_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "material_item_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "material_item_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "site_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "used_on": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "sales_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_rebillable": {
                                    "type": "boolean"
                                  },
                                  "registered_by": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "invoiced": {
                                    "type": "boolean"
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "material_item_id",
                                  "work_order_id",
                                  "site_id",
                                  "used_on",
                                  "quantity",
                                  "unit",
                                  "sales_price_ore",
                                  "is_rebillable",
                                  "registered_by",
                                  "invoiced",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "site_id": null,
                        "used_on": "2026-10-05",
                        "quantity": 2,
                        "unit": "st",
                        "sales_price_ore": 24900,
                        "is_rebillable": true,
                        "registered_by": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "invoiced": false,
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Material är inte aktiv i bolaget (`module: material`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "materials:read",
        "x-fixra-rpc": "api_material_usage_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/material-usage\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createMaterialUsage",
        "tags": [
          "Material"
        ],
        "summary": "Registrera materialåtgång",
        "description": "Registrerar åtgång genom `material_usage_register`. Priset fryses från artikeln.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "material_item_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "quantity": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "work_order_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "site_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "used_on": {
                    "type": "string",
                    "format": "date"
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 2000
                  }
                },
                "required": [
                  "material_item_id",
                  "quantity"
                ],
                "additionalProperties": false
              },
              "example": {
                "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "quantity": 2,
                "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "material_item_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "used_on": {
                              "type": "string"
                            },
                            "quantity": {
                              "type": "number"
                            },
                            "unit": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sales_price_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "is_rebillable": {
                              "type": "boolean"
                            },
                            "registered_by": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "invoiced": {
                              "type": "boolean"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "material_item_id",
                            "work_order_id",
                            "site_id",
                            "used_on",
                            "quantity",
                            "unit",
                            "sales_price_ore",
                            "is_rebillable",
                            "registered_by",
                            "invoiced",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": null,
                    "used_on": "2026-10-05",
                    "quantity": 2,
                    "unit": "st",
                    "sales_price_ore": 24900,
                    "is_rebillable": true,
                    "registered_by": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "invoiced": false,
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Material är inte aktiv i bolaget (`module: material`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARTIKEL_SAKNAS` — Artikeln finns inte i nyckelns bolag.\n\n`ARBETSORDER_SAKNAS` — Arbetsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARTIKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARTIKEL_SAKNAS"
                      ]
                    }
                  },
                  "ARBETSORDER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`ARTIKEL_INAKTIV` — Artikeln är inaktiv.\n\n`OBJEKT_ELLER_ARBETSORDER_KRAVS` — Ange arbetsorder eller plats.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARTIKEL_INAKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARTIKEL_INAKTIV"
                      ]
                    }
                  },
                  "OBJEKT_ELLER_ARBETSORDER_KRAVS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OBJEKT_ELLER_ARBETSORDER_KRAVS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "materials:write",
        "x-fixra-rpc": "api_material_usage_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/material-usage\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"material_item_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"quantity\":2,\"work_order_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\"}'"
          }
        ]
      }
    },
    "/v1/suppliers": {
      "get": {
        "operationId": "listSuppliers",
        "tags": [
          "Leverantörer"
        ],
        "summary": "Lista leverantörer",
        "description": "Leverantörsregistret. Kräver modulen Inköp.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "active",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "enum": [
                    "true",
                    "false"
                  ]
                }
              ]
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                }
              ],
              "description": "Slå upp på ert eget id (external_id)."
            },
            "description": "Slå upp på ert eget id (external_id)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "org_number": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "contact_name": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "email": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "phone": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "payment_terms_days": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_active": {
                                    "type": "boolean"
                                  },
                                  "external_id": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "org_number",
                                  "contact_name",
                                  "email",
                                  "phone",
                                  "payment_terms_days",
                                  "is_active",
                                  "external_id",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "name": "Grossisten AB",
                        "org_number": "556677-8899",
                        "contact_name": "Per Ek",
                        "email": "order@grossisten.se",
                        "phone": "+46812345678",
                        "payment_terms_days": 30,
                        "is_active": true,
                        "external_id": "LEV-4",
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "suppliers:read",
        "x-fixra-rpc": "api_suppliers_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/suppliers\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createSupplier",
        "tags": [
          "Leverantörer"
        ],
        "summary": "Skapa leverantör",
        "description": "Skapar en leverantör genom `supplier_save`.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "org_number": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "contact_name": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 200
                  },
                  "phone": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "payment_terms_days": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 365
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Slå upp på ert eget id (external_id)."
                  }
                },
                "required": [
                  "name"
                ],
                "additionalProperties": false
              },
              "example": {
                "name": "Grossisten AB",
                "email": "order@grossisten.se",
                "external_id": "LEV-4"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "org_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "contact_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "email": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "phone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "payment_terms_days": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "is_active": {
                              "type": "boolean"
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "org_number",
                            "contact_name",
                            "email",
                            "phone",
                            "payment_terms_days",
                            "is_active",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "name": "Grossisten AB",
                    "org_number": "556677-8899",
                    "contact_name": "Per Ek",
                    "email": "order@grossisten.se",
                    "phone": "+46812345678",
                    "payment_terms_days": 30,
                    "is_active": true,
                    "external_id": "LEV-4",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`LEVERANTOR_FINNS_REDAN` — Leverantören finns redan.\n\n`NAMN_SAKNAS` — Namn saknas.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "LEVERANTOR_FINNS_REDAN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "LEVERANTOR_FINNS_REDAN"
                      ]
                    }
                  },
                  "NAMN_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NAMN_SAKNAS"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "suppliers:write",
        "x-fixra-rpc": "api_suppliers_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/suppliers\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Grossisten AB\",\"email\":\"order@grossisten.se\",\"external_id\":\"LEV-4\"}'"
          }
        ]
      }
    },
    "/v1/suppliers/{id}": {
      "patch": {
        "operationId": "updateSupplier",
        "tags": [
          "Leverantörer"
        ],
        "summary": "Ändra leverantör",
        "description": "Ändrar skickade fält genom `supplier_save`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "org_number": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "contact_name": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 200
                  },
                  "phone": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "payment_terms_days": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 365
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Slå upp på ert eget id (external_id)."
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "payment_terms_days": 20
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "org_number": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "contact_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "email": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "phone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "payment_terms_days": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "is_active": {
                              "type": "boolean"
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "org_number",
                            "contact_name",
                            "email",
                            "phone",
                            "payment_terms_days",
                            "is_active",
                            "external_id",
                            "created_at",
                            "updated_at"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "name": "Grossisten AB",
                    "org_number": "556677-8899",
                    "contact_name": "Per Ek",
                    "email": "order@grossisten.se",
                    "phone": "+46812345678",
                    "payment_terms_days": 20,
                    "is_active": true,
                    "external_id": "LEV-4",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`LEVERANTOR_SAKNAS` — Leverantören finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "LEVERANTOR_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "LEVERANTOR_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "suppliers:write",
        "x-fixra-rpc": "api_suppliers_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/suppliers/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"payment_terms_days\":20}'"
          }
        ]
      }
    },
    "/v1/purchase-orders": {
      "get": {
        "operationId": "listPurchaseOrders",
        "tags": [
          "Inköpsorder"
        ],
        "summary": "Lista inköpsorder",
        "description": "Inköpsorder utan rader. Kräver modulen Inköp.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 40
                }
              ]
            }
          },
          {
            "name": "supplier_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "work_order_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                }
              ],
              "description": "Slå upp på ert eget id (external_id)."
            },
            "description": "Slå upp på ert eget id (external_id)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "order_number": {
                                    "type": "string"
                                  },
                                  "supplier_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "draft",
                                      "sent",
                                      "confirmed",
                                      "cancelled"
                                    ]
                                  },
                                  "wanted_delivery_on": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "confirmed_delivery_on": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "site_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "supplier_reference": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "sent_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "cancelled_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "cancel_reason": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "net_amount_ore": {
                                    "type": "integer"
                                  },
                                  "external_id": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "order_number",
                                  "supplier_id",
                                  "status",
                                  "wanted_delivery_on",
                                  "confirmed_delivery_on",
                                  "work_order_id",
                                  "site_id",
                                  "supplier_reference",
                                  "sent_at",
                                  "confirmed_at",
                                  "cancelled_at",
                                  "cancel_reason",
                                  "net_amount_ore",
                                  "external_id",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "order_number": "IO-1004",
                        "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "status": "draft",
                        "wanted_delivery_on": "2026-10-08",
                        "confirmed_delivery_on": null,
                        "work_order_id": null,
                        "site_id": null,
                        "supplier_reference": null,
                        "sent_at": null,
                        "confirmed_at": null,
                        "cancelled_at": null,
                        "cancel_reason": null,
                        "net_amount_ore": 120000,
                        "external_id": "PO-88",
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "purchase_orders:read",
        "x-fixra-rpc": "api_purchase_orders_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/purchase-orders\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createPurchaseOrder",
        "tags": [
          "Inköpsorder"
        ],
        "summary": "Skapa inköpsorder",
        "description": "Skapar ett utkast genom `purchase_order_save`.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "supplier_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "wanted_delivery_on": {
                    "type": "string",
                    "format": "date"
                  },
                  "work_order_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "site_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Slå upp på ert eget id (external_id)."
                  }
                },
                "required": [
                  "supplier_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "wanted_delivery_on": "2026-10-08",
                "external_id": "PO-88"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "order_number": {
                              "type": "string"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "sent",
                                "confirmed",
                                "cancelled"
                              ]
                            },
                            "wanted_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "confirmed_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "supplier_reference": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sent_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "confirmed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancelled_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancel_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "confirmed_unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "outstanding_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "has_quantity_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "has_price_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "material_item_id",
                                  "description",
                                  "quantity",
                                  "unit",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "confirmed_quantity",
                                  "confirmed_unit_price_ore",
                                  "confirmed_net_amount_ore",
                                  "outstanding_quantity",
                                  "has_quantity_deviation",
                                  "has_price_deviation",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "order_number",
                            "supplier_id",
                            "status",
                            "wanted_delivery_on",
                            "confirmed_delivery_on",
                            "work_order_id",
                            "site_id",
                            "supplier_reference",
                            "sent_at",
                            "confirmed_at",
                            "cancelled_at",
                            "cancel_reason",
                            "net_amount_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "order_number": "IO-1004",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "status": "draft",
                    "wanted_delivery_on": "2026-10-08",
                    "confirmed_delivery_on": null,
                    "work_order_id": null,
                    "site_id": null,
                    "supplier_reference": null,
                    "sent_at": null,
                    "confirmed_at": null,
                    "cancelled_at": null,
                    "cancel_reason": null,
                    "net_amount_ore": 120000,
                    "external_id": "PO-88",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`LEVERANTOR_SAKNAS` — Leverantören finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "LEVERANTOR_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "LEVERANTOR_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "purchase_orders:write",
        "x-fixra-rpc": "api_purchase_orders_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/purchase-orders\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"supplier_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"wanted_delivery_on\":\"2026-10-08\",\"external_id\":\"PO-88\"}'"
          }
        ]
      }
    },
    "/v1/purchase-orders/{id}": {
      "get": {
        "operationId": "getPurchaseOrder",
        "tags": [
          "Inköpsorder"
        ],
        "summary": "Hämta inköpsorder",
        "description": "En inköpsorder med rader och bekräftade avvikelser.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "order_number": {
                              "type": "string"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "sent",
                                "confirmed",
                                "cancelled"
                              ]
                            },
                            "wanted_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "confirmed_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "supplier_reference": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sent_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "confirmed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancelled_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancel_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "confirmed_unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "outstanding_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "has_quantity_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "has_price_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "material_item_id",
                                  "description",
                                  "quantity",
                                  "unit",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "confirmed_quantity",
                                  "confirmed_unit_price_ore",
                                  "confirmed_net_amount_ore",
                                  "outstanding_quantity",
                                  "has_quantity_deviation",
                                  "has_price_deviation",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "order_number",
                            "supplier_id",
                            "status",
                            "wanted_delivery_on",
                            "confirmed_delivery_on",
                            "work_order_id",
                            "site_id",
                            "supplier_reference",
                            "sent_at",
                            "confirmed_at",
                            "cancelled_at",
                            "cancel_reason",
                            "net_amount_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "order_number": "IO-1004",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "status": "draft",
                    "wanted_delivery_on": "2026-10-08",
                    "confirmed_delivery_on": null,
                    "work_order_id": null,
                    "site_id": null,
                    "supplier_reference": null,
                    "sent_at": null,
                    "confirmed_at": null,
                    "cancelled_at": null,
                    "cancel_reason": null,
                    "net_amount_ore": 120000,
                    "external_id": "PO-88",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "description": "Allrengöring 5 l",
                        "quantity": 10,
                        "unit": "st",
                        "unit_price_ore": 12000,
                        "net_amount_ore": 120000,
                        "confirmed_quantity": null,
                        "confirmed_unit_price_ore": null,
                        "confirmed_net_amount_ore": null,
                        "outstanding_quantity": null,
                        "has_quantity_deviation": false,
                        "has_price_deviation": false,
                        "sort_order": 1
                      }
                    ]
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`BESTALLNING_SAKNAS` — Inköpsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESTALLNING_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNING_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "purchase_orders:read",
        "x-fixra-rpc": "api_purchase_orders_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/purchase-orders/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "patch": {
        "operationId": "updatePurchaseOrder",
        "tags": [
          "Inköpsorder"
        ],
        "summary": "Ändra inköpsorder",
        "description": "Ändrar ett utkast.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "supplier_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "wanted_delivery_on": {
                    "type": "string",
                    "format": "date"
                  },
                  "work_order_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "site_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Slå upp på ert eget id (external_id)."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "wanted_delivery_on": "2026-10-09"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "order_number": {
                              "type": "string"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "sent",
                                "confirmed",
                                "cancelled"
                              ]
                            },
                            "wanted_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "confirmed_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "supplier_reference": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sent_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "confirmed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancelled_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancel_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "confirmed_unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "outstanding_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "has_quantity_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "has_price_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "material_item_id",
                                  "description",
                                  "quantity",
                                  "unit",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "confirmed_quantity",
                                  "confirmed_unit_price_ore",
                                  "confirmed_net_amount_ore",
                                  "outstanding_quantity",
                                  "has_quantity_deviation",
                                  "has_price_deviation",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "order_number",
                            "supplier_id",
                            "status",
                            "wanted_delivery_on",
                            "confirmed_delivery_on",
                            "work_order_id",
                            "site_id",
                            "supplier_reference",
                            "sent_at",
                            "confirmed_at",
                            "cancelled_at",
                            "cancel_reason",
                            "net_amount_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "order_number": "IO-1004",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "status": "draft",
                    "wanted_delivery_on": "2026-10-08",
                    "confirmed_delivery_on": null,
                    "work_order_id": null,
                    "site_id": null,
                    "supplier_reference": null,
                    "sent_at": null,
                    "confirmed_at": null,
                    "cancelled_at": null,
                    "cancel_reason": null,
                    "net_amount_ore": 120000,
                    "external_id": "PO-88",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "description": "Allrengöring 5 l",
                        "quantity": 10,
                        "unit": "st",
                        "unit_price_ore": 12000,
                        "net_amount_ore": 120000,
                        "confirmed_quantity": null,
                        "confirmed_unit_price_ore": null,
                        "confirmed_net_amount_ore": null,
                        "outstanding_quantity": null,
                        "has_quantity_deviation": false,
                        "has_price_deviation": false,
                        "sort_order": 1
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`BESTALLNING_SAKNAS` — Inköpsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESTALLNING_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNING_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`BESTALLNING_EJ_UTKAST` — Bara utkast kan ändras.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESTALLNING_EJ_UTKAST": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNING_EJ_UTKAST"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "purchase_orders:write",
        "x-fixra-rpc": "api_purchase_orders_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/purchase-orders/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"wanted_delivery_on\":\"2026-10-09\"}'"
          }
        ]
      }
    },
    "/v1/purchase-orders/{id}/lines": {
      "post": {
        "operationId": "createPurchaseOrderLine",
        "tags": [
          "Inköpsorder"
        ],
        "summary": "Lägg till rad",
        "description": "Lägger till en rad genom `purchase_order_line_save`. Svaret är hela ordern.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "description": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "quantity": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "unit": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "unit_price_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "material_item_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "sort_order": {
                    "type": "integer"
                  }
                },
                "required": [
                  "description",
                  "quantity",
                  "unit_price_ore"
                ],
                "additionalProperties": false
              },
              "example": {
                "description": "Allrengöring 5 l",
                "quantity": 10,
                "unit_price_ore": 12000
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "order_number": {
                              "type": "string"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "sent",
                                "confirmed",
                                "cancelled"
                              ]
                            },
                            "wanted_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "confirmed_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "supplier_reference": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sent_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "confirmed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancelled_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancel_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "confirmed_unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "outstanding_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "has_quantity_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "has_price_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "material_item_id",
                                  "description",
                                  "quantity",
                                  "unit",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "confirmed_quantity",
                                  "confirmed_unit_price_ore",
                                  "confirmed_net_amount_ore",
                                  "outstanding_quantity",
                                  "has_quantity_deviation",
                                  "has_price_deviation",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "order_number",
                            "supplier_id",
                            "status",
                            "wanted_delivery_on",
                            "confirmed_delivery_on",
                            "work_order_id",
                            "site_id",
                            "supplier_reference",
                            "sent_at",
                            "confirmed_at",
                            "cancelled_at",
                            "cancel_reason",
                            "net_amount_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "order_number": "IO-1004",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "status": "draft",
                    "wanted_delivery_on": "2026-10-08",
                    "confirmed_delivery_on": null,
                    "work_order_id": null,
                    "site_id": null,
                    "supplier_reference": null,
                    "sent_at": null,
                    "confirmed_at": null,
                    "cancelled_at": null,
                    "cancel_reason": null,
                    "net_amount_ore": 120000,
                    "external_id": "PO-88",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "description": "Allrengöring 5 l",
                        "quantity": 10,
                        "unit": "st",
                        "unit_price_ore": 12000,
                        "net_amount_ore": 120000,
                        "confirmed_quantity": null,
                        "confirmed_unit_price_ore": null,
                        "confirmed_net_amount_ore": null,
                        "outstanding_quantity": null,
                        "has_quantity_deviation": false,
                        "has_price_deviation": false,
                        "sort_order": 1
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`BESTALLNING_SAKNAS` — Inköpsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESTALLNING_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNING_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`BESTALLNING_EJ_UTKAST` — Bara utkast kan ändras.\n\n`PRIS_SAKNAS` — Pris saknas.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESTALLNING_EJ_UTKAST": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNING_EJ_UTKAST"
                      ]
                    }
                  },
                  "PRIS_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PRIS_SAKNAS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "purchase_orders:write",
        "x-fixra-rpc": "api_purchase_order_lines_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/purchase-orders/{id}/lines\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"description\":\"Allrengöring 5 l\",\"quantity\":10,\"unit_price_ore\":12000}'"
          }
        ]
      }
    },
    "/v1/purchase-orders/{id}/lines/{line_id}": {
      "patch": {
        "operationId": "updatePurchaseOrderLine",
        "tags": [
          "Inköpsorder"
        ],
        "summary": "Ändra rad",
        "description": "Ändrar en rad på ett utkast.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "line_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "description": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "quantity": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "unit": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "unit_price_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "material_item_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "sort_order": {
                    "type": "integer"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "quantity": 12
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "order_number": {
                              "type": "string"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "sent",
                                "confirmed",
                                "cancelled"
                              ]
                            },
                            "wanted_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "confirmed_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "supplier_reference": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sent_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "confirmed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancelled_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancel_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "confirmed_unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "outstanding_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "has_quantity_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "has_price_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "material_item_id",
                                  "description",
                                  "quantity",
                                  "unit",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "confirmed_quantity",
                                  "confirmed_unit_price_ore",
                                  "confirmed_net_amount_ore",
                                  "outstanding_quantity",
                                  "has_quantity_deviation",
                                  "has_price_deviation",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "order_number",
                            "supplier_id",
                            "status",
                            "wanted_delivery_on",
                            "confirmed_delivery_on",
                            "work_order_id",
                            "site_id",
                            "supplier_reference",
                            "sent_at",
                            "confirmed_at",
                            "cancelled_at",
                            "cancel_reason",
                            "net_amount_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "order_number": "IO-1004",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "status": "draft",
                    "wanted_delivery_on": "2026-10-08",
                    "confirmed_delivery_on": null,
                    "work_order_id": null,
                    "site_id": null,
                    "supplier_reference": null,
                    "sent_at": null,
                    "confirmed_at": null,
                    "cancelled_at": null,
                    "cancel_reason": null,
                    "net_amount_ore": 120000,
                    "external_id": "PO-88",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "description": "Allrengöring 5 l",
                        "quantity": 10,
                        "unit": "st",
                        "unit_price_ore": 12000,
                        "net_amount_ore": 120000,
                        "confirmed_quantity": null,
                        "confirmed_unit_price_ore": null,
                        "confirmed_net_amount_ore": null,
                        "outstanding_quantity": null,
                        "has_quantity_deviation": false,
                        "has_price_deviation": false,
                        "sort_order": 1
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`BESTALLNING_SAKNAS` — Inköpsordern finns inte i nyckelns bolag.\n\n`BESTALLNINGSRAD_SAKNAS` — Raden finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESTALLNING_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNING_SAKNAS"
                      ]
                    }
                  },
                  "BESTALLNINGSRAD_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNINGSRAD_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`BESTALLNING_EJ_UTKAST` — Bara utkast kan ändras.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESTALLNING_EJ_UTKAST": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNING_EJ_UTKAST"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "purchase_orders:write",
        "x-fixra-rpc": "api_purchase_order_lines_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/purchase-orders/{id}/lines/{line_id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"quantity\":12}'"
          }
        ]
      },
      "delete": {
        "operationId": "deletePurchaseOrderLine",
        "tags": [
          "Inköpsorder"
        ],
        "summary": "Ta bort rad",
        "description": "Tar bort en rad på ett utkast genom `purchase_order_line_delete`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "line_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "order_number": {
                              "type": "string"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "sent",
                                "confirmed",
                                "cancelled"
                              ]
                            },
                            "wanted_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "confirmed_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "supplier_reference": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sent_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "confirmed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancelled_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancel_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "confirmed_unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "outstanding_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "has_quantity_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "has_price_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "material_item_id",
                                  "description",
                                  "quantity",
                                  "unit",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "confirmed_quantity",
                                  "confirmed_unit_price_ore",
                                  "confirmed_net_amount_ore",
                                  "outstanding_quantity",
                                  "has_quantity_deviation",
                                  "has_price_deviation",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "order_number",
                            "supplier_id",
                            "status",
                            "wanted_delivery_on",
                            "confirmed_delivery_on",
                            "work_order_id",
                            "site_id",
                            "supplier_reference",
                            "sent_at",
                            "confirmed_at",
                            "cancelled_at",
                            "cancel_reason",
                            "net_amount_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "order_number": "IO-1004",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "status": "draft",
                    "wanted_delivery_on": "2026-10-08",
                    "confirmed_delivery_on": null,
                    "work_order_id": null,
                    "site_id": null,
                    "supplier_reference": null,
                    "sent_at": null,
                    "confirmed_at": null,
                    "cancelled_at": null,
                    "cancel_reason": null,
                    "net_amount_ore": 120000,
                    "external_id": "PO-88",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`BESTALLNING_SAKNAS` — Inköpsordern finns inte i nyckelns bolag.\n\n`BESTALLNINGSRAD_SAKNAS` — Raden finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESTALLNING_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNING_SAKNAS"
                      ]
                    }
                  },
                  "BESTALLNINGSRAD_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNINGSRAD_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`BESTALLNING_EJ_UTKAST` — Bara utkast kan ändras.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESTALLNING_EJ_UTKAST": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNING_EJ_UTKAST"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "purchase_orders:write",
        "x-fixra-rpc": "api_purchase_order_lines_delete",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.fixra.se/v1/purchase-orders/{id}/lines/{line_id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/purchase-orders/{id}/send": {
      "post": {
        "operationId": "sendPurchaseOrder",
        "tags": [
          "Inköpsorder"
        ],
        "summary": "Skicka inköpsorder",
        "description": "draft → sent genom `purchase_order_send`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "order_number": {
                              "type": "string"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "sent",
                                "confirmed",
                                "cancelled"
                              ]
                            },
                            "wanted_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "confirmed_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "supplier_reference": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sent_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "confirmed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancelled_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancel_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "confirmed_unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "outstanding_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "has_quantity_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "has_price_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "material_item_id",
                                  "description",
                                  "quantity",
                                  "unit",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "confirmed_quantity",
                                  "confirmed_unit_price_ore",
                                  "confirmed_net_amount_ore",
                                  "outstanding_quantity",
                                  "has_quantity_deviation",
                                  "has_price_deviation",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "order_number",
                            "supplier_id",
                            "status",
                            "wanted_delivery_on",
                            "confirmed_delivery_on",
                            "work_order_id",
                            "site_id",
                            "supplier_reference",
                            "sent_at",
                            "confirmed_at",
                            "cancelled_at",
                            "cancel_reason",
                            "net_amount_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "order_number": "IO-1004",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "status": "sent",
                    "wanted_delivery_on": "2026-10-08",
                    "confirmed_delivery_on": null,
                    "work_order_id": null,
                    "site_id": null,
                    "supplier_reference": null,
                    "sent_at": "2026-10-01T09:00:00+02:00",
                    "confirmed_at": null,
                    "cancelled_at": null,
                    "cancel_reason": null,
                    "net_amount_ore": 120000,
                    "external_id": "PO-88",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "description": "Allrengöring 5 l",
                        "quantity": 10,
                        "unit": "st",
                        "unit_price_ore": 12000,
                        "net_amount_ore": 120000,
                        "confirmed_quantity": null,
                        "confirmed_unit_price_ore": null,
                        "confirmed_net_amount_ore": null,
                        "outstanding_quantity": null,
                        "has_quantity_deviation": false,
                        "has_price_deviation": false,
                        "sort_order": 1
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`BESTALLNING_SAKNAS` — Inköpsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESTALLNING_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNING_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`BESTALLNING_EJ_UTKAST` — Ordern är inte ett utkast.\n\n`BESTALLNING_TOM` — Ordern saknar rader.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESTALLNING_EJ_UTKAST": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNING_EJ_UTKAST"
                      ]
                    }
                  },
                  "BESTALLNING_TOM": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNING_TOM"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "purchase_orders:write",
        "x-fixra-rpc": "api_purchase_orders_send",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/purchase-orders/{id}/send\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\""
          }
        ]
      }
    },
    "/v1/purchase-orders/{id}/cancel": {
      "post": {
        "operationId": "cancelPurchaseOrder",
        "tags": [
          "Inköpsorder"
        ],
        "summary": "Avboka inköpsorder",
        "description": "Avbokar genom `purchase_order_cancel`. Orsak krävs.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  }
                },
                "required": [
                  "reason"
                ],
                "additionalProperties": false
              },
              "example": {
                "reason": "Leverantören kan inte leverera i tid."
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "order_number": {
                              "type": "string"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "sent",
                                "confirmed",
                                "cancelled"
                              ]
                            },
                            "wanted_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "confirmed_delivery_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "work_order_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "supplier_reference": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sent_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "confirmed_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancelled_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cancel_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "confirmed_unit_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confirmed_net_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "outstanding_quantity": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "has_quantity_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "has_price_deviation": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "material_item_id",
                                  "description",
                                  "quantity",
                                  "unit",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "confirmed_quantity",
                                  "confirmed_unit_price_ore",
                                  "confirmed_net_amount_ore",
                                  "outstanding_quantity",
                                  "has_quantity_deviation",
                                  "has_price_deviation",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "order_number",
                            "supplier_id",
                            "status",
                            "wanted_delivery_on",
                            "confirmed_delivery_on",
                            "work_order_id",
                            "site_id",
                            "supplier_reference",
                            "sent_at",
                            "confirmed_at",
                            "cancelled_at",
                            "cancel_reason",
                            "net_amount_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "order_number": "IO-1004",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "status": "cancelled",
                    "wanted_delivery_on": "2026-10-08",
                    "confirmed_delivery_on": null,
                    "work_order_id": null,
                    "site_id": null,
                    "supplier_reference": null,
                    "sent_at": null,
                    "confirmed_at": null,
                    "cancelled_at": "2026-10-01T09:00:00+02:00",
                    "cancel_reason": "Leverantören kan inte leverera i tid.",
                    "net_amount_ore": 120000,
                    "external_id": "PO-88",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "description": "Allrengöring 5 l",
                        "quantity": 10,
                        "unit": "st",
                        "unit_price_ore": 12000,
                        "net_amount_ore": 120000,
                        "confirmed_quantity": null,
                        "confirmed_unit_price_ore": null,
                        "confirmed_net_amount_ore": null,
                        "outstanding_quantity": null,
                        "has_quantity_deviation": false,
                        "has_price_deviation": false,
                        "sort_order": 1
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`BESTALLNING_SAKNAS` — Inköpsordern finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESTALLNING_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNING_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`BESTALLNING_REDAN_AVBRUTEN` — Ordern är redan avbokad.\n\n`ORSAK_SAKNAS` — Orsak saknas.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BESTALLNING_REDAN_AVBRUTEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BESTALLNING_REDAN_AVBRUTEN"
                      ]
                    }
                  },
                  "ORSAK_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ORSAK_SAKNAS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "purchase_orders:write",
        "x-fixra-rpc": "api_purchase_orders_cancel",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/purchase-orders/{id}/cancel\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"reason\":\"Leverantören kan inte leverera i tid.\"}'"
          }
        ]
      }
    },
    "/v1/supplier-invoices": {
      "get": {
        "operationId": "listSupplierInvoices",
        "tags": [
          "Leverantörsfakturor"
        ],
        "summary": "Lista leverantörsfakturor",
        "description": "Fakturor utan rader. Kräver modulen Inköp.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 40
                }
              ]
            }
          },
          {
            "name": "supplier_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                }
              ],
              "description": "Slå upp på ert eget id (external_id)."
            },
            "description": "Slå upp på ert eget id (external_id)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "supplier_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "invoice_number": {
                                    "type": "string"
                                  },
                                  "invoice_date": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "due_date": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "net_amount_ore": {
                                    "type": "integer"
                                  },
                                  "vat_amount_ore": {
                                    "type": "integer"
                                  },
                                  "gross_amount_ore": {
                                    "type": "integer"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "draft",
                                      "pending_approval",
                                      "approved",
                                      "rejected"
                                    ]
                                  },
                                  "submitted_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "approved_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "rejection_reason": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "file_object_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "external_id": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "supplier_id",
                                  "invoice_number",
                                  "invoice_date",
                                  "due_date",
                                  "net_amount_ore",
                                  "vat_amount_ore",
                                  "gross_amount_ore",
                                  "status",
                                  "submitted_at",
                                  "approved_at",
                                  "rejection_reason",
                                  "file_object_id",
                                  "external_id",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "invoice_number": "F-20931",
                        "invoice_date": "2026-10-02",
                        "due_date": "2026-11-01",
                        "net_amount_ore": 120000,
                        "vat_amount_ore": 30000,
                        "gross_amount_ore": 150000,
                        "status": "draft",
                        "submitted_at": null,
                        "approved_at": null,
                        "rejection_reason": null,
                        "file_object_id": null,
                        "external_id": "LF-20931",
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "supplier_invoices:read",
        "x-fixra-rpc": "api_supplier_invoices_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/supplier-invoices\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createSupplierInvoice",
        "tags": [
          "Leverantörsfakturor"
        ],
        "summary": "Registrera leverantörsfaktura",
        "description": "Skapar ett utkast genom `supplier_invoice_save`.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "supplier_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "invoice_number": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "invoice_date": {
                    "type": "string",
                    "format": "date"
                  },
                  "due_date": {
                    "type": "string",
                    "format": "date"
                  },
                  "net_amount_ore": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  },
                  "vat_amount_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "gross_amount_ore": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  },
                  "file_object_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Slå upp på ert eget id (external_id)."
                  }
                },
                "required": [
                  "supplier_id",
                  "invoice_number",
                  "net_amount_ore",
                  "vat_amount_ore",
                  "gross_amount_ore"
                ],
                "additionalProperties": false
              },
              "example": {
                "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "invoice_number": "F-20931",
                "net_amount_ore": 120000,
                "vat_amount_ore": 30000,
                "gross_amount_ore": 150000
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "invoice_number": {
                              "type": "string"
                            },
                            "invoice_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "due_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "vat_amount_ore": {
                              "type": "integer"
                            },
                            "gross_amount_ore": {
                              "type": "integer"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "pending_approval",
                                "approved",
                                "rejected"
                              ]
                            },
                            "submitted_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "approved_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "rejection_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "file_object_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit_price_ore": {
                                    "type": "integer"
                                  },
                                  "net_amount_ore": {
                                    "type": "integer"
                                  },
                                  "vat_rate": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "vat_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "purchase_order_line_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_rebillable": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sales_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "invoiced": {
                                    "type": "boolean"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "description",
                                  "quantity",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "vat_rate",
                                  "vat_amount_ore",
                                  "work_order_id",
                                  "material_item_id",
                                  "purchase_order_line_id",
                                  "is_rebillable",
                                  "sales_price_ore",
                                  "invoiced",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "supplier_id",
                            "invoice_number",
                            "invoice_date",
                            "due_date",
                            "net_amount_ore",
                            "vat_amount_ore",
                            "gross_amount_ore",
                            "status",
                            "submitted_at",
                            "approved_at",
                            "rejection_reason",
                            "file_object_id",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "invoice_number": "F-20931",
                    "invoice_date": "2026-10-02",
                    "due_date": "2026-11-01",
                    "net_amount_ore": 120000,
                    "vat_amount_ore": 30000,
                    "gross_amount_ore": 150000,
                    "status": "draft",
                    "submitted_at": null,
                    "approved_at": null,
                    "rejection_reason": null,
                    "file_object_id": null,
                    "external_id": "LF-20931",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`LEVERANTOR_SAKNAS` — Leverantören finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "LEVERANTOR_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "LEVERANTOR_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`BRUTTO_STAMMER_INTE` — Netto + moms ≠ brutto.\n\n`DUBBLETT_FAKTURANUMMER` — Fakturanumret finns redan för leverantören.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BRUTTO_STAMMER_INTE": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BRUTTO_STAMMER_INTE"
                      ]
                    }
                  },
                  "DUBBLETT_FAKTURANUMMER": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "DUBBLETT_FAKTURANUMMER"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "supplier_invoices:write",
        "x-fixra-rpc": "api_supplier_invoices_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/supplier-invoices\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"supplier_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"invoice_number\":\"F-20931\",\"net_amount_ore\":120000,\"vat_amount_ore\":30000,\"gross_amount_ore\":150000}'"
          }
        ]
      }
    },
    "/v1/supplier-invoices/{id}": {
      "get": {
        "operationId": "getSupplierInvoice",
        "tags": [
          "Leverantörsfakturor"
        ],
        "summary": "Hämta leverantörsfaktura",
        "description": "En faktura med rader.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "invoice_number": {
                              "type": "string"
                            },
                            "invoice_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "due_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "vat_amount_ore": {
                              "type": "integer"
                            },
                            "gross_amount_ore": {
                              "type": "integer"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "pending_approval",
                                "approved",
                                "rejected"
                              ]
                            },
                            "submitted_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "approved_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "rejection_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "file_object_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit_price_ore": {
                                    "type": "integer"
                                  },
                                  "net_amount_ore": {
                                    "type": "integer"
                                  },
                                  "vat_rate": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "vat_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "purchase_order_line_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_rebillable": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sales_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "invoiced": {
                                    "type": "boolean"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "description",
                                  "quantity",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "vat_rate",
                                  "vat_amount_ore",
                                  "work_order_id",
                                  "material_item_id",
                                  "purchase_order_line_id",
                                  "is_rebillable",
                                  "sales_price_ore",
                                  "invoiced",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "supplier_id",
                            "invoice_number",
                            "invoice_date",
                            "due_date",
                            "net_amount_ore",
                            "vat_amount_ore",
                            "gross_amount_ore",
                            "status",
                            "submitted_at",
                            "approved_at",
                            "rejection_reason",
                            "file_object_id",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "invoice_number": "F-20931",
                    "invoice_date": "2026-10-02",
                    "due_date": "2026-11-01",
                    "net_amount_ore": 120000,
                    "vat_amount_ore": 30000,
                    "gross_amount_ore": 150000,
                    "status": "draft",
                    "submitted_at": null,
                    "approved_at": null,
                    "rejection_reason": null,
                    "file_object_id": null,
                    "external_id": "LF-20931",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "description": "Allrengöring 5 l",
                        "quantity": 10,
                        "unit_price_ore": 12000,
                        "net_amount_ore": 120000,
                        "vat_rate": 25,
                        "vat_amount_ore": 30000,
                        "work_order_id": null,
                        "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "purchase_order_line_id": null,
                        "is_rebillable": false,
                        "sales_price_ore": null,
                        "invoiced": false,
                        "sort_order": 1
                      }
                    ]
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`FAKTURA_SAKNAS` — Leverantörsfakturan finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FAKTURA_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FAKTURA_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "supplier_invoices:read",
        "x-fixra-rpc": "api_supplier_invoices_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/supplier-invoices/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "patch": {
        "operationId": "updateSupplierInvoice",
        "tags": [
          "Leverantörsfakturor"
        ],
        "summary": "Ändra leverantörsfaktura",
        "description": "Ändrar ett utkast eller en avslagen faktura.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "supplier_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "invoice_number": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "invoice_date": {
                    "type": "string",
                    "format": "date"
                  },
                  "due_date": {
                    "type": "string",
                    "format": "date"
                  },
                  "net_amount_ore": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  },
                  "vat_amount_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "gross_amount_ore": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  },
                  "file_object_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Slå upp på ert eget id (external_id)."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "due_date": "2026-11-05"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "invoice_number": {
                              "type": "string"
                            },
                            "invoice_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "due_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "vat_amount_ore": {
                              "type": "integer"
                            },
                            "gross_amount_ore": {
                              "type": "integer"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "pending_approval",
                                "approved",
                                "rejected"
                              ]
                            },
                            "submitted_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "approved_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "rejection_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "file_object_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit_price_ore": {
                                    "type": "integer"
                                  },
                                  "net_amount_ore": {
                                    "type": "integer"
                                  },
                                  "vat_rate": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "vat_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "purchase_order_line_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_rebillable": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sales_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "invoiced": {
                                    "type": "boolean"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "description",
                                  "quantity",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "vat_rate",
                                  "vat_amount_ore",
                                  "work_order_id",
                                  "material_item_id",
                                  "purchase_order_line_id",
                                  "is_rebillable",
                                  "sales_price_ore",
                                  "invoiced",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "supplier_id",
                            "invoice_number",
                            "invoice_date",
                            "due_date",
                            "net_amount_ore",
                            "vat_amount_ore",
                            "gross_amount_ore",
                            "status",
                            "submitted_at",
                            "approved_at",
                            "rejection_reason",
                            "file_object_id",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "invoice_number": "F-20931",
                    "invoice_date": "2026-10-02",
                    "due_date": "2026-11-01",
                    "net_amount_ore": 120000,
                    "vat_amount_ore": 30000,
                    "gross_amount_ore": 150000,
                    "status": "draft",
                    "submitted_at": null,
                    "approved_at": null,
                    "rejection_reason": null,
                    "file_object_id": null,
                    "external_id": "LF-20931",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "description": "Allrengöring 5 l",
                        "quantity": 10,
                        "unit_price_ore": 12000,
                        "net_amount_ore": 120000,
                        "vat_rate": 25,
                        "vat_amount_ore": 30000,
                        "work_order_id": null,
                        "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "purchase_order_line_id": null,
                        "is_rebillable": false,
                        "sales_price_ore": null,
                        "invoiced": false,
                        "sort_order": 1
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`FAKTURA_SAKNAS` — Leverantörsfakturan finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FAKTURA_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FAKTURA_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`FEL_STATUS_FOR_ANDRING` — Fakturan kan inte ändras i sin status.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FEL_STATUS_FOR_ANDRING": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FEL_STATUS_FOR_ANDRING"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "supplier_invoices:write",
        "x-fixra-rpc": "api_supplier_invoices_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/supplier-invoices/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"due_date\":\"2026-11-05\"}'"
          }
        ]
      }
    },
    "/v1/supplier-invoices/{id}/lines": {
      "post": {
        "operationId": "createSupplierInvoiceLine",
        "tags": [
          "Leverantörsfakturor"
        ],
        "summary": "Lägg till fakturarad",
        "description": "Lägger till en rad genom `supplier_invoice_line_save`. Vidarefakturering kräver arbetsorder och försäljningspris.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "description": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "quantity": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "unit_price_ore": {
                    "type": "integer"
                  },
                  "vat_rate": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "work_order_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "material_item_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "purchase_order_line_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "is_rebillable": {
                    "type": "boolean"
                  },
                  "sales_price_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "sort_order": {
                    "type": "integer"
                  }
                },
                "required": [
                  "description",
                  "quantity",
                  "unit_price_ore"
                ],
                "additionalProperties": false
              },
              "example": {
                "description": "Allrengöring 5 l",
                "quantity": 10,
                "unit_price_ore": 12000,
                "vat_rate": 25
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "invoice_number": {
                              "type": "string"
                            },
                            "invoice_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "due_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "vat_amount_ore": {
                              "type": "integer"
                            },
                            "gross_amount_ore": {
                              "type": "integer"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "pending_approval",
                                "approved",
                                "rejected"
                              ]
                            },
                            "submitted_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "approved_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "rejection_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "file_object_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit_price_ore": {
                                    "type": "integer"
                                  },
                                  "net_amount_ore": {
                                    "type": "integer"
                                  },
                                  "vat_rate": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "vat_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "purchase_order_line_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_rebillable": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sales_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "invoiced": {
                                    "type": "boolean"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "description",
                                  "quantity",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "vat_rate",
                                  "vat_amount_ore",
                                  "work_order_id",
                                  "material_item_id",
                                  "purchase_order_line_id",
                                  "is_rebillable",
                                  "sales_price_ore",
                                  "invoiced",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "supplier_id",
                            "invoice_number",
                            "invoice_date",
                            "due_date",
                            "net_amount_ore",
                            "vat_amount_ore",
                            "gross_amount_ore",
                            "status",
                            "submitted_at",
                            "approved_at",
                            "rejection_reason",
                            "file_object_id",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "invoice_number": "F-20931",
                    "invoice_date": "2026-10-02",
                    "due_date": "2026-11-01",
                    "net_amount_ore": 120000,
                    "vat_amount_ore": 30000,
                    "gross_amount_ore": 150000,
                    "status": "draft",
                    "submitted_at": null,
                    "approved_at": null,
                    "rejection_reason": null,
                    "file_object_id": null,
                    "external_id": "LF-20931",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "description": "Allrengöring 5 l",
                        "quantity": 10,
                        "unit_price_ore": 12000,
                        "net_amount_ore": 120000,
                        "vat_rate": 25,
                        "vat_amount_ore": 30000,
                        "work_order_id": null,
                        "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "purchase_order_line_id": null,
                        "is_rebillable": false,
                        "sales_price_ore": null,
                        "invoiced": false,
                        "sort_order": 1
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`FAKTURA_SAKNAS` — Leverantörsfakturan finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FAKTURA_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FAKTURA_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`FEL_STATUS_FOR_ANDRING` — Fakturan kan inte ändras.\n\n`VIDAREFAKT_KRAVER_ARBETSORDER` — Vidarefakturering kräver arbetsorder.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FEL_STATUS_FOR_ANDRING": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FEL_STATUS_FOR_ANDRING"
                      ]
                    }
                  },
                  "VIDAREFAKT_KRAVER_ARBETSORDER": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "VIDAREFAKT_KRAVER_ARBETSORDER"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "supplier_invoices:write",
        "x-fixra-rpc": "api_supplier_invoice_lines_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/supplier-invoices/{id}/lines\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"description\":\"Allrengöring 5 l\",\"quantity\":10,\"unit_price_ore\":12000,\"vat_rate\":25}'"
          }
        ]
      }
    },
    "/v1/supplier-invoices/{id}/lines/{line_id}": {
      "patch": {
        "operationId": "updateSupplierInvoiceLine",
        "tags": [
          "Leverantörsfakturor"
        ],
        "summary": "Ändra fakturarad",
        "description": "Ändrar en rad.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "line_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "description": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "quantity": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "unit_price_ore": {
                    "type": "integer"
                  },
                  "vat_rate": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "work_order_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "material_item_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "purchase_order_line_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "is_rebillable": {
                    "type": "boolean"
                  },
                  "sales_price_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "sort_order": {
                    "type": "integer"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "quantity": 12
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "invoice_number": {
                              "type": "string"
                            },
                            "invoice_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "due_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "vat_amount_ore": {
                              "type": "integer"
                            },
                            "gross_amount_ore": {
                              "type": "integer"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "pending_approval",
                                "approved",
                                "rejected"
                              ]
                            },
                            "submitted_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "approved_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "rejection_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "file_object_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit_price_ore": {
                                    "type": "integer"
                                  },
                                  "net_amount_ore": {
                                    "type": "integer"
                                  },
                                  "vat_rate": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "vat_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "purchase_order_line_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_rebillable": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sales_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "invoiced": {
                                    "type": "boolean"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "description",
                                  "quantity",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "vat_rate",
                                  "vat_amount_ore",
                                  "work_order_id",
                                  "material_item_id",
                                  "purchase_order_line_id",
                                  "is_rebillable",
                                  "sales_price_ore",
                                  "invoiced",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "supplier_id",
                            "invoice_number",
                            "invoice_date",
                            "due_date",
                            "net_amount_ore",
                            "vat_amount_ore",
                            "gross_amount_ore",
                            "status",
                            "submitted_at",
                            "approved_at",
                            "rejection_reason",
                            "file_object_id",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "invoice_number": "F-20931",
                    "invoice_date": "2026-10-02",
                    "due_date": "2026-11-01",
                    "net_amount_ore": 120000,
                    "vat_amount_ore": 30000,
                    "gross_amount_ore": 150000,
                    "status": "draft",
                    "submitted_at": null,
                    "approved_at": null,
                    "rejection_reason": null,
                    "file_object_id": null,
                    "external_id": "LF-20931",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "description": "Allrengöring 5 l",
                        "quantity": 10,
                        "unit_price_ore": 12000,
                        "net_amount_ore": 120000,
                        "vat_rate": 25,
                        "vat_amount_ore": 30000,
                        "work_order_id": null,
                        "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "purchase_order_line_id": null,
                        "is_rebillable": false,
                        "sales_price_ore": null,
                        "invoiced": false,
                        "sort_order": 1
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`FAKTURA_SAKNAS` — Leverantörsfakturan finns inte i nyckelns bolag.\n\n`FAKTURARAD_SAKNAS` — Raden finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FAKTURA_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FAKTURA_SAKNAS"
                      ]
                    }
                  },
                  "FAKTURARAD_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FAKTURARAD_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`FEL_STATUS_FOR_ANDRING` — Fakturan kan inte ändras.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FEL_STATUS_FOR_ANDRING": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FEL_STATUS_FOR_ANDRING"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "supplier_invoices:write",
        "x-fixra-rpc": "api_supplier_invoice_lines_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/supplier-invoices/{id}/lines/{line_id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"quantity\":12}'"
          }
        ]
      },
      "delete": {
        "operationId": "deleteSupplierInvoiceLine",
        "tags": [
          "Leverantörsfakturor"
        ],
        "summary": "Ta bort fakturarad",
        "description": "Tar bort en rad genom `supplier_invoice_line_delete`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "line_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "invoice_number": {
                              "type": "string"
                            },
                            "invoice_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "due_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "vat_amount_ore": {
                              "type": "integer"
                            },
                            "gross_amount_ore": {
                              "type": "integer"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "pending_approval",
                                "approved",
                                "rejected"
                              ]
                            },
                            "submitted_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "approved_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "rejection_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "file_object_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit_price_ore": {
                                    "type": "integer"
                                  },
                                  "net_amount_ore": {
                                    "type": "integer"
                                  },
                                  "vat_rate": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "vat_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "purchase_order_line_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_rebillable": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sales_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "invoiced": {
                                    "type": "boolean"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "description",
                                  "quantity",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "vat_rate",
                                  "vat_amount_ore",
                                  "work_order_id",
                                  "material_item_id",
                                  "purchase_order_line_id",
                                  "is_rebillable",
                                  "sales_price_ore",
                                  "invoiced",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "supplier_id",
                            "invoice_number",
                            "invoice_date",
                            "due_date",
                            "net_amount_ore",
                            "vat_amount_ore",
                            "gross_amount_ore",
                            "status",
                            "submitted_at",
                            "approved_at",
                            "rejection_reason",
                            "file_object_id",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "invoice_number": "F-20931",
                    "invoice_date": "2026-10-02",
                    "due_date": "2026-11-01",
                    "net_amount_ore": 120000,
                    "vat_amount_ore": 30000,
                    "gross_amount_ore": 150000,
                    "status": "draft",
                    "submitted_at": null,
                    "approved_at": null,
                    "rejection_reason": null,
                    "file_object_id": null,
                    "external_id": "LF-20931",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`FAKTURA_SAKNAS` — Leverantörsfakturan finns inte i nyckelns bolag.\n\n`FAKTURARAD_SAKNAS` — Raden finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FAKTURA_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FAKTURA_SAKNAS"
                      ]
                    }
                  },
                  "FAKTURARAD_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FAKTURARAD_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`FEL_STATUS_FOR_ANDRING` — Fakturan kan inte ändras.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FEL_STATUS_FOR_ANDRING": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FEL_STATUS_FOR_ANDRING"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "supplier_invoices:write",
        "x-fixra-rpc": "api_supplier_invoice_lines_delete",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.fixra.se/v1/supplier-invoices/{id}/lines/{line_id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/supplier-invoices/{id}/submit": {
      "post": {
        "operationId": "submitSupplierInvoice",
        "tags": [
          "Leverantörsfakturor"
        ],
        "summary": "Skicka till attest",
        "description": "draft/rejected → pending_approval genom `supplier_invoice_submit`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "invoice_number": {
                              "type": "string"
                            },
                            "invoice_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "due_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "vat_amount_ore": {
                              "type": "integer"
                            },
                            "gross_amount_ore": {
                              "type": "integer"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "pending_approval",
                                "approved",
                                "rejected"
                              ]
                            },
                            "submitted_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "approved_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "rejection_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "file_object_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit_price_ore": {
                                    "type": "integer"
                                  },
                                  "net_amount_ore": {
                                    "type": "integer"
                                  },
                                  "vat_rate": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "vat_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "purchase_order_line_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_rebillable": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sales_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "invoiced": {
                                    "type": "boolean"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "description",
                                  "quantity",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "vat_rate",
                                  "vat_amount_ore",
                                  "work_order_id",
                                  "material_item_id",
                                  "purchase_order_line_id",
                                  "is_rebillable",
                                  "sales_price_ore",
                                  "invoiced",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "supplier_id",
                            "invoice_number",
                            "invoice_date",
                            "due_date",
                            "net_amount_ore",
                            "vat_amount_ore",
                            "gross_amount_ore",
                            "status",
                            "submitted_at",
                            "approved_at",
                            "rejection_reason",
                            "file_object_id",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "invoice_number": "F-20931",
                    "invoice_date": "2026-10-02",
                    "due_date": "2026-11-01",
                    "net_amount_ore": 120000,
                    "vat_amount_ore": 30000,
                    "gross_amount_ore": 150000,
                    "status": "pending_approval",
                    "submitted_at": "2026-10-01T09:00:00+02:00",
                    "approved_at": null,
                    "rejection_reason": null,
                    "file_object_id": null,
                    "external_id": "LF-20931",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "description": "Allrengöring 5 l",
                        "quantity": 10,
                        "unit_price_ore": 12000,
                        "net_amount_ore": 120000,
                        "vat_rate": 25,
                        "vat_amount_ore": 30000,
                        "work_order_id": null,
                        "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "purchase_order_line_id": null,
                        "is_rebillable": false,
                        "sales_price_ore": null,
                        "invoiced": false,
                        "sort_order": 1
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`FAKTURA_SAKNAS` — Leverantörsfakturan finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FAKTURA_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FAKTURA_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`RADER_SAKNAS` — Fakturan saknar rader.\n\n`RADSUMMA_STAMMER_INTE` — Radernas summa ≠ fakturans netto.\n\n`FEL_STATUS_FOR_INSKICK` — Fel status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "RADER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RADER_SAKNAS"
                      ]
                    }
                  },
                  "RADSUMMA_STAMMER_INTE": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RADSUMMA_STAMMER_INTE"
                      ]
                    }
                  },
                  "FEL_STATUS_FOR_INSKICK": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FEL_STATUS_FOR_INSKICK"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "supplier_invoices:write",
        "x-fixra-rpc": "api_supplier_invoices_submit",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/supplier-invoices/{id}/submit\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\""
          }
        ]
      }
    },
    "/v1/supplier-invoices/{id}/approve": {
      "post": {
        "operationId": "approveSupplierInvoice",
        "tags": [
          "Leverantörsfakturor"
        ],
        "summary": "Attestera",
        "description": "pending_approval → approved genom `supplier_invoice_approve`. Nyckelns skapare måste ha purchase.approve och får inte vara den som skickade in.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "invoice_number": {
                              "type": "string"
                            },
                            "invoice_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "due_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "vat_amount_ore": {
                              "type": "integer"
                            },
                            "gross_amount_ore": {
                              "type": "integer"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "pending_approval",
                                "approved",
                                "rejected"
                              ]
                            },
                            "submitted_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "approved_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "rejection_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "file_object_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit_price_ore": {
                                    "type": "integer"
                                  },
                                  "net_amount_ore": {
                                    "type": "integer"
                                  },
                                  "vat_rate": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "vat_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "purchase_order_line_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_rebillable": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sales_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "invoiced": {
                                    "type": "boolean"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "description",
                                  "quantity",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "vat_rate",
                                  "vat_amount_ore",
                                  "work_order_id",
                                  "material_item_id",
                                  "purchase_order_line_id",
                                  "is_rebillable",
                                  "sales_price_ore",
                                  "invoiced",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "supplier_id",
                            "invoice_number",
                            "invoice_date",
                            "due_date",
                            "net_amount_ore",
                            "vat_amount_ore",
                            "gross_amount_ore",
                            "status",
                            "submitted_at",
                            "approved_at",
                            "rejection_reason",
                            "file_object_id",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "invoice_number": "F-20931",
                    "invoice_date": "2026-10-02",
                    "due_date": "2026-11-01",
                    "net_amount_ore": 120000,
                    "vat_amount_ore": 30000,
                    "gross_amount_ore": 150000,
                    "status": "approved",
                    "submitted_at": null,
                    "approved_at": "2026-10-01T09:00:00+02:00",
                    "rejection_reason": null,
                    "file_object_id": null,
                    "external_id": "LF-20931",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "description": "Allrengöring 5 l",
                        "quantity": 10,
                        "unit_price_ore": 12000,
                        "net_amount_ore": 120000,
                        "vat_rate": 25,
                        "vat_amount_ore": 30000,
                        "work_order_id": null,
                        "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "purchase_order_line_id": null,
                        "is_rebillable": false,
                        "sales_price_ore": null,
                        "invoiced": false,
                        "sort_order": 1
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).\n\n`SAKNAR_RATTIGHET` — Nyckelns skapare saknar attesträtt.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  },
                  "SAKNAR_RATTIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_RATTIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`FAKTURA_SAKNAS` — Leverantörsfakturan finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FAKTURA_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FAKTURA_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`EGEN_ATTEST_EJ_TILLATEN` — Den som skickade in får inte attestera.\n\n`FEL_STATUS_FOR_ATTEST` — Fakturan väntar inte på attest.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "EGEN_ATTEST_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EGEN_ATTEST_EJ_TILLATEN"
                      ]
                    }
                  },
                  "FEL_STATUS_FOR_ATTEST": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FEL_STATUS_FOR_ATTEST"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "supplier_invoices:write",
        "x-fixra-rpc": "api_supplier_invoices_approve",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/supplier-invoices/{id}/approve\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\""
          }
        ]
      }
    },
    "/v1/supplier-invoices/{id}/reject": {
      "post": {
        "operationId": "rejectSupplierInvoice",
        "tags": [
          "Leverantörsfakturor"
        ],
        "summary": "Avslå",
        "description": "pending_approval → rejected genom `supplier_invoice_reject`. Orsak krävs.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  }
                },
                "required": [
                  "reason"
                ],
                "additionalProperties": false
              },
              "example": {
                "reason": "Fel pris på rad 1."
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "supplier_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "invoice_number": {
                              "type": "string"
                            },
                            "invoice_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "due_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "net_amount_ore": {
                              "type": "integer"
                            },
                            "vat_amount_ore": {
                              "type": "integer"
                            },
                            "gross_amount_ore": {
                              "type": "integer"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "pending_approval",
                                "approved",
                                "rejected"
                              ]
                            },
                            "submitted_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "approved_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "rejection_reason": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "file_object_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "unit_price_ore": {
                                    "type": "integer"
                                  },
                                  "net_amount_ore": {
                                    "type": "integer"
                                  },
                                  "vat_rate": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "vat_amount_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "work_order_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "material_item_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "purchase_order_line_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_rebillable": {
                                    "type": [
                                      "boolean",
                                      "null"
                                    ]
                                  },
                                  "sales_price_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "invoiced": {
                                    "type": "boolean"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "description",
                                  "quantity",
                                  "unit_price_ore",
                                  "net_amount_ore",
                                  "vat_rate",
                                  "vat_amount_ore",
                                  "work_order_id",
                                  "material_item_id",
                                  "purchase_order_line_id",
                                  "is_rebillable",
                                  "sales_price_ore",
                                  "invoiced",
                                  "sort_order"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "supplier_id",
                            "invoice_number",
                            "invoice_date",
                            "due_date",
                            "net_amount_ore",
                            "vat_amount_ore",
                            "gross_amount_ore",
                            "status",
                            "submitted_at",
                            "approved_at",
                            "rejection_reason",
                            "file_object_id",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "lines"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "supplier_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "invoice_number": "F-20931",
                    "invoice_date": "2026-10-02",
                    "due_date": "2026-11-01",
                    "net_amount_ore": 120000,
                    "vat_amount_ore": 30000,
                    "gross_amount_ore": 150000,
                    "status": "rejected",
                    "submitted_at": null,
                    "approved_at": null,
                    "rejection_reason": "Fel pris på rad 1.",
                    "file_object_id": null,
                    "external_id": "LF-20931",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "lines": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "description": "Allrengöring 5 l",
                        "quantity": 10,
                        "unit_price_ore": 12000,
                        "net_amount_ore": 120000,
                        "vat_rate": 25,
                        "vat_amount_ore": 30000,
                        "work_order_id": null,
                        "material_item_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "purchase_order_line_id": null,
                        "is_rebillable": false,
                        "sales_price_ore": null,
                        "invoiced": false,
                        "sort_order": 1
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Inköp är inte aktiv i bolaget (`module: purchase`).\n\n`SAKNAR_RATTIGHET` — Nyckelns skapare saknar attesträtt.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  },
                  "SAKNAR_RATTIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_RATTIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`FAKTURA_SAKNAS` — Leverantörsfakturan finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FAKTURA_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FAKTURA_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`AVSLAGSORSAK_SAKNAS` — Orsak saknas.\n\n`FEL_STATUS_FOR_ATTEST` — Fakturan väntar inte på attest.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "AVSLAGSORSAK_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "AVSLAGSORSAK_SAKNAS"
                      ]
                    }
                  },
                  "FEL_STATUS_FOR_ATTEST": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FEL_STATUS_FOR_ATTEST"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "supplier_invoices:write",
        "x-fixra-rpc": "api_supplier_invoices_reject",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/supplier-invoices/{id}/reject\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"reason\":\"Fel pris på rad 1.\"}'"
          }
        ]
      }
    },
    "/v1/projects": {
      "get": {
        "operationId": "listProjects",
        "tags": [
          "Projekt"
        ],
        "summary": "Lista projekt",
        "description": "Projekt utan faser. Budgetbelopp är null om nyckelns skapare saknar economy.read. Kräver modulen Projekt.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100
                }
              ],
              "description": "Antal rader per sida, 1–100. Standard 25."
            },
            "description": "Antal rader per sida, 1–100. Standard 25."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 200
                }
              ],
              "description": "Värdet `next_cursor` från föregående sida."
            },
            "description": "Värdet `next_cursor` från föregående sida."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ],
              "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
            },
            "description": "Bara rader ändrade vid eller efter tidpunkten (ISO 8601 med offset)."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 40
                }
              ]
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "format": "uuid"
                }
              ]
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                }
              ],
              "description": "Slå upp på ert eget id (external_id)."
            },
            "description": "Slå upp på ert eget id (external_id)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "project_number": {
                                    "type": "string"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "description": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "planned",
                                      "active",
                                      "on_hold",
                                      "done",
                                      "cancelled"
                                    ]
                                  },
                                  "customer_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "site_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "responsible_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "starts_on": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "ends_on": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "budget_minutes": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "budget_cost_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "budget_revenue_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "external_id": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "project_number",
                                  "name",
                                  "description",
                                  "status",
                                  "customer_id",
                                  "site_id",
                                  "responsible_id",
                                  "starts_on",
                                  "ends_on",
                                  "budget_minutes",
                                  "budget_cost_ore",
                                  "budget_revenue_ore",
                                  "external_id",
                                  "created_at",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "next_cursor": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "items",
                            "next_cursor"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "project_number": "P-1012",
                        "name": "Badrum Ekbacken",
                        "description": null,
                        "status": "planned",
                        "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "responsible_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "starts_on": "2026-10-05",
                        "ends_on": "2026-10-30",
                        "budget_minutes": 9600,
                        "budget_cost_ore": 7200000,
                        "budget_revenue_ore": 9800000,
                        "external_id": "PRJ-12",
                        "created_at": "2026-10-01T09:00:00+02:00",
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "next_cursor": "323032362d31302d..."
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Projekt är inte aktiv i bolaget (`module: project`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter eller cursor är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "projects:read",
        "x-fixra-rpc": "api_projects_list",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/projects\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "createProject",
        "tags": [
          "Projekt"
        ],
        "summary": "Skapa projekt",
        "description": "Skapar ett projekt genom `project_save`.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "customer_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Krävs: projekt har alltid en kund."
                  },
                  "site_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "responsible_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "starts_on": {
                    "type": "string",
                    "format": "date"
                  },
                  "ends_on": {
                    "type": "string",
                    "format": "date"
                  },
                  "budget_minutes": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "budget_cost_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "budget_revenue_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "planned",
                      "active",
                      "on_hold"
                    ]
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Slå upp på ert eget id (external_id)."
                  }
                },
                "required": [
                  "name",
                  "customer_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "name": "Badrum Ekbacken",
                "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "starts_on": "2026-10-05",
                "external_id": "PRJ-12"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "project_number": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "planned",
                                "active",
                                "on_hold",
                                "done",
                                "cancelled"
                              ]
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "responsible_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "starts_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "ends_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "budget_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "budget_cost_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "budget_revenue_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "phases": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "planned_start": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "planned_end": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "planned",
                                      "active",
                                      "done",
                                      "cancelled"
                                    ]
                                  },
                                  "budget_minutes": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "budget_cost_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "null om nyckelns skapare saknar economy.read."
                                  },
                                  "budget_revenue_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "null om nyckelns skapare saknar economy.read."
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "sort_order",
                                  "planned_start",
                                  "planned_end",
                                  "status",
                                  "budget_minutes",
                                  "budget_cost_ore",
                                  "budget_revenue_ore",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "project_number",
                            "name",
                            "description",
                            "status",
                            "customer_id",
                            "site_id",
                            "responsible_id",
                            "starts_on",
                            "ends_on",
                            "budget_minutes",
                            "budget_cost_ore",
                            "budget_revenue_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "phases"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "project_number": "P-1012",
                    "name": "Badrum Ekbacken",
                    "description": null,
                    "status": "planned",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "responsible_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "starts_on": "2026-10-05",
                    "ends_on": "2026-10-30",
                    "budget_minutes": 9600,
                    "budget_cost_ore": 7200000,
                    "budget_revenue_ore": 9800000,
                    "external_id": "PRJ-12",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "phases": [],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Projekt är inte aktiv i bolaget (`module: project`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`NAMN_SAKNAS` — Namn saknas.\n\n`SLUTDATUM_FORE_STARTDATUM` — Slutdatum före startdatum.\n\n`KUND_SAKNAS` — Kunden finns inte.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NAMN_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NAMN_SAKNAS"
                      ]
                    }
                  },
                  "SLUTDATUM_FORE_STARTDATUM": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SLUTDATUM_FORE_STARTDATUM"
                      ]
                    }
                  },
                  "KUND_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KUND_SAKNAS"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "projects:write",
        "x-fixra-rpc": "api_projects_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/projects\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Badrum Ekbacken\",\"customer_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"starts_on\":\"2026-10-05\",\"external_id\":\"PRJ-12\"}'"
          }
        ]
      }
    },
    "/v1/projects/{id}": {
      "get": {
        "operationId": "getProject",
        "tags": [
          "Projekt"
        ],
        "summary": "Hämta projekt",
        "description": "Ett projekt med faser.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "project_number": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "planned",
                                "active",
                                "on_hold",
                                "done",
                                "cancelled"
                              ]
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "responsible_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "starts_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "ends_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "budget_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "budget_cost_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "budget_revenue_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "phases": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "planned_start": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "planned_end": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "planned",
                                      "active",
                                      "done",
                                      "cancelled"
                                    ]
                                  },
                                  "budget_minutes": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "budget_cost_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "null om nyckelns skapare saknar economy.read."
                                  },
                                  "budget_revenue_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "null om nyckelns skapare saknar economy.read."
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "sort_order",
                                  "planned_start",
                                  "planned_end",
                                  "status",
                                  "budget_minutes",
                                  "budget_cost_ore",
                                  "budget_revenue_ore",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "project_number",
                            "name",
                            "description",
                            "status",
                            "customer_id",
                            "site_id",
                            "responsible_id",
                            "starts_on",
                            "ends_on",
                            "budget_minutes",
                            "budget_cost_ore",
                            "budget_revenue_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "phases"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "project_number": "P-1012",
                    "name": "Badrum Ekbacken",
                    "description": null,
                    "status": "planned",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "responsible_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "starts_on": "2026-10-05",
                    "ends_on": "2026-10-30",
                    "budget_minutes": 9600,
                    "budget_cost_ore": 7200000,
                    "budget_revenue_ore": 9800000,
                    "external_id": "PRJ-12",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "phases": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "name": "Rivning",
                        "sort_order": 1,
                        "planned_start": "2026-10-05",
                        "planned_end": "2026-10-09",
                        "status": "planned",
                        "budget_minutes": 2400,
                        "budget_cost_ore": 1800000,
                        "budget_revenue_ore": 2600000,
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ]
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Projekt är inte aktiv i bolaget (`module: project`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PROJEKT_SAKNAS` — Projektet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PROJEKT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PROJEKT_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "projects:read",
        "x-fixra-rpc": "api_projects_get",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/projects/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      },
      "patch": {
        "operationId": "updateProject",
        "tags": [
          "Projekt"
        ],
        "summary": "Ändra projekt",
        "description": "Ändrar skickade fält. Avslutade projekt kan inte ändras.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "customer_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Krävs: projekt har alltid en kund."
                  },
                  "site_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "responsible_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "starts_on": {
                    "type": "string",
                    "format": "date"
                  },
                  "ends_on": {
                    "type": "string",
                    "format": "date"
                  },
                  "budget_minutes": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "budget_cost_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "budget_revenue_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "planned",
                      "active",
                      "on_hold"
                    ]
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Slå upp på ert eget id (external_id)."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "ends_on": "2026-11-06"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "project_number": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "planned",
                                "active",
                                "on_hold",
                                "done",
                                "cancelled"
                              ]
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "responsible_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "starts_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "ends_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "budget_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "budget_cost_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "budget_revenue_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "phases": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "planned_start": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "planned_end": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "planned",
                                      "active",
                                      "done",
                                      "cancelled"
                                    ]
                                  },
                                  "budget_minutes": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "budget_cost_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "null om nyckelns skapare saknar economy.read."
                                  },
                                  "budget_revenue_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "null om nyckelns skapare saknar economy.read."
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "sort_order",
                                  "planned_start",
                                  "planned_end",
                                  "status",
                                  "budget_minutes",
                                  "budget_cost_ore",
                                  "budget_revenue_ore",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "project_number",
                            "name",
                            "description",
                            "status",
                            "customer_id",
                            "site_id",
                            "responsible_id",
                            "starts_on",
                            "ends_on",
                            "budget_minutes",
                            "budget_cost_ore",
                            "budget_revenue_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "phases"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "project_number": "P-1012",
                    "name": "Badrum Ekbacken",
                    "description": null,
                    "status": "planned",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "responsible_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "starts_on": "2026-10-05",
                    "ends_on": "2026-10-30",
                    "budget_minutes": 9600,
                    "budget_cost_ore": 7200000,
                    "budget_revenue_ore": 9800000,
                    "external_id": "PRJ-12",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "phases": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "name": "Rivning",
                        "sort_order": 1,
                        "planned_start": "2026-10-05",
                        "planned_end": "2026-10-09",
                        "status": "planned",
                        "budget_minutes": 2400,
                        "budget_cost_ore": 1800000,
                        "budget_revenue_ore": 2600000,
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Projekt är inte aktiv i bolaget (`module: project`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PROJEKT_SAKNAS` — Projektet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PROJEKT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PROJEKT_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PROJEKT_AVSLUTAT` — Projektet är avslutat.\n\n`EXTERNT_ID_UPPTAGET` — external_id används redan av en annan rad i bolaget.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PROJEKT_AVSLUTAT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PROJEKT_AVSLUTAT"
                      ]
                    }
                  },
                  "EXTERNT_ID_UPPTAGET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EXTERNT_ID_UPPTAGET"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "projects:write",
        "x-fixra-rpc": "api_projects_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/projects/{id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"ends_on\":\"2026-11-06\"}'"
          }
        ]
      }
    },
    "/v1/projects/{id}/status": {
      "post": {
        "operationId": "setProjectStatus",
        "tags": [
          "Projekt"
        ],
        "summary": "Byt projektstatus",
        "description": "Sätter status genom `project_set_status`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "planned",
                      "active",
                      "on_hold",
                      "done",
                      "cancelled"
                    ]
                  }
                },
                "required": [
                  "status"
                ],
                "additionalProperties": false
              },
              "example": {
                "status": "active"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "project_number": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "planned",
                                "active",
                                "on_hold",
                                "done",
                                "cancelled"
                              ]
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "responsible_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "starts_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "ends_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "budget_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "budget_cost_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "budget_revenue_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "phases": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "planned_start": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "planned_end": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "planned",
                                      "active",
                                      "done",
                                      "cancelled"
                                    ]
                                  },
                                  "budget_minutes": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "budget_cost_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "null om nyckelns skapare saknar economy.read."
                                  },
                                  "budget_revenue_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "null om nyckelns skapare saknar economy.read."
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "sort_order",
                                  "planned_start",
                                  "planned_end",
                                  "status",
                                  "budget_minutes",
                                  "budget_cost_ore",
                                  "budget_revenue_ore",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "project_number",
                            "name",
                            "description",
                            "status",
                            "customer_id",
                            "site_id",
                            "responsible_id",
                            "starts_on",
                            "ends_on",
                            "budget_minutes",
                            "budget_cost_ore",
                            "budget_revenue_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "phases"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "project_number": "P-1012",
                    "name": "Badrum Ekbacken",
                    "description": null,
                    "status": "active",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "responsible_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "starts_on": "2026-10-05",
                    "ends_on": "2026-10-30",
                    "budget_minutes": 9600,
                    "budget_cost_ore": 7200000,
                    "budget_revenue_ore": 9800000,
                    "external_id": "PRJ-12",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "phases": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "name": "Rivning",
                        "sort_order": 1,
                        "planned_start": "2026-10-05",
                        "planned_end": "2026-10-09",
                        "status": "planned",
                        "budget_minutes": 2400,
                        "budget_cost_ore": 1800000,
                        "budget_revenue_ore": 2600000,
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Projekt är inte aktiv i bolaget (`module: project`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PROJEKT_SAKNAS` — Projektet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PROJEKT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PROJEKT_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`OGILTIG_STATUS` — Okänd status.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OGILTIG_STATUS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIG_STATUS"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "projects:write",
        "x-fixra-rpc": "api_projects_status",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/projects/{id}/status\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"status\":\"active\"}'"
          }
        ]
      }
    },
    "/v1/projects/{id}/economy": {
      "get": {
        "operationId": "getProjectEconomy",
        "tags": [
          "Projekt"
        ],
        "summary": "Projektets ekonomi",
        "description": "Utfall mot budget per fas ur `project_economy`. Personalkostnad lämnas bara summerad; arbetsgivarfaktorn lämnas aldrig ut. Nyckelns skapare måste ha economy.read.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "project_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "project_number": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "purchase_module": {
                              "type": "boolean"
                            },
                            "expense_module": {
                              "type": "boolean"
                            },
                            "project_budget": {
                              "type": "object",
                              "properties": {},
                              "additionalProperties": true
                            },
                            "phase_budget_sum": {
                              "type": "object",
                              "properties": {},
                              "additionalProperties": true
                            },
                            "rows": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "minutes": {
                                    "type": "integer"
                                  },
                                  "rework_minutes": {
                                    "type": "integer"
                                  },
                                  "travel_minutes": {
                                    "type": "integer"
                                  },
                                  "staff_cost_ore": {
                                    "type": "integer",
                                    "description": "Lön + arbetsgivaravgift summerat. Delarna och faktorn lämnas aldrig ut."
                                  },
                                  "material_cost_ore": {
                                    "type": "integer"
                                  },
                                  "material_replaced_cost_ore": {
                                    "type": "integer"
                                  },
                                  "purchase_cost_ore": {
                                    "type": "integer"
                                  },
                                  "subcontractor_cost_ore": {
                                    "type": "integer"
                                  },
                                  "rework_cost_ore": {
                                    "type": "integer"
                                  },
                                  "travel_cost_ore": {
                                    "type": "integer"
                                  },
                                  "expense_cost_ore": {
                                    "type": "integer"
                                  },
                                  "cost_ore": {
                                    "type": "integer"
                                  },
                                  "revenue_ore": {
                                    "type": "integer"
                                  },
                                  "margin_ore": {
                                    "type": "integer"
                                  },
                                  "margin_pct": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  }
                                },
                                "required": [
                                  "minutes",
                                  "rework_minutes",
                                  "travel_minutes",
                                  "staff_cost_ore",
                                  "material_cost_ore",
                                  "material_replaced_cost_ore",
                                  "purchase_cost_ore",
                                  "subcontractor_cost_ore",
                                  "rework_cost_ore",
                                  "travel_cost_ore",
                                  "expense_cost_ore",
                                  "cost_ore",
                                  "revenue_ore",
                                  "margin_ore",
                                  "margin_pct"
                                ],
                                "additionalProperties": true
                              }
                            },
                            "total": {
                              "type": "object",
                              "properties": {
                                "minutes": {
                                  "type": "integer"
                                },
                                "rework_minutes": {
                                  "type": "integer"
                                },
                                "travel_minutes": {
                                  "type": "integer"
                                },
                                "staff_cost_ore": {
                                  "type": "integer",
                                  "description": "Lön + arbetsgivaravgift summerat. Delarna och faktorn lämnas aldrig ut."
                                },
                                "material_cost_ore": {
                                  "type": "integer"
                                },
                                "material_replaced_cost_ore": {
                                  "type": "integer"
                                },
                                "purchase_cost_ore": {
                                  "type": "integer"
                                },
                                "subcontractor_cost_ore": {
                                  "type": "integer"
                                },
                                "rework_cost_ore": {
                                  "type": "integer"
                                },
                                "travel_cost_ore": {
                                  "type": "integer"
                                },
                                "expense_cost_ore": {
                                  "type": "integer"
                                },
                                "cost_ore": {
                                  "type": "integer"
                                },
                                "revenue_ore": {
                                  "type": "integer"
                                },
                                "margin_ore": {
                                  "type": "integer"
                                },
                                "margin_pct": {
                                  "type": [
                                    "number",
                                    "null"
                                  ]
                                }
                              },
                              "required": [
                                "minutes",
                                "rework_minutes",
                                "travel_minutes",
                                "staff_cost_ore",
                                "material_cost_ore",
                                "material_replaced_cost_ore",
                                "purchase_cost_ore",
                                "subcontractor_cost_ore",
                                "rework_cost_ore",
                                "travel_cost_ore",
                                "expense_cost_ore",
                                "cost_ore",
                                "revenue_ore",
                                "margin_ore",
                                "margin_pct"
                              ],
                              "additionalProperties": true
                            }
                          },
                          "required": [
                            "project_id",
                            "project_number",
                            "name",
                            "purchase_module",
                            "expense_module",
                            "project_budget",
                            "phase_budget_sum",
                            "rows",
                            "total"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "project_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "project_number": "P-1012",
                    "name": "Badrum Ekbacken",
                    "purchase_module": true,
                    "expense_module": false,
                    "project_budget": {
                      "budget_minutes": 9600,
                      "budget_cost_ore": 7200000,
                      "budget_revenue_ore": 9800000
                    },
                    "phase_budget_sum": {
                      "budget_minutes": 2400,
                      "budget_cost_ore": 1800000,
                      "budget_revenue_ore": 2600000
                    },
                    "rows": [
                      {
                        "phase_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "phase_name": "Rivning",
                        "minutes": 2400,
                        "rework_minutes": 0,
                        "travel_minutes": 120,
                        "staff_cost_ore": 1450000,
                        "material_cost_ore": 90000,
                        "material_replaced_cost_ore": 0,
                        "purchase_cost_ore": 120000,
                        "subcontractor_cost_ore": 0,
                        "rework_cost_ore": 0,
                        "travel_cost_ore": 30000,
                        "expense_cost_ore": 0,
                        "cost_ore": 1690000,
                        "revenue_ore": 2600000,
                        "margin_ore": 910000,
                        "margin_pct": 35
                      }
                    ],
                    "total": {
                      "minutes": 2400,
                      "rework_minutes": 0,
                      "travel_minutes": 120,
                      "staff_cost_ore": 1450000,
                      "material_cost_ore": 90000,
                      "material_replaced_cost_ore": 0,
                      "purchase_cost_ore": 120000,
                      "subcontractor_cost_ore": 0,
                      "rework_cost_ore": 0,
                      "travel_cost_ore": 30000,
                      "expense_cost_ore": 0,
                      "cost_ore": 1690000,
                      "revenue_ore": 2600000,
                      "margin_ore": 910000,
                      "margin_pct": 35
                    }
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Projekt är inte aktiv i bolaget (`module: project`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PROJEKT_SAKNAS` — Projektet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PROJEKT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PROJEKT_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "projects:read",
        "x-fixra-rpc": "api_projects_economy",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/v1/projects/{id}/economy\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/projects/{id}/phases": {
      "post": {
        "operationId": "createProjectPhase",
        "tags": [
          "Projekt"
        ],
        "summary": "Lägg till fas",
        "description": "Skapar en fas genom `project_phase_save`. Svaret är hela projektet.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "sort_order": {
                    "type": "integer"
                  },
                  "planned_start": {
                    "type": "string",
                    "format": "date"
                  },
                  "planned_end": {
                    "type": "string",
                    "format": "date"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "planned",
                      "active",
                      "done",
                      "cancelled"
                    ]
                  },
                  "budget_minutes": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "budget_cost_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "budget_revenue_ore": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "required": [
                  "name"
                ],
                "additionalProperties": false
              },
              "example": {
                "name": "Rivning",
                "planned_start": "2026-10-05",
                "planned_end": "2026-10-09"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "project_number": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "planned",
                                "active",
                                "on_hold",
                                "done",
                                "cancelled"
                              ]
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "responsible_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "starts_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "ends_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "budget_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "budget_cost_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "budget_revenue_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "phases": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "planned_start": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "planned_end": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "planned",
                                      "active",
                                      "done",
                                      "cancelled"
                                    ]
                                  },
                                  "budget_minutes": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "budget_cost_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "null om nyckelns skapare saknar economy.read."
                                  },
                                  "budget_revenue_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "null om nyckelns skapare saknar economy.read."
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "sort_order",
                                  "planned_start",
                                  "planned_end",
                                  "status",
                                  "budget_minutes",
                                  "budget_cost_ore",
                                  "budget_revenue_ore",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "project_number",
                            "name",
                            "description",
                            "status",
                            "customer_id",
                            "site_id",
                            "responsible_id",
                            "starts_on",
                            "ends_on",
                            "budget_minutes",
                            "budget_cost_ore",
                            "budget_revenue_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "phases"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "project_number": "P-1012",
                    "name": "Badrum Ekbacken",
                    "description": null,
                    "status": "planned",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "responsible_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "starts_on": "2026-10-05",
                    "ends_on": "2026-10-30",
                    "budget_minutes": 9600,
                    "budget_cost_ore": 7200000,
                    "budget_revenue_ore": 9800000,
                    "external_id": "PRJ-12",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "phases": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "name": "Rivning",
                        "sort_order": 1,
                        "planned_start": "2026-10-05",
                        "planned_end": "2026-10-09",
                        "status": "planned",
                        "budget_minutes": 2400,
                        "budget_cost_ore": 1800000,
                        "budget_revenue_ore": 2600000,
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Projekt är inte aktiv i bolaget (`module: project`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PROJEKT_SAKNAS` — Projektet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PROJEKT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PROJEKT_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PROJEKT_AVSLUTAT` — Projektet är avslutat.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PROJEKT_AVSLUTAT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PROJEKT_AVSLUTAT"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "projects:write",
        "x-fixra-rpc": "api_project_phases_create",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/projects/{id}/phases\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Rivning\",\"planned_start\":\"2026-10-05\",\"planned_end\":\"2026-10-09\"}'"
          }
        ]
      }
    },
    "/v1/projects/{id}/phases/{phase_id}": {
      "patch": {
        "operationId": "updateProjectPhase",
        "tags": [
          "Projekt"
        ],
        "summary": "Ändra fas",
        "description": "Ändrar en fas.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "phase_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "sort_order": {
                    "type": "integer"
                  },
                  "planned_start": {
                    "type": "string",
                    "format": "date"
                  },
                  "planned_end": {
                    "type": "string",
                    "format": "date"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "planned",
                      "active",
                      "done",
                      "cancelled"
                    ]
                  },
                  "budget_minutes": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "budget_cost_ore": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "budget_revenue_ore": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "status": "active"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "project_number": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "planned",
                                "active",
                                "on_hold",
                                "done",
                                "cancelled"
                              ]
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "responsible_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "starts_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "ends_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "budget_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "budget_cost_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "budget_revenue_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "phases": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "planned_start": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "planned_end": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "planned",
                                      "active",
                                      "done",
                                      "cancelled"
                                    ]
                                  },
                                  "budget_minutes": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "budget_cost_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "null om nyckelns skapare saknar economy.read."
                                  },
                                  "budget_revenue_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "null om nyckelns skapare saknar economy.read."
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "sort_order",
                                  "planned_start",
                                  "planned_end",
                                  "status",
                                  "budget_minutes",
                                  "budget_cost_ore",
                                  "budget_revenue_ore",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "project_number",
                            "name",
                            "description",
                            "status",
                            "customer_id",
                            "site_id",
                            "responsible_id",
                            "starts_on",
                            "ends_on",
                            "budget_minutes",
                            "budget_cost_ore",
                            "budget_revenue_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "phases"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "project_number": "P-1012",
                    "name": "Badrum Ekbacken",
                    "description": null,
                    "status": "planned",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "responsible_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "starts_on": "2026-10-05",
                    "ends_on": "2026-10-30",
                    "budget_minutes": 9600,
                    "budget_cost_ore": 7200000,
                    "budget_revenue_ore": 9800000,
                    "external_id": "PRJ-12",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "phases": [
                      {
                        "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                        "name": "Rivning",
                        "sort_order": 1,
                        "planned_start": "2026-10-05",
                        "planned_end": "2026-10-09",
                        "status": "planned",
                        "budget_minutes": 2400,
                        "budget_cost_ore": 1800000,
                        "budget_revenue_ore": 2600000,
                        "updated_at": "2026-10-01T09:00:00+02:00"
                      }
                    ],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Projekt är inte aktiv i bolaget (`module: project`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PROJEKT_SAKNAS` — Projektet finns inte i nyckelns bolag.\n\n`FAS_SAKNAS` — Fasen finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PROJEKT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PROJEKT_SAKNAS"
                      ]
                    }
                  },
                  "FAS_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FAS_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "projects:write",
        "x-fixra-rpc": "api_project_phases_update",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/v1/projects/{id}/phases/{phase_id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"status\":\"active\"}'"
          }
        ]
      },
      "delete": {
        "operationId": "deleteProjectPhase",
        "tags": [
          "Projekt"
        ],
        "summary": "Ta bort fas",
        "description": "Tar bort en fas utan arbetsorder genom `project_phase_delete`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "phase_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "project_number": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "description": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "planned",
                                "active",
                                "on_hold",
                                "done",
                                "cancelled"
                              ]
                            },
                            "customer_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "site_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "responsible_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "starts_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "ends_on": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "budget_minutes": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "budget_cost_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "budget_revenue_ore": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "phases": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "sort_order": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "planned_start": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "planned_end": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "planned",
                                      "active",
                                      "done",
                                      "cancelled"
                                    ]
                                  },
                                  "budget_minutes": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "budget_cost_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "null om nyckelns skapare saknar economy.read."
                                  },
                                  "budget_revenue_ore": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "null om nyckelns skapare saknar economy.read."
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "sort_order",
                                  "planned_start",
                                  "planned_end",
                                  "status",
                                  "budget_minutes",
                                  "budget_cost_ore",
                                  "budget_revenue_ore",
                                  "updated_at"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "project_number",
                            "name",
                            "description",
                            "status",
                            "customer_id",
                            "site_id",
                            "responsible_id",
                            "starts_on",
                            "ends_on",
                            "budget_minutes",
                            "budget_cost_ore",
                            "budget_revenue_ore",
                            "external_id",
                            "created_at",
                            "updated_at",
                            "phases"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "project_number": "P-1012",
                    "name": "Badrum Ekbacken",
                    "description": null,
                    "status": "planned",
                    "customer_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "site_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "responsible_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "starts_on": "2026-10-05",
                    "ends_on": "2026-10-30",
                    "budget_minutes": 9600,
                    "budget_cost_ore": 7200000,
                    "budget_revenue_ore": 9800000,
                    "external_id": "PRJ-12",
                    "created_at": "2026-10-01T09:00:00+02:00",
                    "updated_at": "2026-10-01T09:00:00+02:00",
                    "phases": [],
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Projekt är inte aktiv i bolaget (`module: project`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`PROJEKT_SAKNAS` — Projektet finns inte i nyckelns bolag.\n\n`FAS_SAKNAS` — Fasen finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PROJEKT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PROJEKT_SAKNAS"
                      ]
                    }
                  },
                  "FAS_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FAS_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`FAS_HAR_ARBETSORDER` — Fasen har arbetsorder.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FAS_HAR_ARBETSORDER": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FAS_HAR_ARBETSORDER"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "projects:write",
        "x-fixra-rpc": "api_project_phases_delete",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.fixra.se/v1/projects/{id}/phases/{phase_id}\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/v1/work-orders/{id}/project": {
      "post": {
        "operationId": "linkWorkOrderProject",
        "tags": [
          "Arbetsorder"
        ],
        "summary": "Koppla till projekt",
        "description": "Kopplar arbetsordern till ett projekt och en fas genom `project_work_order_link`. `project_id: null` kopplar loss.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "project_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "phase_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "project_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "project_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                "phase_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "work_order_id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "project_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "phase_id": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "work_order_id",
                            "project_id",
                            "phase_id"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "work_order_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "project_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "phase_id": "5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e",
                    "dry_run": false,
                    "idempotent": false
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "`IDEMPOTENS_NYCKEL_SAKNAS` — Huvudet Idempotency-Key saknas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_NYCKEL_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_NYCKEL_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_UTGANGEN` — Nyckelns utgångsdatum har passerats.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad eller rullad.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_UTGANGEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_UTGANGEN"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`MODUL_AVSTANGD` — Modulen Öppet API är avstängd för bolaget.\n\n`MODUL_EJ_AKTIV` — Modulen resursen hör till (t.ex. Uppgifter, Ärenden, Kvalitet) är inte aktiv i bolaget; `module` anger vilken.\n\n`IP_EJ_TILLATEN` — Anropet kommer från en IP-adress utanför nyckelns lista.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare saknar längre behörigheten scopet kräver.\n\n`MODUL_EJ_AKTIV` — Modulen Projekt är inte aktiv i bolaget (`module: project`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "MODUL_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_AVSTANGD"
                      ]
                    }
                  },
                  "MODUL_EJ_AKTIV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "MODUL_EJ_AKTIV"
                      ]
                    }
                  },
                  "IP_EJ_TILLATEN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IP_EJ_TILLATEN"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`ARBETSORDER_SAKNAS` — Arbetsordern finns inte i nyckelns bolag.\n\n`PROJEKT_SAKNAS` — Projektet finns inte i nyckelns bolag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "ARBETSORDER_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "ARBETSORDER_SAKNAS"
                      ]
                    }
                  },
                  "PROJEKT_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PROJEKT_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`IDEMPOTENS_KONFLIKT` — Samma Idempotency-Key användes med en annan kropp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "IDEMPOTENS_KONFLIKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "IDEMPOTENS_KONFLIKT"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`FAS_TILLHOR_ANNAT_PROJEKT` — Fasen hör till ett annat projekt.\n\n`PROJEKT_AVSLUTAT` — Projektet är avslutat.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "FAS_TILLHOR_ANNAT_PROJEKT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "FAS_TILLHOR_ANNAT_PROJEKT"
                      ]
                    }
                  },
                  "PROJEKT_AVSLUTAT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PROJEKT_AVSLUTAT"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "projects:write",
        "x-fixra-rpc": "api_work_orders_project",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/v1/work-orders/{id}/project\" \\\n  -H \"Authorization: Bearer fx_test_DIN_NYCKEL\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"project_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\",\"phase_id\":\"5b0c7a52-3f7e-4d1a-9c7e-1f2a3b4c5d6e\"}'"
          }
        ]
      }
    },
    "/partner/v1/kunder": {
      "get": {
        "operationId": "partnerListCustomers",
        "tags": [
          "Partner-API"
        ],
        "summary": "Lista kunder",
        "description": "Partnerns kundbolag och väntande inbjudningar — samma lista som portalen (`pp_kunder`). Bara kundfakta och licens, aldrig verksamhetsdata.",
        "security": [
          {
            "partnerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 20
                }
              ],
              "description": "prov, aktiv, pausad, uppsagd eller inbjuden."
            },
            "description": "prov, aktiv, pausad, uppsagd eller inbjuden."
          },
          {
            "name": "sok",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "maxLength": 100
                }
              ],
              "description": "Del av namn eller org.nr."
            },
            "description": "Del av namn eller org.nr."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "kunder": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "tenant_id": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "onboarding_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "namn": {
                                    "type": "string"
                                  },
                                  "org_number": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "description": "prov | aktiv | pausad | uppsagd | inbjuden"
                                  },
                                  "plan": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "seats": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "addons": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "rabatt_pct": {
                                    "type": "number"
                                  },
                                  "aktiva_anvandare": {
                                    "type": "integer"
                                  },
                                  "mrr_ore": {
                                    "type": "integer"
                                  },
                                  "provperiod_slut": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "halsa_score": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "halsa_signaler": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "required": [
                                  "tenant_id",
                                  "namn",
                                  "org_number",
                                  "status",
                                  "plan",
                                  "seats",
                                  "addons",
                                  "rabatt_pct",
                                  "aktiva_anvandare",
                                  "mrr_ore",
                                  "provperiod_slut",
                                  "halsa_score",
                                  "halsa_signaler"
                                ],
                                "additionalProperties": true
                              }
                            }
                          },
                          "required": [
                            "kunder"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "kunder": [
                      {
                        "tenant_id": "3f1c2a9e-7b1d-4c55-9a0e-2d6f1b7c8e90",
                        "namn": "Städbolaget AB",
                        "org_number": "5591234567",
                        "status": "aktiv",
                        "plan": "fixra",
                        "seats": 8,
                        "addons": [
                          "ticket"
                        ],
                        "rabatt_pct": 0,
                        "aktiva_anvandare": 6,
                        "mrr_ore": 288200,
                        "provperiod_slut": null,
                        "halsa_score": 72,
                        "halsa_signaler": []
                      }
                    ]
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad i partnerportalen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`PARTNER_AVSTANGD` — Partnern är pausad eller avslutad.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare är inte längre aktiv partneradmin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "PARTNER_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARTNER_AVSTANGD"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "kunder.read",
        "x-fixra-rpc": "partner_api_call",
        "x-fixra-partner-op": "kunder_lista",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/partner/v1/kunder\" \\\n  -H \"Authorization: Bearer fx_ptnr_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "partnerCreateCustomer",
        "tags": [
          "Partner-API"
        ],
        "summary": "Skapa kund",
        "description": "Samma väg och regler som portalens Skapa kund (`pp_kund_skapa`): signup_request → onboarding → välkomstmejl med partnerns namn och logga. Kunden aktiverar själv.",
        "security": [
          {
            "partnerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company_name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "org_number": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "full_name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 200
                  },
                  "phone": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "industry": {
                    "type": "string",
                    "maxLength": 50
                  },
                  "seats": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 9999
                  },
                  "addons": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "trial_days": {
                    "type": "integer",
                    "minimum": 7,
                    "maximum": 365
                  },
                  "discount_pct": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 2000
                  }
                },
                "required": [
                  "company_name",
                  "org_number",
                  "full_name",
                  "email",
                  "seats"
                ],
                "additionalProperties": false
              },
              "example": {
                "company_name": "Nya Städ AB",
                "org_number": "559123-4567",
                "full_name": "Anna Andersson",
                "email": "anna@nyastad.se",
                "seats": 5,
                "addons": [],
                "trial_days": 30
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "onboarding_id": "3f1c2a9e-7b1d-4c55-9a0e-2d6f1b7c8e90",
                    "email": "anna@nyastad.se",
                    "company_name": "Nya Städ AB",
                    "seats": 5,
                    "addons": [],
                    "trial_days": 30,
                    "discount_pct": 0,
                    "mejl_status": "koat"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad i partnerportalen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`PARTNER_AVSTANGD` — Partnern är pausad eller avslutad.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare är inte längre aktiv partneradmin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "PARTNER_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARTNER_AVSTANGD"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`BOLAG_FINNS_REDAN` — Organisationsnumret har redan ett bolag eller en väntande registrering.\n\n`DEAL_SKYDDAD` — En annan partner har dealskydd på organisationsnumret.\n\n`PRIS_UNDER_GOLV` — Rabatten ger ett pris under prisbokens golv.\n\n`OGILTIG_PROVPERIOD` — Provperioden ligger utanför partnerns ram.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "BOLAG_FINNS_REDAN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BOLAG_FINNS_REDAN"
                      ]
                    }
                  },
                  "DEAL_SKYDDAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "DEAL_SKYDDAD"
                      ]
                    }
                  },
                  "PRIS_UNDER_GOLV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PRIS_UNDER_GOLV"
                      ]
                    }
                  },
                  "OGILTIG_PROVPERIOD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIG_PROVPERIOD"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "kunder.write",
        "x-fixra-rpc": "partner_api_call",
        "x-fixra-partner-op": "kund_skapa",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/partner/v1/kunder\" \\\n  -H \"Authorization: Bearer fx_ptnr_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"company_name\":\"Nya Städ AB\",\"org_number\":\"559123-4567\",\"full_name\":\"Anna Andersson\",\"email\":\"anna@nyastad.se\",\"seats\":5,\"addons\":[],\"trial_days\":30}'"
          }
        ]
      }
    },
    "/partner/v1/kunder/{tenant_id}": {
      "get": {
        "operationId": "partnerGetCustomer",
        "tags": [
          "Partner-API"
        ],
        "summary": "Hämta kund",
        "description": "Kundkortet (`pp_kund_kort`): licens, administratörer, licenshistorik och onboarding.",
        "security": [
          {
            "partnerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "kund": {
                      "tenant_id": "3f1c2a9e-7b1d-4c55-9a0e-2d6f1b7c8e90",
                      "namn": "Städbolaget AB",
                      "org_number": "5591234567",
                      "status": "aktiv",
                      "plan": "fixra",
                      "seats": 8,
                      "addons": [
                        "ticket"
                      ],
                      "rabatt_pct": 0,
                      "aktiva_anvandare": 6,
                      "mrr_ore": 288200,
                      "provperiod_slut": null,
                      "halsa_score": 72,
                      "halsa_signaler": []
                    },
                    "administratorer": [],
                    "licenshistorik": [],
                    "onboarding": null
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad i partnerportalen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`PARTNER_AVSTANGD` — Partnern är pausad eller avslutad.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare är inte längre aktiv partneradmin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "PARTNER_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARTNER_AVSTANGD"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`KUND_SAKNAS` — Bolaget finns inte bland partnerns aktiva kunder (avslöjar aldrig om någon annan äger det).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "KUND_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KUND_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "kunder.read",
        "x-fixra-rpc": "partner_api_call",
        "x-fixra-partner-op": "kund_hamta",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/partner/v1/kunder/{tenant_id}\" \\\n  -H \"Authorization: Bearer fx_ptnr_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/partner/v1/kunder/{tenant_id}/licens": {
      "patch": {
        "operationId": "partnerUpdateLicense",
        "tags": [
          "Partner-API"
        ],
        "summary": "Ändra licens",
        "description": "Antal användare, tillägg och rabatt (`pp_licens_andra`). Loggas i licenshistoriken med aktören `api:<prefix>` och ger händelsen `licens.andrad`.",
        "security": [
          {
            "partnerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "seats": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 9999
                  },
                  "addons": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "discount_pct": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "reason": {
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "seats": 8,
                "addons": [
                  "ticket"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "tenant_id": "3f1c2a9e-7b1d-4c55-9a0e-2d6f1b7c8e90",
                    "andrad": true,
                    "licens": {
                      "seats": 8,
                      "addons": [
                        "ticket"
                      ],
                      "discount_pct": 0
                    },
                    "mrr_ore": 288200
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad i partnerportalen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`PARTNER_AVSTANGD` — Partnern är pausad eller avslutad.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare är inte längre aktiv partneradmin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "PARTNER_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARTNER_AVSTANGD"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`KUND_SAKNAS` — Bolaget finns inte bland partnerns aktiva kunder (avslöjar aldrig om någon annan äger det).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "KUND_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KUND_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`SEATS_UNDER_AKTIVA` — Färre licenser än aktiva användare.\n\n`PRIS_UNDER_GOLV` — Rabatten ger ett pris under golvet.\n\n`LICENS_UPPSAGD` — Licensen är uppsagd.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SEATS_UNDER_AKTIVA": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SEATS_UNDER_AKTIVA"
                      ]
                    }
                  },
                  "PRIS_UNDER_GOLV": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PRIS_UNDER_GOLV"
                      ]
                    }
                  },
                  "LICENS_UPPSAGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "LICENS_UPPSAGD"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "licenser.write",
        "x-fixra-rpc": "partner_api_call",
        "x-fixra-partner-op": "licens_andra",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/partner/v1/kunder/{tenant_id}/licens\" \\\n  -H \"Authorization: Bearer fx_ptnr_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"seats\":8,\"addons\":[\"ticket\"]}'"
          }
        ]
      }
    },
    "/partner/v1/kunder/{tenant_id}/provperiod": {
      "post": {
        "operationId": "partnerExtendTrial",
        "tags": [
          "Partner-API"
        ],
        "summary": "Förläng provperiod",
        "description": "Förlänger provperioden med `dagar` (`pp_provperiod_forlang`), inom partnerns högsta provperiod.",
        "security": [
          {
            "partnerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "dagar": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 365
                  }
                },
                "required": [
                  "dagar"
                ],
                "additionalProperties": false
              },
              "example": {
                "dagar": 7
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "tenant_id": "3f1c2a9e-7b1d-4c55-9a0e-2d6f1b7c8e90",
                    "provperiod_slut": "2026-11-15",
                    "tidigare": "2026-11-08"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad i partnerportalen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`PARTNER_AVSTANGD` — Partnern är pausad eller avslutad.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare är inte längre aktiv partneradmin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "PARTNER_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARTNER_AVSTANGD"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`KUND_SAKNAS` — Bolaget finns inte bland partnerns aktiva kunder (avslöjar aldrig om någon annan äger det).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "KUND_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "KUND_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`EJ_PROVPERIOD` — Kunden är inte i provperiod.\n\n`OGILTIG_PROVPERIOD` — Över partnerns högsta provperiod.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "EJ_PROVPERIOD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "EJ_PROVPERIOD"
                      ]
                    }
                  },
                  "OGILTIG_PROVPERIOD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIG_PROVPERIOD"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "licenser.write",
        "x-fixra-rpc": "partner_api_call",
        "x-fixra-partner-op": "provperiod_forlang",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/partner/v1/kunder/{tenant_id}/provperiod\" \\\n  -H \"Authorization: Bearer fx_ptnr_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"dagar\":7}'"
          }
        ]
      }
    },
    "/partner/v1/provision": {
      "get": {
        "operationId": "partnerGetCommission",
        "tags": [
          "Partner-API"
        ],
        "summary": "Provision för en månad",
        "description": "Provisionsrader per kund och summa (`pp_provision`). Utan `period` gäller innevarande månad.",
        "security": [
          {
            "partnerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "period",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "string",
                  "pattern": "^\\d{4}-(0[1-9]|1[0-2])$"
                }
              ],
              "description": "YYYY-MM."
            },
            "description": "YYYY-MM."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "period": "2026-09-01",
                    "last": false,
                    "summa_ore": 57640,
                    "rader": []
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad i partnerportalen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`PARTNER_AVSTANGD` — Partnern är pausad eller avslutad.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare är inte längre aktiv partneradmin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "PARTNER_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARTNER_AVSTANGD"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`OGILTIG_PERIOD` — Perioden är ogiltig.\n\n`PARAMETER_OGILTIG` — En frågeparameter är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "OGILTIG_PERIOD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIG_PERIOD"
                      ]
                    }
                  },
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "provision.read",
        "x-fixra-rpc": "partner_api_call",
        "x-fixra-partner-op": "provision",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/partner/v1/provision\" \\\n  -H \"Authorization: Bearer fx_ptnr_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/partner/v1/deals": {
      "post": {
        "operationId": "partnerCreateDeal",
        "tags": [
          "Partner-API"
        ],
        "summary": "Registrera deal",
        "description": "Dealregistrering (`pp_deal_registrera`). Fixra beslutar; beslutet kommer som `deal.beslutad`.",
        "security": [
          {
            "partnerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company_name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "org_number": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "contact_name": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "contact_email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 200
                  },
                  "est_seats": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 9999
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 2000
                  }
                },
                "required": [
                  "company_name",
                  "org_number"
                ],
                "additionalProperties": false
              },
              "example": {
                "company_name": "Prospekt AB",
                "org_number": "559876-5432",
                "est_seats": 10
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "deal_id": "3f1c2a9e-7b1d-4c55-9a0e-2d6f1b7c8e90",
                    "status": "vantar"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad i partnerportalen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`PARTNER_AVSTANGD` — Partnern är pausad eller avslutad.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare är inte längre aktiv partneradmin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "PARTNER_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARTNER_AVSTANGD"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`DEAL_SKYDDAD` — En annan partner har skydd på organisationsnumret.\n\n`DEAL_FINNS` — Partnern har redan en öppen deal på numret.\n\n`BOLAG_FINNS_REDAN` — Bolaget är redan kund.\n\n`OGILTIGT_ORGANISATIONSNUMMER` — Organisationsnumret är ogiltigt.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "DEAL_SKYDDAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "DEAL_SKYDDAD"
                      ]
                    }
                  },
                  "DEAL_FINNS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "DEAL_FINNS"
                      ]
                    }
                  },
                  "BOLAG_FINNS_REDAN": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "BOLAG_FINNS_REDAN"
                      ]
                    }
                  },
                  "OGILTIGT_ORGANISATIONSNUMMER": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "OGILTIGT_ORGANISATIONSNUMMER"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "deals.write",
        "x-fixra-rpc": "partner_api_call",
        "x-fixra-partner-op": "deal_skapa",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/partner/v1/deals\" \\\n  -H \"Authorization: Bearer fx_ptnr_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"company_name\":\"Prospekt AB\",\"org_number\":\"559876-5432\",\"est_seats\":10}'"
          }
        ]
      },
      "get": {
        "operationId": "partnerListDeals",
        "tags": [
          "Partner-API"
        ],
        "summary": "Lista deals",
        "description": "Partnerns dealregistreringar (`pp_deals`).",
        "security": [
          {
            "partnerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "deals": []
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad i partnerportalen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`PARTNER_AVSTANGD` — Partnern är pausad eller avslutad.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare är inte längre aktiv partneradmin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "PARTNER_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARTNER_AVSTANGD"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "deals.write",
        "x-fixra-rpc": "partner_api_call",
        "x-fixra-partner-op": "deals_lista",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/partner/v1/deals\" \\\n  -H \"Authorization: Bearer fx_ptnr_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/partner/v1/webhooks": {
      "get": {
        "operationId": "partnerListWebhooks",
        "tags": [
          "Partner-API"
        ],
        "summary": "Lista webhooks",
        "description": "Partnerns mottagare och händelsekatalogen.",
        "security": [
          {
            "partnerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "webhooks": [
                      {
                        "id": "3f1c2a9e-7b1d-4c55-9a0e-2d6f1b7c8e90",
                        "url": "https://exempel.se/fixra",
                        "beskrivning": null,
                        "events": [
                          "licens.andrad"
                        ],
                        "is_active": true,
                        "avstangd_efter_fel": null,
                        "senaste_status": null,
                        "senaste_fel": null,
                        "senaste_leverans": null,
                        "skapad": "2026-10-08T12:00:00Z"
                      }
                    ],
                    "handelser": [
                      "kund.aktiverad",
                      "kund.uppsagd",
                      "licens.andrad",
                      "provperiod.slutar",
                      "halsa.risk",
                      "deal.beslutad",
                      "provision.last"
                    ]
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad i partnerportalen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`PARTNER_AVSTANGD` — Partnern är pausad eller avslutad.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare är inte längre aktiv partneradmin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "PARTNER_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARTNER_AVSTANGD"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "webhooks.manage",
        "x-fixra-rpc": "partner_api_call",
        "x-fixra-partner-op": "webhooks_lista",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/partner/v1/webhooks\" \\\n  -H \"Authorization: Bearer fx_ptnr_DIN_NYCKEL\""
          }
        ]
      },
      "post": {
        "operationId": "partnerCreateWebhook",
        "tags": [
          "Partner-API"
        ],
        "summary": "Skapa webhook",
        "description": "Ny mottagare. Svaret har `secret` (whsec_…) en enda gång — signaturen är `X-Fixra-Signature: t=<unix>,v1=<hex HMAC-SHA256 av \"t.body\">`, samma som Öppet API.",
        "security": [
          {
            "partnerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2000,
                    "description": "Bara https://."
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "kund.aktiverad",
                        "kund.uppsagd",
                        "licens.andrad",
                        "provperiod.slutar",
                        "halsa.risk",
                        "deal.beslutad",
                        "provision.last"
                      ]
                    },
                    "minItems": 1
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 200
                  }
                },
                "required": [
                  "url",
                  "events"
                ],
                "additionalProperties": false
              },
              "example": {
                "url": "https://exempel.se/fixra",
                "events": [
                  "licens.andrad",
                  "kund.aktiverad"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "3f1c2a9e-7b1d-4c55-9a0e-2d6f1b7c8e90",
                    "url": "https://exempel.se/fixra",
                    "beskrivning": null,
                    "events": [
                      "licens.andrad"
                    ],
                    "is_active": true,
                    "avstangd_efter_fel": null,
                    "senaste_status": null,
                    "senaste_fel": null,
                    "senaste_leverans": null,
                    "skapad": "2026-10-08T12:00:00Z",
                    "secret": "whsec_…"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad i partnerportalen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`PARTNER_AVSTANGD` — Partnern är pausad eller avslutad.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare är inte längre aktiv partneradmin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "PARTNER_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARTNER_AVSTANGD"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`WEBHOOK_URL_OGILTIG` — Adressen måste vara https:// och publik.\n\n`HANDELSE_OGILTIG` — Okänd händelse.\n\n`WEBHOOK_GRANS_NADD` — Högst 10 mottagare per partner.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "WEBHOOK_URL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "WEBHOOK_URL_OGILTIG"
                      ]
                    }
                  },
                  "HANDELSE_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "HANDELSE_OGILTIG"
                      ]
                    }
                  },
                  "WEBHOOK_GRANS_NADD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "WEBHOOK_GRANS_NADD"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "webhooks.manage",
        "x-fixra-rpc": "partner_api_call",
        "x-fixra-partner-op": "webhook_spara",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/partner/v1/webhooks\" \\\n  -H \"Authorization: Bearer fx_ptnr_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"url\":\"https://exempel.se/fixra\",\"events\":[\"licens.andrad\",\"kund.aktiverad\"]}'"
          }
        ]
      }
    },
    "/partner/v1/webhooks/{id}": {
      "patch": {
        "operationId": "partnerUpdateWebhook",
        "tags": [
          "Partner-API"
        ],
        "summary": "Ändra webhook",
        "description": "Adress, händelser, beskrivning eller på/av. Hemligheten byts inte.",
        "security": [
          {
            "partnerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2000
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "kund.aktiverad",
                        "kund.uppsagd",
                        "licens.andrad",
                        "provperiod.slutar",
                        "halsa.risk",
                        "deal.beslutad",
                        "provision.last"
                      ]
                    },
                    "minItems": 1
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "is_active": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "3f1c2a9e-7b1d-4c55-9a0e-2d6f1b7c8e90",
                    "url": "https://exempel.se/fixra",
                    "beskrivning": null,
                    "events": [
                      "licens.andrad"
                    ],
                    "is_active": true,
                    "avstangd_efter_fel": null,
                    "senaste_status": null,
                    "senaste_fel": null,
                    "senaste_leverans": null,
                    "skapad": "2026-10-08T12:00:00Z"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad i partnerportalen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`PARTNER_AVSTANGD` — Partnern är pausad eller avslutad.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare är inte längre aktiv partneradmin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "PARTNER_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARTNER_AVSTANGD"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`WEBHOOK_SAKNAS` — Mottagaren finns inte hos partnern.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "WEBHOOK_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "WEBHOOK_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`WEBHOOK_URL_OGILTIG` — Adressen måste vara https:// och publik.\n\n`PAYLOAD_OGILTIG` — Kroppen följer inte schemat.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "WEBHOOK_URL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "WEBHOOK_URL_OGILTIG"
                      ]
                    }
                  },
                  "PAYLOAD_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "webhooks.manage",
        "x-fixra-rpc": "partner_api_call",
        "x-fixra-partner-op": "webhook_spara",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.fixra.se/partner/v1/webhooks/{id}\" \\\n  -H \"Authorization: Bearer fx_ptnr_DIN_NYCKEL\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"is_active\":true}'"
          }
        ]
      },
      "delete": {
        "operationId": "partnerDeleteWebhook",
        "tags": [
          "Partner-API"
        ],
        "summary": "Ta bort webhook",
        "description": "Tar bort mottagaren och dess hemlighet.",
        "security": [
          {
            "partnerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "3f1c2a9e-7b1d-4c55-9a0e-2d6f1b7c8e90",
                    "borttagen": true
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad i partnerportalen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`PARTNER_AVSTANGD` — Partnern är pausad eller avslutad.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare är inte längre aktiv partneradmin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "PARTNER_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARTNER_AVSTANGD"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`WEBHOOK_SAKNAS` — Mottagaren finns inte hos partnern.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "WEBHOOK_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "WEBHOOK_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "webhooks.manage",
        "x-fixra-rpc": "partner_api_call",
        "x-fixra-partner-op": "webhook_ta_bort",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.fixra.se/partner/v1/webhooks/{id}\" \\\n  -H \"Authorization: Bearer fx_ptnr_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/partner/v1/webhooks/{id}/test": {
      "post": {
        "operationId": "partnerTestWebhook",
        "tags": [
          "Partner-API"
        ],
        "summary": "Skicka ping",
        "description": "Lägger en `ping` till just den här mottagaren.",
        "security": [
          {
            "partnerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "event_id": "3f1c2a9e-7b1d-4c55-9a0e-2d6f1b7c8e90",
                    "webhook_id": "3f1c2a9e-7b1d-4c55-9a0e-2d6f1b7c8e90",
                    "type": "ping"
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad i partnerportalen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`PARTNER_AVSTANGD` — Partnern är pausad eller avslutad.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare är inte längre aktiv partneradmin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "PARTNER_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARTNER_AVSTANGD"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`WEBHOOK_SAKNAS` — Mottagaren finns inte hos partnern.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "WEBHOOK_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "WEBHOOK_SAKNAS"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "webhooks.manage",
        "x-fixra-rpc": "partner_api_call",
        "x-fixra-partner-op": "webhook_testa",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST \"https://api.fixra.se/partner/v1/webhooks/{id}/test\" \\\n  -H \"Authorization: Bearer fx_ptnr_DIN_NYCKEL\""
          }
        ]
      }
    },
    "/partner/v1/webhooks/leveranser": {
      "get": {
        "operationId": "partnerListWebhookDeliveries",
        "tags": [
          "Partner-API"
        ],
        "summary": "Leveranslogg",
        "description": "De senaste leveranserna: händelse, status, försök och HTTP-svar.",
        "security": [
          {
            "partnerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 200
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "warnings",
                    "errors"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "ok": true,
                  "data": {
                    "leveranser": []
                  },
                  "warnings": [],
                  "errors": []
                }
              }
            }
          },
          "401": {
            "description": "`NYCKEL_OGILTIG` — Nyckeln saknas eller finns inte.\n\n`NYCKEL_ATERKALLAD` — Nyckeln är återkallad i partnerportalen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "NYCKEL_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_OGILTIG"
                      ]
                    }
                  },
                  "NYCKEL_ATERKALLAD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "NYCKEL_ATERKALLAD"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`SCOPE_SAKNAS` — Nyckeln saknar scopet; `required_scope` anger vilket.\n\n`PARTNER_AVSTANGD` — Partnern är pausad eller avslutad.\n\n`SAKNAR_BEHORIGHET` — Nyckelns skapare är inte längre aktiv partneradmin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "SCOPE_SAKNAS": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SCOPE_SAKNAS"
                      ]
                    }
                  },
                  "PARTNER_AVSTANGD": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARTNER_AVSTANGD"
                      ]
                    }
                  },
                  "SAKNAR_BEHORIGHET": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "SAKNAR_BEHORIGHET"
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`PAYLOAD_FOR_STOR` — Kroppen är större än 256 kB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PAYLOAD_FOR_STOR": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PAYLOAD_FOR_STOR"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`PARAMETER_OGILTIG` — En frågeparameter är ogiltig.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "PARAMETER_OGILTIG": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "PARAMETER_OGILTIG"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`STRYPT` — För många misslyckade nyckeluppslag från samma IP (20 per 15 min).\n\n`RATELIMIT` — Över 120 anrop eller 30 skrivningar per minut för nyckeln. Se `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "STRYPT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "STRYPT"
                      ]
                    }
                  },
                  "RATELIMIT": {
                    "value": {
                      "ok": false,
                      "data": null,
                      "warnings": [],
                      "errors": [
                        "RATELIMIT"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "x-fixra-scope": "webhooks.manage",
        "x-fixra-rpc": "partner_api_call",
        "x-fixra-partner-op": "webhook_leveranser",
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X GET \"https://api.fixra.se/partner/v1/webhooks/leveranser\" \\\n  -H \"Authorization: Bearer fx_ptnr_DIN_NYCKEL\""
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "`fx_live_…` eller `fx_test_…`. Testnycklar kör skrivningar torrt."
      },
      "partnerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Partnernyckel `fx_ptnr_…` från partnerportalen."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "ok",
          "data",
          "warnings",
          "errors"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "const": false
          },
          "data": {
            "type": [
              "object",
              "null"
            ]
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "required_scope": {
            "type": "string"
          }
        }
      }
    }
  }
}