{
  "info": {
    "name": "Nexus365Desk Public API",
    "_postman_id": "n365-public-api-v1",
    "description": "REST access to Nexus365Desk service-desk data (tickets, comments, agents, assets) via Microsoft Graph. Requires the Public API add-on and the setup wizard credentials.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "tenantId", "value": "your-tenant-id-guid" },
    { "key": "clientId", "value": "your-client-id-guid" },
    { "key": "clientSecret", "value": "your-client-secret" },
    { "key": "siteId", "value": "contoso.sharepoint.com,site-collection-guid,site-guid" },
    { "key": "graphBase", "value": "https://graph.microsoft.com/v1.0/sites/{{siteId}}" }
  ],
  "auth": {
    "type": "oauth2",
    "oauth2": [
      { "key": "grant_type", "value": "client_credentials" },
      { "key": "accessTokenUrl", "value": "https://login.microsoftonline.com/{{tenantId}}/oauth2/v2.0/token" },
      { "key": "clientId", "value": "{{clientId}}" },
      { "key": "clientSecret", "value": "{{clientSecret}}" },
      { "key": "scope", "value": "https://graph.microsoft.com/.default" },
      { "key": "addTokenTo", "value": "header" }
    ]
  },
  "item": [
    {
      "name": "Tickets — list open",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{graphBase}}/lists/SD_Tickets/items?$expand=fields&$filter=fields/SD_Status eq 'New'&$orderby=fields/Created desc&$top=50",
          "host": ["{{graphBase}}"],
          "path": ["lists", "SD_Tickets", "items"],
          "query": [
            { "key": "$expand", "value": "fields" },
            { "key": "$filter", "value": "fields/SD_Status eq 'New'" },
            { "key": "$orderby", "value": "fields/Created desc" },
            { "key": "$top", "value": "50" }
          ]
        }
      }
    },
    {
      "name": "Tickets — get by id",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{graphBase}}/lists/SD_Tickets/items/:itemId?$expand=fields",
          "host": ["{{graphBase}}"],
          "path": ["lists", "SD_Tickets", "items", ":itemId"],
          "query": [{ "key": "$expand", "value": "fields" }],
          "variable": [{ "key": "itemId", "value": "123" }]
        }
      }
    },
    {
      "name": "Tickets — create",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"fields\": {\n    \"Title\": \"Printer offline on floor 3\",\n    \"SD_Description\": \"HP M553 not responding since 09:00.\",\n    \"SD_Priority\": \"Medium\",\n    \"SD_Status\": \"New\",\n    \"SD_Category\": \"Hardware\",\n    \"SD_SubmittedBy\": \"user@contoso.com\",\n    \"SD_SubmittedByName\": \"Facilities\",\n    \"SD_SubmittedByEmail\": \"user@contoso.com\"\n  }\n}"
        },
        "url": {
          "raw": "{{graphBase}}/lists/SD_Tickets/items",
          "host": ["{{graphBase}}"],
          "path": ["lists", "SD_Tickets", "items"]
        }
      }
    },
    {
      "name": "Tickets — update status",
      "request": {
        "method": "PATCH",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "If-Match", "value": "*" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"SD_Status\": \"Resolved\",\n  \"SD_AssignedTo\": \"agent@contoso.com\"\n}"
        },
        "url": {
          "raw": "{{graphBase}}/lists/SD_Tickets/items/:itemId/fields",
          "host": ["{{graphBase}}"],
          "path": ["lists", "SD_Tickets", "items", ":itemId", "fields"],
          "variable": [{ "key": "itemId", "value": "123" }]
        }
      }
    },
    {
      "name": "Comments — list for ticket",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{graphBase}}/lists/SD_Comments/items?$expand=fields&$filter=fields/SD_TicketId eq 123&$orderby=fields/Created asc",
          "host": ["{{graphBase}}"],
          "path": ["lists", "SD_Comments", "items"],
          "query": [
            { "key": "$expand", "value": "fields" },
            { "key": "$filter", "value": "fields/SD_TicketId eq 123" },
            { "key": "$orderby", "value": "fields/Created asc" }
          ]
        }
      }
    },
    {
      "name": "Comments — add",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"fields\": {\n    \"Title\": \"Triage\",\n    \"SD_TicketId\": 123,\n    \"SD_Body\": \"Dispatched field engineer.\",\n    \"SD_AuthorEmail\": \"agent@contoso.com\",\n    \"SD_AuthorName\": \"Agent Smith\",\n    \"SD_IsInternal\": false\n  }\n}"
        },
        "url": {
          "raw": "{{graphBase}}/lists/SD_Comments/items",
          "host": ["{{graphBase}}"],
          "path": ["lists", "SD_Comments", "items"]
        }
      }
    },
    {
      "name": "Agents — list active",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{graphBase}}/lists/SD_Agents/items?$expand=fields&$filter=fields/SD_IsActive eq true",
          "host": ["{{graphBase}}"],
          "path": ["lists", "SD_Agents", "items"],
          "query": [
            { "key": "$expand", "value": "fields" },
            { "key": "$filter", "value": "fields/SD_IsActive eq true" }
          ]
        }
      }
    },
    {
      "name": "Assets — list in-use",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{graphBase}}/lists/SD_Assets/items?$expand=fields&$filter=fields/SD_Status eq 'In Use'",
          "host": ["{{graphBase}}"],
          "path": ["lists", "SD_Assets", "items"],
          "query": [
            { "key": "$expand", "value": "fields" },
            { "key": "$filter", "value": "fields/SD_Status eq 'In Use'" }
          ]
        }
      }
    }
  ]
}
