{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mojeeb-app/json-schema/mojeeb-app-ticket-schema.json",
  "title": "Ticket",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mojeeb-app-openapi.yaml#/components/schemas/Ticket",
  "type": "object",
  "required": [
    "id",
    "agent_id",
    "number",
    "contact_id",
    "conversation_id",
    "lead_id",
    "description",
    "category",
    "priority",
    "status",
    "custom_fields",
    "assigned_to",
    "source",
    "created_at",
    "updated_at",
    "last_activity_at",
    "resolved_at"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "agent_id": {
      "type": "string",
      "format": "uuid"
    },
    "number": {
      "type": "integer",
      "description": "The number customers and your team quote (`#1007`), unique per agent and counting up from 1001. Never reused, even after a delete."
    },
    "contact_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "The person the ticket is about: their name, mobile and the timeline holding the ticket's notes (`getContact`, `listContactNotes`)."
    },
    "conversation_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "The conversation the ticket came from, if any."
    },
    "lead_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "The lead captured in the same conversation, or the lead it was opened for, if any."
    },
    "description": {
      "type": "string",
      "description": "What the customer reported: the problem, what they want done, and any order number or reference."
    },
    "category": {
      "type": [
        "string",
        "null"
      ],
      "description": "A short free-text label for the kind of issue, such as `refund` or `delivery`; the AI writes its own when it opens one."
    },
    "priority": {
      "type": "string",
      "enum": [
        "normal",
        "urgent"
      ]
    },
    "status": {
      "type": "string",
      "description": "The `value` of one of the agent's ticket statuses, or of a status your team has since removed (a ticket keeps its status when the status is removed)."
    },
    "custom_fields": {
      "$ref": "#/$defs/CustomFields"
    },
    "assigned_to": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "The teammate the ticket is assigned to: a `user_id` from `listAgentMembers`. Changed with `assignTicket`."
    },
    "source": {
      "type": "string",
      "enum": [
        "team",
        "ai",
        "api"
      ],
      "description": "Who opened it: a teammate in the dashboard, the AI from a conversation, or an API key."
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "The last change to any of the ticket's fields, by anyone or anything (a customer's follow-up included)."
    },
    "last_activity_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "The last time a person worked the ticket: a status change or a new note on its contact. A new ticket's is its creation. AI replies, follow-ups and assignment don't move it. Filter with `last_activity_since` and `last_activity_before` on `listTickets`."
    },
    "resolved_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When the ticket moved to a closing status (`final: true` in `listTicketFields`, such as `resolved`); null while it is open. Filter open or resolved tickets with `open` on `listTickets`."
    }
  },
  "$defs": {
    "CustomFields": {
      "type": "object",
      "additionalProperties": true,
      "description": "Free-form fields keyed by name, stored as sent (see Partial updates in the API\ndescription for how date-time strings and decimals are normalized). For a lead, use the\nkeys of the agent's own lead fields (`listLeadFields`, `built_in: false`), and the whole\nobject is limited to about 10,000 characters of JSON (`422 invalid_request` beyond).\nFor a lead, a value written to a `number`, `currency`, `boolean`, `date`, `datetime` or\n`timestamp` field must fit that type (`422 invalid_request`; `null` and `\"\"` clear it, and\na value sent unchanged is not re-checked); keys, `options` and `required` are not\nchecked. On update the object merges key by key, and a key sent as `null` stays with the\nvalue `null`.\n"
    }
  }
}