API V2
Concept
When using the GLPI API, communication occurs in a universal language called JSON (a very simple text format to read) and relies on the standard web network (HTTP), with 4 main actions:
GET (Read): Give me the list of computers at the Lyon site.
POST (Create): Create a new ticket with the title 'Internet outage'.
PUT/PATCH (Update): Change the status of computer #45 to 'Under repair'.
DELETE (Delete): Delete ticket #1234.
Each request is sent to a specific URL, called an Endpoint (e.g., https://my-glpi.com/api.php/Ticket).
What is it for?
The API allows, among other things, to automate time-consuming tasks and simplify repetitive actions:
Supervision (Monitoring): Instead of sending a simple email, the API can automatically create a critical ticket and assign it to the network team in GLPI.
Human Resources: When the HR department adds an employee to their software, it automatically transmits the data to GLPI via the API to create a user account, generate a PC preparation ticket, and assign a software license.
External Reporting: A Python script that queries the API every evening to retrieve the number of open tickets and display it on a screen in the open-space.
Creating an Oauth Client
To use the API, GLPI requires an OAuth client to be configured. This client will generate a Client ID and a Client secret, which are essential for authorizing API usage.
From
Configuration>OAuth clients,click on+ AddEnter:
A name
The relevant
scopes: email, user, api, inventory, status, graphqlThe authorization type (grants): Password, Clients credentials, Authorization code
Save your OAuth client
Click on your OAuth client, and note the 2 values:
Client IDClient secret

Method 1 - API Endpoints
The recommended method is to use the API Endpoints feature natively available in GLPI. You can find the URL at:
Configuration>General>API>API EndpointsOr at the address https://my_instance/api.php/v2.2/doc
Usage
From
Configuration>General>API>API Endpointsor https://my_instance/api.php/v2.2/doc, select the module you need

In our example, we will display ticket with
id 60From
Administration, select GET** /Assistance/Ticket/{id}**Click on
Try it outEnter the ticket number
Click on
Execute

Response:

In this first box, you will find:
Curl: The request used
The Request URL
The request response: the content of our ticket
The header response: a list of parameters in "Key: Value" format (request weight, timestamp, formatting, etc.).
In another box, you will find the raw values of the request, i.e., the schema used.

It is also possible to view the schema and the expected value type in list mode by clicking on
Schema

Method 2 - Via curl requests
Example Commands
If you do not wish to fill in certain fields in your requests, you can either indicate the value "null" (e.g., "sla_ttr": null) or remove them from your request. The essential thing is that your json is correctly structured. All values containing an "id": 0 must also be replaced by the value null
Tickets
Create a ticket:
Limitation:
The expected format for dates is "YYYY-MM-DD HH:MM:SS". The variable $date-time is not applicable at this time (currently being corrected by the technical teams).
Retrieve the content of a ticket:
Retrieve the solution of a ticket:
Retrieve the documents of a ticket:
User
Create a user:
Delete a user
Profile
List profiles
Entity
List entities
View entity details
Status
View GLPI service status
Last updated
