openapi: "3.0.3"
info:
  title: ABT Contracts CRUD APIs
  version: "1.0"
  description: CRUD APIs for ABT Contract database. These are NOT the functional APIs from Service Engine.
servers:
  - url: https://services.acc.api.htm.nl/abt/abtcontracts/1.0
paths:
  /customers/{customerProfileId}/contracts:
    parameters:
      - in: path
        name: customerProfileId
        schema:
          type: integer
          example: 1337
        required: true
        description: The customerNumber.
    get:
      summary: List all contracts for a certain customer profile.
      description: List all contracts for a certain customer profile.
      tags:
        - Contract
      parameters:
        - in: query
          name: contractStatusId
          schema:
            type: integer
            example: 1
          required: false
          description: Filter on possible contract status. 1 = new, 2 = active, 3 = suspended, 4 = cancelled, 5 = terminated, 6 = pending cancellation, 7 = pending termination.
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Contracts"
              example:
                {
                  "contracts":
                    [
                      {
                        "contractId": "5a3876a1-e9a1-4278-8983-4679a8d583c2",
                        "contractNumber": "D123456",
                        "customerProfileId": 42,
                        "orderId": "eb3d08f7-7feb-4f31-9f5b-daa634e51f48",
                        "orderLineId": "52efbbfc-8c28-4016-9ece-dc3ef9a70bd8",
                        "touchpointId": 2,
                        "contractStatus":
                          { "contractStatusId": 2, "name": "active" },
                        "termDuration": "P0Y1M0D",
                        "billingDay": 15,
                        "highestInvoiceTerm": 1,
                        "created": "2024-08-01 15:01:00.000",
                        "contractVersions":
                          [
                            {
                              "contractVersionId": 1,
                              "termsAndConditions": "https://www.htm.nl/reisproducten/productvoorwaarden/htm-maandkorting/",
                              "productId": 1,
                              "productName": "HTM Maand 20% korting",
                              "taxCode": "V9",
                              "taxPercentage": 9.0,
                              "termAmountInclTax": 400,
                              "start": "2024-08-01 15:01:00.000",
                            },
                          ],
                      },
                      {
                        "contractId": "f07253e6-c364-474c-a342-a10a4a7cf305",
                        "contractNumber": "D123456",
                        "customerProfileId": 42,
                        "orderId": "945d43e6-516e-425b-8847-9aba41289acd",
                        "orderLineId": "42f68042-908f-41f4-9d9b-4cab843ff0e8",
                        "touchpointId": 2,
                        "contractStatus":
                          { "contractStatusId": 1, "name": "new" },
                        "termDuration": "P0Y1M0D",
                        "billingDay": 15,
                        "highestInvoiceTerm": 1,
                        "created": "2024-08-01 15:01:00.000",
                        "contractVersions":
                          [
                            {
                              "contractVersionId": 1,
                              "termsAndConditions": "https://www.htm.nl/reisproducten/productvoorwaarden/htm-maandkorting/",
                              "productId": 1,
                              "productName": "HTM Maand 20% korting",
                              "taxCode": "V9",
                              "taxPercentage": 9.0,
                              "termAmountInclTax": 400,
                              "start": "2024-08-01 15:01:00.000",
                            },
                          ],
                      },
                    ],
                  "href": null,
                }
    post:
      summary: Create a contract for an existing customer profile.
      description: Create a contract for an existing customer profile.
      tags:
        - Contract
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PostContractsRequestBody"
            example:
              {
                "contract":
                  {
                    "orderId": "eb3d08f7-7feb-4f31-9f5b-daa634e51f48",
                    "orderLineId": "52efbbfc-8c28-4016-9ece-dc3ef9a70bd8",
                    "touchpointId": 2,
                    "contractStatusId": 1,
                    "termDuration": "P0Y1M0D",
                    "billingDay": 15,
                    "highestInvoiceTerm": 0,
                    "contractVersions":
                      [
                        {
                          "termsAndConditions": "https://www.htm.nl/reisproducten/productvoorwaarden/htm-maandkorting/",
                          "productId": 1,
                          "productName": "HTM Maand 20% korting",
                          "taxCode": "V9",
                          "taxPercentage": 9.0,
                          "termAmountInclTax": 400,
                          "start": "2024-07-04 15:01:00.000",
                          "end": "",
                        },
                      ],
                    "contractActions":
                      [
                        {
                          "actionTypeId": 1,
                          "user": "subid123456",
                          "details": "Contract created",
                          "correlationId": "976e7a4c-bf24-43d2-b444-55817556e7ee",
                        },
                      ],
                  },
              }
      responses:
        "201":
          description: CREATED
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PostContractsResponseBody"
              example:
                {
                  "contract":
                    {
                      "contractId": "5a3876a1-e9a1-4278-8983-4679a8d583c2",
                      "contractNumber": "123456",
                    },
                }
  /contracts:
    get:
      summary: Get all contracts.
      description: Get all contracts.
      tags:
        - Contract
      parameters:
        - in: query
          name: contractStatusId
          schema:
            type: array
            items:
              type: integer
          explode: false
          required: false
          description: Filter on possible contract status. 1 = new, 2 = active, 3 = suspended, 4 = cancelled, 5 = terminated, 6 = pending cancellation, 7 = pending termination.
        - in: query
          name: billingDay
          schema:
            type: integer
            example: 13
          required: false
          description: Filter on billingDay. In case of weekly termDuration, Sunday = 0, Monday = 1, etc.
        - in: query
          name: termDuration
          schema:
            type: string
            example: P1M
          required: false
          description: Filter on termDuration.
        - in: query
          name: invoiceLimit
          schema:
            type: integer
            example: 2
          required: false
          description: Number of invoices to include in response body (per contract).
        - in: query
          name: pageSize
          schema:
            type: integer
            example: 2
          required: false
          description: Number of contracts to in the response body (per page).
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Contracts"
              example:
                {
                  "contracts":
                    [
                      {
                        "contractId": "5a3876a1-e9a1-4278-8983-4679a8d583c2",
                        "contractNumber": "D123456",
                        "customerProfileId": 42,
                        "orderId": "eb3d08f7-7feb-4f31-9f5b-daa634e51f48",
                        "orderLineId": "52efbbfc-8c28-4016-9ece-dc3ef9a70bd8",
                        "touchpointId": 2,
                        "contractStatus":
                          { "contractStatusId": 2, "name": "active" },
                        "termDuration": "P0Y1M0D",
                        "billingDay": 15,
                        "highestInvoiceTerm": 1,
                        "contractInvoices":
                          [
                            {
                              "contractInvoiceId": "8699d72a-cf4d-4e6b-9e9c-549d837ca51f",
                              "externalReference": "F2024-0001",
                              "term": 1,
                              "invoiceDate": "2024-06-02",
                              "created": "2024-06-02 15:01:00.000",
                              "updated": "2024-06-02 15:01:00.000",
                              "state": "invoice_created",
                              "isCredit": false,
                              "invoiceAccountingStatuses":
                                [
                                  {
                                    "invoiceAccountingStatusId": "32785417-1fb8-42c7-bda1-533f5868809f",
                                    "accountingStatus":
                                      {
                                        "accountingStatusId": 1,
                                        "name": "open",
                                      },
                                    "createdOn": "2024-06-02 15:01:00.000",
                                    "description": null,
                                  },
                                ],
                            },
                            {
                              "contractInvoiceId": "1c345237-4d84-47f0-93c2-7b94338e3355",
                              "externalReference": "F2024-0002",
                              "term": 2,
                              "invoiceDate": "2024-07-02",
                              "created": "2024-07-02 15:01:00.000",
                              "updated": "2024-07-02 15:01:00.000",
                              "state": "invoice_created",
                              "isCredit": false,
                              "invoiceAccountingStatuses":
                                [
                                  {
                                    "invoiceAccountingStatusId": "1e95b854-0094-42a4-9268-c16353fb72a8",
                                    "accountingStatus":
                                      {
                                        "accountingStatusId": 1,
                                        "name": "open",
                                      },
                                    "createdOn": "2024-07-02 15:01:00.000",
                                    "description": null,
                                  },
                                ],
                            },
                          ],
                        "contractVersions":
                          [
                            {
                              "contractVersionId": 1,
                              "termsAndConditions": "https://www.htm.nl/reisproducten/productvoorwaarden/htm-maandkorting/",
                              "productId": 1,
                              "productName": "HTM Maand 20% korting",
                              "taxCode": "V9",
                              "taxPercentage": 9.0,
                              "termAmountInclTax": 400,
                              "start": "2024-07-04 15:01:00.000",
                              "end": "2024-12-31 15:01:00.000",
                            },
                            {
                              "contractVersionId": 2,
                              "termsAndConditions": "https://www.htm.nl/reisproducten/productvoorwaarden/htm-maandkorting/",
                              "productId": 1,
                              "productName": "HTM Maand 20% korting",
                              "taxCode": "V9",
                              "taxPercentage": 9.0,
                              "termAmountInclTax": 400,
                              "start": "2025-01-01 15:01:00.000",
                            },
                          ],
                      },
                      {
                        "contractId": "f07253e6-c364-474c-a342-a10a4a7cf305",
                        "contractNumber": "D123456",
                        "customerProfileId": 42,
                        "orderId": "945d43e6-516e-425b-8847-9aba41289acd",
                        "orderLineId": "42f68042-908f-41f4-9d9b-4cab843ff0e8",
                        "touchpointId": 2,
                        "contractStatus":
                          { "contractStatusId": 1, "name": "new" },
                        "termDuration": "P0Y1M0D",
                        "billingDay": 15,
                        "highestInvoiceTerm": 1,
                        "contractInvoices":
                          [
                            {
                              "contractInvoiceId": "8699d72a-cf4d-4e6b-9e9c-549d837ca51f",
                              "externalReference": "F2024-0003",
                              "term": 1,
                              "invoiceDate": "2024-06-02",
                              "created": "2024-06-02 15:01:00.000",
                              "updated": "2024-06-02 15:01:00.000",
                              "state": "invoice_created",
                              "isCredit": false,
                              "invoiceAccountingStatuses":
                                [
                                  {
                                    "invoiceAccountingStatusId": "32785417-1fb8-42c7-bda1-533f5868809f",
                                    "accountingStatus":
                                      {
                                        "accountingStatusId": 1,
                                        "name": "open",
                                      },
                                    "createdOn": "2024-06-02 15:01:00.000",
                                    "description": null,
                                  },
                                ],
                            },
                            {
                              "contractInvoiceId": "1c345237-4d84-47f0-93c2-7b94338e3355",
                              "externalReference": "F2024-0004",
                              "term": 2,
                              "invoiceDate": "2024-07-02",
                              "created": "2024-07-02 15:01:00.000",
                              "updated": "2024-07-02 15:01:00.000",
                              "state": "invoice_created",
                              "isCredit": false,
                              "invoiceAccountingStatuses":
                                [
                                  {
                                    "invoiceAccountingStatusId": "1e95b854-0094-42a4-9268-c16353fb72a8",
                                    "accountingStatus":
                                      {
                                        "accountingStatusId": 1,
                                        "name": "open",
                                      },
                                    "createdOn": "2024-07-02 15:01:00.000",
                                    "description": null,
                                  },
                                ],
                            },
                          ],
                        "contractVersions":
                          [
                            {
                              "contractVersionId": 1,
                              "termsAndConditions": "https://www.htm.nl/reisproducten/productvoorwaarden/htm-maandkorting/",
                              "productId": 1,
                              "productName": "HTM Maand 20% korting",
                              "taxCode": "V9",
                              "taxPercentage": 9.0,
                              "termAmountInclTax": 400,
                              "start": "2024-07-04 15:01:00.000",
                              "end": "2024-12-31 15:01:00.000",
                            },
                            {
                              "contractVersionId": 2,
                              "termsAndConditions": "https://www.htm.nl/reisproducten/productvoorwaarden/htm-maandkorting/",
                              "productId": 1,
                              "productName": "HTM Maand 20% korting",
                              "taxCode": "V9",
                              "taxPercentage": 9.0,
                              "termAmountInclTax": 400,
                              "start": "2025-01-01 15:01:00.000",
                            },
                          ],
                      },
                    ],
                }
  /contracts/{contractId}:
    parameters:
      - in: path
        name: contractId
        schema:
          type: string
          format: uuid
          example: d1dd439b-6072-4b97-89c9-724268865b93
        required: true
        description: The contractId of the Contract, formatted as UUID.
    get:
      summary: Get contract details of a single contract.
      description: Get contract details of a single contract.
      tags:
        - Contract
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Contract"
              example:
                {
                  "contract":
                    {
                      "contractId": "5a3876a1-e9a1-4278-8983-4679a8d583c2",
                      "contractNumber": "D123456",
                      "customerProfileId": 42,
                      "orderId": "eb3d08f7-7feb-4f31-9f5b-daa634e51f48",
                      "orderLineId": "52efbbfc-8c28-4016-9ece-dc3ef9a70bd8",
                      "touchpointId": 2,
                      "contractStatus":
                        { "contractStatusId": 2, "name": "active" },
                      "termDuration": "P0Y1M0D",
                      "billingDay": 15,
                      "highestInvoiceTerm": 1,
                      "contractVersions":
                        [
                          {
                            "contractVersionId": 1,
                            "termsAndConditions": "https://www.htm.nl/reisproducten/productvoorwaarden/htm-maandkorting/",
                            "productId": 1,
                            "productName": "HTM Maand 20% korting",
                            "taxCode": "V9",
                            "taxPercentage": 9.0,
                            "termAmountInclTax": 400,
                            "start": "2024-07-04 15:01:00.000",
                            "end": "2024-12-31 15:01:00.000",
                          },
                          {
                            "contractVersionId": 2,
                            "termsAndConditions": "https://www.htm.nl/reisproducten/productvoorwaarden/htm-maandkorting/",
                            "productId": 1,
                            "productName": "HTM Maand 20% korting",
                            "taxCode": "V9",
                            "taxPercentage": 9.0,
                            "termAmountInclTax": 400,
                            "start": "2025-01-01 15:01:00.000",
                          },
                        ],
                      "contractActions":
                        [
                          {
                            "contractActionId": "67687851-59dd-4bbc-aa74-0f7abd26c883",
                            "actionType":
                              { "actionTypeId": 1, "name": "create" },
                            "user": "subid123456",
                            "timestamp": "2024-07-02 15:01:00.000",
                            "details": "Contract created",
                            "correlationId": "976e7a4c-bf24-43d2-b444-55817556e7ee",
                          },
                          {
                            "contractActionId": "ea9ad287-9cd3-4e76-bcb9-d71db551cf55",
                            "actionType":
                              { "actionTypeId": 2, "name": "change" },
                            "user": "subid123456",
                            "timestamp": "2024-07-03 15:01:00.000",
                            "details": "Contract changed",
                            "correlationId": "e2462347-6749-4841-b42a-cf8de19ec727",
                          },
                        ],
                      "contractInvoices":
                        [
                          {
                            "contractInvoiceId": "8699d72a-cf4d-4e6b-9e9c-549d837ca51f",
                            "externalReference": "F2024-0001",
                            "term": 1,
                            "invoiceDate": "2024-07-02",
                            "created": "2024-07-02 15:01:00.000",
                            "updated": "2024-07-02 15:01:00.000",
                            "state": "invoice_created",
                            "data": "{json}",
                            "isCredit": false,
                            "invoiceAccountingStatuses":
                              [
                                {
                                  "invoiceAccountingStatusId": "32785417-1fb8-42c7-bda1-533f5868809f",
                                  "accountingStatus":
                                    { "accountingStatusId": 1, "name": "open" },
                                  "createdOn": "2024-06-02 15:01:00.000",
                                  "description": null,
                                },
                              ],
                          },
                        ],
                    },
                }
    patch:
      summary: Update an existing contract.
      description: Update an existing contract.
      tags:
        - Contract
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PatchContractsRequestBody"
            example:
              {
                "contract":
                  {
                    "contractStatusId": 2,
                    "billingDay": 15,
                    "highestInvoiceTerm": 2,
                  },
              }
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PatchContractsResponseBody"
              example:
                {
                  "contract":
                    {
                      "contractId": "5a3876a1-e9a1-4278-8983-4679a8d583c2",
                      "contractNumber": "123456",
                    },
                }
  /contracts/{contractId}/contractversions:
    parameters:
      - in: path
        name: contractId
        schema:
          type: string
          format: uuid
          example: d1dd439b-6072-4b97-89c9-724268865b93
        required: true
        description: The contractId of the Contract, formatted as UUID.
    post:
      summary: Add a version to an existing contract.
      description: Add a version to an existing contract.
      tags:
        - ContractVersion
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PostContractVersionsRequestBody"
            example:
              {
                "contractVersion":
                  {
                    "termsAndConditions": "https://www.htm.nl/reisproducten/productvoorwaarden/htm-maandkorting/",
                    "productId": 1,
                    "productName": "HTM Maand 20% korting",
                    "taxCode": "V9",
                    "taxPercentage": 9.0,
                    "termAmountInclTax": 400,
                    "start": "2024-07-08 15:01:00.000",
                    "end": "",
                  },
              }
      responses:
        "201":
          description: CREATED
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PostContractVersionsResponseBody"
              example:
                {
                  "contractVersion":
                    {
                      "contractId": "5a3876a1-e9a1-4278-8983-4679a8d583c2",
                      "contractVersionId": 2,
                    },
                }
  /contracts/{contractId}/contractversions/{contractVersionId}:
    parameters:
      - in: path
        name: contractId
        schema:
          type: string
          format: uuid
          example: d1dd439b-6072-4b97-89c9-724268865b93
        required: true
        description: The contractId of the Contract, formatted as UUID.
      - in: path
        name: contractVersionId
        schema:
          type: integer
          example: 1
        required: true
        description: The id of the ContractVersion, formatted as UUID.
    patch:
      summary: Add an existing contract version.
      description: Add an existing contract version.
      tags:
        - ContractVersion
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PatchContractVersionsRequestBody"
            example: { "contractVersion": { "end": "2024-07-03 15:01:00.000" } }
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PatchContractVersionsResponseBody"
              example:
                {
                  "contractVersion":
                    {
                      "contractId": "5a3876a1-e9a1-4278-8983-4679a8d583c2",
                      "contractVersionId": 1,
                    },
                }
    delete:
      summary: Delete an existing contract version.
      description: Delete an existing contract version.
      tags:
        - ContractVersion
      responses:
        "200":
          description: OK
  /contracts/{contractId}/contractinvoices:
    parameters:
      - in: path
        name: contractId
        schema:
          type: string
          format: uuid
          example: d1dd439b-6072-4b97-89c9-724268865b93
        required: true
        description: The contractId of the Contract, formatted as UUID.
    post:
      summary: Add an invoice to an existing contract.
      description: Add an invoice to an existing contract.
      tags:
        - ContractInvoice
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PostContractInvoicesRequestBody"
            example:
              {
                "contractInvoice":
                  {
                    "externalReference": "F2024-0001",
                    "term": 1,
                    "invoiceDate": "2024-07-02",
                    "created": "2024-07-02 15:01:00.000",
                    "updated": "2024-07-02 15:01:00.000",
                    "state": "invoice_created",
                    "data": "{json}",
                    "isCredit": false,
                    "invoiceAccountingStatuses":
                      [
                        {
                          "invoiceAccountingStatusId": 1,
                          "createdOn": "2024-07-02 15:01:00.000",
                          "description": null,
                        },
                      ],
                  },
              }
      responses:
        "201":
          description: CREATED
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PostContractInvoicesResponseBody"
              example:
                {
                  "contractInvoice":
                    {
                      "contractInvoiceId": "8699d72a-cf4d-4e6b-9e9c-549d837ca51f",
                    },
                }
  /contractinvoices:
    get:
      summary: Get all contract invoices.
      description: Get all contract invoices.
      tags:
        - ContractInvoice
      parameters:
        - in: query
          name: contractInvoiceId
          schema:
            type: string
            format: uuid
            example: 8699d72a-cf4d-4e6b-9e9c-549d837ca51f
          required: false
          description: Id of the contract invoice to fetch.
        - in: query
          name: contractId
          schema:
            type: string
            format: uuid
            example: f13dbd2d-315d-4839-b0db-e03a2cade495
          required: false
          description: Id of the contract to fetch invoices for.
        - in: query
          name: externalReference
          schema:
            type: string
            example: F2024-0030
          required: false
          description: External reference of the invoice.
        - in: query
          name: term
          schema:
            type: integer
            example: 4
          required: false
          description: Term of the invoice.
        - in: query
          name: invoiceDateFrom
          schema:
            type: string
            format: date
            example: 2024-06-02
          required: false
          description: Invoice date of the invoice (from).
        - in: query
          name: invoiceDateUntil
          schema:
            type: string
            format: date
            example: 2024-06-02
          required: false
          description: Invoice date of the invoice (until).
        - in: query
          name: createdFrom
          schema:
            type: string
            format: date-time
            example: 2024-06-02 15:01:00.000
          required: false
          description: Billing date of the invoice (from).
        - in: query
          name: createdUntil
          schema:
            type: string
            format: date-time
            example: 2024-06-02 15:01:00.000
          required: false
          description: Billing date of the invoice (until).
        - in: query
          name: updatedFrom
          schema:
            type: string
            format: date-time
            example: 2024-06-02 15:01:00.000
          required: false
          description: Updated timestamp of the invoice (from).
        - in: query
          name: updatedUntil
          schema:
            type: string
            format: date-time
            example: 2024-06-02 15:01:00.000
          required: false
          description: Updated timestamp of the invoice (until).
        - in: query
          name: state
          schema:
            type: string
            example: created
          required: false
          description: Invoice state.
        - in: query
          name: isCredit
          schema:
            type: boolean
            example: false
          required: false
          description: Whether the invoice is a credit invoice.
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  contractInvoices:
                    type: array
                    items:
                      $ref: "#/components/schemas/ContractInvoice"
              example:
                {
                  "contractInvoices":
                    [
                      {
                        "contractId": "f13dbd2d-315d-4839-b0db-e03a2cade495",
                        "contractInvoiceId": "8699d72a-cf4d-4e6b-9e9c-549d837ca51f",
                        "externalReference": "F2024-0030",
                        "term": 1,
                        "invoiceDate": "2024-06-02",
                        "created": "2024-06-02 15:01:00.000",
                        "updated": "2024-06-02 15:01:00.000",
                        "state": "invoice_created",
                        "data": "{json}",
                        "isCredit": false,
                        "invoiceAccountingStatuses":
                          [
                            {
                              "invoiceAccountingStatusId": "32785417-1fb8-42c7-bda1-533f5868809f",
                              "accountingStatus":
                                { "accountingStatusId": 1, "name": "open" },
                              "createdOn": "2024-06-02 15:01:00.000",
                              "description": null,
                            },
                          ],
                      },
                      {
                        "contractId": "a7452e22-3894-40cc-87d6-869370a92277",
                        "contractInvoiceId": "dadff658-4ff5-4eb8-b516-492f1f6c6245",
                        "externalReference": "F2024-0002",
                        "term": 2,
                        "invoiceDate": "2024-08-02",
                        "created": "2024-08-02 15:01:00.000",
                        "updated": "2024-08-02 15:01:00.000",
                        "state": "invoice_created",
                        "data": "{json}",
                        "isCredit": false,
                        "invoiceAccountingStatuses":
                          [
                            {
                              "invoiceAccountingStatusId": "84af0f01-0416-4860-851a-a0d4b3cf674a",
                              "accountingStatus":
                                { "accountingStatusId": 1, "name": "open" },
                              "createdOn": "2024-08-02 15:01:00.000",
                              "description": null,
                            },
                          ],
                      },
                    ],
                }
  /contractinvoices/{contractInvoiceId}:
    parameters:
      - in: path
        name: contractInvoiceId
        schema:
          type: string
          format: uuid
          example: d1dd439b-6072-4b97-89c9-724268865b93
        required: true
        description: The id of the ContractInvoice, formatted as UUID.
    patch:
      summary: Update an existing invoice.
      description: Update an existing invoice.
      tags:
        - ContractInvoice
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PatchContractInvoicesRequestBody"
            example:
              {
                "contractInvoice":
                  {
                    "updated": "2024-07-02 15:01:00.000",
                    "state": "invoice_reopened",
                    "data": "{json}",
                  },
              }
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PatchContractInvoicesResponseBody"
              example:
                {
                  "contractInvoice":
                    {
                      "contractInvoiceId": "8699d72a-cf4d-4e6b-9e9c-549d837ca51f",
                    },
                }
  /contractinvoices/{contractInvoiceId}/invoiceaccountingstatuses:
    parameters:
      - in: path
        name: contractInvoiceId
        schema:
          type: string
          format: uuid
          example: d1dd439b-6072-4b97-89c9-724268865b93
        required: true
        description: The id of the ContractInvoice, formatted as UUID.
    post:
      summary: Add a new invoice accounting status to a contract invoice.
      description: Add a new invoice accounting status to a contract invoice.
      tags:
        - ContractInvoice
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PostInvoiceAccountingStatusesRequestBody"
            example:
              {
                "accountingStatusId": 1,
                "createdOn": "2024-07-02 15:01:00.000",
                "description": null,
              }
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PostInvoiceAccountingStatusesResponseBody"
              example:
                {
                  "invoiceAccountingStatusId": "a6836364-4812-4960-9226-69deb2e2b903",
                }
  /contracts/{contractId}/contractactions:
    parameters:
      - in: path
        name: contractId
        schema:
          type: string
          format: uuid
          example: d1dd439b-6072-4b97-89c9-724268865b93
        required: true
        description: The contractId of the Contract, formatted as UUID.
    get:
      summary: Get all actions of a single contract.
      description: Get all actions of a single contract.
      tags:
        - ContractAction
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  contractActions:
                    type: array
                    items:
                      $ref: "#/components/schemas/ContractAction"
              example:
                {
                  "contractActions":
                    [
                      {
                        "contractActionId": "67687851-59dd-4bbc-aa74-0f7abd26c883",
                        "actionType": { "actionTypeId": 1, "name": "create" },
                        "user": "subid123456",
                        "timestamp": "2024-07-02 15:01:00.000",
                        "details": "Contract created",
                        "correlationId": "976e7a4c-bf24-43d2-b444-55817556e7ee",
                      },
                      {
                        "contractActionId": "ea9ad287-9cd3-4e76-bcb9-d71db551cf55",
                        "actionType": { "actionTypeId": 2, "name": "change" },
                        "user": "subid123456",
                        "timestamp": "2024-07-03 15:01:00.000",
                        "details": "Contract changed",
                        "correlationId": "e2462347-6749-4841-b42a-cf8de19ec727",
                      },
                    ],
                }
    post:
      summary: Add a new action to an existing contract.
      description: Add a new action to an existing contract.
      tags:
        - ContractAction
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PostContractActionsRequestBody"
            example:
              {
                "contractAction":
                  {
                    "actionType": 2,
                    "user": "subid123456",
                    "timestamp": "2024-07-02 15:01:00.000",
                    "details": "Contract changed xyz",
                    "correlationId": "976e7a4c-bf24-43d2-b444-55817556e7ee",
                  },
              }
      responses:
        "201":
          description: CREATED
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PostContractActionsResponseBody"
              example:
                {
                  "contractAction":
                    {
                      "contractActionId": "8699d72a-cf4d-4e6b-9e9c-549d837ca51f",
                    },
                }
  /contractstatuses:
    get:
      summary: Return a list of all possible values of the ContractStatus reference table. Used for populating drop down lists for example.
      description: Return a list of all possible values of the ContractStatus reference table. Used for populating drop down lists for example.
      tags:
        - Reference Tables
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  contractStatuses:
                    type: array
                    items:
                      $ref: "#/components/schemas/ContractStatus"
              example:
                {
                  "contractStatuses":
                    [
                      { "contractStatusId": 1, "name": "new" },
                      { "contractStatusId": 2, "name": "active" },
                      { "contractStatusId": 3, "name": "suspended" },
                      { "contractStatusId": 4, "name": "cancelled" },
                      { "contractStatusId": 5, "name": "terminated" },
                      { "contractStatusId": 6, "name": "pending cancellation" },
                      { "contractStatusId": 7, "name": "pending termination" },
                      { "contractStatusId": 8, "name": "pending change" },
                    ],
                }
  /actiontypes:
    get:
      summary: Return a list of all possible values of the ActionType reference table. Used for populating drop down lists for example.
      description: Return a list of all possible values of the ActionType reference table. Used for populating drop down lists for example.
      tags:
        - Reference Tables
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  actionTypes:
                    type: array
                    items:
                      $ref: "#/components/schemas/ActionType"
              example:
                {
                  "actionTypes":
                    [
                      { "contractActionId": 1, "name": "create" },
                      { "contractActionId": 2, "name": "change" },
                      { "contractActionId": 3, "name": "cancel" },
                      { "contractActionId": 4, "name": "suspend" },
                      { "contractActionId": 5, "name": "terminate" },
                      { "contractActionId": 6, "name": "renew" },
                      { "contractActionId": 7, "name": "invoice" },
                    ],
                }
