{
  "openapi": "3.0.1",
  "info": {
    "title": "KS Fiks: Varsling SMS V2",
    "description": "Service for varsling via SMS",
    "contact": {
      "name": "Fiks-brukerstøtte",
      "url": "https://ks-no.github.io/",
      "email": "fiks@ksdigital.no"
    },
    "version": "v2"
  },
  "servers": [
    {
      "url": "https://api.fiks.ks.no",
      "description": "KS Fiks API host"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "SmsV2",
      "description": "API for å håndtere funksjonalitet for sending av sms og epost "
    }
  ],
  "paths": {
    "/varsling/api/v2/sms/{kontoId}/sms/{smsId}": {
      "get": {
        "tags": [
          "SmsV2"
        ],
        "summary": "Henter status på sms",
        "operationId": "hentStatus",
        "parameters": [
          {
            "name": "kontoId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "smsId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Status for sms",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsRespons"
                }
              }
            }
          },
          "403": {
            "description": "Ingen tilgang",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "404": {
            "description": "Ingen sms",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "description": "Systemfeil",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          }
        }
      }
    },
    "/varsling/api/v2/sms/{kontoId}/oppslag": {
      "post": {
        "tags": [
          "SmsV2"
        ],
        "summary": "Kontakt- og reservasjonsregister oppslag",
        "operationId": "krrOppslagSync",
        "parameters": [
          {
            "name": "kontoId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OppslagRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Gjør oppslag på fødselsnummer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/KontaktInformasjonRespons"
                  }
                }
              }
            }
          },
          "default": {
            "description": "Noe gikk galt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          }
        }
      }
    },
    "/varsling/api/v2/sms/{kontoId}/sendBatch": {
      "post": {
        "tags": [
          "SmsV2"
        ],
        "summary": "Send enkel batch med sms",
        "operationId": "sendBatchSms",
        "parameters": [
          {
            "name": "kontoId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SmsBatchRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Send enkel batch med sms"
          },
          "default": {
            "description": "Noe gikk galt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          }
        }
      }
    },
    "/varsling/api/v2/sms/{kontoId}/send": {
      "post": {
        "tags": [
          "SmsV2"
        ],
        "summary": "Sender sms",
        "operationId": "sendSms",
        "parameters": [
          {
            "name": "kontoId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SmsMeldingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Send sms",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsId"
                }
              }
            }
          },
          "403": {
            "description": "Ingen tilgang",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "500": {
            "description": "Systemfeil",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "SmsRespons": {
        "required": [
          "id",
          "status"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Id på meldingen",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "description": "Status på sms meldingen",
            "enum": [
              "OPPRETTET",
              "SENDT",
              "IKKE_SENDT",
              "IKKE_LEVERT",
              "LEVERT",
              "UKJENT"
            ]
          }
        }
      },
      "ErrorMessage": {
        "type": "object",
        "properties": {
          "timestamp": {
            "type": "integer",
            "format": "int64"
          },
          "status": {
            "type": "integer",
            "format": "int32"
          },
          "error": {
            "type": "string"
          },
          "errorId": {
            "type": "string",
            "format": "uuid"
          },
          "path": {
            "type": "string"
          },
          "originalPath": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "errorCode": {
            "type": "string"
          },
          "errorJson": {
            "type": "string"
          }
        }
      },
      "KontaktInformasjonRespons": {
        "type": "object",
        "required": [
          "fnrOrgnr",
          "telefonnummerStatus"
        ],
        "properties": {
          "fnrOrgnr": {
            "type": "string"
          },
          "telefonnummer": {
            "type": "string"
          },
          "telefonnummerStatus": {
            "type": "string",
            "enum": [
              "GYLDIG",
              "UGYLDIG",
              "IKKE_FUNNET"
            ]
          }
        }
      },
      "OppslagRequest": {
        "type": "object",
        "required": [
          "fnrOrgnrs"
        ],
        "properties": {
          "fnrOrgnrs": {
            "maxItems": 1000,
            "minItems": 1,
            "type": "array",
            "description": "Fødselsnummere og/eller orgnummere det skal gjøres oppslag på",
            "items": {
              "type": "string",
              "description": "Fødselsnummere og/eller orgnummere det skal gjøres oppslag på"
            }
          }
        }
      },
      "SmsBatchRequest": {
        "required": [
          "telefonnummere",
          "tekst"
        ],
        "type": "object",
        "properties": {
          "telefonnummere": {
            "maxItems": 1000,
            "minItems": 1,
            "type": "array",
            "description": "Telefonnummre til mottakere. Telefonnummer må ha minimumslengde på åtte tall. Telefonnummer uten landskode (00 eller + etterfulgt av landskode) blir tolket som norske og må begynne på 4 eller 9. Internasjonale telefonnummer må begynne med + (eller 00) etterfulgt av landskode og telefonnummer.",
            "items": {
              "type": "string"
            }
          },
          "tekst": {
            "maxLength": 1600,
            "minLength": 2,
            "type": "string",
            "description": "Meldingsteksten. Merk at bruk av tegn utenfor GSM-7 encoding vil føre til at maksimalt antall tegn per SMS reduseres kraftig."
          },
          "skjulTekstIRapport": {
            "type": "boolean",
            "description": "Settes til true dersom det ønskes at SMS-teksten skal skjules fra rapport. Default er at den vises."
          }
        }
      },
      "SmsId": {
        "required": [
          "id"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Id på sms melding",
            "format": "uuid"
          }
        }
      },
      "SmsMeldingRequest": {
        "required": [
          "tekst"
        ],
        "type": "object",
        "properties": {
          "tekst": {
            "maxLength": 1600,
            "minLength": 2,
            "type": "string",
            "description": "Meldingsteksten. Merk at bruk av tegn utenfor GSM-7 encoding vil føre til at maksimalt antall tegn per SMS reduseres kraftig."
          },
          "skjulTekstIRapport": {
            "type": "boolean",
            "description": "Settes til true dersom det ønskes at SMS-teksten skal skjules fra rapport. Default er at den vises."
          },
          "fnr": {
            "pattern": "^[0-9]{11}$",
            "type": "string",
            "description": "Fødselsnummer til mottaker"
          },
          "telefonnummer": {
            "type": "string",
            "description": "Telefonnummer til mottaker. Telefonnummer må ha minimumslengde på åtte tall. Telefonnummer uten landskode (00 eller + etterfulgt av landskode) blir tolket som norske og må begynne på 4 eller 9. Internasjonale telefonnummer må begynne med + (eller 00) etterfulgt av landskode og telefonnummer."
          }
        }
      }
    }
  }
}