{
  "openapi": "3.1.0",
  "info": {
    "title": "Agreements Beta - Internal",
    "description": "Internal API for managing and fetching agreements.\n\nError handling:\n- REST failures use `application/problem+json` with the shared `ApiError` schema.\n- `code` is the stable machine-readable identifier, for example `request.validation_failed`, `agreement.not_found`, `template.version_conflict`, or `dependency.service_unavailable`.\n- `detail` contains the human-readable explanation, and `fieldErrors` is populated for validation and binding failures.\n- `401` is reserved for unauthenticated requests handled by the security layer. `403` is used for authorization failures from `@PreAuthorize`, `AccessDeniedException`, and service-level permission checks.\n- Unexpected application failures are sanitized to `500 internal.server_error`.",
    "termsOfService": "https://developer.entur.no/terms-of-service",
    "contact": {
      "name": "Team Aktør",
      "url": "https://enturas.atlassian.net/wiki/spaces/TA/overview",
      "email": "team.aktor@entur.org"
    },
    "version": "2026.10.0"
  },
  "servers": [
    {
      "url": "https://api.entur.io/agreements",
      "description": "Entur's Production Beta environment"
    },
    {
      "url": "https://api.staging.entur.io/agreements",
      "description": "Entur's Staging Beta environment"
    },
    {
      "url": "https://api.dev.entur.io/agreements",
      "description": "Entur's Development Beta environment"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    },
    {
      "etClientName": []
    }
  ],
  "tags": [
    {
      "name": "Adapter"
    },
    {
      "name": "Agreements"
    }
  ],
  "paths": {
    "/v1/agreements/{agreementNumber}": {
      "get": {
        "tags": [
          "Agreements"
        ],
        "summary": "Retrieve agreement by agreement number",
        "description": "Fetches the current ACTIVE agreement for a business agreement number.",
        "operationId": "getAgreementByNumber",
        "parameters": [
          {
            "name": "agreementNumber",
            "in": "path",
            "description": "Agreement Number",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful retrieval",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgreementResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input supplied, bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "x-entur-permissions": {
          "value": "Agreement:les"
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ET-Client-Name"
        },
        {
          "$ref": "#/components/parameters/X-Correlation-Id"
        }
      ]
    },
    "/v1/agreements/{agreementNumber}/versions": {
      "get": {
        "tags": [
          "Agreements"
        ],
        "summary": "Retrieve agreement versions by agreement number",
        "description": "Fetches all agreements sharing the same business agreement number, optionally filtered by status.",
        "operationId": "getAgreementVersionsByNumber",
        "parameters": [
          {
            "name": "agreementNumber",
            "in": "path",
            "description": "Agreement Number",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Agreement statuses to filter by",
            "required": false,
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "ACTIVE",
                  "DRAFT",
                  "REVISING",
                  "REVISED",
                  "APPROVAL",
                  "APPROVED",
                  "REJECTED",
                  "DEPRECATED",
                  "TERMINATED",
                  "PENDING"
                ]
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful retrieval",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AgreementResponse"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input supplied, bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "x-entur-permissions": {
          "value": "Agreement:les"
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ET-Client-Name"
        },
        {
          "$ref": "#/components/parameters/X-Correlation-Id"
        }
      ]
    },
    "/v1/agreements/{agreementNumber}/full": {
      "get": {
        "tags": [
          "Agreements"
        ],
        "summary": "Retrieve one full agreement by agreement number",
        "description": "Fetches the current ACTIVE agreement for a business agreement number, including template element definitions with values from agreement details.",
        "operationId": "getAgreementByNumberFull",
        "parameters": [
          {
            "name": "agreementNumber",
            "in": "path",
            "description": "Agreement Number",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful retrieval",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgreementFullResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input supplied, bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "x-entur-permissions": {
          "value": "Agreement:les"
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ET-Client-Name"
        },
        {
          "$ref": "#/components/parameters/X-Correlation-Id"
        }
      ]
    },
    "/v1/agreements/type/{templateType}": {
      "get": {
        "tags": [
          "Agreements"
        ],
        "summary": "Retrieve agreements by template type having specific statuses",
        "description": "Fetches a list of active agreements",
        "operationId": "getAgreementsByTemplateType",
        "parameters": [
          {
            "name": "templateType",
            "in": "path",
            "description": "Template Type",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Agreement statuses to filter by",
            "required": false,
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "ACTIVE",
                  "DRAFT",
                  "REVISING",
                  "REVISED",
                  "APPROVAL",
                  "APPROVED",
                  "REJECTED",
                  "DEPRECATED",
                  "TERMINATED",
                  "PENDING"
                ]
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful retrieval of agreements",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AgreementResponse"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input supplied, bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "x-entur-permissions": {
          "value": "Agreement:les"
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ET-Client-Name"
        },
        {
          "$ref": "#/components/parameters/X-Correlation-Id"
        }
      ]
    },
    "/v1/agreements/id/{agreementId}": {
      "get": {
        "tags": [
          "Agreements"
        ],
        "summary": "Retrieve agreement by internal id",
        "description": "Fetches a specific agreement by its internal id.",
        "operationId": "getAgreementById",
        "parameters": [
          {
            "name": "agreementId",
            "in": "path",
            "description": "Agreement internal id",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful retrieval",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgreementResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input supplied, bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "x-entur-permissions": {
          "value": "Agreement:les"
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ET-Client-Name"
        },
        {
          "$ref": "#/components/parameters/X-Correlation-Id"
        }
      ]
    },
    "/v1/agreements/id/{agreementId}/full": {
      "get": {
        "tags": [
          "Agreements"
        ],
        "summary": "Retrieve one full agreement by internal id",
        "description": "Fetches one specific agreement including template element definitions with values from agreement details.",
        "operationId": "getAgreementByIdFull",
        "parameters": [
          {
            "name": "agreementId",
            "in": "path",
            "description": "Agreement internal id",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful retrieval",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgreementFullResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input supplied, bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "x-entur-permissions": {
          "value": "Agreement:les"
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ET-Client-Name"
        },
        {
          "$ref": "#/components/parameters/X-Correlation-Id"
        }
      ]
    },
    "/v1/adapter/transmodel/organisations/{type}": {
      "get": {
        "tags": [
          "Adapter"
        ],
        "summary": "Get organisations by type",
        "description": "Retrieves organisations filtered by the given organisation type.",
        "operationId": "getOrganisationIdForRoleId",
        "parameters": [
          {
            "name": "type",
            "in": "path",
            "description": "Organisation type",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string",
              "enum": [
                "AUTHORITY",
                "OPERATOR",
                "OTHER"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of organisations returned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TransmodelResponse"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input supplied, bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "x-entur-permissions": {
          "value": "Agreement:les"
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ET-Client-Name"
        },
        {
          "$ref": "#/components/parameters/X-Correlation-Id"
        }
      ]
    },
    "/v1/adapter/transmodel/organisation/find/{roleIdOrAlias}": {
      "get": {
        "tags": [
          "Adapter"
        ],
        "summary": "Get organisation ID for NeTEx ID or alias",
        "description": "Retrieves the organisation ID associated with a given agreement-derived role ID, GeneralOrganisation ID, or organisation alias.",
        "operationId": "getOrganisationIdForRoleIdOrAlias",
        "parameters": [
          {
            "name": "roleIdOrAlias",
            "in": "path",
            "description": "Role ID, GeneralOrganisation ID, or alias to search for",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved organisation ID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "integer",
                  "format": "int32"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input supplied, bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ET-Client-Name"
        },
        {
          "$ref": "#/components/parameters/X-Correlation-Id"
        }
      ]
    },
    "/v1/adapter/transmodel/ids": {
      "get": {
        "tags": [
          "Adapter"
        ],
        "summary": "List role IDs and aliases for Transmodel organisations",
        "description": "List agreement-derived role IDs and aliases for organisations in active or terminated agreements. Can optionally include all organisations with GeneralOrganisation NeTEx IDs.",
        "operationId": "getRoleIdsAndAliases",
        "parameters": [
          {
            "name": "allOrganisations",
            "in": "query",
            "description": "Include all organisations from the organisation register with GeneralOrganisation NeTEx IDs.",
            "required": false,
            "style": "form",
            "explode": true,
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully exported role IDs and aliases",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/IdsResponse"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input supplied, bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ET-Client-Name"
        },
        {
          "$ref": "#/components/parameters/X-Correlation-Id"
        }
      ]
    },
    "/v1/adapter/transmodel/export": {
      "get": {
        "tags": [
          "Adapter"
        ],
        "summary": "Export Transmodel roles and optionally contracts",
        "description": "Exports agreement-derived Transmodel roles and optionally contract members in XML format. Can optionally include all organisations as GeneralOrganisation entries.",
        "operationId": "transmodelExport",
        "parameters": [
          {
            "name": "allOrganisations",
            "in": "query",
            "description": "Include all organisations from the organisation register as GeneralOrganisation elements.",
            "required": false,
            "style": "form",
            "explode": true,
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "includeContracts",
            "in": "query",
            "description": "Include contracts.",
            "required": false,
            "style": "form",
            "explode": true,
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully exported Transmodel XML",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input supplied, bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ET-Client-Name"
        },
        {
          "$ref": "#/components/parameters/X-Correlation-Id"
        }
      ]
    },
    "/v1/adapter/transmodel/agreements/{organisationIdOrAlias}": {
      "get": {
        "tags": [
          "Adapter"
        ],
        "summary": "Get agreements for organisation",
        "description": "Retrieves all agreements associated with a given organisation ID.",
        "operationId": "getTransmodelAgreementsFor",
        "parameters": [
          {
            "name": "organisationIdOrAlias",
            "in": "path",
            "description": "Organisation ID or Alias (e.g. 1 or ENT:Authority:ENT)",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of agreements returned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TransmodelPartiesResponse"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input supplied, bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden access",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "x-entur-permissions": {
          "value": "Agreement:les"
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ET-Client-Name"
        },
        {
          "$ref": "#/components/parameters/X-Correlation-Id"
        }
      ]
    }
  },
  "components": {
    "schemas": {
      "AgreementDetailResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32"
          },
          "key": {
            "type": "string"
          },
          "value": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "key"
        ]
      },
      "AgreementResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "agreementNumber": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "ACTIVE",
              "DRAFT",
              "REVISING",
              "REVISED",
              "APPROVAL",
              "APPROVED",
              "REJECTED",
              "DEPRECATED",
              "TERMINATED",
              "PENDING"
            ]
          },
          "validFrom": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "validTo": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "changedAt": {
            "type": "string",
            "format": "date-time"
          },
          "parties": {
            "type": "array",
            "description": "List of parties involved in the agreement",
            "items": {
              "$ref": "#/components/schemas/Party.Response"
            },
            "maxItems": 2,
            "minItems": 1
          },
          "templateId": {
            "type": "integer",
            "format": "int32"
          },
          "sourceAgreementId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Internal ID of another agreement: the source agreement this agreement was migrated from. Null if not migrated."
          },
          "details": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgreementDetailResponse"
            }
          },
          "processingStatus": {
            "type": "string",
            "enum": [
              "NEW",
              "PROCESSING",
              "PROCESSED",
              "FAILED",
              "ROLLBACK_FAILED"
            ]
          },
          "processedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "commandParameters": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            },
            "description": "Per-command parameters grouped by command configuration id"
          },
          "eventParameters": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            },
            "description": "Per-event parameters grouped by event configuration id"
          }
        },
        "required": [
          "agreementNumber",
          "changedAt",
          "commandParameters",
          "createdAt",
          "details",
          "eventParameters",
          "id",
          "name",
          "notes",
          "parties",
          "processingStatus",
          "status",
          "templateId"
        ]
      },
      "Party.Response": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "organisationId": {
            "type": "integer",
            "format": "int32"
          },
          "role": {
            "type": "string",
            "enum": [
              "OWNER",
              "OPERATOR",
              "SELLER",
              "RECIPIENT",
              "PARTICIPANT",
              "CREATOR"
            ]
          },
          "approvalRequired": {
            "type": "boolean"
          },
          "approvedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "rejectedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "approvalRequired",
          "id",
          "organisationId",
          "role"
        ]
      },
      "ApiError": {
        "type": "object",
        "description": "Problem response emitted by the global exception handler. The stable machine-readable meaning is carried by `code`; validation and binding failures also populate `fieldErrors`.",
        "properties": {
          "title": {
            "type": "string",
            "description": "HTTP reason phrase for the response status.",
            "example": "Bad Request"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "Server timestamp when the problem response was created.",
            "example": "2026-05-19T12:34:56Z"
          },
          "exception": {
            "type": [
              "string",
              "null"
            ],
            "description": "Legacy compatibility field. REST responses currently set this to null."
          },
          "message": {
            "type": [
              "string",
              "null"
            ],
            "description": "Compatibility message field. Usually mirrors `detail` for 4xx responses and is null for sanitized 5xx responses.",
            "example": "Agreement with agreementNumber 123 not found"
          },
          "detail": {
            "type": "string",
            "description": "Human-readable explanation of the problem.",
            "example": "Agreement with agreementNumber 123 not found"
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "description": "HTTP status code.",
            "example": 404
          },
          "path": {
            "type": "string",
            "description": "Request path that produced the error.",
            "example": "/v1/agreements/123"
          },
          "code": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stable machine-readable error code from the server exception model. Representative values include `request.validation_failed`, `agreement.not_found`, `template.version_conflict`, `dependency.service_unavailable`, and `internal.server_error`.",
            "example": "agreement.not_found"
          },
          "fieldErrors": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {
              "type": "string"
            },
            "description": "Validation or binding errors keyed by field or parameter name. Present for request validation failures.",
            "example": {
              "templateId": "must not be null",
              "status": "must be one of [ACTIVE, PENDING]"
            }
          }
        },
        "required": [
          "detail",
          "path",
          "status",
          "timestamp",
          "title"
        ]
      },
      "AgreementDetailFullResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32"
          },
          "key": {
            "type": "string"
          },
          "value": {
            "type": [
              "string",
              "null"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "STRING",
              "INTEGER",
              "BOOLEAN",
              "DATE"
            ]
          },
          "format": {
            "type": "string",
            "enum": [
              "AMOUNT",
              "DATE",
              "DATE_TIME",
              "EMAIL",
              "LONG_TEXT",
              "PHONE_NUMBER",
              "SHORT_TEXT",
              "URL"
            ]
          },
          "required": {
            "type": "boolean"
          },
          "overrideAllowed": {
            "type": "boolean"
          },
          "defaultValue": {
            "type": [
              "string",
              "null"
            ]
          },
          "resolvedValue": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "format",
          "key",
          "overrideAllowed",
          "required",
          "type"
        ]
      },
      "AgreementFullResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "agreementNumber": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "ACTIVE",
              "DRAFT",
              "REVISING",
              "REVISED",
              "APPROVAL",
              "APPROVED",
              "REJECTED",
              "DEPRECATED",
              "TERMINATED",
              "PENDING"
            ]
          },
          "validFrom": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "validTo": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "changedAt": {
            "type": "string",
            "format": "date-time"
          },
          "parties": {
            "type": "array",
            "description": "List of parties involved in the agreement",
            "items": {
              "$ref": "#/components/schemas/Party.Response"
            },
            "maxItems": 2,
            "minItems": 1
          },
          "templateId": {
            "type": "integer",
            "format": "int32"
          },
          "sourceAgreementId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Internal ID of another agreement: the source agreement this agreement was migrated from. Null if not migrated."
          },
          "details": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgreementDetailFullResponse"
            }
          },
          "processingStatus": {
            "type": "string",
            "enum": [
              "NEW",
              "PROCESSING",
              "PROCESSED",
              "FAILED",
              "ROLLBACK_FAILED"
            ]
          },
          "processedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "commandParameters": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            },
            "description": "Per-command parameters grouped by command configuration id"
          },
          "eventParameters": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            },
            "description": "Per-event parameters grouped by event configuration id"
          }
        },
        "required": [
          "agreementNumber",
          "changedAt",
          "commandParameters",
          "createdAt",
          "details",
          "eventParameters",
          "id",
          "name",
          "notes",
          "parties",
          "processingStatus",
          "status",
          "templateId"
        ]
      },
      "TransmodelResponse": {
        "type": "object",
        "properties": {
          "organisationId": {
            "type": "integer",
            "format": "int32"
          },
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "AUTHORITY",
              "OPERATOR",
              "OTHER"
            ]
          }
        },
        "required": [
          "id",
          "organisationId",
          "type"
        ]
      },
      "IdsResponse": {
        "type": "object",
        "properties": {
          "organisationId": {
            "type": "integer",
            "format": "int32"
          },
          "roleIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "aliases": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "aliases",
          "organisationId",
          "roleIds"
        ]
      },
      "TransmodelPartiesResponse": {
        "type": "object",
        "properties": {
          "part1": {
            "$ref": "#/components/schemas/TransmodelResponse"
          },
          "part2": {
            "$ref": "#/components/schemas/TransmodelResponse"
          },
          "agreementNumber": {
            "type": "integer",
            "format": "int32"
          }
        },
        "required": [
          "agreementNumber",
          "part1",
          "part2"
        ]
      }
    },
    "parameters": {
      "ET-Client-Name": {
        "name": "ET-Client-Name",
        "in": "header",
        "description": "Entur Client Header.\nIt is required that all consumers identify themselves by using this header.\nEntur will deploy strict rate-limiting policies on API-consumers who do not identify with a header and reserves the right to block unidentified consumers.\nThe structure of ET-Client-Name should be: `<company>-<application>`.",
        "required": false,
        "style": "simple",
        "explode": false,
        "schema": {
          "type": "string"
        }
      },
      "X-Correlation-Id": {
        "name": "X-Correlation-Id",
        "in": "header",
        "description": "Correlation id",
        "required": false,
        "style": "simple",
        "explode": false,
        "schema": {
          "type": "string"
        }
      }
    },
    "securitySchemes": {
      "etClientName": {
        "type": "apiKey",
        "description": "Client name identifier. Required for API requests.",
        "name": "et-client-name",
        "in": "header"
      },
      "bearerAuth": {
        "type": "http",
        "description": "Enter your Bearer token in the format: Bearer {token}",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  }
}