components:
  securitySchemes:
    bearerToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    PostContractsRequestBody:
      type: object
      properties:
        contract:
          type: object
          properties:
            orderId:
              type: string
              format: uuid
              example: eb3d08f7-7feb-4f31-9f5b-daa634e51f48
            orderLineId:
              type: string
              format: uuid
              example: 52efbbfc-8c28-4016-9ece-dc3ef9a70bd8
            touchpointId:
              type: integer
              example: 2
            termDuration:
              type: string
              format: ISO8601
              example: P0Y1M0D
            billingDay:
              type: integer
              example: 15
            highestInvoiceTerm:
              type: integer
              example: 0
            contractVersions:
              type: array
              items:
                type: object
                properties:
                  termsAndConditions:
                    type: string
                    format: url
                    example: https://www.htm.nl/reisproducten/productvoorwaarden/htm-maandkorting/
                  productId:
                    type: integer
                    example: 1
                  productName:
                    type: string
                    example: HTM Maand 20% korting
                  taxCode:
                    type: string
                    example: V9
                  taxPercentage:
                    type: number
                    format: float
                    example: 9.0
                  termAmountInclTax:
                    type: integer
                    example: 400
                  start:
                    type: string
                    format: date-time
                    example: 2024-07-04 15:01:00.000
                  end:
                    type: string
                    format: date-time
                    example: 2024-12-31 15:01:00.000
                required:
                  - termsAndConditions
                  - productId
                  - productName
                  - taxCode
                  - taxPercentage
                  - termAmountInclTax
                  - start
          required:
            - orderId
            - orderLineId
            - touchpointId
            - termDuration
            - billingDay
            - highestInvoiceTerm
            - contractVersions
      required:
        - contract
    PostContractsResponseBody:
      type: object
      properties:
        contract:
          type: object
          properties:
            contractId:
              type: string
              format: uuid
              example: 5a3876a1-e9a1-4278-8983-4679a8d583c2
            contractNumber:
              type: string
              pattern: '^D\d{6}$'
              example: D123456
          required:
            - contractId
            - contractNumber
      required:
        - contract
    PatchContractsRequestBody:
      type: object
      properties:
        contract:
          type: object
          properties:
            contractStatusId:
              type: integer
              example: 2
            billingDay:
              type: integer
              example: 15
            highestInvoiceTerm:
              type: integer
              example: 2
      required:
        - contract
    PatchContractsResponseBody:
      type: object
      properties:
        contract:
          type: object
          properties:
            contractId:
              type: string
              format: uuid
              example: 5a3876a1-e9a1-4278-8983-4679a8d583c2
            contractNumber:
              type: string
              pattern: '^D\d{6}$'
              example: D123456
          required:
            - contractId
            - contractNumber
      required:
        - contract
    PostContractVersionsRequestBody:
      type: object
      properties:
        contractVersion:
          type: object
          properties:
            termsAndConditions:
              type: string
              format: url
              example: https://www.htm.nl/reisproducten/productvoorwaarden/htm-maandkorting/
            productId:
              type: integer
              example: 1
            productName:
              type: string
              example: HTM Maand 20% korting
            taxCode:
              type: string
              example: V9
            taxPercentage:
              type: number
              format: float
              example: 9.0
            termAmountInclTax:
              type: integer
              example: 400
            start:
              type: string
              format: date-time
              example: 2024-07-04 15:01:00.000
            end:
              type: string
              format: date-time
              example: 2024-12-31 15:01:00.000
          required:
            - termsAndConditions
            - productId
            - productName
            - taxCode
            - taxPercentage
            - termAmountInclTax
            - start
      required:
        - contractVersion
    PostContractVersionsResponseBody:
      type: object
      properties:
        contractVersion:
          type: object
          properties:
            contractId:
              type: string
              format: uuid
              example: 5a3876a1-e9a1-4278-8983-4679a8d583c2
            contractVersionId:
              type: integer
              example: 1
          required:
            - contractId
            - contractVersionId
      required:
        - contractVersion
    PatchContractVersionsRequestBody:
      type: object
      properties:
        contractVersion:
          type: object
          properties:
            end:
              type: string
              format: date-time
              example: 2024-12-31 15:01:00.000
      required:
        - contractVersion
    PatchContractVersionsResponseBody:
      type: object
      properties:
        contractVersion:
          type: object
          properties:
            contractId:
              type: string
              format: uuid
              example: 5a3876a1-e9a1-4278-8983-4679a8d583c2
            contractVersionId:
              type: integer
              example: 1
          required:
            - contractId
            - contractVersionId
      required:
        - contractVersion
    PostContractInvoicesRequestBody:
      type: object
      properties:
        contractInvoice:
          type: object
          properties:
            externalReference:
              type: string
              example: F2024-0001
            term:
              type: integer
              example: 1
            invoiceDate:
              type: string
              format: date
              example: 2024-07-02
            created:
              type: string
              format: date-time
              example: 2024-07-02 15:01:00.000
            updated:
              type: string
              format: date-time
              example: 2024-07-02 15:01:00.000
            state:
              type: string
              example: invoice_created
            data:
              type: string
              format: json
              example: "{json}"
            isCredit:
              type: boolean
              example: false
            invoiceAccountingStatuses:
              type: array
              items:
                type: object
                properties:
                  accountingStatusId:
                    type: integer
                    example: 1
                  createdOn:
                    type: string
                    format: date-time
                    example: 2024-07-02 15:01:00.000
                  description:
                    type: string
                    example: null
                required:
                  - accountingStatusId
                  - createdOn
          required:
            - externalReference
            - term
            - invoiceDate
            - created
            - updated
            - state
            - data
            - isCredit
            - invoiceAccountingStatuses
      required:
        - contractInvoice
    PostContractInvoicesResponseBody:
      type: object
      properties:
        contractInvoice:
          type: object
          properties:
            contractInvoiceId:
              type: string
              format: uuid
              example: 8699d72a-cf4d-4e6b-9e9c-549d837ca51f
          required:
            - contractInvoiceId
      required:
        - contractInvoice
    PatchContractInvoicesRequestBody:
      type: object
      properties:
        contractInvoice:
          type: object
          properties:
            updated:
              type: string
              format: date-time
              example: 2024-07-02 15:01:00.000
            state:
              type: string
              example: invoice_reopened
            data:
              type: string
              format: json
              example: "{json}"
      required:
        - contractInvoice
    PatchContractInvoicesResponseBody:
      type: object
      properties:
        contractInvoice:
          type: object
          properties:
            contractInvoiceId:
              type: string
              format: uuid
              example: 8699d72a-cf4d-4e6b-9e9c-549d837ca51f
          required:
            - contractInvoiceId
      required:
        - contractInvoice
    PostInvoiceAccountingStatusesRequestBody:
      type: object
      properties:
        accountingStatusId:
          type: integer
          example: 1
        createdOn:
          type: string
          format: date-time
          example: 2024-07-02 15:01:00.000
        description:
          type: string
          example: null
      required:
        - accountingStatusId
        - createdOn
    PostInvoiceAccountingStatusesResponseBody:
      type: object
      properties:
        invoiceAccountingStatusId:
          type: string
          format: uuid
          example: a6836364-4812-4960-9226-69deb2e2b903
      required:
        - invoiceAccountingStatusId
    PostContractActionsRequestBody:
      type: object
      properties:
        contractAction:
          type: object
          properties:
            actionType:
              type: integer
              example: 2
            user:
              type: string
              example: subid123456
            timestamp:
              type: string
              format: date-time
              example: 2024-07-02 15:01:00.000
            details:
              type: string
              example: Contract changed xyz
            correlationId:
              type: string
              format: uuid
              example: 976e7a4c-bf24-43d2-b444-55817556e7ee
          required:
            - actionType
            - user
            - timestamp
            - details
            - correlationId
      required:
        - contractAction
    PostContractActionsResponseBody:
      type: object
      properties:
        contractAction:
          type: object
          properties:
            contractActionId:
              type: string
              format: uuid
              example: 8699d72a-cf4d-4e6b-9e9c-549d837ca51f
          required:
            - contractActionId
      required:
        - contractAction
    Contract:
      type: object
      properties:
        contractId:
          type: string
          format: uuid
          example: 5a3876a1-e9a1-4278-8983-4679a8d583c2
        contractNumber:
          type: string
          pattern: '^D\d{6}$'
          example: D123456
        customerProfileId:
          type: integer
          example: 42
        orderId:
          type: string
          format: uuid
          example: eb3d08f7-7feb-4f31-9f5b-daa634e51f48
        orderLineId:
          type: string
          format: uuid
          example: 52efbbfc-8c28-4016-9ece-dc3ef9a70bd8
        touchpointId:
          type: integer
          example: 2
        contractStatus:
          type: object
          $ref: "#/components/schemas/ContractStatus"
        termDuration:
          type: string
          format: ISO8601
          example: P0Y1M0D
        billingDay:
          type: integer
          example: 15
        highestInvoiceTerm:
          type: integer
          example: 1
        contractVersions:
          type: array
          items:
            $ref: "#/components/schemas/ContractVersion"
            minItems: 0
        contractActions:
          type: array
          items:
            $ref: "#/components/schemas/ContractAction"
            minItems: 0
        contractInvoices:
          type: array
          items:
            $ref: "#/components/schemas/ContractInvoice"
            minItems: 0
    Contracts:
      type: object
      properties:
        contracts:
          type: array
          items:
            $ref: "#/components/schemas/Contract"
            minItems: 0
    ContractAction:
      type: object
      properties:
        contractActionId:
          type: string
          format: uuid
          example: 67687851-59dd-4bbc-aa74-0f7abd26c883
        actionType:
          type: object
          $ref: "#/components/schemas/ActionType"
        user:
          type: string
          example: subid123456
        timestamp:
          type: string
          format: date-time
          example: 2024-07-02 15:01:00.000
        details:
          type: string
          example: Contract created
        correlationId:
          type: string
          format: uuid
          example: 976e7a4c-bf24-43d2-b444-55817556e7ee
    ContractVersion:
      type: object
      properties:
        contractVersionId:
          type: integer
          example: 1
        termsAndConditions:
          type: string
          format: url
          example: https://www.htm.nl/reisproducten/productvoorwaarden/htm-maandkorting/
        productId:
          type: integer
          example: 1
        productName:
          type: string
          example: HTM Maand 20% korting
        taxCode:
          type: string
          example: V9
        taxPercentage:
          type: number
          format: float
          example: 9.0
        termAmountInclTax:
          type: integer
          example: 400
        start:
          type: string
          format: date-time
          example: 2024-07-04 15:01:00.000
        end:
          type: string
          format: date-time
          example: 2024-12-31 15:01:00.000
    ContractInvoice:
      type: object
      properties:
        contractInvoiceId:
          type: string
          format: uuid
          example: 8699d72a-cf4d-4e6b-9e9c-549d837ca51f
        externalReference:
          type: string
          example: F2024-0001
        term:
          type: integer
          example: 1
        invoiceDate:
          type: string
          format: date
          example: 2024-07-02
        created:
          type: string
          format: date-time
          example: 2024-07-02 15:01:00.000
        updated:
          type: string
          format: date-time
          example: 2024-07-02 15:01:00.000
        state:
          type: string
          example: invoice_created
        data:
          type: string
          format: json
          example: "{json}"
        isCredit:
          type: boolean
          example: false
    InvoiceAccountingStatus:
      type: object
      properties:
        invoiceAccountingStatusId:
          type: string
          format: uuid
          example: 6b6f0f5e-5d3f-4a6d-8e7d-6a7d0f9e6c5b
        contractInvoiceId:
          type: string
          format: uuid
          example: 8699d72a-cf4d-4e6b-9e9c-549d837ca51f
        accountingStatus:
          type: object
          $ref: "#/components/schemas/AccountingStatus"
        createdOn:
          type: string
          format: date-time
          example: 2024-07-02 15:01:00.000
        description:
          type: string
          example: Open
    AccountingStatus:
      type: object
      properties:
        accountingStatusId:
          type: integer
          example: 1
        name:
          type: string
          enum: [open, sent, received, rejected]
          example: open
    ContractStatus:
      type: object
      properties:
        contractStatusId:
          type: integer
          example: 2
        name:
          type: string
          enum:
            [
              new,
              active,
              suspended,
              cancelled,
              terminated,
              pending cancellation,
              pending termination,
            ]
          example: active
    ActionType:
      type: object
      properties:
        actionTypeId:
          type: integer
          example: 1
        name:
          type: string
          enum: [create, change, cancel, suspend, terminate, renew, invoice]
          example: create
