{
  "openapi": "3.0.1",
  "info": {
    "title": "Ticketing Public API",
    "description": "REST API for Ticketing as a Service. All operations require a Ticketing instance API key in the key query parameter. Responses are JSON and list operations return records in reverse chronological order by default. Rate limit: 100 requests per 60 seconds.",
    "version": "1.1.0"
  },
  "servers": [
    {
      "url": "https://teamswork.azure-api.net/ticketing/v1",
      "description": "Production - Global (US)"
    },
    {
      "url": "https://ticketing-apim-eu.azure-api.net/ticketing/v1",
      "description": "Production - EU (EMEA)"
    },
    {
      "url": "https://ticketing-apim-aus.azure-api.net/ticketing/v1",
      "description": "Production - APAC (AUS)"
    }
  ],
  "paths": {
    "/tickets": {
      "get": {
        "summary": "Get all tickets",
        "description": "Retrieve tickets in reverse chronological order by default. Supports filtering, sorting, field selection, optional HTML fields, and pagination via limit/offset or the continuationToken response value.",
        "operationId": "get-all-tickets",
        "parameters": [
          {
            "name": "timezone",
            "in": "query",
            "description": "Timezone offset of the caller, e.g. 7 means GMT+7.",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Number of records to return per page. Max 1000, default 10.",
            "schema": {
              "type": "integer",
              "maximum": 1000,
              "default": 10
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Starting position (0-based). Default 0.",
            "schema": {
              "type": "integer",
              "default": 0
            }
          },
          {
            "name": "continuationToken",
            "in": "header",
            "description": "Token from previous response to fetch the next page.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Full-text search string.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "title",
            "in": "query",
            "description": "Filter by ticket title.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Legacy resolved-state filter. Open, Reopened, or In Progress return unresolved tickets; Resolved or Closed return resolved tickets. Use statusId for an exact workflow-state match.",
            "schema": {
              "type": "string",
              "enum": [
                "Open",
                "Reopened",
                "In Progress",
                "Resolved",
                "Closed"
              ]
            }
          },
          {
            "name": "statusId",
            "in": "query",
            "description": "Filter by statusId.",
            "schema": {
              "type": "string",
              "enum": [
                "Open",
                "Reopened",
                "In Progress",
                "Resolved",
                "Closed"
              ]
            }
          },
          {
            "name": "isResolved",
            "in": "query",
            "description": "Filter by resolved state.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "priority",
            "in": "query",
            "description": "Filter by priority.",
            "schema": {
              "type": "string",
              "enum": [
                "Low",
                "Medium",
                "Important",
                "Urgent"
              ]
            }
          },
          {
            "name": "tags",
            "in": "query",
            "description": "Comma-separated tag filter in format 'tagCategoryId_tagText'.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "description": "Field to sort by.",
            "schema": {
              "type": "string",
              "enum": [
                "status",
                "ticketId",
                "title",
                "requestorName",
                "requestorEmail",
                "assigneeName",
                "assigneeEmail",
                "expectedDate",
                "priority",
                "createdDateTime",
                "lastInteraction"
              ]
            }
          },
          {
            "name": "order",
            "in": "query",
            "description": "Sort direction.",
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "select",
            "in": "query",
            "description": "Comma-separated list of fields to return. Available: id, ticketId, title, description, status, requestor, customFields, priority, assignee, expectedDate, resolution, firstResponseOn, firstResolutionOn, lastResolutionOn, createdOn, tags, lastUpdatedOn, isFrtEscalated, isRtEscalated, createdBy, lastUpdatedBy, lastResolutionComment. Use include=description_HTML for HTML; include fields are retained even when select is present.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "createdAfter",
            "in": "query",
            "description": "Filter tickets created after this datetime. Format: YYYY-MM-DDTHH:mm:ss",
            "schema": {
              "type": "string",
              "format": "date-time",
              "example": "2025-09-26T00:00:00"
            }
          },
          {
            "name": "createdBefore",
            "in": "query",
            "description": "Filter tickets created before this datetime. Format: YYYY-MM-DDTHH:mm:ss",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "expectedDateAfter",
            "in": "query",
            "description": "Filter by expected date after this datetime.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "expectedDateBefore",
            "in": "query",
            "description": "Filter by expected date before this datetime.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "lastUpdateAfter",
            "in": "query",
            "description": "Filter tickets last updated after this datetime.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "lastUpdateBefore",
            "in": "query",
            "description": "Filter tickets last updated before this datetime.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "description": "Optional response field to include. Use description_HTML to return the sanitized HTML description alongside the always-present plain-text description. This remains included when select is also used.",
            "schema": {
              "type": "string",
              "enum": [
                "description_HTML"
              ]
            },
            "example": "description_HTML"
          }
        ],
        "responses": {
          "200": {
            "description": "List of tickets.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ITicket"
                      },
                      "description": "Tickets returned by the query."
                    },
                    "continuationToken": {
                      "type": "string",
                      "description": "Pass as header in next request to fetch the next page. Absent when no more pages."
                    },
                    "error": {
                      "type": "boolean",
                      "description": "Whether the request resulted in an error."
                    },
                    "message": {
                      "type": "string",
                      "description": "Human-readable status message from the API."
                    },
                    "itemCount": {
                      "type": "integer",
                      "description": "Total number of items matching the query, before pagination."
                    }
                  },
                  "description": "Response containing a page of tickets and an optional continuation token."
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized. Invalid or missing API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          }
        },
        "x-example": "GET [Base URL]/tickets?key={your_API_Key}&timezone=0&orderBy=status&order=ASC&select=id,ticketId,title,description,status,requestorName&offset=0&limit=20&createdAfter=2025-09-26T00:00:00"
      },
      "post": {
        "summary": "Create a ticket",
        "description": "Create a ticket. ticket.title and ticket.requestor are required. Use ticket.description for plain text or ticket.description_HTML for sanitized HTML; when both are supplied, description takes precedence. To trigger an email-to-ticket workflow, set all requestor fields to the requestor email address.",
        "operationId": "insert-ticket",
        "parameters": [
          {
            "name": "timezone",
            "in": "query",
            "description": "Timezone offset of the caller.",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "description": "Set to description_HTML to include the sanitized HTML description in the created ticket response.",
            "schema": {
              "type": "string",
              "enum": [
                "description_HTML"
              ]
            },
            "example": "description_HTML"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/insertTicketRequest"
              },
              "examples": {
                "basic": {
                  "summary": "Basic ticket",
                  "value": {
                    "ticket": {
                      "title": "My first ticket",
                      "requestor": {
                        "id": "053660b7-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                        "name": "Jason Doe",
                        "email": "john.doe@teamswork.app"
                      }
                    },
                    "user": {
                      "id": "053660b7-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                      "name": "Jason Doe",
                      "email": "jason.doe@teamswork.app"
                    }
                  }
                },
                "with-custom-fields": {
                  "summary": "Ticket with custom fields, priority, assignee, and tags",
                  "value": {
                    "ticket": {
                      "title": "My first ticket",
                      "requestor": {
                        "id": "053660b7-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                        "name": "Jason Doe",
                        "email": "john.doe@teamswork.app"
                      },
                      "description": "ticket description\nline 1\nline 2",
                      "priority": "Urgent",
                      "assignee": {
                        "id": "708edddc-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                        "name": "Alex Wilber",
                        "email": "AlexW@xxxxxxxx.com"
                      },
                      "expectedDate": "2023-07-26",
                      "tags": [
                        {
                          "tagCategoryId": "2283653a-8d36-40eb-9a68-73eb3b331811",
                          "text": "my tag"
                        }
                      ],
                      "customFields": {
                        "146db0c4-de24-4818-a131-a27161bb7ad0": [
                          {
                            "id": "053660b7-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                            "name": "Allan Deyoung",
                            "email": "AllanD@xxxxxxxx.com"
                          }
                        ],
                        "fef751d6-067d-431b-8a6d-667056eff6ee": [
                          "70d42d78-899a-4d5e-8cf0-79a0e4a6b0b1"
                        ],
                        "4aad4ef9-3242-4bb6-87f7-29428567429f": "long text area\nbla bla bla",
                        "7670050a-cf1a-4d3d-8179-5eba888dea5f": "text in custom field",
                        "862bd88d-f691-4a7b-a89a-f6f48550fc27": true,
                        "5b9f56bc-ec6a-45a3-b7ce-c25e1d8cfd69": [
                          "f72541a9-c964-4c81-bc1a-4f1f2d948416"
                        ],
                        "7ee98e41-c4d0-4d4c-beb9-2b7f8f8c35c8": "2023-07-26"
                      }
                    },
                    "user": {
                      "id": "053660b7-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                      "name": "Jason Doe",
                      "email": "jason.doe@xxxxxxxx.com"
                    }
                  }
                },
                "email-to-ticket": {
                  "summary": "Email-to-ticket workflow (set all requestor fields to email)",
                  "value": {
                    "ticket": {
                      "title": "Email to Ticket First",
                      "requestor": {
                        "id": "john.doe@contoso.com",
                        "name": "john.doe@contoso.com",
                        "email": "john.doe@contoso.com"
                      }
                    },
                    "user": {
                      "id": "053660b7-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                      "name": "Jason Doe",
                      "email": "jason.doe@teamswork.app"
                    }
                  }
                },
                "with-html-description": {
                  "summary": "Ticket with a sanitized HTML description",
                  "value": {
                    "ticket": {
                      "title": "Printer is unavailable",
                      "requestor": {
                        "id": "053660b7-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                        "name": "Jason Doe",
                        "email": "jason.doe@teamswork.app"
                      },
                      "description_HTML": "<p>The <strong>office printer</strong> is unavailable.</p>"
                    },
                    "user": {
                      "id": "053660b7-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                      "name": "Jason Doe",
                      "email": "jason.doe@teamswork.app"
                    }
                  }
                }
              }
            }
          },
          "description": "Ticket creation payload."
        },
        "responses": {
          "201": {
            "description": "Ticket created successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ITicketResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request. Missing or invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized. Invalid or missing API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{ticketId}": {
      "get": {
        "summary": "Get a ticket",
        "description": "Retrieve the full details of a ticket by its UUID.",
        "operationId": "get-ticket",
        "parameters": [
          {
            "name": "ticketId",
            "in": "path",
            "description": "UUID of the ticket.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "timezone",
            "in": "query",
            "description": "Timezone offset of the caller.",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "description": "Set to description_HTML to include the sanitized HTML description alongside the plain-text description.",
            "schema": {
              "type": "string",
              "enum": [
                "description_HTML"
              ]
            },
            "example": "description_HTML"
          }
        ],
        "responses": {
          "200": {
            "description": "Ticket details.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "item": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/ITicket"
                        }
                      ],
                      "description": "Ticket matching the requested ticket ID."
                    },
                    "error": {
                      "type": "boolean",
                      "description": "Whether the request resulted in an error."
                    },
                    "message": {
                      "type": "string",
                      "description": "Human-readable status message from the API."
                    }
                  },
                  "description": "Response containing the requested ticket."
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Ticket not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          }
        },
        "x-example": "GET [Base URL]/tickets/a261xxxx-xxxx-xxxx-xxxx-xxxxxxxx1797?key={your_API_Key}&timezone=0"
      },
      "put": {
        "summary": "Update a ticket",
        "description": "Update an existing ticket by UUID. Only include fields you want to change. Use description for plain text or description_HTML for sanitized HTML; when both are supplied, description takes precedence.",
        "operationId": "update-ticket",
        "parameters": [
          {
            "name": "ticketId",
            "in": "path",
            "description": "UUID of the ticket.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "timezone",
            "in": "query",
            "description": "Timezone offset of the caller.",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "description": "Set to description_HTML to include the sanitized HTML description in the updated ticket response.",
            "schema": {
              "type": "string",
              "enum": [
                "description_HTML"
              ]
            },
            "example": "description_HTML"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/updateTicketRequest"
              },
              "example": {
                "ticket": {
                  "title": "My 2nd ticket",
                  "requestor": {
                    "id": "053660b7-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                    "name": "Jason Doe",
                    "email": "john.doe@wwwwww.com"
                  },
                  "priority": "Urgent",
                  "assignee": {
                    "id": "708edddc-xxxx-xxxx-xxxx-xxxxxxxxxx",
                    "name": "Alex Wilber",
                    "email": "AlexW@wwwwwww.com"
                  },
                  "customFields": {
                    "dcd58c80-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxx": [
                      {
                        "id": "053660b7-xxxx-xxxx-xxxx-xxxxxxxxxx",
                        "name": "Allan Deyoung",
                        "email": "AllanD@xxxxxxxxxxx.com"
                      }
                    ]
                  }
                },
                "user": {
                  "id": "053660b7-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                  "name": "Jason Doe",
                  "email": "jason.doe@wwwwwww.com"
                }
              }
            }
          },
          "description": "Ticket update payload."
        },
        "responses": {
          "200": {
            "description": "Updated ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "item": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/ITicket"
                        }
                      ],
                      "description": "Ticket after the update was applied."
                    },
                    "error": {
                      "type": "boolean",
                      "description": "Whether the request resulted in an error."
                    },
                    "message": {
                      "type": "string",
                      "description": "Human-readable status message from the API."
                    }
                  },
                  "description": "Response containing the updated ticket."
                }
              }
            }
          },
          "400": {
            "description": "Bad request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Ticket not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          }
        },
        "x-example": "PUT [Base URL]/tickets/a261xxxx-xxxx-xxxx-xxxx-xxxxxxxx1797?key={your_API_Key}&timezone=0"
      }
    },
    "/tickets/{ticketId}/status": {
      "put": {
        "summary": "Update ticket status",
        "description": "Move a ticket to a valid next workflow state. For custom workflows, status is the target workflow-state ID returned by GET /instance or in the ticket workflow. The transition must be allowed from the ticket's current state.",
        "operationId": "update-ticket-status",
        "parameters": [
          {
            "name": "ticketId",
            "in": "path",
            "description": "UUID of the ticket.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "timezone",
            "in": "query",
            "description": "Timezone offset of the caller.",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/updateTicketStatusRequest"
              },
              "example": {
                "status": "Resolved",
                "resolution": "fixed",
                "comment": "Great job!",
                "user": {
                  "id": "23424-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                  "name": "Jason Doe",
                  "email": "jason.doe@wwww.com"
                }
              }
            }
          },
          "description": "Ticket status update payload."
        },
        "responses": {
          "200": {
            "description": "Updated ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "item": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/ITicket"
                        }
                      ],
                      "description": "Ticket after the status change was applied."
                    },
                    "error": {
                      "type": "boolean",
                      "description": "Whether the request resulted in an error."
                    },
                    "message": {
                      "type": "string",
                      "description": "Human-readable status message from the API."
                    }
                  },
                  "description": "Response containing the ticket after the status update."
                }
              }
            }
          },
          "400": {
            "description": "Bad request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Ticket not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          }
        },
        "x-example": "PUT [Base URL]/tickets/a261xxxx-xxxx-xxxx-xxxx-xxxxxxxx1797/status?key={your_API_Key}&timezone=0"
      }
    },
    "/tickets/{ticketId}/activities": {
      "get": {
        "summary": "Get ticket activities",
        "description": "Retrieve ticket activities in reverse chronological order. comment is plain text; request include=comment_HTML when sanitized HTML is also needed. Pagination uses the continuationToken response value.",
        "operationId": "get-ticket-activities",
        "parameters": [
          {
            "name": "ticketId",
            "in": "path",
            "description": "UUID of the ticket.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "description": "Set to comment_HTML to include sanitized HTML in comment_HTML while comment remains plain text.",
            "schema": {
              "type": "string",
              "enum": [
                "comment_HTML"
              ]
            },
            "example": "comment_HTML"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum number of activities to return. When omitted, all matching activities are requested.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "continuationToken",
            "in": "header",
            "required": false,
            "description": "Token from the previous response to fetch the next activity page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of activities.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IActivity"
                      },
                      "description": "Activities recorded on the ticket."
                    },
                    "error": {
                      "type": "boolean",
                      "description": "Whether the request resulted in an error."
                    },
                    "message": {
                      "type": "string",
                      "description": "Human-readable status message from the API."
                    },
                    "continuationToken": {
                      "type": "string",
                      "nullable": true,
                      "description": "Pass this value in the continuationToken header to fetch the next page."
                    }
                  },
                  "description": "Response containing activities recorded on the ticket."
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Ticket not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          }
        },
        "x-example": "GET [Base URL]/tickets/a261xxxx-xxxx-xxxx-xxxx-xxxxxxxx1797/activities?key={your_API_Key}&timezone=0"
      },
      "post": {
        "summary": "Add a comment to a ticket",
        "description": "Add a comment. Use comment for plain text or comment_HTML for sanitized HTML; when both are supplied, comment takes precedence.",
        "operationId": "insert-comment",
        "parameters": [
          {
            "name": "ticketId",
            "in": "path",
            "description": "UUID of the ticket.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "description": "Set to comment_HTML to include sanitized HTML in the created activity response.",
            "schema": {
              "type": "string",
              "enum": [
                "comment_HTML"
              ]
            },
            "example": "comment_HTML"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/insertCommentRequest"
              },
              "example": {
                "comment": "comment from API",
                "user": {
                  "id": "053660b7-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                  "name": "Jason Doe",
                  "email": "jason.doe@wwwwww.com"
                }
              }
            }
          },
          "description": "Comment creation payload."
        },
        "responses": {
          "201": {
            "description": "Comment created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "item": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/IComment"
                        }
                      ],
                      "description": "Comment activity that was created."
                    },
                    "error": {
                      "type": "boolean",
                      "description": "Whether the request resulted in an error."
                    },
                    "message": {
                      "type": "string",
                      "description": "Human-readable status message from the API."
                    }
                  },
                  "description": "Response containing the created comment activity."
                }
              }
            }
          },
          "400": {
            "description": "Bad request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Ticket not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          }
        },
        "x-example": "POST [Base URL]/tickets/a261xxxx-xxxx-xxxx-xxxx-xxxxxxxx1797/activities?key={your_API_Key}&timezone=0"
      }
    },
    "/tickets/{ticketId}/attachments": {
      "get": {
        "summary": "Get ticket attachments",
        "description": "Get list of attachments associated with a specific ticket.",
        "operationId": "get-ticket-attachments",
        "parameters": [
          {
            "name": "ticketId",
            "in": "path",
            "description": "UUID of the ticket.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "timezone",
            "in": "query",
            "description": "Timezone offset of the caller.",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of attachments.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IAttachment"
                      },
                      "description": "Attachments associated with the ticket."
                    },
                    "message": {
                      "type": "string",
                      "description": "Human-readable result message."
                    },
                    "error": {
                      "type": "boolean",
                      "description": "Whether the request returned an error."
                    }
                  },
                  "description": "Response containing attachments associated with the ticket."
                },
                "example": {
                  "items": [
                    {
                      "id": "1234567890123456",
                      "caption": "1234567890123456-sample_image.png",
                      "createdDateTime": "2025-01-09T08:00:00.000Z",
                      "createdBy": "Jason Doe",
                      "src": "https://exampleblobstorage.blob.core.windows.net/sample/1234567890123456-sample_image.png",
                      "isArchive": false
                    }
                  ],
                  "message": "Successfully executed request",
                  "error": false
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Ticket not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          }
        },
        "x-example": "GET [Base URL]/tickets/{ticketId}/attachments?key={your_API_Key}&timezone=0"
      },
      "post": {
        "summary": "Add link attachments to a ticket",
        "description": "Add hyperlink attachments with application/json, or upload files with multipart/form-data. The response item.activityId can be used with GET /tickets/activity/{activityId}/attachments.",
        "operationId": "insert-ticket-attachments",
        "parameters": [
          {
            "name": "ticketId",
            "in": "path",
            "description": "UUID of the ticket.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "timezone",
            "in": "query",
            "description": "Timezone offset of the caller.",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "description": "Set to comment_HTML to include sanitized HTML in the created attachment activity response.",
            "schema": {
              "type": "string",
              "enum": [
                "comment_HTML"
              ]
            },
            "example": "comment_HTML"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/insertAttachmentLinkRequest"
              },
              "example": {
                "comment": "This is a sample comment for testing purposes.",
                "isPrivate": false,
                "attachments": [
                  {
                    "caption": "Example Site 1",
                    "src": "https://www.example1.com"
                  },
                  {
                    "caption": "Example Site 2",
                    "src": "https://www.example2.com"
                  }
                ],
                "user": {
                  "id": "053660b7-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                  "name": "Jason Doe",
                  "email": "jason.doe@teamswork.app"
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/insertAttachmentMultipartRequest"
              },
              "encoding": {
                "files": {
                  "style": "form",
                  "explode": true
                }
              },
              "examples": {
                "file-upload": {
                  "summary": "Upload one or more files",
                  "value": {
                    "files": [
                      "(binary)"
                    ],
                    "comment": "Supporting files",
                    "isPrivate": "false",
                    "user": "{\"id\":\"053660b7-xxxx-xxxx-xxxx-xxxxxxxxxxx\",\"name\":\"Jason Doe\",\"email\":\"jason.doe@teamswork.app\"}"
                  }
                }
              }
            }
          },
          "description": "Link attachment creation payload."
        },
        "responses": {
          "201": {
            "description": "Attachments added.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "item": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/IAttachmentActivityResponse"
                        }
                      ],
                      "description": "Attachment activity created for the ticket."
                    },
                    "error": {
                      "type": "boolean",
                      "description": "Whether the request returned an error."
                    },
                    "message": {
                      "type": "string",
                      "description": "Human-readable result message."
                    }
                  },
                  "description": "Response containing the created attachment activity."
                }
              }
            }
          },
          "400": {
            "description": "Bad request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          }
        },
        "x-example": "POST [Base URL]/tickets/{ticketId}/attachments?key={your_API_Key}&timezone=0"
      }
    },
    "/tickets/activity/{activityId}/attachments": {
      "get": {
        "summary": "Get activity attachments",
        "description": "Get list of attachments linked to a specific attachment activity. IMPORTANT: the activityId must be the value of item.activityId from the POST /tickets/{ticketId}/attachments response. Activity IDs from GET /tickets/{ticketId}/activities are not valid here — only attachment activities are supported, and passing a non-attachment activity ID will result in a 500 Internal error.",
        "operationId": "get-activity-attachments",
        "parameters": [
          {
            "name": "activityId",
            "in": "path",
            "description": "ID of the attachment activity. Must come from item.activityId in the POST /tickets/{ticketId}/attachments response.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "timezone",
            "in": "query",
            "description": "Timezone offset of the caller.",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of attachments.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IAttachment"
                      },
                      "description": "Attachments associated with the activity."
                    },
                    "message": {
                      "type": "string",
                      "description": "Human-readable result message."
                    },
                    "error": {
                      "type": "boolean",
                      "description": "Whether the request returned an error."
                    }
                  },
                  "description": "Response containing attachments associated with the activity."
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Attachment activity not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          }
        },
        "x-example": "GET [Base URL]/tickets/activity/{activityId}/attachments?key={your_API_Key}&timezone=0"
      }
    },
    "/instance": {
      "get": {
        "summary": "Get instance details",
        "description": "Retrieve instance details including custom fields definitions and assignee list. Use this to discover available custom field IDs before creating or updating tickets.",
        "operationId": "get-instance",
        "parameters": [
          {
            "name": "timezone",
            "in": "query",
            "description": "Timezone offset of the caller.",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Instance details.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "item": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/IInstance"
                        }
                      ],
                      "description": "Ticketing instance settings and metadata."
                    },
                    "error": {
                      "type": "boolean",
                      "description": "Whether the request resulted in an error."
                    },
                    "message": {
                      "type": "string",
                      "description": "Human-readable status message from the API."
                    }
                  },
                  "description": "Response containing Ticketing instance settings and metadata."
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          }
        },
        "x-example": "GET [Base URL]/instance?key={your_API_Key}&timezone=0"
      }
    },
    "/tags": {
      "get": {
        "summary": "Get tag categories",
        "description": "Retrieve all tag categories and their tags.",
        "operationId": "get-tag-categories",
        "parameters": [],
        "responses": {
          "200": {
            "description": "List of tag categories.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ITagCategory"
                      },
                      "description": "Tag categories configured for the Ticketing instance."
                    },
                    "error": {
                      "type": "boolean",
                      "description": "Whether the request resulted in an error."
                    },
                    "message": {
                      "type": "string",
                      "description": "Human-readable status message from the API."
                    }
                  },
                  "description": "Response containing tag categories configured for the Ticketing instance."
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IErrorResponse"
                }
              }
            }
          }
        },
        "x-example": "GET [Base URL]/tags?key={your_API_Key}&timezone=0"
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "name": "key",
        "in": "query",
        "description": "Primary Ticketing instance API key from the Ticketing App settings. Example: ?key={your_API_Key}"
      }
    },
    "schemas": {
      "IUser": {
        "description": "Provide id, name, and email, or email only with a Microsoft Graph bearer token.",
        "oneOf": [
          {
            "title": "Full user",
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "Azure Object ID or email (for email-to-ticket)."
              },
              "name": {
                "type": "string",
                "description": "Display name."
              },
              "email": {
                "type": "string",
                "description": "Email address."
              }
            },
            "required": [
              "id",
              "name",
              "email"
            ]
          },
          {
            "title": "Email-only user",
            "type": "object",
            "description": "For ticket creation and updates only. Requires a Microsoft Graph access token in the Authorization: Bearer <token> header.",
            "additionalProperties": false,
            "properties": {
              "email": {
                "type": "string",
                "format": "email",
                "minLength": 1,
                "description": "Email address used to retrieve the user details from Microsoft Graph."
              }
            },
            "required": [
              "email"
            ]
          }
        ]
      },
      "IPriority": {
        "type": "string",
        "description": "Ticket priority. Empty string when no priority is set.",
        "enum": [
          "",
          "Low",
          "Medium",
          "Important",
          "Urgent"
        ]
      },
      "IStatus": {
        "type": "string",
        "description": "Workflow state ID or display label. Default workflows use Open, Reopened, In Progress, Resolved, and Closed; custom workflows can use other values.",
        "example": "In Progress"
      },
      "IResolution": {
        "type": "string",
        "description": "Resolution reason used when resolving or closing a ticket.",
        "enum": [
          "fixed",
          "cannotResolve",
          "cancelled"
        ]
      },
      "ITicketTag": {
        "type": "object",
        "description": "Tag assigned to a ticket, including the tag category ID and tag text.",
        "properties": {
          "tagCategoryId": {
            "type": "string",
            "description": "ID of the tag category."
          },
          "text": {
            "type": "string",
            "description": "Tag text value."
          }
        },
        "required": [
          "tagCategoryId",
          "text"
        ],
        "additionalProperties": false
      },
      "ITicket": {
        "type": "object",
        "description": "Public ticket representation. Write requests accept the writable subset; server-managed fields are returned in responses. Custom-field IDs are available from GET /instance.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Internal UUID of the ticket. Present in responses."
          },
          "ticketNo": {
            "type": "integer",
            "description": "Human-readable ticket number (e.g. 1839). Present in responses."
          },
          "title": {
            "type": "string",
            "description": "Short ticket title shown in ticket lists and details."
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IStatus"
              }
            ],
            "description": "Current workflow status of the ticket."
          },
          "requestor": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IUser"
              }
            ],
            "description": "User who requested or raised the ticket."
          },
          "assignee": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IUser"
              }
            ],
            "description": "Current assignee responsible for the ticket."
          },
          "description": {
            "type": "string",
            "description": "Plain-text ticket description. HTML characters are escaped and line breaks are preserved. If description and description_HTML are both sent, description takes precedence."
          },
          "priority": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IPriority"
              }
            ],
            "description": "Priority level assigned to the ticket."
          },
          "expectedDate": {
            "type": "string",
            "format": "date",
            "description": "Date only, format YYYY-MM-DD (e.g. 2026-04-01). IMPORTANT: using a datetime format (e.g. 2026-04-01T17:00:00Z) when customFields is also present causes a silent validation failure — the ticket is not created and no error message is returned. Returned as empty string when no expected date is set."
          },
          "tags": {
            "type": "array",
            "description": "Tags currently applied to the ticket.",
            "items": {
              "$ref": "#/components/schemas/ITicketTag"
            }
          },
          "customFields": {
            "type": "object",
            "description": "Key-value pairs where key is the 36-character custom field ID. Value type depends on field type: string (text/date), boolean (toggle), array of strings (item picker), array of IUser (people picker)."
          },
          "createdOn": {
            "type": "string",
            "format": "date-time",
            "description": "Creation datetime. Present in responses."
          },
          "lastUpdatedOn": {
            "type": "string",
            "format": "date-time",
            "description": "Last update datetime. Present in responses."
          },
          "createdBy": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IUser"
              }
            ],
            "description": "User who created the ticket."
          },
          "lastUpdatedBy": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IUser"
              }
            ],
            "description": "User who last updated the ticket."
          },
          "resolvedStatus": {
            "type": "array",
            "description": "List of statuses that are treated as resolved in this Ticketing instance. Present in responses.",
            "items": {
              "type": "string",
              "description": "A status value treated as resolved, such as Resolved or Closed."
            }
          },
          "firstResponseOn": {
            "type": "string",
            "format": "date-time",
            "description": "Datetime when the ticket first received a response."
          },
          "category": {
            "type": "string",
            "description": "Ticket category. Deprecated; retained for backward compatibility with existing responses.",
            "deprecated": true
          },
          "department": {
            "type": "string",
            "description": "Department associated with the ticket. Deprecated; retained for backward compatibility with existing responses.",
            "deprecated": true
          },
          "trackingId": {
            "type": "string",
            "description": "External tracking identifier for the ticket."
          },
          "assigneeUnseenEventCnt": {
            "type": "integer",
            "description": "Number of activity events the assignee has not yet viewed."
          },
          "requestorUnseenEventCnt": {
            "type": "integer",
            "description": "Number of activity events the requestor has not yet viewed."
          },
          "isCustomWorkflow": {
            "type": "boolean",
            "description": "Whether this ticket uses a custom workflow."
          },
          "workflow": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IWorkflowState"
            },
            "description": "Workflow states and transitions configured for this ticket."
          },
          "description_HTML": {
            "type": "string",
            "description": "Sanitized HTML ticket description. Accepted on create/update. Returned only when include=description_HTML is requested; description is still returned as plain text. Script-capable elements, event-handler attributes, and javascript: URLs are removed."
          },
          "resolution": {
            "type": "string",
            "description": "Most recently recorded resolution label, when available."
          },
          "firstResolutionOn": {
            "type": "string",
            "format": "date-time",
            "description": "Datetime when the ticket was first resolved."
          },
          "lastResolutionOn": {
            "type": "string",
            "format": "date-time",
            "description": "Datetime when the ticket was most recently resolved."
          },
          "lastResolutionComment": {
            "type": "string",
            "description": "Comment recorded for the latest resolution."
          },
          "isFrtBreached": {
            "type": "boolean",
            "nullable": true,
            "description": "Whether the first-response SLA was breached."
          },
          "isRtBreached": {
            "type": "boolean",
            "nullable": true,
            "description": "Whether the resolution-time SLA was breached."
          },
          "isFrtEscalated": {
            "type": "boolean",
            "nullable": true,
            "description": "Whether the first-response SLA was escalated."
          },
          "isRtEscalated": {
            "type": "boolean",
            "nullable": true,
            "description": "Whether the resolution-time SLA was escalated."
          },
          "origin": {
            "type": "string",
            "enum": [
              "WebApp",
              "Email",
              "API"
            ],
            "description": "Channel where the ticket originated."
          }
        }
      },
      "IAttachmentActivityResponse": {
        "type": "object",
        "description": "Response body from POST /tickets/{ticketId}/attachments. Contains activityId which must be used with GET /tickets/activity/{activityId}/attachments.",
        "properties": {
          "activityId": {
            "type": "string",
            "format": "uuid",
            "description": "ID of the created attachment activity. Use this with GET /tickets/activity/{activityId}/attachments."
          },
          "comment": {
            "type": "string",
            "description": "Comment text stored with the attachment activity."
          },
          "ticketId": {
            "type": "string",
            "format": "uuid",
            "description": "ID of the ticket that owns the attachment activity."
          },
          "attachments": {
            "type": "array",
            "description": "Attachments added in this activity.",
            "items": {
              "$ref": "#/components/schemas/IAttachment"
            }
          },
          "user": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IUser"
              }
            ],
            "description": "User who created the attachment activity."
          },
          "ticketNo": {
            "type": "integer",
            "description": "Human-readable number of the ticket that owns the activity."
          },
          "comment_HTML": {
            "type": "string",
            "description": "Sanitized HTML comment, returned only when include=comment_HTML is requested."
          }
        }
      },
      "IActivity": {
        "type": "object",
        "description": "An activity on a ticket — either a status change or a comment.",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID of the activity record."
          },
          "ticketId": {
            "type": "string",
            "description": "ID of the ticket the activity belongs to."
          },
          "comment": {
            "type": "string",
            "description": "Plain-text activity comment. Request include=comment_HTML for the sanitized HTML form."
          },
          "isPrivate": {
            "type": "boolean",
            "description": "Whether the activity is visible only to internal agents."
          },
          "createdDateTime": {
            "type": "string",
            "format": "date-time",
            "description": "When the activity was created."
          },
          "createdBy": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IUser"
              }
            ],
            "description": "User who created the activity."
          },
          "comment_HTML": {
            "type": "string",
            "description": "Sanitized HTML comment, returned only when include=comment_HTML is requested."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IAttachment"
            },
            "description": "Attachments associated with this activity."
          },
          "changes": {
            "type": "array",
            "description": "Field changes recorded by this activity.",
            "items": {
              "$ref": "#/components/schemas/IActivityChange"
            }
          }
        }
      },
      "IComment": {
        "type": "object",
        "description": "Public representation of a newly created comment activity.",
        "properties": {
          "activityId": {
            "type": "string",
            "description": "ID of the created activity."
          },
          "ticketId": {
            "type": "string",
            "format": "uuid",
            "description": "Internal UUID of the ticket."
          },
          "ticketNo": {
            "type": "integer",
            "description": "Human-readable ticket number."
          },
          "comment": {
            "type": "string",
            "description": "Plain-text comment."
          },
          "comment_HTML": {
            "type": "string",
            "description": "Sanitized HTML comment, returned only when include=comment_HTML is requested."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IAttachment"
            },
            "description": "Attachments created with the comment activity."
          },
          "user": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IUser"
              }
            ],
            "description": "User who created the comment activity."
          }
        },
        "required": [
          "activityId",
          "ticketId",
          "comment",
          "attachments",
          "user"
        ]
      },
      "IAttachment": {
        "type": "object",
        "description": "Attachment or attachment link associated with a ticket activity.",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID of the attachment."
          },
          "caption": {
            "type": "string",
            "description": "Display caption for the attachment."
          },
          "createdDateTime": {
            "type": "string",
            "format": "date-time",
            "description": "When the attachment was added."
          },
          "createdBy": {
            "type": "string",
            "description": "Identifier or name of the user who added the attachment."
          },
          "src": {
            "type": "string",
            "format": "uri",
            "description": "Direct URL to the attachment content."
          },
          "isArchive": {
            "type": "boolean",
            "description": "Whether the attachment is an archive file."
          },
          "isHyperlink": {
            "type": "boolean",
            "description": "Whether the attachment is represented as an external link."
          },
          "isImage": {
            "type": "boolean",
            "description": "Whether the attachment is an image."
          },
          "filename": {
            "type": "string",
            "description": "Original file name of the attachment."
          }
        }
      },
      "IAttachmentLink": {
        "type": "object",
        "description": "Link attachment to add to a ticket.",
        "properties": {
          "src": {
            "type": "string",
            "format": "uri",
            "description": "URL of the link."
          },
          "caption": {
            "type": "string",
            "description": "Display name for the link."
          }
        },
        "required": [
          "src",
          "caption"
        ]
      },
      "ITagCategory": {
        "type": "object",
        "description": "Tag category configured for the Ticketing instance.",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID of the tag category."
          },
          "instanceId": {
            "type": "string",
            "description": "ID of the Ticketing instance that owns the category."
          },
          "text": {
            "type": "string",
            "description": "Display name of the tag category."
          },
          "color": {
            "type": "string",
            "description": "Display color used for the tag category."
          },
          "tags": {
            "type": "array",
            "description": "Tags available under this category.",
            "items": {
              "$ref": "#/components/schemas/ITag"
            }
          },
          "deleted": {
            "type": "boolean",
            "description": "Whether the tag category has been deleted."
          }
        }
      },
      "ITag": {
        "type": "object",
        "description": "Tag value inside a tag category.",
        "properties": {
          "text": {
            "type": "string",
            "description": "Display text of the tag."
          },
          "deleted": {
            "type": "boolean",
            "description": "Whether the tag has been deleted."
          }
        }
      },
      "ICustomField": {
        "type": "object",
        "description": "Custom field definition returned by GET /instance.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "ID used as a key in ticket.customFields."
          },
          "title": {
            "type": "string",
            "description": "Display label."
          },
          "type": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ICustomFieldType"
              }
            ],
            "description": "Custom field type definition."
          },
          "isMandatory": {
            "type": "boolean",
            "description": "Whether a value is required for this custom field."
          },
          "status": {
            "type": "string",
            "enum": [
              "hidden",
              "visible"
            ],
            "description": "Whether the custom field is shown or hidden."
          },
          "defaultValue": {
            "nullable": true,
            "description": "Configured default value; its type depends on the custom field type."
          },
          "options": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ICustomFieldOption"
            },
            "description": "Selectable options for list-like custom fields."
          },
          "isMultiple": {
            "type": "boolean",
            "description": "Whether the field accepts more than one selected value."
          }
        },
        "required": [
          "id",
          "title",
          "type",
          "isMandatory",
          "status"
        ]
      },
      "IInstance": {
        "type": "object",
        "description": "Ticketing instance settings and metadata.",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID of the Ticketing instance."
          },
          "groupId": {
            "type": "string",
            "description": "Microsoft 365 group ID associated with the instance."
          },
          "enabled": {
            "type": "boolean",
            "description": "Whether the instance is currently enabled."
          },
          "tenantId": {
            "type": "string",
            "description": "Microsoft Entra tenant ID associated with the instance."
          },
          "teamId": {
            "type": "string",
            "description": "Microsoft Teams team ID hosting the instance."
          },
          "channelId": {
            "type": "string",
            "description": "Microsoft Teams channel ID hosting the instance."
          },
          "subscriptionId": {
            "type": "string",
            "description": "Subscription identifier tied to the instance."
          },
          "customFields": {
            "type": "array",
            "description": "All custom fields configured for the instance.",
            "items": {
              "$ref": "#/components/schemas/ICustomField"
            }
          },
          "customFieldsLeft": {
            "type": "array",
            "description": "Custom fields shown in the left column of the ticket form.",
            "items": {
              "$ref": "#/components/schemas/ICustomField"
            }
          },
          "customFieldsRight": {
            "type": "array",
            "description": "Custom fields shown in the right column of the ticket form.",
            "items": {
              "$ref": "#/components/schemas/ICustomField"
            }
          },
          "assignees": {
            "type": "object",
            "description": "Assignee configuration for the instance.",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "teamsOwner",
                  "customAssignee"
                ],
                "description": "How assignees are managed for the instance."
              },
              "peoples": {
                "type": "array",
                "description": "Users available for assignment when custom assignees are configured.",
                "items": {
                  "$ref": "#/components/schemas/IPersona"
                }
              }
            }
          },
          "isAutomaticAssignTickets": {
            "type": "boolean",
            "description": "Whether new tickets are automatically assigned."
          },
          "isAutoAssignIdleTickets": {
            "type": "boolean",
            "description": "Whether idle tickets are reassigned automatically."
          },
          "dayBeforeTicketsIdle": {
            "type": "integer",
            "description": "Number of idle days before automatic reassignment runs."
          },
          "_ts": {
            "type": "integer",
            "description": "Server-side timestamp of the last instance update."
          },
          "optionalFieldsLeft": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ICustomField"
            },
            "description": "Built-in optional fields shown in the left column of the ticket form."
          },
          "optionalFieldsRight": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ICustomField"
            },
            "description": "Built-in optional fields shown in the right column of the ticket form."
          },
          "workflows": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "description": "Configured instance workflow definition."
            },
            "description": "Workflow definitions configured for the Ticketing instance."
          },
          "displayName": {
            "type": "string",
            "description": "Configured public display name."
          },
          "code": {
            "type": "string",
            "description": "Short instance code used in ticket references."
          },
          "appVersion": {
            "type": "string",
            "description": "Installed Ticketing App version."
          },
          "instanceType": {
            "type": "string",
            "enum": [
              "channel",
              "virtual"
            ],
            "description": "Instance hosting type."
          },
          "instanceName": {
            "type": "string",
            "description": "Display name of the Ticketing instance as returned by the public API."
          },
          "sla": {
            "type": "object",
            "additionalProperties": true,
            "description": "SLA configuration returned for the Ticketing instance."
          }
        }
      },
      "insertTicketRequest": {
        "type": "object",
        "description": "Request body for creating a ticket.",
        "properties": {
          "ticket": {
            "description": "Ticket fields to create. title and requestor are required. Use description for plain text or description_HTML for sanitized HTML.",
            "allOf": [
              {
                "$ref": "#/components/schemas/ITicket"
              },
              {
                "required": [
                  "title",
                  "requestor"
                ]
              }
            ]
          },
          "user": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IUser"
              }
            ],
            "description": "User performing the create action."
          }
        },
        "required": [
          "ticket",
          "user"
        ]
      },
      "updateTicketRequest": {
        "type": "object",
        "description": "Request body for updating a ticket.",
        "properties": {
          "ticket": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ITicket"
              }
            ],
            "description": "Ticket fields to update. Use description for plain text or description_HTML for sanitized HTML; omit fields that should not change."
          },
          "user": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IUser"
              }
            ],
            "description": "User performing the update action."
          }
        },
        "required": [
          "ticket",
          "user"
        ]
      },
      "updateTicketStatusRequest": {
        "type": "object",
        "description": "Request body for changing a ticket status.",
        "properties": {
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IStatus"
              }
            ],
            "description": "Target workflow-state ID. It must be one of the valid nextSteps for the ticket's current workflow state."
          },
          "resolution": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IResolution"
              }
            ],
            "description": "Resolution code to store when moving the ticket to a resolved state."
          },
          "comment": {
            "type": "string",
            "description": "Optional note recorded with the status change."
          },
          "user": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IUser"
              }
            ],
            "description": "User performing the status change."
          }
        },
        "required": [
          "status",
          "user"
        ]
      },
      "insertCommentRequest": {
        "type": "object",
        "description": "Request body for adding a comment to a ticket.",
        "properties": {
          "comment": {
            "type": "string",
            "description": "Plain-text comment. HTML characters are escaped. Takes precedence over comment_HTML when both are supplied."
          },
          "user": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IUser"
              }
            ],
            "description": "User performing the comment action."
          },
          "comment_HTML": {
            "type": "string",
            "description": "Sanitized HTML comment. Script-capable content is removed."
          },
          "isPrivate": {
            "type": "boolean",
            "default": false,
            "description": "Whether the comment is private to internal agents."
          }
        },
        "required": [
          "user"
        ],
        "oneOf": [
          {
            "required": [
              "comment"
            ]
          },
          {
            "required": [
              "comment_HTML"
            ]
          }
        ]
      },
      "insertAttachmentLinkRequest": {
        "type": "object",
        "description": "Request body for adding link attachments to a ticket.",
        "properties": {
          "comment": {
            "type": "string",
            "description": "Plain-text comment shown with the attachments. Takes precedence over comment_HTML when both are supplied."
          },
          "attachments": {
            "type": "array",
            "description": "Attachment links to add to the ticket.",
            "items": {
              "$ref": "#/components/schemas/IAttachmentLink"
            }
          },
          "user": {
            "allOf": [
              {
                "$ref": "#/components/schemas/IUser"
              }
            ],
            "description": "User performing the attachment action."
          },
          "isPrivate": {
            "type": "boolean",
            "default": false,
            "description": "Whether the attachment activity should be private to internal agents."
          },
          "comment_HTML": {
            "type": "string",
            "description": "Sanitized HTML comment shown with the attachments."
          }
        },
        "required": [
          "attachments",
          "user",
          "isPrivate"
        ],
        "oneOf": [
          {
            "required": [
              "comment"
            ]
          },
          {
            "required": [
              "comment_HTML"
            ]
          }
        ]
      },
      "IWorkflowTransition": {
        "type": "object",
        "description": "A transition between two workflow states.",
        "properties": {
          "targetId": {
            "type": "string",
            "description": "Identifier of the destination workflow state."
          },
          "transitionLabel": {
            "type": "string",
            "description": "Label shown on the transition action."
          },
          "transitionIcon": {
            "type": "string",
            "description": "Icon name shown alongside the transition action."
          },
          "authorizedUsers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Roles permitted to trigger this transition (e.g. owner, assignee, requestor)."
          },
          "recordComment": {
            "type": "boolean",
            "description": "Whether triggering this transition requires a comment."
          },
          "recordResolutionSLA": {
            "type": "boolean",
            "description": "Whether this transition stops the resolution SLA timer."
          }
        }
      },
      "IWorkflowState": {
        "type": "object",
        "description": "A workflow state with its available outgoing transitions.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Identifier of the workflow state."
          },
          "label": {
            "type": "string",
            "description": "Display label for the state."
          },
          "color": {
            "type": "string",
            "description": "Hex color used to display the state."
          },
          "recordResolutionSLA": {
            "type": "boolean",
            "description": "Whether entering this state stops the resolution SLA timer."
          },
          "nextSteps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IWorkflowTransition"
            },
            "description": "Transitions available from this state."
          }
        }
      },
      "IErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "boolean",
            "example": true,
            "description": "Whether the request failed."
          },
          "message": {
            "type": "string",
            "description": "Human-readable error message."
          },
          "statusCode": {
            "type": "integer",
            "description": "HTTP status code when supplied by the gateway."
          }
        },
        "required": [
          "message"
        ]
      },
      "ITicketResponse": {
        "type": "object",
        "properties": {
          "item": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ITicket"
              }
            ],
            "description": "Ticket returned by the operation."
          },
          "error": {
            "type": "boolean",
            "example": false,
            "description": "Whether the operation failed."
          },
          "message": {
            "type": "string",
            "description": "Human-readable operation result."
          }
        },
        "required": [
          "item",
          "error",
          "message"
        ]
      },
      "IActivityChange": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the ticket field that changed."
          },
          "oldValue": {
            "nullable": true,
            "description": "Value before the activity; type depends on the changed field."
          },
          "newValue": {
            "nullable": true,
            "description": "Value after the activity; type depends on the changed field."
          }
        }
      },
      "insertAttachmentMultipartRequest": {
        "type": "object",
        "description": "Multipart file-upload payload. user and attachments, when present, are JSON-encoded form fields. At least one files part is required.",
        "properties": {
          "files": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "format": "binary"
            },
            "description": "One or more files. Repeat the files field for multiple uploads."
          },
          "comment": {
            "type": "string",
            "description": "Plain-text comment. Takes precedence over comment_HTML."
          },
          "comment_HTML": {
            "type": "string",
            "description": "Sanitized HTML comment."
          },
          "isPrivate": {
            "type": "string",
            "enum": [
              "true",
              "false"
            ],
            "description": "Boolean encoded as a multipart text field."
          },
          "user": {
            "type": "string",
            "description": "JSON-encoded IUser object."
          },
          "attachments": {
            "type": "string",
            "description": "Optional JSON-encoded array of IAttachmentLink objects."
          }
        },
        "required": [
          "files",
          "isPrivate",
          "user"
        ],
        "oneOf": [
          {
            "required": [
              "comment"
            ]
          },
          {
            "required": [
              "comment_HTML"
            ]
          }
        ]
      },
      "ICustomFieldType": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "enum": [
              "1_text",
              "2_textarea",
              "3_date",
              "4_toggle",
              "5_list",
              "6_peoplepicker",
              "7_emailpicker"
            ],
            "description": "Stable custom-field type key."
          },
          "text": {
            "type": "string",
            "description": "Human-readable custom-field type name."
          },
          "data": {
            "type": "object",
            "properties": {
              "icon": {
                "type": "string",
                "description": "Icon identifier used by the Ticketing UI."
              },
              "color": {
                "type": "string",
                "description": "Display color used by the Ticketing UI."
              }
            },
            "description": "Display metadata for the custom-field type."
          }
        },
        "required": [
          "key",
          "text"
        ]
      },
      "ICustomFieldOption": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "Stable option identifier stored in ticket custom-field values."
          },
          "text": {
            "type": "string",
            "description": "Option display text."
          }
        }
      },
      "IPersona": {
        "type": "object",
        "description": "Internal person-picker representation returned in instance configuration.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Microsoft Entra object ID or other stable user identifier."
          },
          "text": {
            "type": "string",
            "description": "Display name."
          },
          "secondaryText": {
            "type": "string",
            "description": "Email address."
          },
          "imageUrl": {
            "type": "string",
            "format": "uri",
            "description": "Optional profile-image URL."
          },
          "imageInitials": {
            "type": "string",
            "description": "Initials used when no profile image is available."
          }
        }
      }
    }
  },
  "security": [
    {
      "apiKey": []
    }
  ]
}
