{
  "openapi": "3.0.4",
  "info": {
    "title": "Politiloggen API",
    "description": "Dette APIet er kontinuerlig under utvikling. Formatet kan endres uten forvarsel. <br><br>Et API utviklet av Politiet for å hente ut operative meldinger fra operasjonssentralene i Norge. Dersom du har tilbakemeldinger kan disse sendes til politiloggen@politiet.no. Disse dataene er under norsk lisens for offentlige data (NLOD) 2.0: https://data.norge.no/nlod/no/2.0.",
    "contact": {
      "name": "Politiet",
      "url": "https://www.politiet.no",
      "email": "politiloggen@politiet.no"
    },
    "version": "v1"
  },
  "paths": {
    "/categories": {
      "get": {
        "tags": [
          "Common"
        ],
        "summary": "Retrieves categories.",
        "parameters": [
          {
            "name": "language",
            "in": "query",
            "description": "Supports: nb, nn",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/districts": {
      "get": {
        "tags": [
          "Common"
        ],
        "summary": "Retrieves police districts.",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/districts/extended": {
      "get": {
        "tags": [
          "Common"
        ],
        "summary": "Retrieves police districts and their municipalities.",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/feeds/atom": {
      "get": {
        "tags": [
          "Feed"
        ],
        "summary": "Retrieves the latest messages as an Atom feed.",
        "parameters": [
          {
            "name": "districts",
            "in": "query",
            "description": "An array of district names to filter the messages.",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/DistrictEnum"
              }
            }
          },
          {
            "name": "municipalities",
            "in": "query",
            "description": "An array of municipality names to filter the messages.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "categories",
            "in": "query",
            "description": "An array of category names to filter the messages.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/feeds/rss": {
      "get": {
        "tags": [
          "Feed"
        ],
        "summary": "Retrieves the latest messages as an RSS feed.",
        "parameters": [
          {
            "name": "districts",
            "in": "query",
            "description": "An array of district names to filter the messages.",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/DistrictEnum"
              }
            }
          },
          {
            "name": "municipalities",
            "in": "query",
            "description": "An array of municipality names to filter the messages.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "categories",
            "in": "query",
            "description": "An array of category names to filter the messages.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/messages": {
      "get": {
        "tags": [
          "Message"
        ],
        "summary": "Retrieves a collection of messages filtered by various criteria.",
        "parameters": [
          {
            "name": "Districts",
            "in": "query",
            "description": "Filter messages by police district names.",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/DistrictEnum"
              }
            }
          },
          {
            "name": "Municipalities",
            "in": "query",
            "description": "Filter messages by municipality names.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "Categories",
            "in": "query",
            "description": "Filter messages by category names.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "Ids",
            "in": "query",
            "description": "Filter messages by unique ids.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "IsActive",
            "in": "query",
            "description": "Filter messages by their current status.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "DateFrom",
            "in": "query",
            "description": "The start date for filtering messages. Formatted as yyyy-mm-dd.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "DateTo",
            "in": "query",
            "description": "The end date for filtering messages. Formatted as yyyy-mm-dd.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "SortBy",
            "in": "query",
            "description": "The sorting criteria.",
            "schema": {
              "$ref": "#/components/schemas/SortTypeEnum"
            }
          },
          {
            "name": "SortOrder",
            "in": "query",
            "description": "The sorting order.",
            "schema": {
              "$ref": "#/components/schemas/SortOrderEnum"
            }
          },
          {
            "name": "Fields",
            "in": "query",
            "description": "Specifies which fields of the message should be included in the response.",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/FieldsEnum"
              }
            }
          },
          {
            "name": "Skip",
            "in": "query",
            "description": "The number of records to take. The default is 0.",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "Take",
            "in": "query",
            "description": "The number of records to skip for pagination. The default is 10. Max is 50.",
            "schema": {
              "maximum": 50,
              "minimum": 1,
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/MessageFilterResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageFilterResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageFilterResponse"
                }
              }
            }
          }
        }
      }
    },
    "/messages/{id}": {
      "get": {
        "tags": [
          "Message"
        ],
        "summary": "Retrieves a specific message by its ID.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The unique identifier of the message to retrieve.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/MessageDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageDto"
                }
              }
            }
          }
        }
      }
    },
    "/messages/{id}/image": {
      "get": {
        "tags": [
          "Message"
        ],
        "summary": "Retrieves an image by message ID.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The unique identifier of the message that includes the image.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "scale",
            "in": "query",
            "description": "The width of the image.",
            "schema": {
              "type": "string",
              "default": "S1440"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/messages/export": {
      "get": {
        "tags": [
          "Message"
        ],
        "summary": "Exports all messages as a .csv file. Generated once a day.",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/messagethreads": {
      "get": {
        "tags": [
          "MessageThread"
        ],
        "summary": "Retrieves a collection of message threads filtered by various criteria.",
        "description": "This endpoint supports filtering.",
        "parameters": [
          {
            "name": "TimeSpanType",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/TimeSpanTypeEnum"
            }
          },
          {
            "name": "SortByEnum",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/SortTypeEnum"
            }
          },
          {
            "name": "IsActiveEnum",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/IsActiveEnum"
            }
          },
          {
            "name": "SortByAsc",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "DateTimeFrom",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "DateTimeTo",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "Districts",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "DistrictIds",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int32"
              }
            }
          },
          {
            "name": "Area",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Municipalities",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "Ids",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "Category",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "Take",
            "in": "query",
            "schema": {
              "maximum": 1000,
              "minimum": 1,
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "Skip",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/MessageThreadFilterResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageThreadFilterResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageThreadFilterResponse"
                }
              }
            }
          }
        }
      }
    },
    "/messagethreads/{id}": {
      "get": {
        "tags": [
          "MessageThread"
        ],
        "summary": "Retrieves a specific message thread by its ID.",
        "description": "This endpoint fetches a single message thread that matches the specified ID.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The unique identifier of the message thread to retrieve.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/MessageThreadDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageThreadDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageThreadDto"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DistrictEnum": {
        "enum": [
          "Oslo",
          "Øst",
          "Innlandet",
          "SørØst",
          "Agder",
          "SørVest",
          "Vest",
          "MøreOgRomsdal",
          "Trøndelag",
          "Nordland",
          "Troms",
          "Finnmark"
        ],
        "type": "string"
      },
      "FieldsEnum": {
        "enum": [
          "Id",
          "ThreadId",
          "Text",
          "District",
          "Category",
          "Municipality",
          "Area",
          "CreatedOn",
          "UpdatedOn",
          "ImageUrl",
          "IsEdited",
          "IsActive"
        ],
        "type": "string"
      },
      "IsActiveEnum": {
        "enum": [
          "None",
          "Active",
          "Inactive"
        ],
        "type": "string"
      },
      "MessageDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "threadId": {
            "type": "string",
            "nullable": true
          },
          "category": {
            "type": "string",
            "nullable": true
          },
          "district": {
            "type": "string",
            "nullable": true
          },
          "municipality": {
            "type": "string",
            "nullable": true
          },
          "area": {
            "type": "string",
            "nullable": true
          },
          "isActive": {
            "type": "boolean"
          },
          "text": {
            "type": "string",
            "nullable": true
          },
          "createdOn": {
            "type": "string",
            "format": "date-time"
          },
          "updatedOn": {
            "type": "string",
            "format": "date-time"
          },
          "imageUrl": {
            "type": "string",
            "nullable": true
          },
          "previouslyIncludedImage": {
            "type": "boolean"
          },
          "isEdited": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "MessageFilterResponse": {
        "type": "object",
        "properties": {
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessageDto"
            },
            "nullable": true
          },
          "hasMoreResults": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "MessageThreadDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "district": {
            "type": "string",
            "nullable": true
          },
          "districtId": {
            "type": "integer",
            "format": "int32"
          },
          "category": {
            "type": "string",
            "nullable": true
          },
          "municipality": {
            "type": "string",
            "nullable": true
          },
          "area": {
            "type": "string",
            "nullable": true
          },
          "createdOn": {
            "type": "string",
            "format": "date-time"
          },
          "updatedOn": {
            "type": "string",
            "format": "date-time"
          },
          "lastMessageOn": {
            "type": "string",
            "format": "date-time"
          },
          "isActive": {
            "type": "boolean"
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ThreadMessageDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "MessageThreadFilterResponse": {
        "type": "object",
        "properties": {
          "messageThreads": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessageThreadDto"
            },
            "nullable": true
          },
          "hasMoreResults": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "MessageTypeEnum": {
        "enum": [
          "Draft",
          "Published",
          "Edited",
          "Removed"
        ],
        "type": "string"
      },
      "SortOrderEnum": {
        "enum": [
          "Ascending",
          "Descending"
        ],
        "type": "string"
      },
      "SortTypeEnum": {
        "enum": [
          "None",
          "Date",
          "Update",
          "LastMessageOn",
          "District",
          "Category",
          "Area",
          "Municipality",
          "IsActive"
        ],
        "type": "string"
      },
      "ThreadMessageDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "text": {
            "type": "string",
            "nullable": true
          },
          "createdOn": {
            "type": "string",
            "format": "date-time"
          },
          "updatedOn": {
            "type": "string",
            "format": "date-time"
          },
          "hasImage": {
            "type": "boolean"
          },
          "previouslyIncludedImage": {
            "type": "boolean"
          },
          "type": {
            "$ref": "#/components/schemas/MessageTypeEnum"
          }
        },
        "additionalProperties": false
      },
      "TimeSpanTypeEnum": {
        "enum": [
          "None",
          "Custom",
          "LastHour",
          "LastDay",
          "LastWeek",
          "LastMonth",
          "LastQuarter",
          "LastYear"
        ],
        "type": "string"
      }
    }
  },
  "tags": [
    {
      "name": "Common"
    },
    {
      "name": "Feed"
    },
    {
      "name": "Message"
    },
    {
      "name": "MessageThread"
    }
  ]
}