openapi: 3.0.2
info:
  version: 2.0.0
  title: Fiken API
  description: |

    ## Introduction
    [Fiken.no](https://fiken.no) is an online accounting system aimed at making accounting easy for small businesses. The API Module allows other systems to integrate with Fiken. This document describes Fiken's API.

    ## Using the API
    Use of this API in production environments on live data is normally associated with a fee for the end user (company). API access costs 99kr per month and can be ordered through the Module access page under Settings in your Fiken account. If you have any questions regarding the API pricing, contact us at <api@fiken.no>.

    The API provides two different ways of authorizing requests.

      1. OAuth2
      2. Personal API tokens

    Third parties that wish to integrate with Fiken on behalf of their customers should use the OAuth2 authorization method. In order to develop OAuth2 applications that integrate with this API you must log into your Fiken account and check the box saying that you are a developer (**Rediger konto -> Profil -> Andre innstillinger**). This will allow you to create an App by clicking on the "API" tab under Brukerinnstillinger. If you don't have an existing Fiken account you can create a new user and demo company (demoforetak) at no charge. Send an email to <api@fiken.no> to get free access to Fiken for longer than the included 30 day free trial period. 

    Upon creation of the new App you will be provided a Client ID and Client Secret that are needed for the OAuth2 authorization flow.

    This will allow you to use the API during development with up to 5 users. If you would like to use the API with more than 5 users and gain production status, you will need to send an email to <api@fiken.no> to gain full access to the API module.

    Fiken customers that wish to integrate their own solutions with this API can use personal API tokens. Personal API tokens can be created in **Rediger konto -> API -> Personlige API-nøkler**. Note that personal API tokens do not expire.

    ## Base URL
    All URLs start with https://api.fiken.no/api/v2. Note that TLS is required, unencrypted HTTP is not supported. Although we currently redirect HTTP requests to HTTPS, you are not allowed to this with your application as using HTTP is a security risk. In the future we might respond with 403 Forbidden instead.

    ## Concurrent requests / rate limiting
    You are only allowed to make a single concurrent API-request. Sending multiple requests concurrently may result in a 429 error response. If you break this rule you might be banned. In case of a ban please contact us to be unbanned.

    API calls may be slowed if you execute more than 4 requests per second.

    ## Personal API tokens

    Personal API tokens can be created in **Rediger konto -> API**. Personal API tokens never expire and can be revoked from the same place.

    To use a personal API token simply send it as a bearer token in the `Authorization` header:

        GET https://api.fiken.no/api/v2/companies
        Authorization: Bearer <api token>

    ## Authorization with OAuth2
    Fiken API V2 uses OAuth 2.0 for authorizing API requests. Authorized requests to the API should use an `Authorization` header with the value `Bearer <TOKEN>` where `<TOKEN>` is an access token obtained through the OAuth flow.

    ### Authorize Endpoint

    To start the OAuth flow in order to obtain an access token for a user, you will first have to get consent from the user. To do this, direct your user to the authorization endpoint:

        GET https://fiken.no/oauth/authorize?response_type=code&client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&state=STATE

    If the user is logged in and accepts your request, the user is redirected back to your redirect url. If the user is not logged in, the regular Fiken.no login form is presented first, requiring the user to authenticate before accepting or rejecting your request.

    If the user rejects the request or if there is an error in your request, the user is redirected back to your redirect url with the parameters `error` and `error_description`. If the user rejected the request the error code will be `access_denied`.

    #### Parameters

    | Name          | Description                                                                                                      |
    | :------------ | :--------------------------------------------------------------------------------------------------------------- |
    | response_type | **Required** Should always be the value `code`                                                     |
    | client_id     | **Required** The client id you received from Fiken when you registered your application                          |
    | redirect_uri  | **Required** The URL in your application where users will be sent with an authorization code after authorization |
    | state         | **Required** An unguessable random string, used to protect against CSRF attacks                                  |


    ### Token Endpoint

    If the user accepts your request, Fiken redirects the user back to your `redirect_uri` with a parameter named `code` as well as the state you provided in the previous step in the `state` parameter. This temporary code will expire after a short while.

    The temporary authorization code can be exchanged for an access token at the token endpoint.

    The token endpoint is protected with Http Basic Authentication and you should use your application client id and client secret as credentials to authenticate.

        POST https://fiken.no/oauth/token
        Content-Type: application/x-www-form-urlencoded
        Authorization: Basic dXNlIHlvdXIgY2xpZW50IGlkOmFuZCBjbGllbnQgc2VjcmV0

        grant_type=authorization_code&code=AUTHCODE&redirect_uri=REDIRECT_URI&state=STATE

    The response will contain the access token, a refresh token (see below) as well as information about the expiry time for the token.

        {
          "access_token": "K2QwoFp4ZfugWLWk7Ipu9kni5cyv3luXKQ-GDShvV2g=",
          "refresh_token": "naFOD_j8m6PFGcP0pfImVZlSxKklHLbgj9Hzao4rhg8=",
          "token_type": "bearer",
          "expires_in": 86157
        }

    If an error occurs during the token exchange request, an error object is returned with an error and an error description.

        {
            "error": "invalid_grant",
            "error_description": "The authorization code is invalid or expired."
        }

    #### Parameters

    | Name         | Description                                                                                                      |
    | :----------- | :--------------------------------------------------------------------------------------------------------------- |
    | grant_type   | **Required** Should be the value `authorization_code`                                                            |
    | code         | **Required** The authorization code that was received in the redirect from the authorize endpoint                |
    | redirect_uri | **Required** The URL in your application where users will be sent with an authorization code after authorization |
    | state        | **Required** An unguessable random string, used to protect against CSRF attacks                                  |

    ### Refresh Tokens

    If an access token has expired you can use the refresh token that was sent in the response from the token endpoint to get a new access token.

    Note that if the user has revoked the consent to your app, the refresh token will no longer be valid.

    To get a new access token from the refresh token, use the token endpoint with the grant type `refresh_token`:

        POST https://fiken.no/oauth/token
        Content-Type: application/x-www-form-urlencoded
        Authorization: Basic dXNlIHlvdXIgY2xpZW50IGlkOmFuZCBjbGllbnQgc2VjcmV0

        grant_type=refresh_token&refresh_token=REFRESH_TOKEN

    The response contains a fresh access token along with a possibly updated refresh token:

        {
          "access_token": "K2QwoFp4ZfugWLWk7Ipu9kni5cyv3luXKQ-GDShvV2g=",
          "refresh_token": "naFOD_j8m6PFGcP0pfImVZlSxKklHLbgj9Hzao4rhg8=",
          "token_type": "bearer",
          "expires_in": 86157
        }

    #### Parameters

    | Name         | Description                                                                                                      |
    | :----------- | :--------------------------------------------------------------------------------------------------------------- |
    | grant_type   | **Required** Should be the value `refresh_token`                                                                 |
    | refresh_token| **Required** The refresh token last returned for this user from the token endpoint                               |

    ### Using Access Tokens in API Requests

    To execute API requests on behalf of the end user, send the access token obtained at the token endpoint as a bearer token, as in this example:

        GET https://api.fiken.no/api/v2/companies
        Authorization: Bearer <access_token_value>

    ### Revoking tokens

    To revoke an access token and refresh token use the Revoke Token endpoint.

    The Revoke Token endpoint disables the application grant, the access token and the corresponding refresh token used to authenticate the call. Other access tokens obtained from the same refresh token are also revoked.

        POST https://fiken.no/oauth/revoke
        Authorization: Bearer <access_token_value>

    The response for a successful revocation is 200/OK.
    
    ### Managing access

    The end user can manage which companies a given app has access to under **Rediger konto -> Sikkerhet -> Apper du har gitt tilgang til**. 
    All companies created after the initial consent has been given need to be actively added so that the app will have access to their information. 
    Additionally the end user can revoke access to any of their companies' data as well.


    ## Try It Out

    For each endpoint in the documentation below there is a button *Try It Out*. To invoke the API from this documentation you need an app and you need to authorize usage for you Fiken.no user.

    Your app needs to be configured with a redirect URL for this documentation, add `https://api.fiken.no/api/v2/docs/oauth2-redirect.html` to the list of redirect URLs for your app.

    Click the padlock symbol on any of the endpoints and enter your `client_id` and `client_secret` and then press *Authorize* to start the OAuth2 authorization flow, then click *Close*.

    Enter the required parameters for the endpoint, such as `company_slug`, and then press *Execute* to test.

    ## Request

    We recommend sending the `X-Request-ID` header with all requests.

    ### Request Headers
    | Request  Header           | Format   | Description                                                       |
    | ----------------          | -------- | -----------------------------                                     |
    | `X-Request-ID`            | UUID     | UUID used to identify the request                                 |
    


    ## Response
    ### Response code
    All HTTP codes should be expected with their normal semantics. These are some of the common ones:

    * **200** for successful GET
    * **201** for successful POST where you get a Location-header for the created content
    * **400** when invalid content has be sent (for instance a required field is missing, unexpected fields, wrong format, etc)
    * **401** when the user is not authenticated
    * **403** when the user does not have the proper authorization
    * **404** when the requested content is not found
    * **405** When you are trying a method to a resource which doesn't support it (i.e. DELETE on an account).
    * **415** Wrong media type. we accept application/json only.

    ### Response Content
    The default content type on the result of GET requests is application/json. On successful POSTs/PUTs/PATCHs and DELETEs an empty body is returned.

    For successful POSTs/PUTs/PATCHs a Location header is given in all cases.

    ## Pagination, Sorting & Filtering
    Pagination, sorting and filtering query parameters are all optional.


    | URI                                                                     | Pagination? | Sortable? | Sortable Fields                       | Filterable? | Filtered Fields                                                                                                                         |
    | :---------                                                              |:----------- | :-------- | :-------------                        | :---        | :---                                                                                                                                    |
    | https://api.fiken.no/api/v2/companies                                  | Yes         | Yes       | createdDate, name, organizationNumber | No          |                                                                                                                                         |
    | https://api.fiken.no/api/v2/companies/{companySlug}/accounts           | No          | No        |                                       | Yes         | fromAccount, toAccount                                                                                                                  |
    | https://api.fiken.no/api/v2/companies/{companySlug}/accountBalances    | Yes         | No        |                                       | Yes         | fromAccount, toAccount                                                                                                                  |
    | https://api.fiken.no/api/v2/companies/{companySlug}/bankAccounts       | Yes         | No        |                                       | Yes         | inactive                                                                                                                                |
    | https://api.fiken.no/api/v2/companies/{companySlug}/contacts           | Yes         | Yes       | createdDate, lastModified             | Yes         | supplierNumber, customerNumber, memberNumber, name, organizationNumber, email, group, lastModified, createdDate, inactive, phoneNumber  |
    | https://api.fiken.no/api/v2/companies/{companySlug}/creditNotes        | Yes         | No        |                                       | Yes         | issueDate, settled, customerId                                                                                                          |
    | https://api.fiken.no/api/v2/companies/{companySlug}/inbox              | Yes         | Yes       | createdDate, name                     | Yes         | status, name                                                                                                                            |
    | https://api.fiken.no/api/v2/companies/{companySlug}/invoices           | Yes         | No        |                                       | Yes         | issueDate, lastModified, settled, customerId, orderReference, invoiceDraftUuid                                                          |
    | https://api.fiken.no/api/v2/companies/{companySlug}/invoices/drafts    | Yes         | No        |                                       | No          |                                                                                                                                         |
    | https://api.fiken.no/api/v2/companies/{companySlug}/journalEntries     | Yes         | No        |                                       | Yes         | date                                                                                                                                    |
    | https://api.fiken.no/api/v2/companies/{companySlug}/offers             | Yes         | No        |                                       | No          |                                                                                                                                         |
    | https://api.fiken.no/api/v2/companies/{companySlug}/orderConfirmations | Yes         | No        |                                       | No          |                                                                                                                                         |
    | https://api.fiken.no/api/v2/companies/{companySlug}/products           | Yes         | No        |                                       | Yes         | name, productNumber, active, createdDate, lastModified                                                                                  |
    | https://api.fiken.no/api/v2/companies/{companySlug}/projects           | Yes         | No        |                                       | Yes         | completed                                                                                                                               |
    | https://api.fiken.no/api/v2/companies/{companySlug}/purchases          | Yes         | Yes       | createdDate                           | No          | date                                                                                                                                    |
    | https://api.fiken.no/api/v2/companies/{companySlug}/purchases/drafts   | Yes         | No        |                                       | No          |                                                                                                                                         |
    | https://api.fiken.no/api/v2/companies/{companySlug}/sales              | Yes         | No        |                                       | Yes         | saleNumber, lastModified, date, contactId                                                                                                          |
    | https://api.fiken.no/api/v2/companies/{companySlug}/sales/drafts       | Yes         | No        |                                       | No          |                                                                                                                                         |
    | https://api.fiken.no/api/v2/companies/{companySlug}/transactions       | Yes         | No        |                                       | Yes         | createdDate, lastModified                                                                                                               |

    ### Pagination
    By default the API sets `page=0` and `pageSize=25` and returns the first 25 elements in a collection resource, if nothing else is specified.
    PageSize has a maximum value of 100 meaning that you can only access at most 100 elements at once.

    To request a collection resource with pagination, query the resource with the query filters page and pageSize, note that both query parameters need to be set to enable pagination.
    The page counter starts at 0. The response will contain up to Fiken-Api-Page-Size elements and the response headers below, detailing how many elements the resource has in total and the total number of pages as well.

    By default the API returns the resources in the order they were created, if nothing else is specified in the documentation.

    #### Pagination Response Headers
    | Response Header           | Format   | Description                                                       |
    | ----------------          | -------- | -----------------------------                                     |
    | `Fiken-Api-Page`          | integer  | From the request header                                           |
    | `Fiken-Api-Page-Size`     | integer  | From the request header                                           |
    | `Fiken-Api-Page-Count`    | integer  | The total number of pages in this resource with this page size    |
    | `Fiken-Api-Result-Count`  | integer  | The total number of elements in this resource                     |

    ### Sorting
    To change the sort order for a resource, set the sortBy query parameter to a sort field in either ascending or descending order. Ex: `https://api.fiken.no/api/v2/companies?sortBy=name%20asc`

    ### Filtering
    Some collections support filtering, and depending on the type of field, different filters can be used. Dates are the most complex, and allow you do apply different filters with different parameter names. For instance, for a field called date, the following mutations are available:

    | Parameter | Field | Format    | Description                                   |
    | ---       |---    | ---       |---                                            |
    |  `date`   |date	|yyyy-MM-dd	|date equal to parameter value                  |
    |  `dateLe`	|date	|yyyy-MM-dd	|date less than or equal to parameter value     |
    |  `dateLt`	|date	|yyyy-MM-dd	|date less than parameter value                 |
    |  `dateGe`	|date	|yyyy-MM-dd	|date greater than or equal to parameter value  |
    |  `dateGt`	|date	|yyyy-MM-dd	|date greater than parameter value              |

    All date-fields will have these mutations of parameter name that applies

    ## Data Types
    These are simple data-types that are used in several of our objects.

    ### Date
    Dates are represented as strings formatted as yyyy-MM-dd.
    "Last modified" returns the date of last modification of the object. 
    If the object was never modified after creation, last modified date is equal to created date. 

    ##### Examples:
    January 2nd, 1970: "1970-01-02"

    ### Amount
    Amounts are always represented as a number, and specifies the number of cents in the amount. Fractions will be ignored.

    ##### Examples:
    One thousand: 100000

    One hundred and twelve cents: 10012

    ### Account
    An account is a string with either four digits, or four digits, a colon and five digits ("reskontro").

    ##### Examples:
    3020

    1500:10001

    ### VAT Code
    Fiken's VAT codes are based upon Sticos mvakoder. To see all VAT codes go to Fiken support, check the "Mva kode"-selector in the Fiken web interface while creating a genereal ledger item ("Fri postering"). 
    See below the mapping between VAT codes and types (codes are used at the transaction level while types are used for sales and purchases).
    
    | Vat Code | Vat Type                                                                                                                                 | Valid for Purchases/Sales    | 
    | ---      |---                                                                                                                                       | ---                          |                                         
    |  0/7     |NONE (Ingen - KJØP_INGEN_MVABEHANDLING/SALG_INNTEKTER_UTEN_MVABEHANDLING)	                                                              |Both	                         |
    |  1/3	   |HIGH (Høy - KJØP/SALG_MED_HØY_SATS)	                                                                                                      |Both                          |
    |  11/31   |MEDIUM (Middels - KJØP/SALG_MED_MIDDELS_SATS)	                                                                                          |Both         	             |
    |  12/32   |RAW_FISH (Råfisk - KJØP/SALG_MED_RÅFISK_SATS)	                                                                                          |Both   	                     |
    |  13/33   |LOW (Lav - KJØP/SALG_MED_LAV_SATS)	                                                                                                      |Both	                         |
    |  52	   |EXEMPT_IMPORT_EXPORT (Fritatt import/export - SALG_UTFØRSEL_AV_VARER_OG_TJENESTER)                                                        |Sales	                     |
    |  5	   |EXEMPT (Fritatt - SALG_FRITATT_FOR_MVA_AVGIFTSFRITT)	                                                                                  |Sales      	                 |
    |  6	   |OUTSIDE (Utenfor - SALG_FRITATT_FOR_MVA_UTENFOR_AVGIFTSOMRÅDET)	                                                                          |Sales	                     |
    |  51	   |EXEMPT_REVERSE (Fritatt omvendt - SALG_INNENLANDSK_OMSETNING_MED_OMVENDT_AVGIFTPLIKT)	                                                  |Sales	                     |
    |  14	   |HIGH_DIRECT (Høy direkt - KUN_KJØPSMVA_HØY_SATS)	                                                                                      |Purchases	                 |
    |  21	   |HIGH_BASIS (Høy grunnlag - KUN_GRUNNLAG_KJØPSMVA_HØY_SATS)	                                                                              |Purchases	                 |
    |  15	   |MEDIUM_DIRECT (Middels direkte - KUN_KJØPSMVA_MIDDELS_SATS)	                                                                              |Purchases	                 |
    |  22	   |MEDIUM_BASIS (Middels grunnlag - KUN_GRUNNLAG_KJØPSMVA_MIDDELS_SATS)	                                                                  |Purchases	                 |
    |  23	   |NONE_IMPORT_BASIS (Ingen import grunnlag - KUN_GRUNNLAG_KJØPSMVA_INGEN_SATS)	                                                          |Purchases	                 |
    |  86	   |HIGH_FOREIGN_SERVICE_DEDUCTIBLE (Tjeneste utlandet - TJENESTER_KJØPT_FRA_UTLANDET_MED_FRADRAG_FOR_HØY_MVA)	                              |Purchases	                 |
    |  87	   |HIGH_FOREIGN_SERVICE_NONDEDUCTIBLE (Tjeneste utlandet uten fradrag - TJENESTER_KJØPT_FRA_UTLANDET_UTEN_FRADRAG_FOR_HØY_MVA)	              |Purchases	                 |
    |  88	   |LOW_FOREIGN_SERVICE_DEDUCTIBLE (Lav tjeneste utlandet - TJENESTER_KJØPT_FRA_UTLANDET_MED_FRADRAG_FOR_LAV_MVA)	                          |Purchases	                 |
    |  89	   |LOW_FOREIGN_SERVICE_NONDEDUCTIBLE (Lav tjeneste utlandet uten fradrag - TJENESTER_KJØPT_FRA_UTLANDET_UTEN_FRADRAG_FOR_LAV_MVA)	          |Purchases	                 |
    |  91	   |HIGH_PURCHASE_OF_EMISSIONSTRADING_OR_GOLD_DEDUCTIBLE (Gull - KJØP_AV_KLIMAKVOTER_ELLER_GULL_MED_FRADRAG_FOR_MVA)	                      |Purchases	                 |
    |  92	   |HIGH_PURCHASE_OF_EMISSIONSTRADING_OR_GOLD_NONDEDUCTIBLE (Gull uten fradrag - KJØP_AV_KLIMAKVOTER_ELLER_GULL_UTEN_FRADRAG_FOR_MVA)	      |Purchases	                 |
    

servers:
  - url: https://api.fiken.no/api/v2


paths:
  /user:
    get:
      description: Returns information about the user
      operationId: getUser
      tags:
        - user
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/userinfo'
  /companies:
    get:
      description: Returns all companies from the system that the user has access to
      operationId: getCompanies
      tags:
        - companies
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - name: sortBy
          in: query
          schema:
            type: string
            enum: [createdDate asc, createdDate desc, name asc, name desc, organizationNumber asc, organizationNumber desc]
            default: name asc
            description: Sorts results in either ascending (asc) or descending (desc) order based on the parameter value.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/company'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

  /companies/{companySlug}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns company associated with slug.
      operationId: getCompany
      tags:
        - companies
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/company'


  /companies/{companySlug}/accounts:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: |
        Retrieves the bookkeeping accounts for the current year
      operationId: getAccounts
      tags:
        - accounts
      parameters:
        - $ref: '#/components/parameters/fromAccount'
        - $ref: '#/components/parameters/toAccount'
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/account'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

  /companies/{companySlug}/accounts/{accountCode}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - name: accountCode
        in: path
        required: true
        description: Code number of the bookkeeping account to retrieve for the current year.
        schema:
          type: string
    get:
      description: |
        Retrieves the specified bookkeping account.
        An account is a string with either four digits, or four digits, a colon and five digits ("reskontro").
              Examples:
              3020 and 1500:10001
      operationId: getAccount
      tags:
        - accounts
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/account'

  /companies/{companySlug}/accountBalances:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: |
        Retrieves the bookkeeping accounts and closing balances for a given date.
        An account is a string with either four digits, or four digits, a colon and five digits ("reskontro").
        Examples:
        3020 and 1500:10001
      operationId: getAccountBalances
      tags:
        - account balances
      parameters:
        - $ref: '#/components/parameters/fromAccount'
        - $ref: '#/components/parameters/toAccount'
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
          description: |
            Dates are represented as strings formatted as YYYY-MM-DD.
            Example: January 1st, 1970: "1970-01-01"
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/accountBalance'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

  /companies/{companySlug}/accountBalances/{accountCode}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - name: accountCode
        in: path
        required: true
        description: Code number of the bookkeeping account to retrieve
        schema:
          type: string
    get:
      description: Retrieves the specified bookkeping account and balance for a given date.
      operationId: getAccountBalance
      tags:
        - account balances
      parameters:
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
          description: |
            Dates are represented as strings formatted as YYYY-MM-DD.
            Example: January 1st, 1970: "1970-01-01"
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/accountBalance'


  /companies/{companySlug}/bankAccounts:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Retrieves all bank accounts associated with the company.
      operationId: getBankAccounts
      tags:
        - bank accounts
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - name: inactive
          in: query
          schema:
            type: boolean
          description: Return all active bank accounts (false) or all inactive bank accounts (true).
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/bankAccountResult'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

    post:
      description: |
        Creates a new bank account. The Location response header returns the URL of the newly created bank account.
        Possible types of bank accounts are NORMAL, TAX_DEDUCTION, FOREIGN, and CREDIT_CARD. The field "foreignService" should only be filled out for accounts of type FOREIGN.
      operationId: createBankAccount
      tags:
        - bank accounts
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/bankAccountRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created bank account

  /companies/{companySlug}/bankAccounts/{bankAccountId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - name: bankAccountId
        in: path
        required: true
        schema:
          type: integer
          format: int64
    get:
      description: Retrieves specified bank account.
      operationId: getBankAccount
      tags:
        - bank accounts
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/bankAccountResult'


  /companies/{companySlug}/contacts:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Retrieves all contacts for the specified company.
      operationId: getContacts
      tags:
        - contacts
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/lastModified'
        - $ref: '#/components/parameters/lastModifiedLe'
        - $ref: '#/components/parameters/lastModifiedLt'
        - $ref: '#/components/parameters/lastModifiedGe'
        - $ref: '#/components/parameters/lastModifiedGt'
        - $ref: '#/components/parameters/createdDate'
        - $ref: '#/components/parameters/createdDateLe'
        - $ref: '#/components/parameters/createdDateLt'
        - $ref: '#/components/parameters/createdDateGe'
        - $ref: '#/components/parameters/createdDateGt'
        - name: supplierNumber
          in: query
          schema:
            type: integer
          description: Find all results with the supplier number equal to the specified parameter.
        - name: customerNumber
          in: query
          schema:
            type: integer
          description: Find all results with the customer number equal to the specified parameter.
        - name: memberNumber
          in: query
          schema:
            type: integer
          description: Find all results with the member number equal to the specified parameter.
        - name: name
          in: query
          schema:
            type: string
          description: Find all results with the name equal to the specified parameter.
        - name: organizationNumber
          in: query
          schema:
            type: string
          description: Find all results with the organization number equal to the specified parameter.
        - name: email
          in: query
          schema:
            type: string
          description: Find all results with the email equal to the specified parameter.
        - name: customer
          in: query
          schema:
            type: boolean
          description: Returns all contacts that are customers. If filter is set for both supplier and customer = true, only contacts that are both supplier and customer will be returned.
        - name: supplier
          in: query
          schema:
            type: boolean
          description: Returns all contacts that are suppliers. If filter is set for both supplier and customer = true, only contacts that are both supplier and customer will be returned.
        - name: inactive
          in: query
          schema:
            type: boolean
          description: Return all active contacts (false) or all inactive contacts (true).
        - name: group
          in: query
          schema:
            type: string
          description: Return contacts in contact group, exact match only. Groups are only used for customers, not suppliers.
        - name: sortBy
          in: query
          schema:
            type: string
            enum: [ lastModified asc, lastModified desc, createdDate asc, createdDate desc ]
            default: createdDate asc
            description: Sorts results in either ascending (asc) or descending (desc) order based on the parameter value.
        - name: phoneNumber
          in: query
          schema:
            type: string
          description: Find all results with the phone number equal to the specified parameter.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/contact'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

    post:
      description: Creates a new contact. The Location response header returns the URL of the newly created contact.
      operationId: createContact
      tags:
        - contacts
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/contact'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created contact

  /companies/{companySlug}/contacts/{contactId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - name: contactId
        in: path
        required: true
        schema:
          type: integer
          format: int64
    get:
      description: |
        Retrieves specified contact. ContactId is returned with a GET contacts call as the first returned field.
        ContactId is returned in the Location response header for POST contact.
      operationId: getContact
      tags:
        - contacts
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/contact'

    put:
      description: Updates an existing contact.
      operationId: updateContact
      tags:
        - contacts
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/contact'
      responses:
        '200':
          description: Updated
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of updated contact
    delete:
      description: Deletes the contact if possible (no associated journal entries/sales/invoices/etc). 
        If not possible to delete will set the contact to inactive
      operationId: deleteContact
      tags:
        - contacts
      responses:
        '204':
          description: Contact deleted successfully.
        '200':
          description: Contact set to inactive because it has associated journal entries/sales/invoices/etc.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/contact'

  /companies/{companySlug}/contacts/{contactId}/attachments:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - name: contactId
        in: path
        required: true
        schema:
          type: integer
          format: int64
    post:
      description: Creates and adds a new attachment/document to a contact
      operationId: addAttachmentToContact
      tags:
        - contacts
      requestBody:
        required: false
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                filename:
                  type: string
                  example: invoice_24760.pdf
                  description: Required. The filename. Must end with either .png, .jpeg, .jpg, .gif or .pdf
                comment:
                  type: string
                  description: Not required.
                file:
                  type: string
                  format: binary
                  example: https://fiken.no/api/v2/files/745b2f15-gh75-4408-bgf2-b1d2dt610cb2/invoice24760.pdf
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created attachment

  /companies/{companySlug}/contacts/{contactId}/contactPerson:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - name: contactId
        in: path
        required: true
        schema:
          type: integer
          format: int64
    get:
      description: |
        Retrieves contact person(s) for a specified contact.
      operationId: getContactContactPerson
      tags:
        - contacts
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/contactPerson'
    post:
      description: Adds a new contact person to a contact
      operationId: addContactPersonToContact
      tags:
        - contacts
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/contactPerson'
      responses:
        '200':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created contact person

  /companies/{companySlug}/contacts/{contactId}/contactPerson/{contactPersonId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - name: contactId
        in: path
        required: true
        schema:
          type: integer
          format: int64
      - name: contactPersonId
        in: path
        required: true
        schema:
          type: integer
          format: int64
    get:
      description: |
        Retrieves specified contact person
      operationId: getContactPerson
      tags:
        - contacts
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/contactPerson'
    put:
      description: Updates an existing contact person.
      operationId: updateContactContactPerson
      tags:
        - contacts
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/contactPerson'
      responses:
        '200':
          description: Updated
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of updated contact person
    delete:
      description: Delete a contact's contact person.
      operationId: deleteContactContactPerson
      tags:
        - contacts
      responses:
        '204':
          description: Deleted


  /companies/{companySlug}/groups:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all customer groups for given company
      operationId: getGroups
      tags:
        - groups
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

  /companies/{companySlug}/products/salesReport:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    post:
      description: Creates a report based on provided specifications.
      operationId: createProductSalesReport
      tags:
        - products
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/productSalesReportRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/productSalesReportResult'

  /companies/{companySlug}/journalEntries:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all general journal entries (posteringer) for the specified company.
      operationId: getJournalEntries
      tags:
        - journal entries
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/date'
        - $ref: '#/components/parameters/dateLe'
        - $ref: '#/components/parameters/dateLt'
        - $ref: '#/components/parameters/dateGe'
        - $ref: '#/components/parameters/dateGt'
        - $ref: '#/components/parameters/lastModified'
        - $ref: '#/components/parameters/lastModifiedLe'
        - $ref: '#/components/parameters/lastModifiedLt'
        - $ref: '#/components/parameters/lastModifiedGe'
        - $ref: '#/components/parameters/lastModifiedGt'
        - $ref: '#/components/parameters/createdDate'
        - $ref: '#/components/parameters/createdDateLe'
        - $ref: '#/components/parameters/createdDateLt'
        - $ref: '#/components/parameters/createdDateGe'
        - $ref: '#/components/parameters/createdDateGt'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/journalEntry'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

  /companies/{companySlug}/generalJournalEntries:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    post:
      description: Creates a new general journal entry (fri postering).
      operationId: createGeneralJournalEntry
      tags:
        - journal entries
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/generalJournalEntryRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created General Journal Entry

  /companies/{companySlug}/journalEntries/{journalEntryId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/journalEntryId'
    get:
      description: Returns all journal entries within a given company's Journal Entry Service
      operationId: getJournalEntry
      tags:
        - journal entries
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/journalEntry'

  /companies/{companySlug}/journalEntries/{journalEntryId}/attachments:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/journalEntryId'
    get:
      description: Returns all attachments for a given Journal Entry
      operationId: getJournalEntryAttachments
      tags:
        - journal entries
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/attachment'

    post:
      description: Creates and adds a new attachment to a Journal Entry
      operationId: addAttachmentToJournalEntry
      tags:
        - journal entries
      requestBody:
        required: false
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                filename:
                  type: string
                  example: invoice_24760.pdf
                  description: Required. The filename. Must end with either .png, .jpeg, .jpg, .gif or .pdf
                file:
                  type: string
                  format: binary
                  example: https://fiken.no/api/v2/files/745b2f15-gh75-4408-bgf2-b1d2dt610cb2/invoice24760.pdf
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created attachment


  /companies/{companySlug}/transactions:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all transactions for the specified company
      operationId: getTransactions
      tags:
        - transactions
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/lastModified'
        - $ref: '#/components/parameters/lastModifiedLe'
        - $ref: '#/components/parameters/lastModifiedLt'
        - $ref: '#/components/parameters/lastModifiedGe'
        - $ref: '#/components/parameters/lastModifiedGt'
        - $ref: '#/components/parameters/createdDate'
        - $ref: '#/components/parameters/createdDateLe'
        - $ref: '#/components/parameters/createdDateLt'
        - $ref: '#/components/parameters/createdDateGe'
        - $ref: '#/components/parameters/createdDateGt'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/transaction'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

  /companies/{companySlug}/transactions/{transactionId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - name: transactionId
        in: path
        required: true
        schema:
          type: integer
          format: int64
    get:
      description: |
        Returns given transaction with associated id. Transaction id is returned in GET calls for
        sales, purchases, and journal entries.
      operationId: getTransaction
      tags:
        - transactions
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/transaction'


  /companies/{companySlug}/invoices:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all invoices for given company. You can filter based on issue date, last modified date, customer ID, and if the invoice is settled or not.
      operationId: getInvoices
      tags:
        - invoices
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/issueDate'
        - $ref: '#/components/parameters/issueDateLe'
        - $ref: '#/components/parameters/issueDateLt'
        - $ref: '#/components/parameters/issueDateGe'
        - $ref: '#/components/parameters/issueDateGt'
        - $ref: '#/components/parameters/lastModified'
        - $ref: '#/components/parameters/lastModifiedLe'
        - $ref: '#/components/parameters/lastModifiedLt'
        - $ref: '#/components/parameters/lastModifiedGe'
        - $ref: '#/components/parameters/lastModifiedGt'
        - name: customerId
          in: query
          description: |
            Returns only invoices sent to specified customer. Must be the contactId provided by a GET contacts call.
          schema:
            type: integer
            format: int64
        - name: settled
          in: query
          description: |
            When set to true, returns only invoices that have been settled. Otherwise false returns all invoices
            that have not been fully settled.
          schema:
            type: boolean
        - name: orderReference
          in: query
          description: Filter based on order reference for a given invoice
          schema:
            type: string
        - name: invoiceDraftUuid
          in: query
          description: Filter based on the UUID of the invoice draft that was used to create a given invoice
          schema:
            type: string
            format: uuid
        - name: invoiceNumber
          in: query
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/invoiceResult'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

    post:
      description: |
        Creates an invoice. This corresponds to "Ny faktura" in Fiken.
        There are two types of invoice lines that can be added to an invoice line: product line or free text line.
        Provide a product Id if you are invoicing a product. All information regarding the price and VAT for this product will be added to the invoice.
        It is however also possible to override the unit amount by sending information in both fields "productId" and "unitAmount".
        An invoice line can also be a free text line meaning that no existing product will be associated with the invoiced line.
        In this case all information regarding the price and VAT of the product or service to be invoiced must be provided.
      operationId: createInvoice
      tags:
        - invoices
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/invoiceRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created invoice

  /companies/{companySlug}/invoices/{invoiceId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/invoiceId'
    get:
      description: Returns invoice with specified id.
      operationId: getInvoice
      tags:
        - invoices
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/invoiceResult'
    patch:
      description: |
        Updates invoice with provided id. It is possible to update the due date of an invoice
        as well as if the invoice was sent manually, outside of Fiken.
      operationId: updateInvoice
      tags:
        - invoices
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/updateInvoiceRequest'
      responses:
        '200':
          description: OK
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of updated invoice


  /companies/{companySlug}/invoices/{invoiceId}/attachments:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/invoiceId'
    get:
      description: Returns all attachments for a given Invoice
      operationId: getInvoiceAttachments
      tags:
        - invoices
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/attachment'

    post:
      description: Creates and adds a new attachment to an Invoice
      operationId: addAttachmentToInvoice
      tags:
        - invoices
      requestBody:
        required: false
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                filename:
                  type: string
                  example: invoice_24760.pdf
                  description: The filename. Must end with either .png, .jpeg, .jpg, .gif or .pdf
                file:
                  type: string
                  format: binary
                  example: https://fiken.no/api/v2/files/745b2f15-gh75-4408-bgf2-b1d2dt610cb2/invoice24760.pdf
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created attachment

  /companies/{companySlug}/invoices/send:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    post:
      description: Sends the specified document
      operationId: sendInvoice
      tags:
        - invoices
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/sendInvoiceRequest'
      responses:
        '200':
          description: Sent

  /companies/{companySlug}/invoices/counter:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: |
        Retrieves the counter for invoices if it has been created
      operationId: getInvoiceCounter
      tags:
        - invoices
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/counter'
    post:
      description: Creates the first invoice number which is then increased by one with every new invoice. By sending an empty request body the default is base number 10000 (the first invoice number will thus be 10001), but can be specified to another starting value.
      operationId: createInvoiceCounter
      tags:
        - invoices
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/counter'
      responses:
        '201':
          description: Created

  /companies/{companySlug}/invoices/drafts:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all invoice drafts for given company.
      operationId: getInvoiceDrafts
      tags:
        - invoices
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - name: orderReference
          in: query
          description: Filter based on order reference for a given invoice draft
          schema:
            type: string
        - name: uuid
          in: query
          description: Filter based on the UUID of the draft.
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/invoiceishDraftResult'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

    post:
      description: Creates an invoice draft.
      operationId: createInvoiceDraft
      tags:
        - invoices
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/invoiceishDraftRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created invoice draft

  /companies/{companySlug}/invoices/drafts/{draftId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    get:
      description: Returns invoice draft with specified id.
      operationId: getInvoiceDraft
      tags:
        - invoices
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/invoiceishDraftResult'
    put:
      description: |
        Updates invoice draft with provided id.
      operationId: updateInvoiceDraft
      tags:
        - invoices
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/invoiceishDraftRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of updated invoice draft
    delete:
      description: Delete invoice draft with specified id.
      operationId: deleteInvoiceDraft
      tags:
        - invoices
      responses:
        '204':
          description: Deleted

  /companies/{companySlug}/invoices/drafts/{draftId}/attachments:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    get:
      description: Returns all attachments for specified draft.
      operationId: getInvoiceDraftAttachments
      tags:
        - invoices
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/attachment'
    post:
      description: Creates and adds a new attachment to an invoice draft
      operationId: addAttachmentToInvoiceDraft
      tags:
        - invoices
      requestBody:
        required: false
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                filename:
                  type: string
                  example: invoice_24760.pdf
                  description: Required. The filename. Must end with either .png, .jpeg, .jpg, .gif or .pdf
                comment:
                  type: string
                  description: Not required.
                file:
                  type: string
                  format: binary
                  example: https://fiken.no/api/v2/files/745b2f15-gh75-4408-bgf2-b1d2dt610cb2/invoice24760.pdf
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created attachment

  /companies/{companySlug}/invoices/drafts/{draftId}/createInvoice:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    post:
      description: Creates an invoice from an already created draft.
      operationId: createInvoiceFromDraft
      tags:
        - invoices
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created invoice


  /companies/{companySlug}/creditNotes:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all credit notes for given company
      operationId: getCreditNotes
      tags:
        - credit notes
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/issueDate'
        - $ref: '#/components/parameters/issueDateLe'
        - $ref: '#/components/parameters/issueDateLt'
        - $ref: '#/components/parameters/issueDateGe'
        - $ref: '#/components/parameters/issueDateGt'
        - name: customerId
          in: query
          description: |
            Returns only credit notes sent to specified customer. Must be the contactId provided by a GET contacts call.
          schema:
            type: integer
            format: int64
        - name: settled
          in: query
          description: |
            When set to true, returns only credit notes that have been settled. Otherwise false returns all credit notes
            that have not been fully settled.
          schema:
            type: boolean
        - name: creditNoteDraftUuid
          in: query
          description: Filter based on the UUID of the credit note draft that was used to create a given invoice. Applies only to "uavhengig kreditnotaer".
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/creditNoteResult'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource


  /companies/{companySlug}/creditNotes/full:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    post:
      description: Creates a new credit note that covers the full amount of the associated invoice.
      operationId: createFullCreditNote
      tags:
        - credit notes
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/fullCreditNoteRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created credit note

  /companies/{companySlug}/creditNotes/partial:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    post:
      description: Creates a new credit note that doesn't fully cover the total amount of the associated invoice.
      operationId: createPartialCreditNote
      tags:
        - credit notes
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/partialCreditNoteRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created credit note


  /companies/{companySlug}/creditNotes/{creditNoteId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - name: creditNoteId
        in: path
        description: |
          The creditNoteId (primary key of the returned object) is returned as the first field in the GET all
          credit notes call; not to be confused with creditNoteNumber
        required: true
        schema:
          type: string
    get:
      description: Returns credit note with specified id.
      operationId: getCreditNote
      tags:
        - credit notes
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/creditNoteResult'

  /companies/{companySlug}/creditNotes/send:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    post:
      description: Sends the specified document
      operationId: sendCreditNote
      tags:
        - credit notes
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/sendCreditNoteRequest'
      responses:
        '200':
          description: Sent

  /companies/{companySlug}/creditNotes/counter:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: |
        Retrieves the counter for credit notes if it has been created
      operationId: getCreditNoteCounter
      tags:
        - credit notes
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/counter'
    post:
      description: Creates the first credit note number which is then increased by one with every new credit note. By sending an empty request body the default is base number 10000 (the first credit note number will thus be 10001), but can be specified to another starting value.
      operationId: createCreditNoteCounter
      tags:
        - credit notes
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/counter'
      responses:
        '201':
          description: Created

  /companies/{companySlug}/creditNotes/drafts:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all credit note drafts for given company.
      operationId: getCreditNoteDrafts
      tags:
        - credit notes
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/invoiceishDraftResult'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

    post:
      description: Creates a credit note draft. This draft corresponds to a draft for an "uavhengig kreditnota" in Fiken.
      operationId: createCreditNoteDraft
      tags:
        - credit notes
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/invoiceishDraftRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created credit note draft

  /companies/{companySlug}/creditNotes/drafts/{draftId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    get:
      description: Returns credit note draft with specified id.
      operationId: getCreditNoteDraft
      tags:
        - credit notes
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/invoiceishDraftResult'
    put:
      description: |
        Updates credit note draft with provided id.
      operationId: updateCreditNoteDraft
      tags:
        - credit notes
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/invoiceishDraftRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of updated credit note draft

    delete:
      description: Delete credit note draft with specified id.
      operationId: deleteCreditNoteDraft
      tags:
        - credit notes
      responses:
        '204':
          description: Deleted

  /companies/{companySlug}/creditNotes/drafts/{draftId}/attachments:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    get:
      description: Returns all attachments for specified draft.
      operationId: getCreditNoteDraftAttachments
      tags:
        - credit notes
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/attachment'
    post:
      description: Creates and adds a new attachment to a credit note draft
      operationId: addAttachmentToCreditNoteDraft
      tags:
        - credit notes
      requestBody:
        required: false
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                filename:
                  type: string
                  example: invoice_24760.pdf
                  description: Required. The filename. Must end with either .png, .jpeg, .jpg, .gif or .pdf
                comment:
                  type: string
                  description: Not required.
                file:
                  type: string
                  format: binary
                  example: https://fiken.no/api/v2/files/745b2f15-gh75-4408-bgf2-b1d2dt610cb2/invoice24760.pdf
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created attachment


  /companies/{companySlug}/creditNotes/drafts/{draftId}/createCreditNote:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    post:
      description: Creates a credit note from an already created draft.
      operationId: createCreditNoteFromDraft
      tags:
        - credit notes
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created credit note


  /companies/{companySlug}/offers:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all offers for given company
      operationId: getOffers
      tags:
        - offers
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/offer'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource


  /companies/{companySlug}/offers/{offerId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - name: offerId
        in: path
        description: |
          The offerId (primary key of the returned object) is returned as the first field in the GET all
          offers call
        required: true
        schema:
          type: string
    get:
      description: Returns offer with specified id.
      operationId: getOffer
      tags:
        - offers
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/offer'

  /companies/{companySlug}/offers/counter:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: |
        Retrieves the counter for offers if it has been created
      operationId: getOfferCounter
      tags:
        - offers
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/counter'
    post:
      description: Creates the first offer number which is then increased by one with every new offer. By sending an empty request body the default is base number (the first offer number will thus be 10001), but can be specified to another starting value.
      operationId: createOfferCounter
      tags:
        - offers
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/counter'
      responses:
        '201':
          description: Created

  /companies/{companySlug}/offers/drafts:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all offer drafts for given company.
      operationId: getOfferDrafts
      tags:
        - offers
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/invoiceishDraftResult'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource
    post:
      description: Creates an offer draft.
      operationId: createOfferDraft
      tags:
        - offers
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/invoiceishDraftRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created offer draft

  /companies/{companySlug}/offers/drafts/{draftId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    get:
      description: Returns offer draft with specified id.
      operationId: getOfferDraft
      tags:
        - offers
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/invoiceishDraftResult'
    put:
      description: |
        Updates offer draft with provided id.
      operationId: updateOfferDraft
      tags:
        - offers
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/invoiceishDraftRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of updated offer draft
    delete:
      description: Delete offer draft with specified id.
      operationId: deleteOfferDraft
      tags:
        - offers
      responses:
        '204':
          description: Deleted

  /companies/{companySlug}/offers/drafts/{draftId}/attachments:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    get:
      description: Returns all attachments for specified draft.
      operationId: getOfferDraftAttachments
      tags:
        - offers
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/attachment'
    post:
      description: Creates and adds a new attachment to an offer draft
      operationId: addAttachmentToOfferDraft
      tags:
        - offers
      requestBody:
        required: false
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                filename:
                  type: string
                  example: invoice_24760.pdf
                  description: Required. The filename. Must end with either .png, .jpeg, .jpg, .gif or .pdf
                comment:
                  type: string
                  description: Not required.
                file:
                  type: string
                  format: binary
                  example: https://fiken.no/api/v2/files/745b2f15-gh75-4408-bgf2-b1d2dt610cb2/invoice24760.pdf
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created attachment

  /companies/{companySlug}/offers/drafts/{draftId}/createOffer:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    post:
      description: Creates an offer from an already created draft.
      operationId: createOfferFromDraft
      tags:
        - offers
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created offer


  /companies/{companySlug}/orderConfirmations:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all order confirmations for given company
      operationId: getOrderConfirmations
      tags:
        - order confirmations
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/orderConfirmation'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource


  /companies/{companySlug}/orderConfirmations/{confirmationId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - name: confirmationId
        in: path
        description: |
          The confirmationId (primary key of the returned object) is returned as the first field in the GET all
          order confirmations call
        required: true
        schema:
          type: string
    get:
      description: Returns order confirmation with specified id.
      operationId: getOrderConfirmation
      tags:
        - order confirmations
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/orderConfirmation'

  /companies/{companySlug}/orderConfirmations/counter:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: |
        Retrieves the counter for order confirmations if it has been created
      operationId: getOrderConfirmationCounter
      tags:
        - order confirmations
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/counter'
    post:
      description: Creates the first order confirmation number which is then increased by one with every new order confirmation. By sending an empty request body the default is base number (the first order confirmation number will thus be 10001), but can be specified to another starting value.
      operationId: createOrderConfirmationCounter
      tags:
        - order confirmations
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/counter'
      responses:
        '201':
          description: Created

  /companies/{companySlug}/orderConfirmations/{confirmationId}/createInvoiceDraft:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - name: confirmationId
        in: path
        description: |
          The confirmationId (primary key of the returned object) is returned as the first field in the GET all
          order confirmations call
        required: true
        schema:
          type: string
    post:
      description: Creates an invoice draft from an order confirmation
      operationId: createInvoiceDraftFromOrderConfirmation
      tags:
        - order confirmations
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created invoice draft

  /companies/{companySlug}/orderConfirmations/drafts:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all order confirmation drafts for given company.
      operationId: getOrderConfirmationDrafts
      tags:
        - order confirmations
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/invoiceishDraftResult'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

    post:
      description: Creates an order confirmation draft.
      operationId: createOrderConfirmationDraft
      tags:
        - order confirmations
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/invoiceishDraftRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created order confirmation draft

  /companies/{companySlug}/orderConfirmations/drafts/{draftId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    get:
      description: Returns order confirmation draft with specified id.
      operationId: getOrderConfirmationDraft
      tags:
        - order confirmations
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/invoiceishDraftResult'
    put:
      description: |
        Updates order confirmation draft with provided id.
      operationId: updateOrderConfirmationDraft
      tags:
        - order confirmations
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/invoiceishDraftRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of updated order confirmation draft
    delete:
      description: Delete order confirmation draft with specified id.
      operationId: deleteOrderConfirmationDraft
      tags:
        - order confirmations
      responses:
        '204':
          description: Deleted

  /companies/{companySlug}/orderConfirmations/drafts/{draftId}/attachments:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    get:
      description: Returns all attachments for specified draft.
      operationId: getOrderConfirmationDraftAttachments
      tags:
        - order confirmations
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/attachment'
    post:
      description: Creates and adds a new attachment to an order confirmation draft
      operationId: addAttachmentToOrderConfirmationDraft
      tags:
        - order confirmations
      requestBody:
        required: false
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                filename:
                  type: string
                  example: invoice_24760.pdf
                  description: Required. The filename. Must end with either .png, .jpeg, .jpg, .gif or .pdf
                comment:
                  type: string
                  description: Not required.
                file:
                  type: string
                  format: binary
                  example: https://fiken.no/api/v2/files/745b2f15-gh75-4408-bgf2-b1d2dt610cb2/invoice24760.pdf
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created attachment

  /companies/{companySlug}/orderConfirmations/drafts/{draftId}/createOrderConfirmation:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    post:
      description: Creates an order confirmation from an already created draft.
      operationId: createOrderConfirmationFromDraft
      tags:
        - order confirmations
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created order confirmation


  /companies/{companySlug}/products:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all products for given company
      operationId: getProducts
      tags:
        - products
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/createdDate'
        - $ref: '#/components/parameters/createdDateLe'
        - $ref: '#/components/parameters/createdDateLt'
        - $ref: '#/components/parameters/createdDateGe'
        - $ref: '#/components/parameters/createdDateGt'
        - $ref: '#/components/parameters/lastModified'
        - $ref: '#/components/parameters/lastModifiedLe'
        - $ref: '#/components/parameters/lastModifiedLt'
        - $ref: '#/components/parameters/lastModifiedGe'
        - $ref: '#/components/parameters/lastModifiedGt'
        - name: name
          in: query
          schema:
            type: string
          description: Find all results with product name equal to the specified parameter.
        - name: productNumber
          in: query
          schema:
            type: string
          description: Find all results with product number (varenummer) equal to the specified parameter.
        - name: active
          in: query
          schema:
            type: boolean
          description: Returns active (true) or inactive (false) products.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/product'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

    post:
      description: Creates a new product.
      operationId: createProduct
      tags:
        - products
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/product'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created product


  /companies/{companySlug}/products/{productId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - name: productId
        in: path
        description: |
          The productId (primary key of the returned object) is returned in the GET all
          products call; not to be confused with productNumber.
        required: true
        schema:
          type: integer
          format: int64
    get:
      description: Returns product with specified id.
      operationId: getProduct
      tags:
        - products
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/product'

    put:
      description: Updates an existing product.
      operationId: updateProduct
      tags:
        - products
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/product'
      responses:
        '200':
          description: Updated
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of updated product

    delete:
      description: Delete product with specified id.
      operationId: deleteProduct
      tags:
        - products
      responses:
        '204':
          description: Deleted

  /companies/{companySlug}/sales:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all sales for given company
      operationId: getSales
      tags:
        - sales
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/date'
        - $ref: '#/components/parameters/dateLe'
        - $ref: '#/components/parameters/dateLt'
        - $ref: '#/components/parameters/dateGe'
        - $ref: '#/components/parameters/dateGt'
        - $ref: '#/components/parameters/lastModified'
        - $ref: '#/components/parameters/lastModifiedLe'
        - $ref: '#/components/parameters/lastModifiedLt'
        - $ref: '#/components/parameters/lastModifiedGe'
        - $ref: '#/components/parameters/lastModifiedGt'
        - name: saleNumber
          in: query
          schema:
            type: string
          description: Find all results with the sale number equal to the specified parameter.
        - name: settled
          in: query
          description: |
            When set to true, returns only sales that have been settled. Otherwise false returns all sales
            that have not been fully settled.
          schema:
            type: boolean
        - name: contactId
          in: query
          schema:
            type: integer
            format: int64
          description: Find all sale results for a given customer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/saleResult'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

    post:
      description: Creates a new sale. This corresponds to "Annet salg" in Fiken and should be used when the invoice document and invoice number have been created outside Fiken. Otherwise the invoices-endpoints should be used.
      operationId: createSale
      tags:
        - sales
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/saleRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created sale

  /companies/{companySlug}/sales/{saleId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/saleId'
    get:
      description: Returns sale with specified id.
      operationId: getSale
      tags:
        - sales
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/saleResult'

  /companies/{companySlug}/sales/{saleId}/settled:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/saleId'
      - name: settledDate
        in: query
        required: true
        schema:
          type: string
          format: date
        description: Date that the sale is settled
    patch:
      description: Marks the sale as settled without payment. This is synonymous with "sett til oppgjort uten betaling" in the GUI. It is possible to change the date of settlement by sending a new settledDate.
      operationId: settledSale
      tags:
        - sales
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/saleResult'

  /companies/{companySlug}/sales/{saleId}/delete:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/saleId'
      - name: description
        in: query
        required: true
        schema:
          type: string
        description: Required description for deleting the sale
    patch:
      description: Sets the deleted flag for a sale. The sale is not deleted, but a reverse transaction is created and the "deleted" property is set to true.
      operationId: deleteSale
      tags:
        - sales
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/saleResult'

  /companies/{companySlug}/sales/{saleId}/attachments:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/saleId'
    get:
      description: Returns all attachments for specified sale.
      operationId: getSaleAttachments
      tags:
        - sales
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/attachment'
    post:
      description: Creates and adds a new attachment to a Sale
      operationId: addAttachmentToSale
      tags:
        - sales
      requestBody:
        required: false
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                filename:
                  type: string
                  example: invoice_24760.pdf
                  description: The filename. Must end with either .png, .jpeg, .jpg, .gif or .pdf
                attachToPayment:
                  type: boolean
                  default: true
                  description: True if this attachment may document the payment (i.e. transaction receipt from credit card/payment company, export from bank, etc.). Default value is false if not specified. At least one of attachToPayment and attachToSale must be true.
                attachToSale:
                  type: boolean
                  default: true
                  description: True if this attachment may document the sale (i.e. invoice, etc). Default value is false if not specified. At least one of attachToPayment and attachToSale must be true.
                file:
                  type: string
                  format: binary
                  example: https://fiken.no/api/v2/files/745b2f15-gh75-4408-bgf2-b1d2dt610cb2/invoice24760.pdf
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created attachment


  /companies/{companySlug}/sales/{saleId}/payments:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/saleId'
    get:
      description: Returns all payments for given sale
      operationId: getSalePayments
      tags:
        - sales
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/payment'

    post:
      description: Creates a new payment for a given sale.
      operationId: createSalePayment
      tags:
        - sales
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/payment'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created payment

  /companies/{companySlug}/sales/{saleId}/payments/{paymentId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/saleId'
      - $ref: '#/components/parameters/paymentId'
    get:
      description: Returns payment with specified id.
      operationId: getSalePayment
      tags:
        - sales
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/payment'

  /companies/{companySlug}/sales/drafts:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all sale drafts for given company.
      operationId: getSaleDrafts
      tags:
        - sales
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/draftResult'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

    post:
      description: Creates a sale draft.
      operationId: createSaleDraft
      tags:
        - sales
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/draftRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created draft

  /companies/{companySlug}/sales/drafts/{draftId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    get:
      description: Returns draft with specified id.
      operationId: getSaleDraft
      tags:
        - sales
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/draftResult'
    put:
      description: |
        Updates draft with provided id.
      operationId: updateSaleDraft
      tags:
        - sales
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/draftRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of updated draft
    delete:
      description: Delete draft with specified id.
      operationId: deleteSaleDraft
      tags:
        - sales
      responses:
        '204':
          description: Deleted

  /companies/{companySlug}/sales/drafts/{draftId}/attachments:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    get:
      description: Returns all attachments for specified draft.
      operationId: getSaleDraftAttachments
      tags:
        - sales
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/attachment'
    post:
      description: Creates and adds a new attachment to a draft
      operationId: addAttachmentToSaleDraft
      tags:
        - sales
      requestBody:
        required: false
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                filename:
                  type: string
                  example: invoice_24760.pdf
                  description: Required. The filename. Must end with either .png, .jpeg, .jpg, .gif or .pdf
                file:
                  type: string
                  format: binary
                  example: https://fiken.no/api/v2/files/745b2f15-gh75-4408-bgf2-b1d2dt610cb2/invoice24760.pdf
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created attachment

  /companies/{companySlug}/sales/drafts/{draftId}/createSale:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    post:
      description: Creates a sale from an already created draft.
      operationId: createSaleFromDraft
      tags:
        - sales
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created sale

  /companies/{companySlug}/purchases:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all purchases for given company
      operationId: getPurchases
      tags:
        - purchases
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/date'
        - $ref: '#/components/parameters/dateLe'
        - $ref: '#/components/parameters/dateLt'
        - $ref: '#/components/parameters/dateGe'
        - $ref: '#/components/parameters/dateGt'
        - name: sortBy
          in: query
          schema:
            type: string
            enum: [date asc, date desc]
            default: date asc
          description: Sorts results in either ascending (asc) or descending (desc) order based on the parameter value.
        - name: paid
          in: query
          description: |
            When set to true, returns only purchases that have been paid. Otherwise false returns all purchases
            that have not been fully settled.
          schema:
            type: boolean
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/purchaseResult'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

    post:
      description: Creates a new purchase.
      operationId: createPurchase
      tags:
        - purchases
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/purchaseRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created purchase

  /companies/{companySlug}/purchases/{purchaseId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/purchaseId'
    get:
      description: Returns purchase with specified id.
      operationId: getPurchase
      tags:
        - purchases
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/purchaseResult'


  /companies/{companySlug}/purchases/{purchaseId}/delete:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/purchaseId'
      - name: description
        in: query
        required: true
        schema:
          type: string
        description: Required description for deleting the purchase
    patch:
      description: Sets the deleted flag for a purchase. The purchase is not deleted, but a reverse transaction is created and the "deleted" property is set to true.
      operationId: deletePurchase
      tags:
        - purchases
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/purchaseResult'


  /companies/{companySlug}/purchases/{purchaseId}/attachments:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/purchaseId'
    get:
      description: Returns all attachments for specified purchase.
      operationId: getPurchaseAttachments
      tags:
        - purchases
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/attachment'
    post:
      description: Creates and adds a new attachment to a Purchase
      operationId: addAttachmentToPurchase
      tags:
        - purchases
      requestBody:
        required: false
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                filename:
                  type: string
                  example: invoice_24760.pdf
                  description: The filename. Must end with either .png, .jpeg, .jpg, .gif or .pdf
                attachToPayment:
                  type: boolean
                  description: True if this attachment may document the payment (i.e. transaction receipt from credit card/payment company, export from bank, etc.). Default value is false if not specified. At least one of attachToPayment and attachToSale must be true.
                attachToSale:
                  type: boolean
                  description: True if this attachment may document the sale (i.e. invoice, etc). Default value is false if not specified. At least one of attachToPayment and attachToSale must be true.
                file:
                  type: string
                  format: binary
                  example: https://fiken.no/api/v2/files/745b2f15-gh75-4408-bgf2-b1d2dt610cb2/invoice24760.pdf
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created attachment

  /companies/{companySlug}/purchases/{purchaseId}/payments:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/purchaseId'
    get:
      description: Returns all purchases for given company
      operationId: getPurchasePayments
      tags:
        - purchases
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/payment'

    post:
      description: Creates a new payment for a purchase
      operationId: createPurchasePayment
      tags:
        - purchases
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/payment'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created payment

  /companies/{companySlug}/purchases/{purchaseId}/payments/{paymentId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/purchaseId'
      - $ref: '#/components/parameters/paymentId'
    get:
      description: Returns given payment for specified purchase
      operationId: getPurchasePayment
      tags:
        - purchases
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/payment'

  /companies/{companySlug}/purchases/drafts:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all purchase drafts for given company.
      operationId: getPurchaseDrafts
      tags:
        - purchases
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/draftResult'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource

    post:
      description: Creates a purchase draft.
      operationId: createPurchaseDraft
      tags:
        - purchases
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/draftRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created draft

  /companies/{companySlug}/purchases/drafts/{draftId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    get:
      description: Returns draft with specified id.
      operationId: getPurchaseDraft
      tags:
        - purchases
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/draftResult'
    put:
      description: |
        Updates draft with provided id.
      operationId: updatePurchaseDraft
      tags:
        - purchases
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/draftRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of updated draft
    delete:
      description: Delete draft with specified id.
      operationId: deletePurchaseDraft
      tags:
        - purchases
      responses:
        '204':
          description: Deleted

  /companies/{companySlug}/purchases/drafts/{draftId}/attachments:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    get:
      description: Returns all attachments for specified draft.
      operationId: getPurchaseDraftAttachments
      tags:
        - purchases
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/attachment'
    post:
      description: Creates and adds a new attachment to a draft
      operationId: addAttachmentToPurchaseDraft
      tags:
        - purchases
      requestBody:
        required: false
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                filename:
                  type: string
                  example: invoice_24760.pdf
                  description: Required. The filename. Must end with either .png, .jpeg, .jpg, .gif or .pdf
                file:
                  type: string
                  format: binary
                  example: https://fiken.no/api/v2/files/745b2f15-gh75-4408-bgf2-b1d2dt610cb2/invoice24760.pdf
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created attachment

  /companies/{companySlug}/purchases/drafts/{draftId}/createPurchase:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/draftId'
    post:
      description: Creates a purchase from an already created draft.
      operationId: createPurchaseFromDraft
      tags:
        - purchases
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created purchase

  /companies/{companySlug}/inbox:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns the contents of the inbox for given company.
      operationId: getInbox
      tags:
        - inbox
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - name: sortBy
          in: query
          schema:
            type: string
            enum: [createdDate asc, createdDate desc, name asc, name desc]
            default: createdDate desc
          description: Sorts results in either ascending (asc) or descending (desc) order based on the parameter value.
        - name: status
          in: query
          schema:
            type: string
            enum: [all, unused, used]
            default: all
            description: |
              Filter documents based on their status. If not specified, all documents are returned.
        - name: name
          in: query
          schema:
            type: string
          description: Filter documents based on their name, case-insensitive substring match.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/inboxResult'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resourceA
    post:
      description: Upload a document to the inbox
      operationId: createInboxDocument
      tags:
        - inbox
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: Invoice for August
                  description: The name of the inbox document, usually the same as the filename
                filename:
                  type: string
                  example: invoice.pdf
                  description: The filename of the file uploaded
                description:
                  type: string
                  example: Uploaded with API
                  description: Additional description of the inbox document
                file:
                  type: string
                  format: binary
      responses:
        201:
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created inbox document

  /companies/{companySlug}/inbox/{inboxDocumentId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/inboxDocumentId'
    get:
      description: Returns the inbox document with specified id
      operationId: getInboxDocument
      tags:
        - inbox
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/inboxResult'

  /companies/{companySlug}/projects:
    parameters:
      - $ref: '#/components/parameters/companySlug'
    get:
      description: Returns all projects for given company
      operationId: getProjects
      tags:
        - projects
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - name: completed
          in: query
          schema:
            type: boolean
          description: Filter results based on completed / not completed.
        - name: name
          in: query
          schema:
            type: string
          description: Filter results based on name of the project.
        - name: number
          in: query
          schema:
            type: string
          description: Filter results based on number of the project.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/projectResult'
          headers:
            Fiken-Api-Page:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Size:
              schema:
                type: integer
              description: From the request header
            Fiken-Api-Page-Count:
              schema:
                type: integer
              description: The total number of pages in this resource with this page size
            Fiken-Api-Result-Count:
              schema:
                type: integer
              description: The total number of elements in this resource
    post:
      description: Creates a new project
      operationId: createProject
      tags:
        - projects
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/projectRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of newly created project

  /companies/{companySlug}/projects/{projectId}:
    parameters:
      - $ref: '#/components/parameters/companySlug'
      - $ref: '#/components/parameters/projectId'
    get:
      description: Returns project with specified id.
      operationId: getProject
      tags:
        - projects
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/projectResult'
    patch:
      description: |
        Updates project with provided id.
      operationId: updateProject
      tags:
        - projects
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/updateProjectRequest'
      responses:
        '201':
          description: Created
          headers:
            Location:
              schema:
                type: string
                format: uri
              description: Full URL of updated project
    delete:
      description: Delete project with specified id.
      operationId: deleteProject
      tags:
        - projects
      responses:
        '204':
          description: Deleted


components:
  securitySchemes:
    fiken_api_oauth:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: 'https://fiken.no/oauth/authorize'
          tokenUrl: 'https://fiken.no/oauth/token'
          scopes: {}
  schemas:
    accountBalance:
      allOf:
        - $ref: '#/components/schemas/account'
        - type: object
          properties:
            balance:
              type: integer
              format: int64
              example: 15200
              description: Balance of account for a given date given in cents (5050 = 50.50)
    account:
      type: object
      properties:
        code:
          type: string
          example: 1500:10029
        name:
          type: string
          example: 'John Lewis'
    address:
      type: object
      required:
        - country
      properties:
        streetAddress:
          type: string
          example: 'Karl Johan 34'
        streetAddressLine2:
          type: string
          example: 'H0405'
        city:
          type: string
          example: 'Oslo'
        postCode:
          type: string
          example: '0550'
        country:
          type: string
          example: 'Norway'
    attachment:
      type: object
      properties:
        identifier:
          type: string
          example: '24760'
          description: User-defined identifier for attachment. Could be the Invoice Id or receipt number for example.
        downloadUrl:
          type: string
          description: For use with API credentials (bearer token or oauth 2)
        downloadUrlWithFikenNormalUserCredentials:
          type: string
          description: Requires the user to login with username and password in Fiken.
        comment:
          type: string
          description: Field for additional information for this attachment.
        type:
          type: string
          enum: [invoice, reminder, unspecified, ocr, bank_statement]
          example: 'invoice'
    bankAccountRequest:
      type: object
      required:
        - bankAccountNumber
        - name
        - type
      properties:
        name:
          type: string
          example: 'Utgiftskonto DNB'
        bankAccountNumber:
          type: string
          example: '11112233334'
        bic:
          type: string
          example: 'DNBANOKKXXX'
        iban:
          type: string
          example: 'NO49 1111 2233 334'
        foreignService:
          type: string
          example: 'Barclays UK'
        type:
          type: string
          enum: [normal, tax_deduction, foreign, credit_card]
          example: 'normal'
        inactive:
          type: boolean
          default: false
          example: false
    bankAccountResult:
      type: object
      properties:
        bankAccountId:
          type: integer
          format: int64
          example: 2747365
        name:
          type: string
          example: 'Utgiftskonto DNB'
        accountCode:
          type: string
          example: '1920:10007'
        bankAccountNumber:
          type: string
          example: '15035646830'
        iban:
          type: string
        bic:
          type: string
        foreignService:
          type: string
        type:
          type: string
          enum: [normal, tax_deduction, foreign, credit_card]
          example: 'normal'
        reconciledBalance:
          type: integer
          format: int64
          example: 10050
          description: Amounts are always represented as a number, and specifies the number of cents in the amount. Fractions will be ignored. ie. 10050 = 100.50
        reconciledDate:
          type: string
          format: date
          example: '2018-04-03'
        inactive:
          type: boolean
          default: false
          example: false
    company:
      type: object
      properties:
        name:
          type: string
          example: 'Fiken AS'
          description: Name of company.
        slug:
          type: string
          example: 'fiken-as'
          description: Formatted name of company. This is the companySlug that should be used in all URLs related to this company.
        organizationNumber:
          type: string
          example: '913312465'
          description: Brreg organization number.
        vatType:
          type: string
          enum: ["no", yearly, monthly, bi-monthly]
        address:
          $ref: '#/components/schemas/address'
        phoneNumber:
          type: string
          example: '62158537'
          writeOnly: true
        email:
          type: string
          example: 'kontakt@fiken.gmail'
        creationDate:
          type: string
          format: date
          example: '2018-04-03'
        hasApiAccess:
          type: boolean
          example: true
        testCompany:
          type: boolean
          description: Whether the company is a demo (true) or not
        accountingStartDate:
          type: string
          format: date
          example: '2018-04-03'
    contact:
      type: object
      required:
        - name
      properties:
        contactId:
          type: integer
          format: int64
          readOnly: true
          example: 2747365
        createdDate:
          type: string
          format: date
          readOnly: true
          example: '2018-04-03'
          description: Date that contact was created in Fiken, format yyyy-mm-dd.
        lastModifiedDate:
          type: string
          format: date
          readOnly: true
          example: '2018-04-03'
          description: Date that contact was last modified in Fiken, format yyyy-mm-dd.
        name:
          type: string
          example: 'Fiken AS'
          minLength: 1
          maxLength: 200
        email:
          type: string
          example: 'kontakt@fiken.gmail'
          maxLength: 200
        organizationNumber:
          type: string
          example: '913312465'
          description: Brreg organization number.
          maxLength: 200
        customerNumber:
          type: integer
          format: int64
          example: 51248
          readOnly: true
        customerAccountCode:
          type: string
          example: '1500:20001'
          readOnly: true
          description: Format 1500:XXXXX
        phoneNumber:
          type: string
          example: '62158537'
          maxLength: 20
          writeOnly: true
        memberNumber:
          type: number
          example: 5464
          writeOnly: true
          description: A number that can be used to connect a contact to your own data.
        supplierNumber:
          type: integer
          format: int64
          readOnly: true
        supplierAccountCode:
          type: string
          example: '2400:20001'
          readOnly: true
          description: Format 2400:XXXXX
        customer:
          type: boolean
          default: false
          description: True if the contact is a customer. It is possible for a contact to be both customer and supplier.
        supplier:
          type: boolean
          default: false
          description: True if the contact is a supplier. It is possible for a contact to be both supplier and customer.
        bankAccountNumber:
          type: string
          example: '11112233334'
          maxLength: 11
        contactPerson:
          type: array
          items:
            $ref: '#/components/schemas/contactPerson'
        notes:
          type: array
          readOnly: true
          items:
            $ref: '#/components/schemas/contactNote'
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          example: 'NOK'
          writeOnly: true
          description: ISO 4217 currency code. Default foreign currency to use when creating invoice to this contact (USD, EUR, SEK etc)
        language:
          type: string
          example: 'Norwegian'
          nullable: true
          description: The language to use when sending documents to this contact. NORWEGIAN or ENGLISH. Defaults to NORWEGIAN.
        inactive:
          type: boolean
          example: true
          description: Whether the contact has been deactivated (true) or is active (false)
        daysUntilInvoicingDueDate:
          type: integer
          format: int32
          description: Default number of days until due date for invoices.
          example: 15
        address:
          $ref: '#/components/schemas/address'
        groups:
          type: array
          items:
            type: string
        documents:
          type: array
          readOnly: true
          items:
            $ref: '#/components/schemas/attachment'
    contactNote:
      type: object
      properties:
        author:
          type: string
          example: 'Betty Boop'
        note:
          type: string
          example: 'Garage 45'
    note:
      type: object
      description: Used for invoices and sales
      properties:
        author:
          type: string
          example: 'James Jones'
        note:
          type: string
          example: 'Invoice sent after telephone conversation with customer'
    contactPerson:
      type: object
      required:
        - name
        - email
      properties:
        contactPersonId:
          type: integer
          format: int64
          readOnly: true
          example: 2747365
        name:
          type: string
          example: 'Betty Boop'
        email:
          type: string
          example: 'bb@gmail.com'
        phoneNumber:
          type: string
          example: '98573564'
        address:
          $ref: '#/components/schemas/address'
    counter:
      type: object
      properties:
        value:
          type: integer
          format: int32
          example: 10000
          default: 10000
          description: Current value of the counter
    creditNoteLineResult:
      type: object
      required:
        - quantity
        - unitPrice
      properties:
        incomeAccount:
          type: string
          description: Field is similar to vatType, it defaults to the product's income account. Either the line or the product needs to have an income account set.
          example: '3000'
        vatType:
          type: string
          description: |
            One of: {"HIGH", "MEDIUM", "LOW", "EXEMPT", "EXEMPT_IMPORT_EXPORT", "EXEMPT_REVERSE", "OUTSIDE", "NONE"}. "HIGH" is the most common.
          example: 'HIGH'
        unitPrice:
          type: integer
          format: int64
          description: Net price per unit in invoice currency (in cents).
          example: 4550
        quantity:
          type: number
          description: Number of units to be invoiced.
          example: 5
        discount:
          type: number
          example: 25
          description: If field is set, all amounts must be given before the discount is applied. The API will calculate the new totals. Discount value should be a percent with a value between 0 and 100. Decimal values such as 25.5 are also allowed.
        productId:
          type: integer
          format: int64
          example: 2888156
          description: Product Id of product associated with invoice line.
        description:
          type: string
          maxLength: 200
          description: Description of the invoiced product or service.
          example: 'Goatskin, with extra-long suede cuffs'
        comment:
          type: string
          maxLength: 200
          description: Additional information to be printed on invoice.
          example: 'One size fits all'
    creditNoteResult:
      type: object
      required:
        - creditNoteId
        - creditNoteNumber
        - customer
        - net
        - vat
        - gross
        - netInNok
        - vatInNok
        - grossInNok
        - address
      properties:
        creditNoteId:
          type: integer
          format: int64
          readOnly: true
          example: 2888156
          description: Id of credit note
        creditNoteNumber:
          type: integer
          format: int64
          example: 10001
          readOnly: true
          description: Unique credit note number generated by us.
        kid:
          type: string
          example: '5855454756'
          description: Norwegian KID number. Number from 2 to 25 digits long.
        customer:
          $ref: '#/components/schemas/contact'
        net:
          type: integer
          format: int64
          example: 25000
          description: Net amount (in creditNote currency) in cents.
        vat:
          type: integer
          format: int64
          example: 5000
          description: VAT amount (in creditNote currency) in cents.
        gross:
          type: integer
          format: int64
          example: 30000
          description: Gross amount (= net+VAT) (in creditNote currency) in cents.
        netInNok:
          type: integer
          format: int64
          example: 25000
          description: Net amount in NOK (in cents)
        vatInNok:
          type: integer
          format: int64
          example: 5000
          description: VAT amount in NOK (in cents)
        grossInNok:
          type: integer
          format: int64
          example: 30000
          description: Gross amount in NOK (in cents)
        creditNoteText:
          type: string
          description: Comment/description printed above the credit note lines.
        yourReference:
          type: string
        ourReference:
          type: string
          readOnly: true
        orderReference:
          type: string
          description: Reference if sending via EHF.
        address:
          $ref: '#/components/schemas/address'
        lines:
          type: array
          items:
            $ref: '#/components/schemas/invoiceLineResult'
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          example: 'NOK'
          description: ISO 4217 currency code
        issueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Issue date of the credit note, format yyyy-mm-dd
        settled:
          type: boolean
          example: true
          description: If the credit note as been marked as settled (True) or not (False).
        associatedInvoiceId:
          type: integer
          format: int64
          example: 2888156
          description: Id of associated invoice
        creditNoteDraftUuid:
          type: string
          example: 123e4567-e89b-12d3-a456-426655440000
          description: |
            The UUID of the credit note draft used to create the credit note. 
            Credit notes created directly from invoices (POST / creditNotes/full and POST /creditNotes/partial) 
            will not have a draft uuid as no draft is created in this case.
        creditNotePdf:
          $ref: '#/components/schemas/attachment'
        project:
          $ref: '#/components/schemas/projectResult'
        sale:
          $ref: '#/components/schemas/saleResult'
    draftLineRequest:
      type: object
      required:
        - text
        - vatType
        - incomeAccount
        - net
        - gross
      properties:
        text:
          type: string
          maxLength: 200
          description: Description of the sale/purchase line.
        vatType:
          type: string
          description: |
            Vat Types for SALES: [NONE, HIGH, MEDIUM, RAW_FISH, LOW, EXEMPT_IMPORT_EXPORT, EXEMPT, OUTSIDE, EXEMPT_REVERSE]
            Vat Types for PURCHASES: [NONE, HIGH, MEDIUM, RAW_FISH, LOW, HIGH_DIRECT, HIGH_BASIS, MEDIUM_DIRECT, MEDIUM_BASIS, NONE_IMPORT_BASIS,
            HIGH_FOREIGN_SERVICE_DEDUCTIBLE, HIGH_FOREIGN_SERVICE_NONDEDUCTIBLE, LOW_FOREIGN_SERVICE_DEDUCTIBLE,
            LOW_FOREIGN_SERVICE_NONDEDUCTIBLE, HIGH_PURCHASE_OF_EMISSIONSTRADING_OR_GOLD_DEDUCTIBLE, HIGH_PURCHASE_OF_EMISSIONSTRADING_OR_GOLD_NONDEDUCTIBLE]
        incomeAccount:
          type: string
          description: Field is similar to vatType, it defaults to the product's income account. Either the line or the product needs to have an income account set.
          example: '3000'
        net:
          type: integer
          format: int64
          example: 25000
          description: Net amount (in creditNote currency) in cents.
        gross:
          type: integer
          format: int64
          example: 30000
          description: Gross amount (= net+VAT) (in creditNote currency) in cents.
        projectId:
          type: integer
          format: int64
          example: 2888156
    draftLineResult:
      type: object
      properties:
        text:
          type: string
          maxLength: 200
          description: Description of the sale/purchase line.
        vatType:
          type: string
          description: |
            Vat Types for SALES: [NONE, HIGH, MEDIUM, RAW_FISH, LOW, EXEMPT_IMPORT_EXPORT, EXEMPT, OUTSIDE, EXEMPT_REVERSE]
            Vat Types for PURCHASES: [NONE, HIGH, MEDIUM, RAW_FISH, LOW, HIGH_DIRECT, HIGH_BASIS, MEDIUM_DIRECT, MEDIUM_BASIS, NONE_IMPORT_BASIS,
            HIGH_FOREIGN_SERVICE_DEDUCTIBLE, HIGH_FOREIGN_SERVICE_NONDEDUCTIBLE, LOW_FOREIGN_SERVICE_DEDUCTIBLE,
            LOW_FOREIGN_SERVICE_NONDEDUCTIBLE, HIGH_PURCHASE_OF_EMISSIONSTRADING_OR_GOLD_DEDUCTIBLE, HIGH_PURCHASE_OF_EMISSIONSTRADING_OR_GOLD_NONDEDUCTIBLE]
        incomeAccount:
          type: string
          description: Field is similar to vatType, it defaults to the product's income account. Either the line or the product needs to have an income account set.
          example: '3000'
        net:
          type: integer
          format: int64
          example: 25000
          description: Net amount (in creditNote currency) in cents.
        gross:
          type: integer
          format: int64
          example: 30000
          description: Gross amount (= net+VAT) (in creditNote currency) in cents.
        project:
          $ref: '#/components/schemas/projectResult'
    draftRequest:
      type: object
      required:
        - cash
        - lines
      properties:
        invoiceIssueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Issue date of the draft, format yyyy-mm-dd
        dueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Due date of draft, format yyyy-mm-dd
        invoiceNumber:
          type: string
          format: int64
          example: 'NOEE2888156'
          description: If invoice associated with draft, this is the invoice number (not to be confused with the invoiceId of an invoice issued from Fiken)
        contactId:
          type: integer
          format: int64
          example: 2888156
          description: Contact Id
        projectId:
          type: integer
          format: int64
          example: 2888156
          description: Project ID if only 1 project associated with entire draft. It is also possible to specify the project on individual draft lines
        cash:
          type: boolean
          description: If a cash sale/purchase (true) or otherwise (false)
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          example: 'NOK'
          description: ISO 4217 currency code
        kid:
          type: string
          example: '5855454756'
          description: Norwegian KID number. Number from 2 to 25 digits long.
        paid:
          type: boolean
          description: Whether the sale/purchase has been paid (true) or not (false)
        payments:
          type: array
          items:
            $ref: '#/components/schemas/payment'
        lines:
          type: array
          items:
            $ref: '#/components/schemas/draftLineRequest'
    draftResult:
      type: object
      properties:
        draftId:
          type: integer
          format: int64
          example: 2888156
          description: Draft ID
        uuid:
          type: string
          example: '123e4567-e89b-12d3-a456-426655440000'
          description: UUID are represented as 32 hexadecimal (base-16) digits, displayed in 5 groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters.
        invoiceIssueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Issue date of the draft, format yyyy-mm-dd
        dueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Due date of draft, format yyyy-mm-dd
        invoiceNumber:
          type: string
          example: 'NOEE2888156'
          description: If invoice associated with draft, this is the invoice number (not to be confused with the invoiceId of an invoice issued from Fiken)
        contact:
          $ref: '#/components/schemas/contact'
        project:
          $ref: '#/components/schemas/projectResult'
        cash:
          type: boolean
          description: If a cash sale/purchase (true) or otherwise (false)
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          example: 'NOK'
          description: ISO 4217 currency code
        kid:
          type: string
          example: '5855454756'
          description: Norwegian KID number. Number from 2 to 25 digits long.
        paid:
          type: boolean
          description: Whether the sale/purchase has been paid (true) or not (false)
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/attachment'
        payments:
          type: array
          items:
            $ref: '#/components/schemas/payment'
        lines:
          type: array
          items:
            $ref: '#/components/schemas/draftLineResult'
    fullCreditNoteRequest:
      type: object
      required:
        - issueDate
        - invoiceId
      properties:
        issueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Date that the credit note is issued, format yyyy-mm-dd
        invoiceId:
          type: integer
          format: int64
          example: 2888156
          description: Id of invoice that the credit note is associated with.
        creditNoteText:
          type: string
          maxLength: 500
          example: 'Invoice for services rendered during the Oslo Knitting Festival.'
    generalJournalEntryRequest:
      type: object
      required:
        - journalEntries
      properties:
        description:
          type: string
          maxLength: 200
        open:
          type: boolean
          example: false
          description: The journal entry can be set to either open or closed (closed is the default). In the case of an open journal entry these can be deleted without creating a counter transaction.
          default: false
        journalEntries:
          type: array
          items:
            $ref: '#/components/schemas/journalEntry'
    inboxResult:
      type: object
      properties:
        documentId:
          type: integer
          format: int64
          example: 1234134
          readOnly: true
        name:
          type: string
          description: Name of the document as it appears in the inbox
        description:
          type: string
          description: Additional description of document
        filename:
          type: string
          description: Name of the underlying file for the inbox document
        status:
          type: boolean
          description: Whether the document has been used as documentation or not
        createdAt:
          type: string
          format: date-time
          description: When the document was created
    invoiceishDraftLine:
      type: object
      required:
        - quantity
      properties:
        invoiceishDraftLineId:
          type: integer
          format: int64
          example: 2888156
          description: Unique draft line ID
        lastModifiedDate:
          type: string
          format: date
          example: '2018-04-03'
          readOnly: true
          description: Date that the draft line was last modified in Fiken, format yyyy-mm-dd.
        productId:
          type: integer
          format: int64
          description: Product to be credited/debited on invoice draft line.
        description:
          type: string
          maxLength: 200
          description: Description of the invoiced product or service.
          example: 'Goatskin, with extra-long suede cuffs'
        unitPrice:
          type: integer
          format: int64
          description: Net price per unit in invoice currency (in cents).
          example: 4550
        vatType:
          type: string
          description: |
            Vat Types for SALES: [NONE, HIGH, MEDIUM, RAW_FISH, LOW, EXEMPT_IMPORT_EXPORT, EXEMPT, OUTSIDE, EXEMPT_REVERSE]
            Vat Types for PURCHASES: [NONE, HIGH, MEDIUM, RAW_FISH, LOW, HIGH_DIRECT, HIGH_BASIS, MEDIUM_DIRECT, MEDIUM_BASIS, NONE_IMPORT_BASIS,
            HIGH_FOREIGN_SERVICE_DEDUCTIBLE, HIGH_FOREIGN_SERVICE_NONDEDUCTIBLE, LOW_FOREIGN_SERVICE_DEDUCTIBLE,
            LOW_FOREIGN_SERVICE_NONDEDUCTIBLE, HIGH_PURCHASE_OF_EMISSIONSTRADING_OR_GOLD_DEDUCTIBLE, HIGH_PURCHASE_OF_EMISSIONSTRADING_OR_GOLD_NONDEDUCTIBLE]
        quantity:
          type: number
          description: Number of units to be invoiced.
          example: 5
        discount:
          type: number
          description: Percentage discount charged on invoice draft line. Should be a value between 0 and 100. Can be decimal values such as 25.5
          example: 25
        comment:
          type: string
          maxLength: 200
          description: Additional information to be printed on invoice.
          example: 'One size fits all'
        incomeAccount:
          type: string
          description: Field is similar to vatType, it defaults to the product's income account. Either the line or the product needs to have an income account set.
          example: '3000'
    invoiceishDraftRequest:
      type: object
      required:
        - customerId
        - daysUntilDueDate
        - type
      properties:
        type:
          type: string
          enum: [invoice, cash_invoice, offer, order_confirmation, credit_note]
          example: 'invoice'
          description: Type of draft.
        uuid:
          type: string
          example: '123e4567-e89b-12d3-a456-426655440000'
          description: UUID are represented as 32 hexadecimal (base-16) digits, displayed in 5 groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters.
        issueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Issue date of the invoice draft, format yyyy-mm-dd
        daysUntilDueDate:
          type: integer
          format: int32
          example: 15
          description: Days until due date of the invoice draft.
        invoiceText:
          type: string
          description: Comment/description printed above the invoice lines. If not present, and standard text is registered, standard text is printed.
        yourReference:
          type: string
        ourReference:
          type: string
        orderReference:
          type: string
          description: Reference if sending invoice via EHF.
        lines:
          type: array
          items:
            $ref: '#/components/schemas/invoiceishDraftLine'
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          example: 'NOK'
          description: ISO 4217 currency code
        bankAccountNumber:
          type: string
          example: '11112233334'
        iban:
          type: string
        bic:
          type: string
        paymentAccount:
          type: string
          example: '1920:10001'
        customerId:
          type: integer
          format: int64
          example: 7340852
          description: customerId = contactId where customer = true
        contactPersonId:
          type: integer
          format: int64
          example: 8588156
          description: Id of the contact person. Must be associated with the provided customer.
        projectId:
          type: integer
          format: int64
          example: 75408386
    invoiceishDraftResult:
      type: object
      properties:
        draftId:
          type: integer
          format: int64
          readOnly: true
          example: 2888156
          description: Invoice draft ID
        uuid:
          type: string
          example: '123e4567-e89b-12d3-a456-426655440000'
          description: UUID are represented as 32 hexadecimal (base-16) digits, displayed in 5 groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters.
        type:
          type: string
          enum: [invoice, cash_invoice, offer, order_confirmation, credit_note, repeating_invoice]
          default: 'invoice'
          example: 'invoice'
          description: Type of invoice draft.
        lastModifiedDate:
          type: string
          format: date
          example: '2023-04-03'
          readOnly: true
          description: Date that the draft was last modified in Fiken, format yyyy-mm-dd.
        issueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Issue date of the invoice draft, format yyyy-mm-dd
        daysUntilDueDate:
          type: integer
          format: int32
          example: 15
          description: Days until due date of the invoice draft.
        invoiceText:
          type: string
          description: Comment/description printed above the invoice lines
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          example: 'NOK'
          description: ISO 4217 currency code
        yourReference:
          type: string
        ourReference:
          type: string
        orderReference:
          type: string
          description: Reference if sending invoice via EHF.
        lines:
          type: array
          items:
            $ref: '#/components/schemas/invoiceishDraftLine'
        net:
          type: integer
          format: int64
          description: The net amount to be invoiced in the specified currency.
          example: 4500
        gross:
          type: integer
          format: int64
          description: The gross amount to be invoiced in the specified currency.
          example: 5000
        bankAccountNumber:
          type: string
          example: '11112233334'
        iban:
          type: string
        bic:
          type: string
        paymentAccount:
          type: string
          example: '1920:10001'
        customers:
          type: array
          items:
            $ref: '#/components/schemas/contact'
          minItems: 1
          description: Customer(s) to be invoiced.
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/attachment'
        createdFromInvoiceId:
          type: integer
          format: int64
          example: 73408306
        projectId:
          type: integer
          format: int64
          example: 73408306
    invoiceLineRequest:
      type: object
      required:
        - quantity
      properties:
        net:
          type: integer
          format: int64
          description: Net amount of invoice line in cents in original currency.
          example: 4500
        vat:
          type: integer
          format: int64
          description: VAT amount of invoice line in cents in original currency.
          example: 500
        vatType:
          type: string
          description: |
            Taken from either 1) the line or 2) the product. At least vatType or vatPercent has to be specified. If both are specified, Fiken will assert that the given vat type matches the given vat percent for the issue date.
            One of: {"HIGH", "MEDIUM", "LOW", "EXEMPT", "EXEMPT_IMPORT_EXPORT", "EXEMPT_REVERSE", "OUTSIDE", "NONE"}. "HIGH" is the most common.
          example: 'HIGH'
        gross:
          type: integer
          format: int64
          description: Gross amount of invoice line in cents.
          example: 5000
        vatInPercent:
          type: number
          description: Percentage value of VAT charged on invoice line. Should be a value between 0 and 100. Can be decimal values such as 25.5
          example: 25
        unitPrice:
          type: integer
          format: int64
          description: Net price per unit in invoice currency (in cents). WARNING - if specified here and different from unitPrice of the product, then this amount overwrites the product price on the invoice.
          example: 4550
        quantity:
          type: number
          description: Number of units to be invoiced.
          example: 5
        discount:
          type: number
          example: 25
          description: If field is set, all amounts must be given before the discount is applied. The API will calculate the new totals. Discount value should be a value between 0 and 100.
        productName:
          type: string
          description: Name of product to be printed on invoice line. Should only be specified when productId is not provided.
          example: 'Gardening Gloves VI2'
        productId:
          type: integer
          format: int64
          example: 2888156
          description: Product Id of product associated with invoice line.
        description:
          type: string
          maxLength: 200
          description: Description of the invoiced product or service. WARNING - if specified here and different from description of the product, then thisoverwrites the product description on the invoice.
          example: 'Goatskin, with extra-long suede cuffs'
        comment:
          type: string
          maxLength: 200
          description: Additional information to be printed on invoice.
          example: 'One size fits all'
        incomeAccount:
          type: string
          description: |
            Field is similar to vatType, it defaults to the product's income account. Either the line or the product needs to have an income account set.
            WARNING - if specified here and different from income account of the product, then this account overwrites the product account on the invoice.
          example: '3000'
    invoiceLineResult:
      type: object
      properties:
        net:
          type: integer
          format: int64
          description: Net amount of invoice line in cents in original currency.
          example: 4500
        vat:
          type: integer
          format: int64
          description: VAT amount of invoice line in cents in original currency.
          example: 500
        vatType:
          type: string
          description: |
            Taken from either 1) the line or 2) the product. At least vatType or vatPercent has to be specified. If both are specified, Fiken will assert that the given vat type matches the given vat percent for the issue date.
            One of: {"HIGH", "MEDIUM", "LOW", "EXEMPT", "EXEMPT_IMPORT_EXPORT", "EXEMPT_REVERSE", "OUTSIDE", "NONE"}. "HIGH" is the most common.
          Example: 'HIGH'
        gross:
          type: integer
          format: int64
          description: Gross amount of invoice line in cents.
          example: 5000
        netInNok:
          type: integer
          format: int64
          description: Net amount of invoice line in cents in NOK if currency and amounts provided are in foreign currency. This is calculated by Fiken.
          example: 4500
        vatInNok:
          type: integer
          format: int64
          description: VAT amount of invoice line in cents in NOK if currency and amounts provided are in foreign currency. This is calculated by Fiken.
          example: 500
        grossInNok:
          type: integer
          format: int64
          description: Gross amount of invoice line in cents in NOK if currency and amounts provided are in foreign currency. This is calculated by Fiken.
          example: 5000
        vatInPercent:
          type: number
          description: Percentage value of VAT charged on invoice line. Should be a value between 0 and 100. Can be decimal values such as 25.5
          example: 25
        unitPrice:
          type: integer
          format: int64
          description: Net price per unit in invoice currency (in cents).
          example: 4550
        quantity:
          type: number
          description: Number of units to be invoiced.
          example: 5
        discount:
          type: number
          example: 25
          description: If field is set, all amounts must be given before the discount is applied. The API will calculate the new totals. Discount value should be a value between 0 and 100.
        productId:
          type: integer
          format: int64
          example: 2888156
          description: Product Id of product associated with invoice line.
        productName:
          type: string
          description: Name of product to be printed on invoice line.
          example: 'Gardening Gloves VI2'
        description:
          type: string
          maxLength: 200
          description: Description of the invoiced product or service.
          example: 'Goatskin, with extra-long suede cuffs'
        comment:
          type: string
          maxLength: 200
          description: Additional information to be printed on invoice.
          example: 'One size fits all'
        incomeAccount:
          type: string
          description: Field is similar to vatType, it defaults to the product's income account. Either the line or the product needs to have an income account set.
          example: '3000'
    invoiceRequest:
      type: object
      required:
        - issueDate
        - dueDate
        - lines
        - bankAccountCode
        - cash
        - customerId
      properties:
        uuid:
          type: string
          example: '123e4567-e89b-12d3-a456-426655440000'
          description: UUID are represented as 32 hexadecimal (base-16) digits, displayed in 5 groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters. If not provided, API will generate a UUID.
        issueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Date that the invoice was issued, format yyyy-mm-dd
        dueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Due date of invoice, format yyyy-mm-dd
        lines:
          type: array
          items:
            $ref: '#/components/schemas/invoiceLineRequest'
          minItems: 1
        ourReference:
          type: string
        yourReference:
          type: string
          description: Your reference for invoice, free string format
        orderReference:
          type: string
          description: Reference if sending via EHF.
        customerId:
          type: integer
          format: int64
          example: 2888156
          description: customerId = contactId where customer = true
        contactPersonId:
          type: integer
          format: int64
          example: 8588156
          description: Id of the contact person. Must be associated with the provided customer.
        bankAccountCode:
          type: string
          example: '1920:10002'
          description: Bank account code associated with invoice, format 1920:XXXXX
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          example: 'NOK'
          description: ISO 4217 currency code. Defaults to "NOK" if unspecified.
        invoiceText:
          type: string
          maxLength: 500
          example: 'Invoice for services rendered during the Oslo Knitting Festival.'
          description: If not present, and standard text is registered, standard text is printed.
        cash:
          type: boolean
          example: false
          description: Payment taken in cash (True) or not (False).
        paymentAccount:
          type: string
          example: '1920:10001'
          description: For Cash Invoices only. For instance "1920:10001".
        projectId:
          type: integer
          format: int64
          example: 15124866
          description: Optional - Associated project for the invoice to be created.
    invoiceResult:
      type: object
      properties:
        invoiceId:
          type: integer
          format: int64
          readOnly: true
          example: 2888156
          description: Invoice Id
        createdDate:
          type: string
          format: date
          example: '2023-04-03'
          readOnly: true
          description: Date that the invoice was created in Fiken, format yyyy-mm-dd.
        lastModifiedDate:
          type: string
          format: date
          example: '2018-04-03'
          readOnly: true
          description: Date that invoices was last modified in Fiken, format yyyy-mm-dd.
        invoiceNumber:
          type: integer
          format: int64
          example: 10001
          description: Unique invoice number generated by us.
        kid:
          type: string
          example: '5855454756'
          description: Norwegian KID number. Number from 2 to 25 digits long.
        issueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Issue date of the invoice, format yyyy-mm-dd
        dueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Due date of the invoice, format yyyy-mm-dd
        originalDueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Original due date of the invoice if the due date has been changed, format yyyy-mm-dd
        net:
          type: integer
          format: int64
          example: 25000
          description: Net amount (in invoice currency) in cents.
        vat:
          type: integer
          format: int64
          example: 5000
          description: VAT amount (in invoice currency) in cents.
        gross:
          type: integer
          format: int64
          example: 30000
          description: Gross amount (= net+VAT) (in invoice currency) in cents.
        netInNok:
          type: integer
          format: int64
          example: 25000
          description: Net amount in NOK (in cents)
        vatInNok:
          type: integer
          format: int64
          example: 5000
          description: VAT amount in NOK (in cents)
        grossInNok:
          type: integer
          format: int64
          example: 30000
          description: Gross amount in NOK (in cents)
        cash:
          type: boolean
          example: true
          description: Purchase associated with Invoice is a cash purchase.
        invoiceText:
          type: string
          description: Comment/description printed above the invoice lines
        yourReference:
          type: string
        ourReference:
          type: string
        orderReference:
          type: string
        invoiceDraftUuid:
          type: string
          example: '123e4567-e89b-12d3-a456-426655440000'
          description: The UUID of invoice draft used to create the invoice.
        address:
          $ref: '#/components/schemas/address'
        lines:
          type: array
          items:
            $ref: '#/components/schemas/invoiceLineResult'
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          default: 'NOK'
          description: ISO 4217 currency code, default value is NOK
        bankAccountNumber:
          type: string
          example: '11112233334'
        sentManually:
          type: boolean
          example: false
          description: If the invoice was not sent using Fiken this can be set to "true"
        invoicePdf:
          $ref: '#/components/schemas/attachment'
        associatedCreditNotes:
          type: array
          items:
            type: integer
            format: int64
          description: Associated credit note Id(s)
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/attachment'
        customer:
          $ref: '#/components/schemas/contact'
        sale:
          $ref: '#/components/schemas/saleResult'
        project:
          $ref: '#/components/schemas/projectResult'
        dispatches:
          type: array
          items:
            $ref: '#/components/schemas/dispatchResult'
    dispatchResult:
      type: object
      properties:
        date:
          type: string
          format: date
          readOnly: true
          example: '2024-04-03'
          description: Date that invoice was sent from Fiken, format yyyy-mm-dd
        dispatchType:
          type: string
          enum: [ email, sms, ehf, letter, vipps, efaktura, unknown ]
          description: The type of disptach. Unknown is returned when an invoice was manually sent and Fiken doesn't know the dispatch method.
          example: 'email'
          readOnly: true
    journalEntryLine:
      type: object
      required:
        - amount
      properties:
        amount:
          type: integer
          format: int64
          example: 310000
          description: |
            This will be the net amount (excluding VAT) for debitAccount lines and gross amount 
            (including VAT) for creditAccount lines. The reason for this difference is due to the 
            way Fiken calculates VAT based on the debitVatCode and creditVatCode.
        account:
          type: string
          readOnly: true
          example: '2400:20079'
        vatCode:
          type: string
          readOnly: true
          example: '1'
        debitAccount:
          type: string
          writeOnly: true
        debitVatCode:
          type: integer
          format: int64
          writeOnly: true
        creditAccount:
          type: string
          writeOnly: true
        creditVatCode:
          type: integer
          format: int64
          writeOnly: true
        projectId:
          type: array
          items:
            type: integer
            format: int64
          readOnly: true
        lastModifiedDate:
          type: string
          format: date
          example: '2018-04-03'
          readOnly: true
          description: Date that journal entry line was last modified in Fiken, format yyyy-mm-dd.
    journalEntry:
      type: object
      required:
        - description
        - date
        - lines
      properties:
        journalEntryId:
          type: integer
          format: int64
          readOnly: true
        createdDate:
          type: string
          format: date
          readOnly: true
          example: '2018-04-03'
          description: Date that journal entry was created in Fiken, format yyyy-mm-dd
        lastModifiedDate:
          type: string
          format: date
          example: '2018-04-03'
          readOnly: true
          description: Date that journal entry was last modified in Fiken, format yyyy-mm-dd.
        transactionId:
          type: integer
          format: int64
          readOnly: true
        offsetTransactionId:
          type: integer
          format: int64
          readOnly: true
          description: If a journal entry has been cancelled this provides the id of the balancing transaction
        journalEntryNumber:
          type: integer
          format: int32
          example: 18
          readOnly: true
        description:
          type: string
          maxLength: 200
          example: Purchase, Schweigaards Gate 34 AS (invoice nr 26083)
        date:
          type: string
          format: date
          example: '2018-04-03'
        lines:
          type: array
          items:
            $ref: '#/components/schemas/journalEntryLine'
        attachments:
          type: array
          readOnly: true
          items:
            $ref: '#/components/schemas/attachment'
    offer:
      type: object
      properties:
        offerId:
          type: integer
          format: int64
          readOnly: true
          example: 2888156
          description: offer ID
        offerDraftUuid:
          type: string
          example: '123e4567-e89b-12d3-a456-426655440000'
          readOnly: true
          description: UUID are represented as 32 hexadecimal (base-16) digits, displayed in 5 groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters.
        date:
          type: string
          format: date
          example: '2018-04-03'
          description: Date for offer
        offerNumber:
          type: integer
          format: int32
          example: 10001
          description: Unique offer number generated by us.
        net:
          type: integer
          format: int64
          example: 25000
          description: Net amount (in invoice currency) in cents.
        vat:
          type: integer
          format: int64
          example: 5000
          description: VAT amount (in invoice currency) in cents.
        gross:
          type: integer
          format: int64
          example: 30000
          description: Gross amount (= net+VAT) (in invoice currency) in cents.
        comment:
          type: string
          description: Comment/description
        yourReference:
          type: string
        ourReference:
          type: string
        orderReference:
          type: string
          description: Reference if sending invoice via EHF.
        discount:
          type: number
          example: 2500
          description: The discount amount in the specified currency.
        address:
          $ref: '#/components/schemas/address'
        lines:
          type: array
          items:
            $ref: '#/components/schemas/invoiceLineResult'
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          default: 'NOK'
          description: ISO 4217 currency code, default value is NOK
        contactId:
          format: int64
          example: 9688154
          description: Contact associated with offer.
        contactPersonId:
          format: int64
          example: 9688154
          description: Contact person associated with offer. Must belong to the provided contact.
        projectId:
          format: int64
          example: 2815556
        archived:
          type: boolean
          default: false
          description: If order confirmation has been archived or not.
          example: false
    orderConfirmation:
      type: object
      properties:
        confirmationId:
          type: integer
          format: int64
          readOnly: true
          example: 2888156
          description: offer ID
        confirmationDraftUuid:
          type: string
          example: '123e4567-e89b-12d3-a456-426655440000'
          readOnly: true
          description: UUID are represented as 32 hexadecimal (base-16) digits, displayed in 5 groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters.
        date:
          type: string
          format: date
          example: '2018-04-03'
          description: Date for offer
        confirmationNumber:
          type: integer
          format: int32
          example: 10001
          description: Unique offer number generated by us.
        net:
          type: integer
          format: int64
          example: 25000
          description: Net amount (in invoice currency) in cents.
        vat:
          type: integer
          format: int64
          example: 5000
          description: VAT amount (in invoice currency) in cents.
        gross:
          type: integer
          format: int64
          example: 30000
          description: Gross amount (= net+VAT) (in invoice currency) in cents.
        comment:
          type: string
          description: Comment/description
        yourReference:
          type: string
        ourReference:
          type: string
        orderReference:
          type: string
          description: Reference if sending invoice via EHF.
        discount:
          type: number
          example: 2500
          description: The discount amount in the specified currency.
        address:
          $ref: '#/components/schemas/address'
        lines:
          type: array
          items:
            $ref: '#/components/schemas/invoiceLineResult'
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          default: 'NOK'
          description: ISO 4217 currency code, default value is NOK
        contactId:
          format: int64
          example: 9688154
          description: Contact associated with offer.
        contactPersonId:
          format: int64
          example: 9688154
          description: Contact person associated with the order confirmation. Must belong to given contact.
        projectId:
          format: int64
          example: 2815556
        createdInvoice:
          format: int64
          example: 2815556
          readOnly: true
          description: If the order confirmation was used to create an invoice, the id of the associated invoice. Otherwise null is returned.
        archived:
          type: boolean
          default: false
          description: If order confirmation has been archived or not.
          example: false
        internalComment:
          type: string
          description: Comment that is not shown on the order confirmation, but kept for internal use only
    orderLine:
      type: object
      required:
        - vatType
      properties:
        description:
          type: string
          maxLength: 200
          description: Description of the product or service.
        netPrice:
          type: integer
          format: int64
          description: Net amount of order line in cents. Either netPrice or netPriceInCurrency must be provided.
          example: 4500
        vat:
          type: integer
          format: int64
          description: VAT amount of order line in cents.
          example: 500
        account:
          type: string
          example: 1500
          description: Expense account (kostnadskonto) associated with payment.
        vatType:
          type: string
          description: |
            Vat Types for SALES: [NONE, HIGH, MEDIUM, RAW_FISH, LOW, EXEMPT_IMPORT_EXPORT, EXEMPT, OUTSIDE, EXEMPT_REVERSE]
            Vat Types for PURCHASES: [NONE, HIGH, MEDIUM, RAW_FISH, LOW, HIGH_DIRECT, HIGH_BASIS, MEDIUM_DIRECT, MEDIUM_BASIS, NONE_IMPORT_BASIS,
            HIGH_FOREIGN_SERVICE_DEDUCTIBLE, HIGH_FOREIGN_SERVICE_NONDEDUCTIBLE, LOW_FOREIGN_SERVICE_DEDUCTIBLE,
            LOW_FOREIGN_SERVICE_NONDEDUCTIBLE, HIGH_PURCHASE_OF_EMISSIONSTRADING_OR_GOLD_DEDUCTIBLE, HIGH_PURCHASE_OF_EMISSIONSTRADING_OR_GOLD_NONDEDUCTIBLE]
        netPriceInCurrency:
          type: integer
          format: int64
          example: 4500
          description: Net amount in currency (in cents)
        vatInCurrency:
          type: integer
          format: int64
          example: 500
          description: VAT amount in currency (in cents)
        projectId:
          type: integer
          format: int64
          example: 2815556
          writeOnly: true
          description: If a purchase is split over several projects, project/line can be specified. This field is only to be used for purchases.
    partialCreditNoteRequest:
      type: object
      required:
        - issueDate
        - lines
      properties:
        ourReference:
          type: string
          description: Optional
        yourReference:
          type: string
          description: Optional - Your reference for invoice, free string format.
        orderReference:
          type: string
          description: Reference if sending via EHF.
        project:
          type: integer
          format: int64
          description: Optional - Project associated with the credit note.
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          example: 'NOK'
          description: ISO 4217 currency code
        issueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Date that the credit note is issued, format yyyy-mm-dd
        invoiceId:
          type: integer
          format: int64
          example: 2888156
          description: Optional - Id of invoice that the credit note is associated with.
        contactId:
          type: integer
          format: int64
          example: 3588152
          description: Id of contact that the credit note is associated with.
        contactPersonId:
          type: integer
          format: int64
          example: 3588152
          description: Id of contact person that the credit note is associated with (Credit person must belong to the provided contact).
        creditNoteText:
          type: string
          maxLength: 500
          example: 'Invoice for services rendered during the Oslo Knitting Festival.'
        lines:
          type: array
          items:
            $ref: '#/components/schemas/creditNoteLineResult'
    payment:
      type: object
      description: Returns a payment object with additional fields currrencyAmount, currency, and fee if it is a foreign currency payment
      required:
        - date
        - account
        - amount
      properties:
        paymentId:
          type: integer
          format: int64
          example: 2888156
          description: Id of given payment.
          readOnly: true
        date:
          type: string
          format: date
          example: '2018-04-03'
          description: Payment date, format yyyy-mm-dd
        account:
          type: string
          example: '1920:10001'
          description: Account associated with payment.
        amount:
          type: integer
          format: int64
          example: 34000
          description: Amount paid in the specified currency. If no currency is provided then currency defaults to "NOK". Formatted in cents (34000 = 340.00)
        amountInNok:
          type: integer
          format: int64
          example: 500000
          readOnly: true
          description: Attribute of a foreign payment only. Is required if amount is provided in currency other than NOK and should be the actual amount that was received in the bank account. Formatted in cents (500000 = 5000.00)
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          example: 'NOK'
          description: Only specify the currency if other than "NOK", otherwise default currency is "NOK". ISO 4217 currency code
        fee:
          type: integer
          format: int64
          description: Any fees additional to the amount paid in the specified currency. This is always a "NOK" amount even if the sale currency is a different currency.
    product:
      type: object
      required:
        - name
        - incomeAccount
        - vatType
        - active
      properties:
        productId:
          type: integer
          format: int64
          readOnly: true
          example: 2888156
          description: Product Id.
        createdDate:
          type: string
          format: date
          readOnly: true
          example: '2018-04-03'
          description: Date that product was created in Fiken, format yyyy-mm-dd
        lastModifiedDate:
          type: string
          format: date
          example: '2018-04-03'
          readOnly: true
          description: Date that product was last modified in Fiken, format yyyy-mm-dd.
        name:
          type: string
          example: 'Spade'
          description: Product name.
        unitPrice:
          type: integer
          format: int64
          example: 300000
          description: The net unit price in cents.
        incomeAccount:
          type: string
          example: '3000'
          description: The accounting account that will receive the payment.
        vatType:
          type: string
          example: 'HIGH'
          description: One of {"HIGH", "MEDIUM", "LOW", "EXEMPT", "EXEMPT_IMPORT_EXPORT", "EXEMPT_REVERSE", "OUTSIDE", "NONE"}. "HIGH" is the most common.
        active:
          type: boolean
          default: true
          description: If product is in use (True) or not (False).
          example: true
        productNumber:
          type: string
          example: '125-1'
        stock:
          type: number
          format: float
          example: 5
          description: Number of products available in stock. If not provided, stock value is set to null. Decimal values are accepted. For example 5.5
        note:
          type: string
          maxLength: 200
          description: Optional field for additional information.
    productSalesLineInfo:
      type: object
      properties:
        count:
          type: integer
          format: int64
          example: 250
        sales:
          type: integer
          format: int64
          example: 45
        netAmount:
          type: integer
          format: int64
          example: 5000
          description: Net amount excluding VAT in cents (5000 = 50.00)
        vatAmount:
          type: integer
          format: int64
          example: 500
          description: VAT amount for sale in cents (500 = 5.00)
        grossAmount:
          type: integer
          format: int64
          example: 5500
          description: Gross amount of sale (net + VAT) in cents (5500 = 55.00)
    productSalesReportRequest:
      type: object
      required:
        - to
        - from
      properties:
        from:
          type: string
          format: date
          example: '2018-04-03'
          description: Start date range for the report, inclusive, format yyyy-mm-dd
        to:
          type: string
          format: date
          example: '2018-04-03'
          description: End date range for the report, inclusive, format yyyy-mm-dd
    productSalesReportResult:
      type: object
      properties:
        product:
          $ref: '#/components/schemas/product'
        sold:
          $ref: '#/components/schemas/productSalesLineInfo'
        credited:
          $ref: '#/components/schemas/productSalesLineInfo'
        sum:
          $ref: '#/components/schemas/productSalesLineInfo'
    projectRequest:
      type: object
      required:
        - startDate
        - number
        - name
      properties:
        number:
          type: string
        name:
          type: string
        description:
          type: string
        startDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Start date for the project, inclusive, format yyyy-mm-dd
        endDate:
          type: string
          format: date
          example: '2018-04-03'
          description: End date for the project, inclusive, format yyyy-mm-dd
        contactId:
          type: integer
          format: int64
          example: 73408306
        completed:
          type: boolean
          description: Whether the project is completed or not.
    projectResult:
      type: object
      properties:
        projectId:
          type: integer
          format: int64
          example: 73408306
        number:
          type: string
          readOnly: true
        name:
          type: string
        description:
          type: string
        startDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Start date for the project, inclusive, format yyyy-mm-dd
        endDate:
          type: string
          format: date
          example: '2018-04-03'
          description: End date for the project, inclusive, format yyyy-mm-dd
        contact:
          $ref: '#/components/schemas/contact'
        completed:
          type: boolean
          description: Whether the project is completed or not.
    purchaseRequest:
      type: object
      required:
        - date
        - kind
        - paid
        - lines
        - currency
      properties:
        transactionId:
          type: integer
          format: int64
          example: 3458156
          readOnly: true
        identifier:
          type: string
          description: Invoice/sale number or similar.
        date:
          type: string
          format: date
          example: '2018-04-03'
          description: Payment date, format yyyy-mm-dd
        dueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Due date of the invoice, format yyyy-mm-dd
        kind:
          type: string
          enum: [cash_purchase, supplier]
          example: 'cash_purchase'
          description: Purchased with cash or through a supplier.
        lines:
          type: array
          items:
            $ref: '#/components/schemas/orderLine'
        supplierId:
          type: integer
          format: int64
          writeOnly: true
          example: 2888156
          description: Id of supplier if not a cash purchase.
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          example: 'NOK'
          description: ISO 4217 currency code
        paymentAccount:
          type: string
          writeOnly: true
          example: '1920:10001'
        paymentDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Payment date, format yyyy-mm-dd
          writeOnly: true
        kid:
          type: string
          writeOnly: true
          example: '5855454756'
          description: Norwegian KID number. Number from 2 to 25 digits long.
        projectId:
          type: integer
          format: int64
          example: 2888156
          description: Id of given project.
    purchaseResult:
      type: object
      required:
        - date
        - kind
        - paid
        - lines
        - currency
      properties:
        purchaseId:
          type: integer
          format: int64
          example: 2888156
          description: Id of given purchase.
          readOnly: true
        transactionId:
          type: integer
          format: int64
          example: 3458156
          readOnly: true
        identifier:
          type: string
          description: Invoice/sale number or similar.
        date:
          type: string
          format: date
          example: '2018-04-03'
          description: Payment date, format yyyy-mm-dd
        dueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Due date of the invoice, format yyyy-mm-dd
        kind:
          type: string
          enum: [cash_purchase, supplier]
          example: 'cash_purchase'
          description: Purchased with cash or through a supplier.
        paid:
          type: boolean
          example: true
        lines:
          type: array
          items:
            $ref: '#/components/schemas/orderLine'
        supplier:
          $ref: '#/components/schemas/contact'
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          example: 'NOK'
          description: ISO 4217 currency code
        paymentAccount:
          type: string
          writeOnly: true
          example: '1920:10001'
        paymentDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Payment date, format yyyy-mm-dd
          writeOnly: true
        payments:
          type: array
          items:
            $ref: '#/components/schemas/payment'
        purchaseAttachments:
          type: array
          items:
            $ref: '#/components/schemas/attachment'
        kid:
          type: string
          writeOnly: true
          example: '5855454756'
          description: Norwegian KID number. Number from 2 to 25 digits long.
        project:
          type: array
          items:
            $ref: '#/components/schemas/projectResult'
        deleted:
          type: boolean
          description: Whether the purchase has been deleted or not
    saleRequest:
      type: object
      required:
        - date
        - kind
        - paid
        - lines
        - currency
      properties:
        saleNumber:
          type: string
          example: 'XK455L'
          description: Identifier for sale.
        date:
          type: string
          format: date
          example: '2018-04-03'
          description: Date of the invoice, format yyyy-mm-dd
        kind:
          type: string
          enum: [cash_sale, invoice, external_invoice]
          example: 'external_invoice'
          description: Either cash_sale, invoice, or external_invoice.
        totalPaid:
          type: integer
          format: int64
          description: Total amount paid in NOK
          example: 524500
        totalPaidInCurrency:
          type: integer
          format: int64
          example: 634550
          description: Total amount paid in other currency.
        lines:
          type: array
          items:
            $ref: '#/components/schemas/orderLine'
        customerId:
          type: integer
          format: int64
          description: customerId = contactId where customer = true
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          example: 'NOK'
          description: ISO 4217 currency code
        dueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Due date of the invoice, format yyyy-mm-dd
        kid:
          type: string
          example: '5855454756'
          description: Norwegian KID number. Number from 2 to 25 digits long.
        paymentAccount:
          type: string
          example: '1920:10001'
        paymentDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Payment date of the invoice, format yyyy-mm-dd
        paymentFee:
          type: integer
          format: int64
          example: 634550
          description: Fee associated with payment of sale.
        projectId:
          type: integer
          format: int64
          example: 2888156
          description: Id of given project.
    saleResult:
      type: object
      properties:
        saleId:
          type: integer
          format: int64
          readOnly: true
          example: 2888156
          description: Sale Id
        lastModifiedDate:
          type: string
          format: date
          example: '2018-04-03'
          readOnly: true
          description: Date that the sale was last modified in Fiken, format yyyy-mm-dd.
        transactionId:
          type: integer
          format: int64
          example: 3458156
          readOnly: true
        saleNumber:
          type: string
          example: 'XK455L'
          description: Identifier for sale.
        date:
          type: string
          format: date
          example: '2018-04-03'
          description: Due date of the invoice, format yyyy-mm-dd
        kind:
          type: string
          enum: [cash_sale, invoice, external_invoice]
          example: 'external_invoice'
          description: Either cash_sale, invoice, or external_invoice.
        netAmount:
          type: integer
          format: int64
          description: Total net amount of the sale to be paid.
          example: 4500
        vatAmount:
          type: integer
          format: int64
          description: VAT amount on sale.
          example: 5400
        settled:
          type: boolean
          example: true
          description: If the sale as been marked as settled (True) or not (False).
        settledDate:
          type: string
          format: date
          example: '2023-04-03'
          description: Date the the sale was marked as settled, format yyyy-mm-dd
        writeOff:
          type: boolean
          example: false
          description: If a loss has been registered for this sale (tapsføring av salg).
        totalPaid:
          type: integer
          format: int64
          description: Total amount paid in NOK
          example: 524500
          readOnly: true
        totalPaidInCurrency:
          type: integer
          format: int64
          example: 634550
          description: Total amount paid in other currency.
          readOnly: true
        outstandingBalance:
          type: integer
          format: int64
          example: 145
        lines:
          type: array
          items:
            $ref: '#/components/schemas/orderLine'
        customer:
          $ref: '#/components/schemas/contact'
        currency:
          type: string
          pattern: '^[A-Z]{3}$'
          example: 'NOK'
          description: ISO 4217 currency code
        dueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Due date of the invoice, format yyyy-mm-dd
        kid:
          type: string
          example: '5855454756'
          description: Norwegian KID number. Number from 2 to 25 digits long.
        paymentAccount:
          type: string
          writeOnly: true
          example: '1920:10001'
        salePayments:
          type: array
          items:
            $ref: '#/components/schemas/payment'
        saleAttachments:
          type: array
          items:
            $ref: '#/components/schemas/attachment'
        paymentDate:
          type: string
          format: date
          readOnly: true
          example: '2018-04-03'
          description: Payment date of the invoice, format yyyy-mm-dd
        project:
          $ref: '#/components/schemas/projectResult'
        notes:
          type: array
          readOnly: true
          items:
            $ref: '#/components/schemas/note'
        deleted:
          type: boolean
          description: Whether the sale has been deleted or not
    sendInvoiceishRequest:
      type: object
      required:
        - method
        - includeDocumentAttachments
      properties:
        method:
          type: array
          items:
            type: string
            enum:
              - email
              - ehf
              - efaktura
              - sms
              - letter
              - auto
          description: |
            The method of sending. Has to be auto, email, ehf, efaktura, sms or letter.
            If several methods are provided they should be in prioritized order as Fiken will only send the invoice to 
            the first successful available method. Method "auto" tries available methods for given customer based on
            the information registered for the customer. The order of priority is EHF, eFaktura, Sms, and email.
            Method "letter" means physical letter, printed and sent by our postal service partner (extra charge per
            letter, available for recipient addresses in Norway only). The option "includeDocumentAttachments" is
            not supported by method "letter", attachments are not included even if this option is set.
          example: ['sms', 'email']
        includeDocumentAttachments:
          type: boolean
          default: true
          description: Whether the document's attachment should be included when sending (True) or not (False).
        recipientName:
          type: string
          example: 'Bjørn Bohler'
        recipientEmail:
          type: string
          example: 'bjorn.bohler@gmail.com'
        message:
          type: string
          example: 'Due upon receipt'
          description: Additional message to send with document.
        emailSendOption:
          type: string
          enum: [document_link, attachment, auto]
          default: 'auto'
          example: document_link
          description: document_link, attachment or auto. Defaults to auto which uses customer/company settings.
        mergeInvoiceAndAttachments:
          type: boolean
          default: false
          description: If sending with emailSendOption = attachment, this merges them into a single document if true.
        organizationNumber:
          type: string
          example: '913312465'
          description: Brreg organization number. Defaults to the customers organization number if not provided.
        mobileNumber:
          type: string
          example: '85262741'
          description: Defaults to the customers phone number. Format should include the country code. If a Norwegian phone number, the country code is not necessary.
    sendCreditNoteRequest:
      allOf:
        - $ref: '#/components/schemas/sendInvoiceishRequest'
        - type: object
          required:
            - creditNoteId
          properties:
            creditNoteId:
              type: integer
              format: int64
              example: 2888156
              description: Id of credit note to send.
    sendInvoiceRequest:
      allOf:
        - $ref: '#/components/schemas/sendInvoiceishRequest'
        - type: object
          required:
            - invoiceId
          properties:
            invoiceId:
              type: integer
              format: int64
              example: 2888156
              description: Id of invoice to send.
    transaction:
      type: object
      description: Transaction result upon creation of a General Journal Entry
      properties:
        transactionId:
          type: integer
          format: int64
          example: 734083065
          readOnly: true
        createdDate:
          type: string
          format: date
          readOnly: true
          example: '2018-04-03'
          description: Date that product was created in Fiken, format yyyy-mm-dd
        lastModifiedDate:
          type: string
          format: date
          example: '2018-04-03'
          readOnly: true
          description: Date that product was last modified in Fiken, format yyyy-mm-dd.
        description:
          type: string
        type:
          type: string
          example: 'General Journal Entry'
        entries:
          type: array
          items:
            $ref: '#/components/schemas/journalEntry'
    updateInvoiceRequest:
      type: object
      properties:
        newDueDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Due date of invoice, format yyyy-mm-dd
        sentManually:
          type: boolean
          example: true
          description: If the invoice was not sent using Fiken this can be set to "true"
    updateProjectRequest:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
        startDate:
          type: string
          format: date
          example: '2018-04-03'
          description: Start date for the project, inclusive, format yyyy-mm-dd
        endDate:
          type: string
          format: date
          example: '2018-04-03'
          description: End date for the project, inclusive, format yyyy-mm-dd
        contactId:
          type: integer
          format: int64
          example: 73408306
        completed:
          type: boolean
          description: Whether the project is completed or not.
    userinfo:
      type: object
      properties:
        name:
          type: string
          example: 'Test Testesen'
          description: Name of the user.
        email:
          type: string
          example: 'test@fiken.no'
          description: Users email address.

  parameters:
    draftId:
      name: draftId
      in: path
      description: |
        The draftId (primary key of the returned object) is returned in the GET all drafts call.
      required: true
      schema:
        type: integer
        format: int64
    invoiceId:
      name: invoiceId
      in: path
      description: |
        The invoiceId (primary key of the returned object) is returned in the GET all
        invoices call; not to be confused with invoiceNumber
      required: true
      schema:
        type: integer
        format: int64
    purchaseId:
      name: purchaseId
      in: path
      required: true
      schema:
        type: integer
        format: int64
    projectId:
      name: projectId
      in: path
      required: true
      schema:
        type: integer
        format: int64
    companySlug:
      name: companySlug
      in: path
      required: true
      description: Slug of company to retrieve
      schema:
        type: string
    journalEntryId:
      name: journalEntryId
      in: path
      required: true
      schema:
        type: integer
        format: int64
    saleId:
      name: saleId
      in: path
      required: true
      schema:
        type: integer
        format: int64
    paymentId:
      name: paymentId
      in: path
      required: true
      schema:
        type: integer
        format: int64
    accountCode:
      name: accountCode
      in: query
      required: false
      description: Code number of the bookkeeping account to retrieve
      schema:
        type: string
    page:
      in: query
      name: page
      description: |
        Returns the number of the page to return. Valid page values are integers from 0 to the total number of pages.
        Default value is 0.
      schema:
        type: integer
        default: 0
        minimum: 0
    pageSize:
      in: query
      name: pageSize
      description: |
        Defines the number of entries to return on each page. Maximum number of results that can be returned at one time are 100.
        Default value is 25.
      schema:
        type: integer
        default: 25
        minimum: 1
        maximum: 100
    field:
      in: query
      name: field
      schema:
        type: string
    collection:
      in: query
      name: collection
      schema:
        type: string
    query:
      in: query
      name: query
      schema:
        type: string
    fromAccount:
      in: query
      name: fromAccount
      schema:
        type: integer
        format: int64
      example: 1000
      description: Filter parameter specifying which account numbers to return. Specify using the from and to parameters (excluding subaccount).
    toAccount:
      in: query
      name: toAccount
      schema:
        type: integer
        format: int64
      example: 2000
      description: Filter parameter specifying which account numbers to return. Specify using the from and to parameters (excluding subaccount).
    date:
      in: query
      name: date
      schema:
        type: string
        format: date
      description: |
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    createdDate:
      in: query
      name: createdDate
      schema:
        type: string
        format: date
      description: |
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    createdDateLe:
      in: query
      name: createdDateLe
      schema:
        type: string
        format: date
      description: |
        Returns results that were created before or on the date provided as a parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    createdDateLt:
      in: query
      name: createdDateLt
      schema:
        type: string
        format: date
      description: |
        Returns results that were created strictly before the date provided as a parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    createdDateGe:
      in: query
      name: createdDateGe
      schema:
        type: string
        format: date
      description: |
        Returns results that were created after or on the date provided as a parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    createdDateGt:
      in: query
      name: createdDateGt
      schema:
        type: string
        format: date
      description: |
        Returns results that were created strictly after the date provided as a parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    issueDate:
      in: query
      name: issueDate
      schema:
        type: string
        format: date
      description: |
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    dateLe:
      in: query
      name: dateLe
      schema:
        type: string
        format: date
      description: |
        Filter based on date less than or equal to parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    issueDateLe:
      in: query
      name: issueDateLe
      schema:
        type: string
        format: date
      description: |
        Filter based on date less than or equal to parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    dateLt:
      in: query
      name: dateLt
      schema:
        type: string
        format: date
      description: |
        Filter based on date strictly less than parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    issueDateLt:
      in: query
      name: issueDateLt
      schema:
        type: string
        format: date
      description: |
        Filter based on date strictly less than parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    dateGe:
      in: query
      name: dateGe
      schema:
        type: string
        format: date
      description: |
        Filter based on date greater than or equal to parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    issueDateGe:
      in: query
      name: issueDateGe
      schema:
        type: string
        format: date
      description: |
        Filter based on date greater than or equal to parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    dateGt:
      in: query
      name: dateGt
      schema:
        type: string
        format: date
      description: |
        Filter based on date strictly greater than parameter value
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    issueDateGt:
      in: query
      name: issueDateGt
      schema:
        type: string
        format: date
      description: |
        Filter based on date strictly greater than parameter value
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    lastModified:
      in: query
      name: lastModified
      schema:
        type: string
        format: date
      description: |
        Filter based on date of last modification. Returns results that were last modified on the date provided as a parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    lastModifiedLe:
      in: query
      name: lastModifiedLe
      schema:
        type: string
        format: date
      description: |
        Returns results that have been last modified before or on the date provided as a parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    lastModifiedLt:
      in: query
      name: lastModifiedLt
      schema:
        type: string
        format: date
      description: |
        Returns results that have been last modified strictly before the date provided as a parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    lastModifiedGe:
      in: query
      name: lastModifiedGe
      schema:
        type: string
        format: date
      description: |
        Returns results that have been last modified after or on the date provided as a parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    lastModifiedGt:
      in: query
      name: lastModifiedGt
      schema:
        type: string
        format: date
      description: |
        Returns results that have been last modified strictly after the date provided as a parameter value.
        Dates are represented as strings formatted as YYYY-MM-DD.
        Example: January 1st, 1970: "1970-01-01"
    inboxDocumentId:
      name: inboxDocumentId
      in: path
      required: true
      schema:
        type: integer
        format: int64


security:
  - fiken_api_oauth: []
