openapi: 3.1.0
info:
  title: Messaging
  contact: {}
  license:
    name: MIT License
    url: https://opensource.org/licenses/MIT
  version: "7.12"
servers:
- url: http://localhost:64409
  description: Generated server url
paths:
  /{municipalityId}/{organizationNumber}/mailboxes:
    post:
      tags:
      - Sending Resources
      summary: Retrieve a list of digital mailboxes
      description: "Response contains a list of partyIds, supplier and if the digital\
        \ mailbox is reachable for the given organization."
      operationId: getMailboxes
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: organizationNumber
        in: path
        description: The organization number of the intended sending organization
        required: true
        schema:
          type: string
        example: 5561234567
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                type: string
        required: true
      responses:
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Mailbox"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "502":
          description: Bad Gateway
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/{organizationNumber}/digital-mail:
    post:
      tags:
      - Sending Resources
      summary: Send a single digital mail to one or more parties
      operationId: sendDigitalMail
      parameters:
      - name: x-origin
        in: header
        description: Origin of the request
        required: false
        schema:
          type: string
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: organizationNumber
        in: path
        description: The organization number of the sending organization
        required: true
        schema:
          type: string
        example: 5561234567
      - name: async
        in: query
        description: If the message should be sent asynchronously or not
        required: false
        schema:
          type: boolean
          default: false
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DigitalMailRequest"
        required: true
      responses:
        "201":
          description: Successful Operation
          headers:
            Location:
              style: simple
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageBatchResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "502":
          description: Bad Gateway
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/webmessage:
    post:
      tags:
      - Sending Resources
      summary: Send a single web message
      operationId: sendWebMessage
      parameters:
      - name: x-origin
        in: header
        description: Origin of the request
        required: false
        schema:
          type: string
      - name: x-issuer
        in: header
        description: "Issuer of the request.  **DEPRECATED**: This parameter will\
          \ be removed in a future version, use X-Sent-By instead."
        required: false
        deprecated: true
        schema:
          type: string
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: async
        in: query
        description: If the message should be sent asynchronously or not
        required: false
        schema:
          type: boolean
          default: false
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebMessageRequest"
        required: true
      responses:
        "201":
          description: Successful Operation
          headers:
            Location:
              style: simple
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "502":
          description: Bad Gateway
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/snail-mail:
    post:
      tags:
      - Sending Resources
      summary: Add snail-mail to a batch
      operationId: addSnailMailToBatch
      parameters:
      - name: x-origin
        in: header
        description: Origin of the request
        required: false
        schema:
          type: string
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: batchId
        in: query
        description: The snail-mail batch id
        required: true
        schema:
          type: string
        example: f427952b-247c-4d3b-b081-675a467b3619
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SnailmailRequest"
        required: true
      responses:
        "201":
          description: Successful Operation
          headers:
            Location:
              style: simple
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "502":
          description: Bad Gateway
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/snail-mail/batch/{batchId}:
    post:
      tags:
      - Sending Resources
      summary: Trigger processing of a snail-mail batch
      operationId: triggerSnailMailBatchProcessing
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: batchId
        in: path
        description: The snail-mail batch id
        required: true
        schema:
          type: string
        example: f427952b-247c-4d3b-b081-675a467b3619
      responses:
        "200":
          description: Successful Operation
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "502":
          description: Bad Gateway
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/sms:
    post:
      tags:
      - Sending Resources
      summary: Send a single SMS
      operationId: sendSms
      parameters:
      - name: x-origin
        in: header
        description: Origin of the request
        required: false
        schema:
          type: string
      - name: x-issuer
        in: header
        description: "Issuer of the request.  **DEPRECATED**: This parameter will\
          \ be removed in a future version, use X-Sent-By instead."
        required: false
        deprecated: true
        schema:
          type: string
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: async
        in: query
        description: If the message should be sent asynchronously or not
        required: false
        schema:
          type: boolean
          default: false
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SmsRequest"
        required: true
      responses:
        "201":
          description: Successful Operation
          headers:
            Location:
              style: simple
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "502":
          description: Bad Gateway
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/sms/batch:
    post:
      tags:
      - Sending Resources
      summary: Send a batch of sms asynchronously
      operationId: sendSmsBatch
      parameters:
      - name: x-origin
        in: header
        description: Origin of the request
        required: false
        schema:
          type: string
      - name: x-issuer
        in: header
        description: "Issuer of the request.  **DEPRECATED**: This parameter will\
          \ be removed in a future version, use X-Sent-By instead."
        required: false
        deprecated: true
        schema:
          type: string
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SmsBatchRequest"
        required: true
      responses:
        "201":
          description: Successful Operation
          headers:
            Location:
              style: simple
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageBatchResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "502":
          description: Bad Gateway
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/slack:
    post:
      tags:
      - Sending Resources
      summary: Send a single Slack message
      operationId: sendToSlack
      parameters:
      - name: x-origin
        in: header
        description: Origin of the request
        required: false
        schema:
          type: string
      - name: x-issuer
        in: header
        description: "Issuer of the request.  **DEPRECATED**: This parameter will\
          \ be removed in a future version, use X-Sent-By instead."
        required: false
        deprecated: true
        schema:
          type: string
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: async
        in: query
        description: If the message should be sent asynchronously or not
        required: false
        schema:
          type: boolean
          default: false
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SlackRequest"
        required: true
      responses:
        "201":
          description: Successful Operation
          headers:
            Location:
              style: simple
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "502":
          description: Bad Gateway
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/messages:
    post:
      tags:
      - Sending Resources
      summary: Send a batch of messages as e-mail or SMS to a list of parties
      operationId: sendMessages
      parameters:
      - name: x-origin
        in: header
        description: Origin of the request
        required: false
        schema:
          type: string
      - name: x-issuer
        in: header
        description: "Issuer of the request.  **DEPRECATED**: This parameter will\
          \ be removed in a future version, use X-Sent-By instead."
        required: false
        deprecated: true
        schema:
          type: string
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: async
        in: query
        description: If the message should be sent asynchronously or not
        required: false
        schema:
          type: boolean
          default: false
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MessageRequest"
        required: true
      responses:
        "201":
          description: Successful Operation
          headers:
            Location:
              style: simple
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageBatchResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "502":
          description: Bad Gateway
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/letter:
    post:
      tags:
      - Sending Resources
      summary: Send a single letter as digital mail or snail mail
      operationId: sendLetter
      parameters:
      - name: x-origin
        in: header
        description: Origin of the request
        required: false
        schema:
          type: string
      - name: x-issuer
        in: header
        description: "Issuer of the request.  **DEPRECATED**: This parameter will\
          \ be removed in a future version, use X-Sent-By instead."
        required: false
        deprecated: true
        schema:
          type: string
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: async
        in: query
        description: If the message should be sent asynchronously or not
        required: false
        schema:
          type: boolean
          default: false
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LetterRequest"
        required: true
      responses:
        "201":
          description: Successful Operation
          headers:
            Location:
              style: simple
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageBatchResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "502":
          description: Bad Gateway
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/email:
    post:
      tags:
      - Sending Resources
      summary: Send a single e-mail
      operationId: sendEmail
      parameters:
      - name: x-origin
        in: header
        description: Origin of the request
        required: false
        schema:
          type: string
      - name: x-issuer
        in: header
        description: "Issuer of the request.  **DEPRECATED**: This parameter will\
          \ be removed in a future version, use X-Sent-By instead."
        required: false
        deprecated: true
        schema:
          type: string
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: async
        in: query
        description: If the message should be sent asynchronously or not
        required: false
        schema:
          type: boolean
          default: false
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EmailRequest"
        required: true
      responses:
        "201":
          description: Successful Operation
          headers:
            Location:
              style: simple
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "502":
          description: Bad Gateway
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/email/batch:
    post:
      tags:
      - Sending Resources
      summary: Send a batch of e-mails asynchronously
      operationId: sendEmailBatch
      parameters:
      - name: x-origin
        in: header
        description: Origin of the request
        required: false
        schema:
          type: string
      - name: x-issuer
        in: header
        description: "Issuer of the request.  **DEPRECATED**: This parameter will\
          \ be removed in a future version, use X-Sent-By instead."
        required: false
        deprecated: true
        schema:
          type: string
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EmailBatchRequest"
        required: true
      responses:
        "201":
          description: Successful Operation
          headers:
            Location:
              style: simple
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageBatchResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "502":
          description: Bad Gateway
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/digital-mail:
    post:
      tags:
      - Sending Resources
      summary: Send a single digital mail to one or more parties
      description: "This endpoint is deprecated in favor of /{organizationNumber}/digital-mail\
        \ and will be removed in a future version."
      operationId: sendDigitalMailDeprecated
      parameters:
      - name: x-origin
        in: header
        description: Origin of the request
        required: false
        schema:
          type: string
      - name: x-issuer
        in: header
        description: "Issuer of the request.  **DEPRECATED**: This parameter will\
          \ be removed in a future version, use X-Sent-By instead."
        required: false
        deprecated: true
        schema:
          type: string
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: async
        in: query
        description: If the message should be sent asynchronously or not
        required: false
        schema:
          type: boolean
          default: false
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DigitalMailRequest"
        required: true
      responses:
        "201":
          description: Successful Operation
          headers:
            Location:
              style: simple
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageBatchResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "502":
          description: Bad Gateway
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
      deprecated: true
  /{municipalityId}/digital-invoice:
    post:
      tags:
      - Sending Resources
      summary: Send a digital invoice
      operationId: sendDigitalInvoice
      parameters:
      - name: x-origin
        in: header
        description: Origin of the request
        required: false
        schema:
          type: string
      - name: x-issuer
        in: header
        description: "Issuer of the request.  **DEPRECATED**: This parameter will\
          \ be removed in a future version, use X-Sent-By instead."
        required: false
        deprecated: true
        schema:
          type: string
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: async
        in: query
        description: If the message should be sent asynchronously or not
        required: false
        schema:
          type: boolean
          default: false
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DigitalInvoiceRequest"
        required: true
      responses:
        "201":
          description: Successful Operation
          headers:
            Location:
              style: simple
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "502":
          description: Bad Gateway
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/users/{userId}/messages:
    get:
      tags:
      - History Resources
      summary: "Get historical messages sent by a user, optionally filtered by batch\
        \ id"
      operationId: getUserMessages
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: userId
        in: path
        description: User id
        required: true
        schema:
          type: string
        example: joe01doe
      - name: batchId
        in: query
        description: Batch id
        required: false
        schema:
          type: string
          format: uuid
        example: 118e05b3-4321-4f46-9a33-b9f43faa58a6
      - name: page
        in: query
        description: Which page to fetch
        required: false
        schema:
          type: integer
          format: int32
          default: 1
          minimum: 1
        example: 1
      - name: limit
        in: query
        description: Sets the amount of entries per page
        required: false
        schema:
          type: integer
          format: int32
          default: 15
          minimum: 1
        example: 1
      responses:
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserMessages"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/users/{userId}/messages/{messageId}:
    get:
      tags:
      - History Resources
      summary: Get a historical message sent by a user
      operationId: getUserMessage
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: userId
        in: path
        description: User id
        required: true
        schema:
          type: string
        example: joe01doe
      - name: messageId
        in: path
        required: true
        schema:
          type: string
          format: uuid
        example: d1e07d2c-2e75-44e0-b978-de7e19d7edad
      responses:
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserMessage"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/users/{userId}/batches:
    get:
      tags:
      - History Resources
      summary: Get information regarding historical batches sent by a user
      operationId: getUserBatches
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: userId
        in: path
        description: User id
        required: true
        schema:
          type: string
        example: joe01doe
      - name: page
        in: query
        description: Which page to fetch
        required: false
        schema:
          type: integer
          format: int32
          default: 1
          minimum: 1
        example: 1
      - name: limit
        in: query
        description: Sets the amount of entries per page
        required: false
        schema:
          type: integer
          format: int32
          default: 15
          minimum: 1
        example: 1
      responses:
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserBatches"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/status/messages/{messageId}:
    get:
      tags:
      - History Resources
      summary: Get the status for a single message and its deliveries
      operationId: getMessageStatus
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: messageId
        in: path
        required: true
        schema:
          type: string
          format: uuid
        example: d1e07d2c-2e75-44e0-b978-de7e19d7edad
      responses:
        "404":
          description: Not Found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/status/delivery/{deliveryId}:
    get:
      tags:
      - History Resources
      summary: Get the status for a single delivery
      operationId: getDeliveryStatus
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: deliveryId
        in: path
        required: true
        schema:
          type: string
          format: uuid
        example: 41141c6f-4825-45a7-b52b-79fbff70765e
      responses:
        "404":
          description: Not Found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeliveryResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/status/batch/{batchId}:
    get:
      tags:
      - History Resources
      summary: "Get the status for a message batch, its messages and their deliveries"
      operationId: getBatchStatus
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: batchId
        in: path
        required: true
        schema:
          type: string
          format: uuid
        example: 118e05b3-4321-4f46-9a33-b9f43faa58a6
      responses:
        "404":
          description: Not Found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageBatchResult"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/statistics:
    get:
      tags:
      - Statistics Resources
      summary: Get delivery statistics
      operationId: getStatistics
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: messageType
        in: query
        description: Message type
        required: false
        schema:
          type: string
          enum:
          - MESSAGE
          - EMAIL
          - SMS
          - WEB_MESSAGE
          - DIGITAL_MAIL
          - DIGITAL_INVOICE
          - SNAIL_MAIL
          - LETTER
          - SLACK
      - name: from
        in: query
        description: "From-date (inclusive). Format: yyyy-MM-dd (ISO8601)"
        required: false
        schema:
          type: string
          format: date
      - name: to
        in: query
        description: "To-date (inclusive). Format: yyyy-MM-dd (ISO8601)"
        required: false
        schema:
          type: string
          format: date
      responses:
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Statistics"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/statistics/departments/{department}:
    get:
      tags:
      - Statistics Resources
      summary: Get letter delivery statistics by department
      operationId: getDepartmentStatistics
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: department
        in: path
        description: Department name
        required: true
        schema:
          type: string
      - name: origin
        in: query
        description: Origin name
        required: false
        schema:
          type: string
      - name: from
        in: query
        description: "From-date (inclusive). Format: yyyy-MM-dd (ISO8601)"
        required: false
        schema:
          type: string
          format: date
      - name: to
        in: query
        description: "To-date (inclusive). Format: yyyy-MM-dd (ISO8601)"
        required: false
        schema:
          type: string
          format: date
      responses:
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/DepartmentStatistics"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/statistics/departments:
    get:
      tags:
      - Statistics Resources
      summary: Get letter delivery statistics by department
      operationId: getDepartmentStatistics_1
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: origin
        in: query
        description: Origin name
        required: false
        schema:
          type: string
      - name: from
        in: query
        description: "From-date (inclusive). Format: yyyy-MM-dd (ISO8601)"
        required: false
        schema:
          type: string
          format: date
      - name: to
        in: query
        description: "To-date (inclusive). Format: yyyy-MM-dd (ISO8601)"
        required: false
        schema:
          type: string
          format: date
      responses:
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/DepartmentStatistics"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/statistics/delivery-status:
    get:
      tags:
      - Statistics Resources
      summary: Get letter and sms delivery statistics by department
      operationId: getStatisticsByDepartment
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: department
        in: query
        description: Department name
        required: false
        schema:
          type: string
      - name: origin
        in: query
        description: Origin name
        required: false
        schema:
          type: string
      - name: from
        in: query
        description: "From-date (inclusive). Format: yyyy-MM-dd (ISO8601)"
        required: false
        schema:
          type: string
          format: date
      - name: to
        in: query
        description: "To-date (inclusive). Format: yyyy-MM-dd (ISO8601)"
        required: false
        schema:
          type: string
          format: date
      responses:
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DepartmentStats"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/messages/{messageId}:
    get:
      tags:
      - History Resources
      summary: Get a message and all its deliveries
      description: "This endpoint is deprecated and will be removed in a future version.Use\
        \ /messages/{messageId}/metadata instead. To get the file content for the\
        \ message use /messages/{messageId}/attachments/{fileName}."
      operationId: getMessage
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: messageId
        in: path
        required: true
        schema:
          type: string
          format: uuid
        example: d1e07d2c-2e75-44e0-b978-de7e19d7edad
      responses:
        "404":
          description: Not Found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/HistoryResponse"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
      deprecated: true
  /{municipalityId}/messages/{messageId}/metadata:
    get:
      tags:
      - History Resources
      summary: Get metadata for a message and all its deliveries
      operationId: getMessageMetadata
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: messageId
        in: path
        required: true
        schema:
          type: string
          format: uuid
        example: d1e07d2c-2e75-44e0-b978-de7e19d7edad
      responses:
        "404":
          description: Not Found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/HistoryResponse"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/messages/{messageId}/attachments:
    get:
      tags:
      - History Resources
      summary: Stream attachment by messageId and fileName
      operationId: readAttachmentByRequestParameter
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: messageId
        in: path
        required: true
        schema:
          type: string
          format: uuid
        example: d1e07d2c-2e75-44e0-b978-de7e19d7edad
      - name: fileName
        in: query
        required: true
        schema:
          type: string
          minLength: 1
        example: some-filename.txt
      responses:
        "200":
          description: Successful Operation
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/messages/{messageId}/attachments/{fileName}:
    get:
      tags:
      - History Resources
      summary: Stream attachment by messageId and fileName
      description: |
        This endpoint is deprecated and will be removed in a future version."
        Use /{municipalityId}/messages/{messageId}/attachments and provide the filename using request parameter fileName.
      operationId: readAttachment
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: messageId
        in: path
        required: true
        schema:
          type: string
          format: uuid
        example: d1e07d2c-2e75-44e0-b978-de7e19d7edad
      - name: fileName
        in: path
        required: true
        schema:
          type: string
        example: some-filename.txt
      responses:
        "200":
          description: Successful Operation
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
      deprecated: true
  /{municipalityId}/conversation-history/{partyId}:
    get:
      tags:
      - History Resources
      summary: Get the entire conversation history for a given party
      operationId: getConversationHistory
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: partyId
        in: path
        required: true
        schema:
          type: string
          format: uuid
        example: 46f9bf9f-09f2-45ac-8c8b-6cad847541ed
      - name: from
        in: query
        description: "From-date (inclusive). Format: yyyy-MM-dd (ISO8601)"
        required: false
        schema:
          type: string
          format: date
      - name: to
        in: query
        description: "To-date (inclusive). Format: yyyy-MM-dd (ISO8601)"
        required: false
        schema:
          type: string
          format: date
      responses:
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/HistoryResponse"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /api-docs:
    get:
      tags:
      - API
      summary: OpenAPI
      operationId: getApiDocs
      responses:
        "200":
          description: OK
          content:
            application/yaml:
              schema:
                type: string
      x-auth-type: None
      x-throttling-tier: Unlimited
      x-wso2-mutual-ssl: Optional
