{
  "info": {
    "name": "GLPI 11 - API v2 (NexTool)",
    "description": "Chamadas testadas pela NexTool num GLPI 11.0.7 (out/2026). Preencha base, client_id, client_secret, username e password. Requer Configurar > Geral > API > Habilitar API e um cliente OAuth com o grant password e o escopo api.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{access_token}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "base",
      "value": "https://glpi.suaempresa.com.br/api.php"
    },
    {
      "key": "api",
      "value": "v2.3"
    },
    {
      "key": "client_id",
      "value": ""
    },
    {
      "key": "client_secret",
      "value": ""
    },
    {
      "key": "username",
      "value": ""
    },
    {
      "key": "password",
      "value": ""
    },
    {
      "key": "access_token",
      "value": ""
    },
    {
      "key": "refresh_token",
      "value": ""
    },
    {
      "key": "ticket_id",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "1. Token (password grant)",
      "request": {
        "method": "POST",
        "header": [],
        "url": {
          "raw": "{{base}}/token",
          "host": [
            "{{base}}"
          ],
          "path": [
            "token"
          ]
        },
        "description": "Gera access_token (1 h) e refresh_token. O script de teste guarda os dois nas variaveis da colecao.",
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            {
              "key": "grant_type",
              "value": "password"
            },
            {
              "key": "client_id",
              "value": "{{client_id}}"
            },
            {
              "key": "client_secret",
              "value": "{{client_secret}}"
            },
            {
              "key": "username",
              "value": "{{username}}"
            },
            {
              "key": "password",
              "value": "{{password}}"
            },
            {
              "key": "scope",
              "value": "api graphql"
            }
          ]
        },
        "auth": {
          "type": "noauth"
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const d = pm.response.json();",
              "pm.collectionVariables.set('access_token', d.access_token);",
              "pm.collectionVariables.set('refresh_token', d.refresh_token);"
            ]
          }
        }
      ]
    },
    {
      "name": "2. Abrir chamado",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{base}}/{{api}}/Assistance/Ticket",
          "host": [
            "{{base}}"
          ],
          "path": [
            "{{api}}",
            "Assistance",
            "Ticket"
          ]
        },
        "description": "Devolve o id do chamado criado.",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"name\": \"Impressora do 2o andar sem toner\",\n  \"content\": \"Aberto pela API v2.\",\n  \"urgency\": 3,\n  \"type\": 1\n}"
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.collectionVariables.set('ticket_id', pm.response.json().id);"
            ]
          }
        }
      ]
    },
    {
      "name": "3. Ler chamado",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{base}}/{{api}}/Assistance/Ticket/{{ticket_id}}",
          "host": [
            "{{base}}"
          ],
          "path": [
            "{{api}}",
            "Assistance",
            "Ticket",
            "{{ticket_id}}"
          ]
        },
        "description": ""
      }
    },
    {
      "name": "4. Mudar urgencia (PATCH)",
      "request": {
        "method": "PATCH",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{base}}/{{api}}/Assistance/Ticket/{{ticket_id}}",
          "host": [
            "{{base}}"
          ],
          "path": [
            "{{api}}",
            "Assistance",
            "Ticket",
            "{{ticket_id}}"
          ]
        },
        "description": "",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"urgency\": 4\n}"
        }
      }
    },
    {
      "name": "5. Adicionar acompanhamento",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{base}}/{{api}}/Assistance/Ticket/{{ticket_id}}/Timeline/Followup",
          "host": [
            "{{base}}"
          ],
          "path": [
            "{{api}}",
            "Assistance",
            "Ticket",
            "{{ticket_id}}",
            "Timeline",
            "Followup"
          ]
        },
        "description": "",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"content\": \"Toner reserva entregue.\",\n  \"is_private\": false\n}"
        }
      }
    },
    {
      "name": "6. Linha do tempo",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{base}}/{{api}}/Assistance/Ticket/{{ticket_id}}/Timeline",
          "host": [
            "{{base}}"
          ],
          "path": [
            "{{api}}",
            "Assistance",
            "Ticket",
            "{{ticket_id}}",
            "Timeline"
          ]
        },
        "description": ""
      }
    },
    {
      "name": "7. Buscar com filtro RSQL",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{base}}/{{api}}/Assistance/Ticket?filter=name=like=*toner*&start=0&limit=50",
          "host": [
            "{{base}}"
          ],
          "path": [
            "{{api}}",
            "Assistance",
            "Ticket?filter=name=like=*toner*&start=0&limit=50"
          ]
        },
        "description": "Paginacao no cabecalho Content-Range."
      }
    },
    {
      "name": "8. GraphQL",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{base}}/{{api}}/GraphQL",
          "host": [
            "{{base}}"
          ],
          "path": [
            "{{api}}",
            "GraphQL"
          ]
        },
        "description": "",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"query\": \"query { Ticket(filter: \\\"id=={{ticket_id}}\\\") { id name urgency priority date_creation } }\"\n}"
        }
      }
    },
    {
      "name": "9. Renovar token (refresh)",
      "request": {
        "method": "POST",
        "header": [],
        "url": {
          "raw": "{{base}}/token",
          "host": [
            "{{base}}"
          ],
          "path": [
            "token"
          ]
        },
        "description": "",
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            {
              "key": "grant_type",
              "value": "refresh_token"
            },
            {
              "key": "client_id",
              "value": "{{client_id}}"
            },
            {
              "key": "client_secret",
              "value": "{{client_secret}}"
            },
            {
              "key": "refresh_token",
              "value": "{{refresh_token}}"
            }
          ]
        },
        "auth": {
          "type": "noauth"
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const d = pm.response.json();",
              "pm.collectionVariables.set('access_token', d.access_token);",
              "pm.collectionVariables.set('refresh_token', d.refresh_token);"
            ]
          }
        }
      ]
    }
  ]
}