components:
  schemas:
    Problem:
      type: object
      properties:
        title:
          type: string
        detail:
          type: string
        instance:
          type: string
          format: uri
        type:
          type: string
          format: uri
        status:
          type: integer
          format: int32
    Mailbox:
      type: object
      description: Response model for a mailbox
      properties:
        partyId:
          type: string
          description: partyId for the person the mailbox belongs to
        reason:
          type: string
          description: "If not reachable, the reason why"
        supplier:
          type: string
          description: "Name of the mailbox, e.g. Kivra"
        reachable:
          type: boolean
          description: If it's possible to send messages to this mailbox
    DigitalMailAttachment:
      type: object
      description: Attachment
      properties:
        contentType:
          type: string
          description: Content type
          enum:
          - application/pdf
        content:
          type: string
          description: Content (BASE64-encoded)
          minLength: 1
        filename:
          type: string
          description: Filename
          minLength: 1
      required:
      - content
      - filename
    DigitalMailParty:
      type: object
      properties:
        partyIds:
          type: array
          items:
            type: string
            format: uuid
            description: The message party ids
          minItems: 1
        externalReferences:
          type: array
          description: External references
          items:
            $ref: "#/components/schemas/ExternalReference"
      required:
      - partyIds
    DigitalMailRequest:
      type: object
      properties:
        party:
          $ref: "#/components/schemas/DigitalMailParty"
          description: Party
        sender:
          $ref: "#/components/schemas/DigitalMailSender"
          description: Sender
        subject:
          type:
          - string
          - "null"
          description: Subject
        department:
          type:
          - string
          - "null"
          description: Department and unit that should be billed for the message
          examples:
          - "SBK(Gatuavdelningen, Trafiksektionen)"
        contentType:
          type: string
          description: Content type
          enum:
          - text/plain
          - text/html
        body:
          type: string
          description: "Body (plain text if contentType is set to 'text/plain', BASE64-encoded\
            \ if contentType is set to 'application/html')"
        attachments:
          type: array
          description: Attachments
          items:
            $ref: "#/components/schemas/DigitalMailAttachment"
      required:
      - party
    DigitalMailSender:
      type: object
      properties:
        supportInfo:
          $ref: "#/components/schemas/DigitalMailSenderSupportInfo"
      required:
      - supportInfo
    DigitalMailSenderSupportInfo:
      type: object
      description: Support info
      properties:
        text:
          type: string
          description: Text
          minLength: 1
        emailAddress:
          type: string
          format: email
          description: E-mail address
        phoneNumber:
          type: string
          description: Phone number
        url:
          type: string
          description: URL
      required:
      - text
    ExternalReference:
      type: object
      properties:
        key:
          type: string
          description: The external reference key
          examples:
          - flowInstanceId
          minLength: 1
        value:
          type: string
          description: The external reference value
          examples:
          - 356t4r34f
          minLength: 1
      required:
      - key
      - value
    DeliveryResult:
      type: object
      description: Delivery result
      properties:
        deliveryId:
          type: string
          format: uuid
          description: The delivery id
        messageType:
          $ref: "#/components/schemas/MessageType"
          description: Message type
        status:
          $ref: "#/components/schemas/MessageStatus"
          description: Status
    MessageBatchResult:
      type: object
      description: Message batch result
      properties:
        batchId:
          type: string
          format: uuid
          description: The batch id
        messages:
          type: array
          description: The individual message results
          items:
            $ref: "#/components/schemas/MessageResult"
    MessageResult:
      type: object
      description: Message result
      properties:
        messageId:
          type: string
          format: uuid
          description: The message id
        deliveries:
          type: array
          description: The message deliveries
          items:
            $ref: "#/components/schemas/DeliveryResult"
    MessageStatus:
      type: string
      enum:
      - PENDING
      - AWAITING_FEEDBACK
      - SENT
      - NOT_SENT
      - FAILED
      - NO_CONTACT_SETTINGS_FOUND
      - NO_CONTACT_WANTED
    MessageType:
      type: string
      enum:
      - MESSAGE
      - EMAIL
      - SMS
      - WEB_MESSAGE
      - DIGITAL_MAIL
      - DIGITAL_INVOICE
      - SNAIL_MAIL
      - LETTER
      - SLACK
    WebMessageAttachment:
      type: object
      description: Attachment
      properties:
        fileName:
          type: string
          description: File name
        mimeType:
          type: string
          description: Mime-type
        base64Data:
          type: string
          description: "BASE64-encoded file, max size 50 MB"
    WebMessageParty:
      type: object
      properties:
        partyId:
          type: string
          format: uuid
          description: The message party id
        externalReferences:
          type: array
          description: External references
          items:
            $ref: "#/components/schemas/ExternalReference"
    WebMessageRequest:
      type: object
      properties:
        party:
          $ref: "#/components/schemas/WebMessageParty"
          description: Party
        message:
          type: string
          description: Message
          minLength: 1
        sender:
          $ref: "#/components/schemas/WebMessageSender"
          description: The sender
        sendAsOwner:
          type: boolean
          default: false
          description: Send as owner
        oepInstance:
          type: string
          description: Determines if the message should be added to the internal or
            external OeP instance
          enum:
          - INTERNAL
          - EXTERNAL
          examples:
          - INTERNAL
        attachments:
          type: array
          items:
            $ref: "#/components/schemas/WebMessageAttachment"
          maxItems: 10
          minItems: 1
      required:
      - message
      - party
    WebMessageSender:
      type: object
      description: Sender
      properties:
        userId:
          type: string
          description: The user ID of the sender. I.e. employee ID
          examples:
          - joe01doe
    Address:
      type: object
      properties:
        firstName:
          type: string
          description: The first name of the recipient
          examples:
          - John
        lastName:
          type: string
          description: The last name of the recipient
          examples:
          - Doe
        organizationName:
          type: string
          description: The organization name of the recipient
          examples:
          - Acme AB
        address:
          type: string
          description: The address
          examples:
          - Main Street 1
        apartmentNumber:
          type: string
          description: The apartment number
          examples:
          - "1101"
        careOf:
          type: string
          description: The care of
          examples:
          - c/o John Doe
        zipCode:
          type: string
          description: The zip code
          examples:
          - "12345"
        city:
          type: string
          description: The city
          examples:
          - Main Street
        country:
          type: string
          description: The country
          examples:
          - Sweden
    SnailmailAttachment:
      type: object
      description: Attachment
      properties:
        filename:
          type: string
          description: The attachment filename
          examples:
          - test.txt
          minLength: 1
        contentType:
          type: string
          description: The attachment content type
          examples:
          - text/plain
        content:
          type: string
          description: The attachment (file) content as a BASE64-encoded string
          examples:
          - aGVsbG8gd29ybGQK
      required:
      - content
      - filename
    SnailmailParty:
      type: object
      properties:
        partyId:
          type: string
          description: The message party id
          examples:
          - f427952b-247c-4d3b-b081-675a467b3619
        externalReferences:
          type: array
          description: External references
          items:
            $ref: "#/components/schemas/ExternalReference"
    SnailmailRequest:
      type: object
      properties:
        party:
          $ref: "#/components/schemas/SnailmailParty"
          description: Party
        address:
          $ref: "#/components/schemas/Address"
          description: Address
        department:
          type: string
          description: Department and unit that should be billed
          examples:
          - "SBK(Gatuavdelningen, Trafiksektionen)"
          minLength: 1
        deviation:
          type: string
          description: If the letter to send deviates from the standard
          examples:
          - A3 Ritning
        attachments:
          type: array
          items:
            $ref: "#/components/schemas/SnailmailAttachment"
          minItems: 1
        folderName:
          type: string
          description: Used by snailmail-sender to set the name of the organization
            folder
          examples:
          - Sundsvalls Kommun
      required:
      - department
    SmsRequest:
      type: object
      properties:
        party:
          $ref: "#/components/schemas/SmsRequestParty"
          description: Party
        sender:
          type: string
          description: "The sender of the SMS, swedish letters(å,ä,ö) will be replaced\
            \ by (a,a,o) respectively"
          examples:
          - sender
          maxLength: 11
          minLength: 3
        mobileNumber:
          type: string
          description: Mobile number. Should start with +467x
        message:
          type: string
          description: Message
          minLength: 1
        priority:
          type: string
          description: "Priority (optional, will be defaulted to NORMAL if not present)"
          enum:
          - HIGH
          - NORMAL
        department:
          type: string
          description: Department
          examples:
          - API-Team
      required:
      - message
      - mobileNumber
    SmsRequestParty:
      type: object
      properties:
        partyId:
          type: string
          description: The message party id
          examples:
          - f427952b-247c-4d3b-b081-675a467b3619
        externalReferences:
          type: array
          description: External references
          items:
            $ref: "#/components/schemas/ExternalReference"
    SmsBatchRequest:
      type: object
      properties:
        sender:
          type: string
          description: "The sender of the SMS, swedish letters(å,ä,ö) will be replaced\
            \ by (a,a,o) respectively"
          examples:
          - sender
          maxLength: 11
          minLength: 3
        message:
          type: string
          description: Message to send as sms
          minLength: 1
        priority:
          type: string
          description: "Priority (optional, will be defaulted to NORMAL if not present)"
          enum:
          - HIGH
          - NORMAL
        department:
          type: string
          description: Department
          examples:
          - API-Team
        parties:
          type: array
          description: Parties to send the sms message to
          items:
            $ref: "#/components/schemas/SmsBatchRequestParty"
          minItems: 1
      required:
      - message
      - parties
    SmsBatchRequestParty:
      type: object
      properties:
        partyId:
          type: string
          description: The message party id (optional)
          examples:
          - f427952b-247c-4d3b-b081-675a467b3619
        mobileNumber:
          type: string
          description: "Mobile number, which should start with +467x"
      required:
      - mobileNumber
    SlackRequest:
      type: object
      properties:
        token:
          type: string
          description: App/bot token
          minLength: 1
        channel:
          type: string
          description: Channel name/id
          minLength: 1
        message:
          type: string
          description: Message (supports Slack markdown formatting)
          minLength: 1
      required:
      - channel
      - message
      - token
    Email:
      type: object
      properties:
        name:
          type: string
          description: The sender of the e-mail
          minLength: 1
        address:
          type: string
          format: email
          description: Sender e-mail address
          examples:
          - sender@sender.se
          minLength: 1
        replyTo:
          type: string
          format: email
          description: Reply-to e-mail address
          examples:
          - sender@sender.se
      required:
      - address
      - name
    Message:
      type: object
      properties:
        party:
          $ref: "#/components/schemas/MessageParty"
          description: Party
        filters:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          description: Filters
          examples:
          - someAttributeName:
            - someAttributeValue
        sender:
          $ref: "#/components/schemas/MessageSender"
          description: Sender
        subject:
          type: string
          description: The message subject (for E-mails)
        message:
          type: string
          description: Plain-text message text
          minLength: 1
        htmlMessage:
          type: string
          description: "HTML message text, for e-mails (BASE64-encoded)"
      required:
      - message
      - party
    MessageParty:
      type: object
      properties:
        partyId:
          type: string
          format: uuid
          description: The message party id
        externalReferences:
          type: array
          description: External references
          items:
            $ref: "#/components/schemas/ExternalReference"
      required:
      - partyId
    MessageRequest:
      type: object
      properties:
        messages:
          type: array
          description: The messages to be sent
          items:
            $ref: "#/components/schemas/Message"
          minItems: 1
      required:
      - messages
    MessageSender:
      type: object
      properties:
        email:
          $ref: "#/components/schemas/Email"
        sms:
          $ref: "#/components/schemas/Sms"
    Sms:
      type: object
      properties:
        name:
          type: string
          description: The sender of the SMS
          examples:
          - sender
          maxLength: 11
          minLength: 0
      required:
      - name
    LetterAttachment:
      type: object
      description: Attachment
      properties:
        deliveryMode:
          type: string
          description: Delivery mode
          enum:
          - ANY
          - DIGITAL_MAIL
          - SNAIL_MAIL
        filename:
          type: string
          description: Filename
          minLength: 1
        contentType:
          type: string
          description: Content type
          enum:
          - application/pdf
        content:
          type: string
          description: Content (BASE64-encoded)
          minLength: 1
      required:
      - content
      - deliveryMode
      - filename
    LetterParty:
      type: object
      properties:
        partyIds:
          type: array
          items:
            type: string
            format: uuid
            description: The message party ids
        addresses:
          type: array
          items:
            $ref: "#/components/schemas/Address"
            description: Addresses that gets a letter copy
        externalReferences:
          type: array
          description: External references
          items:
            $ref: "#/components/schemas/ExternalReference"
    LetterRequest:
      type: object
      properties:
        party:
          $ref: "#/components/schemas/LetterParty"
          description: Party
        subject:
          type: string
          description: Subject
        sender:
          $ref: "#/components/schemas/LetterSender"
          description: Sender
        contentType:
          type: string
          description: Content type
          enum:
          - text/plain
          - text/html
        body:
          type: string
          description: "Body (plain text if contentType is set to 'text/plain', BASE64-encoded\
            \ if contentType is set to 'text/html')"
        department:
          type: string
          description: Department and unit that should be billed in case of snailmail
          examples:
          - "SBK(Gatuavdelningen, Trafiksektionen)"
          minLength: 1
        deviation:
          type: string
          description: If the letter to send deviates from the standard
          examples:
          - A3 Ritning
        attachments:
          type: array
          items:
            $ref: "#/components/schemas/LetterAttachment"
            description: Attachments
          minItems: 1
      required:
      - attachments
      - department
      - party
      - subject
    LetterSender:
      type: object
      properties:
        supportInfo:
          $ref: "#/components/schemas/LetterSenderSupportInfo"
      required:
      - supportInfo
    LetterSenderSupportInfo:
      type: object
      description: Support info
      properties:
        text:
          type: string
          description: Text
          minLength: 1
        emailAddress:
          type: string
          format: email
          description: E-mail address
        phoneNumber:
          type: string
          description: Phone number
        url:
          type: string
          description: URL
      required:
      - text
    EmailAttachment:
      type: object
      description: Attachment
      properties:
        name:
          type: string
          description: The attachment filename
          examples:
          - test.txt
          minLength: 1
        contentType:
          type: string
          description: The attachment content type
          examples:
          - text/plain
        content:
          type: string
          description: The attachment (file) content as a BASE64-encoded string
          examples:
          - aGVsbG8gd29ybGQK
      required:
      - content
      - name
    EmailRequest:
      type: object
      properties:
        party:
          $ref: "#/components/schemas/EmailRequestParty"
          description: Party
        emailAddress:
          type: string
          format: email
          description: Recipient e-mail address. Deprecated, use 'recipients' instead
          deprecated: true
        recipients:
          type: array
          items:
            type: string
            format: email
            description: Recipient (To) e-mail address
            examples:
            - recipient@recipient.se
        cc:
          type: array
          items:
            type: string
            format: email
            description: Carbon-copy (CC) e-mail address
            examples:
            - cc-recipient@recipient.se
        subject:
          type: string
          description: E-mail subject
          minLength: 1
        message:
          type: string
          description: E-mail plain-text body
        htmlMessage:
          type: string
          description: E-mail HTML body (BASE64-encoded)
        sender:
          $ref: "#/components/schemas/EmailSender"
          description: Sender
        attachments:
          type: array
          items:
            $ref: "#/components/schemas/EmailAttachment"
        headers:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          description: Headers
      required:
      - subject
    EmailRequestParty:
      type: object
      properties:
        partyId:
          type: string
          format: uuid
          description: The message party id
        externalReferences:
          type: array
          description: External references
          items:
            $ref: "#/components/schemas/ExternalReference"
    EmailSender:
      type: object
      description: Sender
      properties:
        name:
          type: string
          description: The sender of the e-mail
          minLength: 1
        address:
          type: string
          format: email
          description: Sender e-mail address
          examples:
          - sender@sender.se
          minLength: 1
        replyTo:
          type: string
          format: email
          description: Reply-to e-mail address
          examples:
          - sender@sender.se
      required:
      - address
      - name
    EmailBatchRequest:
      type: object
      properties:
        parties:
          type: array
          items:
            $ref: "#/components/schemas/Party"
          minItems: 1
        subject:
          type: string
          description: E-mail subject
          minLength: 1
        message:
          type: string
          description: E-mail plain-text body
        htmlMessage:
          type: string
          description: E-mail HTML body (BASE64-encoded)
        sender:
          $ref: "#/components/schemas/EmailSender"
          description: Sender
        attachments:
          type: array
          items:
            $ref: "#/components/schemas/EmailAttachment"
        headers:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          description: Headers
      required:
      - parties
      - subject
    Party:
      type: object
      properties:
        partyId:
          type: string
          format: uuid
          description: The message parties id
          examples:
          - e8660aab-6df9-4ed5-86d1-d9b90a5f7e87
        emailAddress:
          type: string
          format: email
          description: Recipient e-mail address
          examples:
          - someone@somewhere.com
          minLength: 1
      required:
      - emailAddress
    Details:
      type: object
      description: Invoice details
      properties:
        amount:
          type: number
          format: float
          description: The invoice amount
          examples:
          - 123.45
        dueDate:
          type: string
          format: date
          description: The invoice due date
          examples:
          - 2023-10-09
        paymentReferenceType:
          type: string
          enum:
          - SE_OCR
          - TENANT_REF
        paymentReference:
          type: string
          description: The payment reference number
          examples:
          - "426523791"
          maxLength: 25
          minLength: 1
        accountType:
          type: string
          enum:
          - BANKGIRO
          - PLUSGIRO
        accountNumber:
          type: string
          description: The receiving account (a valid BANKGIRO or PLUSGIRO number)
          examples:
          - "12345"
          minLength: 1
      required:
      - accountNumber
      - accountType
      - amount
      - dueDate
      - paymentReference
      - paymentReferenceType
    DigitalInvoiceFile:
      type: object
      properties:
        contentType:
          type: string
          description: Content type
          enum:
          - application/pdf
        content:
          type: string
          description: Content (BASE64-encoded)
        filename:
          type: string
          description: Filename
          minLength: 1
      required:
      - content
      - contentType
      - filename
    DigitalInvoiceParty:
      type: object
      properties:
        partyId:
          type: string
          format: uuid
          description: The recipient party id
        externalReferences:
          type: array
          description: External references
          items:
            $ref: "#/components/schemas/ExternalReference"
    DigitalInvoiceRequest:
      type: object
      properties:
        party:
          $ref: "#/components/schemas/DigitalInvoiceParty"
          description: Party
        type:
          type: string
          description: Invoice type
          enum:
          - INVOICE
          - REMINDER
        subject:
          type:
          - string
          - "null"
          description: Subject
        reference:
          type: string
          description: Invoice reference
          examples:
          - "Faktura #12345"
        payable:
          type: boolean
          default: true
          description: Whether the invoice is payable
        details:
          $ref: "#/components/schemas/Details"
        files:
          type: array
          description: Files
          items:
            $ref: "#/components/schemas/DigitalInvoiceFile"
      required:
      - details
      - party
      - type
    ConstraintViolationProblem:
      type: object
      properties:
        type:
          type: string
          format: uri
        status:
          type: integer
          format: int32
        violations:
          type: array
          items:
            $ref: "#/components/schemas/Violation"
        title:
          type: string
        detail:
          type: string
        causeAsProblem:
          $ref: "#/components/schemas/ThrowableProblem"
        instance:
          type: string
          format: uri
    ThrowableProblem:
      type: object
      properties:
        type:
          type: string
          format: uri
        title:
          type: string
        status:
          type: integer
          format: int32
        detail:
          type: string
        instance:
          type: string
          format: uri
        causeAsProblem: {}
    Violation:
      type: object
      properties:
        field:
          type: string
        message:
          type: string
    MessageAttachment:
      type: object
      description: Message attachment model
      properties:
        contentType:
          type: string
          description: The attachment content type
          examples:
          - application/pdf
        fileName:
          type: string
          description: The attachment file name
          examples:
          - attachment.pdf
    PagingMetaData:
      type: object
      description: PagingMetaData model
      properties:
        page:
          type: integer
          format: int32
          description: Current page
          examples:
          - 5
          readOnly: true
        limit:
          type: integer
          format: int32
          description: Displayed objects per page
          examples:
          - 20
          readOnly: true
        count:
          type: integer
          format: int32
          description: Displayed objects on current page
          examples:
          - 13
          readOnly: true
        totalRecords:
          type: integer
          format: int64
          description: Total amount of hits based on provided search parameters
          examples:
          - 98
          readOnly: true
        totalPages:
          type: integer
          format: int32
          description: Total amount of pages based on provided search parameters
          examples:
          - 23
          readOnly: true
    Recipient:
      type: object
      description: Recipient model
      properties:
        address:
          $ref: "#/components/schemas/Address"
          description: The recipient address
        personId:
          type: string
          description: The person identifier
          examples:
          - "199001011234"
        messageType:
          type: string
          description: The message type
          examples:
          - SNAIL_MAIL
        mobileNumber:
          type: string
          description: The recipient mobile number
          examples:
          - "+46123456789"
        status:
          type: string
          description: The message status
          examples:
          - SENT
    UserMessage:
      type: object
      description: User message model
      properties:
        messageId:
          type: string
          description: The message id
          examples:
          - b971e0f8-2942-4b45-9fa3-bd2cc22ed76b
        issuer:
          type: string
          description: The message issuer
          examples:
          - and06sod
        origin:
          type: string
          description: The system that the message originated from
          examples:
          - CASEDATA
        sent:
          type: string
          format: date-time
          description: When the message was sent
          examples:
          - 2021-01-01T12:00:00
        subject:
          type: string
          description: The message subject
          examples:
          - Important message
        body:
          type: string
          description: The message body
          examples:
          - This is a message
        recipients:
          type: array
          items:
            $ref: "#/components/schemas/Recipient"
            readOnly: true
        attachments:
          type: array
          items:
            $ref: "#/components/schemas/MessageAttachment"
            readOnly: true
    UserMessages:
      type: object
      description: User messages model
      properties:
        _meta:
          $ref: "#/components/schemas/PagingMetaData"
          readOnly: true
        messages:
          type: array
          items:
            $ref: "#/components/schemas/UserMessage"
            readOnly: true
    Batch:
      type: object
      description: Batch information model
      properties:
        batchId:
          type: string
          description: The batch id
          examples:
          - b971e0f8-2942-4b45-9fa3-bd2cc22ed76b
        messageType:
          type: string
          description: The original message type
          examples:
          - LETTER
        subject:
          type: string
          description: Message subject if such exists for message(s) attached to the
            batch
          examples:
          - Important message
        sent:
          type: string
          format: date-time
          description: Timestamp when the batch was sent
          examples:
          - 2021-01-01T12:00:00
        attachmentCount:
          type: integer
          format: int32
          description: The amount of documents attached to message(s) in the batch
          examples:
          - 3
        recipientCount:
          type: integer
          format: int32
          description: The amount of recipients included in the batch
          examples:
          - 15
        status:
          $ref: "#/components/schemas/Status"
    Status:
      type: object
      description: Batch status model
      properties:
        successful:
          type: integer
          format: int32
          description: Amount of successfully sent messages
          examples:
          - 13
        unsuccessful:
          type: integer
          format: int32
          description: Amount of failed messages
          examples:
          - 2
    UserBatches:
      type: object
      description: User batches model
      properties:
        _meta:
          $ref: "#/components/schemas/PagingMetaData"
          readOnly: true
        batches:
          type: array
          items:
            $ref: "#/components/schemas/Batch"
            readOnly: true
    LetterStatistics:
      type: object
      properties:
        SNAIL_MAIL:
          $ref: "#/components/schemas/StatisticsCounter"
        DIGITAL_MAIL:
          $ref: "#/components/schemas/StatisticsCounter"
    MessageStatistics:
      type: object
      properties:
        EMAIL:
          $ref: "#/components/schemas/StatisticsCounter"
        SMS:
          $ref: "#/components/schemas/StatisticsCounter"
        UNDELIVERABLE:
          type: integer
          format: int32
    Statistics:
      type: object
      properties:
        EMAIL:
          $ref: "#/components/schemas/StatisticsCounter"
        SMS:
          $ref: "#/components/schemas/StatisticsCounter"
        WEB_MESSAGE:
          $ref: "#/components/schemas/StatisticsCounter"
        DIGITAL_MAIL:
          $ref: "#/components/schemas/StatisticsCounter"
        SNAIL_MAIL:
          $ref: "#/components/schemas/StatisticsCounter"
        MESSAGE:
          $ref: "#/components/schemas/MessageStatistics"
        LETTER:
          $ref: "#/components/schemas/LetterStatistics"
    StatisticsCounter:
      type: object
      properties:
        sent:
          type: integer
          format: int32
        failed:
          type: integer
          format: int32
    DepartmentLetterStatistics:
      type: object
      properties:
        DEPARTMENT:
          type: string
        SNAIL_MAIL:
          $ref: "#/components/schemas/StatisticsCounter"
        DIGITAL_MAIL:
          $ref: "#/components/schemas/StatisticsCounter"
    DepartmentStatistics:
      type: object
      properties:
        ORIGIN:
          type: string
        DEPARTMENT_STATISTICS:
          type: array
          items:
            $ref: "#/components/schemas/DepartmentLetterStatistics"
    DepartmentStats:
      type: object
      properties:
        ORIGIN:
          type: string
        DEPARTMENT:
          type: string
        SNAIL_MAIL:
          $ref: "#/components/schemas/StatisticsCounter"
        DIGITAL_MAIL:
          $ref: "#/components/schemas/StatisticsCounter"
        SMS:
          $ref: "#/components/schemas/StatisticsCounter"
    HistoryResponse:
      type: object
      properties:
        messageType:
          $ref: "#/components/schemas/MessageType"
        status:
          $ref: "#/components/schemas/MessageStatus"
        content: {}
        timestamp:
          type: string
          format: date-time
  securitySchemes: {}
