Endpoint : Resource available though the API. The endpoint is the URL where your API can be accessed by a client application
Method : HTTP verbs to indicate the desired action to be performed on the identified resource. See: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods
itemtype : A GLPI type, could be an asset, an ITIL or a configuration object, etc. This type must be a class who inherits CommonDTBM GLPI class.
searchOption : A column identifier (integer) of an itemtype (ex: 1 -> id, 2 -> name, ...). See List searchOptions endpoint.
JSON Payload : content of HTTP Request in JSON format (HTTP body)
Query string : URL parameters
User token : Used in login process instead of login/password couple. It represent the user with a string. You can find user token in the settings tabs of users.
Session token : A string describing a valid session in glpi. Except initSession endpoint who provide this token, all others require this string to be used.
App(lication) token : An optional way to filter the access to the API. On API call, it will try to find an API client matching your IP and the app token (if provided). You can define an API client with an app token in general configuration for each of your external applications to identify them (each API client have its own history).
You should always provide a Content-Type header in your HTTP calls. Currently, the API supports:
GET requests must have an empty body. You must pass all parameters in URL. Failing to do so will trigger an HTTP 400 response.
By default, sessions used in this API are read-only. Only some methods have write access to session:
You could pass an additional parameter "session_write=true" to bypass this default. This read-only mode allow to use this API with parallel calls. In write mode, sessions are locked and your client must wait the end of a call before the next one can execute.
You can filter API access by enable the following parameters in GLPI General Configuration (API tab):
Session and App tokens could be provided in query string instead of header parameters.
App-Token: authorization string provided by the GLPI API configuration. Optional.
a couple login & password: 2 parameters to login with user authentication. You should pass this 2 parameters in http basic auth. It consists in a Base64 string with login and password separated by ":" A valid Authorization header is: * "Authorization: Basic base64({login}:{password})"
OR
an user_token defined in User Preference (See 'Remote access key') You should pass this parameter in 'Authorization' HTTP header. A valid Authorization header is: * "Authorization: user_token q56hqkniwot8wntb3z1qarka5atf365taaa2uyjrn"
Examples usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Authorization: Basic Z2xwaTpnbHBp" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/initSession'
< 200 OK
< {
"session_token": "83af7e620c83a50a18d3eac2f6ed05a3ca0bea62"
}
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Authorization: user_token q56hqkniwot8wntb3z1qarka5atf365taaa2uyjrn" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/initSession?get_full_session=true'
< 200 OK
< {
"session_token": "83af7e620c83a50a18d3eac2f6ed05a3ca0bea62",
"session": {
'glpi_plugins': ...,
'glpicookietest': ...,
'glpicsrftokens': ...,
...
}
}
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/killSession'
< 200 OK
This endpoint allows to request password recovery and password reset. This endpoint works under the following conditions:
Reset password request:
$ curl -X PUT \
-H 'Content-Type: application/json' \
-d '{"email": "user@domain.com"}' \
'http://path/to/glpi/apirest.php/lostPassword'
< 200 OK
Password reset :
$ curl -X PUT \
-H 'Content-Type: application/json' \
-d '{"email": "user@domain.com", \
"password_forget_token": "b0a4cfe81448299ebed57442f4f21929c80ebee5" \
"password": "NewPassword" \
}' \
'http://path/to/glpi/apirest.php/lostPassword'
< 200 OK
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getMyProfiles'
< 200 OK
< {
'myprofiles': [
{
'id': 1
'name': "Super-admin",
'entities': [
...
],
...
},
....
]
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getActiveProfile'
< 200 OK
< {
'name': "Super-admin",
'entities': [
...
]
}
Example usage (CURL):
$ curl -X POST \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"profiles_id": 4}' \
'http://path/to/glpi/apirest.php/changeActiveProfile'
< 200 OK
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getMyEntities'
< 200 OK
< {
'myentities': [
{
'id': 71
'name': "my_entity"
},
....
]
}
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getActiveEntities'
< 200 OK
< {
'active_entity': {
'id': 1,
'active_entity_recursive': true,
'active_entities': [
{"id":1},
{"id":71},...
]
}
}
Example usage (CURL):
$ curl -X POST \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"entities_id": 1, "is_recursive": true}' \
'http://path/to/glpi/apirest.php/changeActiveEntities'
< 200 OK
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getFullSession'
< 200 OK
< {
'session': {
'glpi_plugins': ...,
'glpicookietest': ...,
'glpicsrftokens': ...,
...
}
}
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getGlpiConfig'
< 200 OK
< {
'cfg_glpi': {
'languages': ...,
'glpitables': ...,
'unicity_types':...,
...
}
}
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/Computer/71?expand_dropdowns=true'
< 200 OK
< {
"id": 71,
"entities_id": "Root Entity",
"name": "adelaunay-ThinkPad-Edge-E320",
"serial": "12345",
"otherserial": "test2",
"contact": "adelaunay",
"contact_num": null,
"users_id_tech": " ",
"groups_id_tech": " ",
"comment": "test222222qsdqsd",
"date_mod": "2015-09-25 09:33:41",
"autoupdatesystems_id": " ",
"locations_id": "00:0e:08:3b:7d:04",
"networks_id": " ",
"computermodels_id": "1298A8G",
"computertypes_id": "Notebook",
"is_template": 0,
"template_name": null,
"manufacturers_id": "LENOVO",
"is_deleted": 0,
"is_dynamic": 1,
"users_id": "adelaunay",
"groups_id": " ",
"states_id": "Production",
"ticket_tco": "0.0000",
"uuid": "",
"date_creation": null,
"links": [{
"rel": "Entity",
"href": "http://path/to/glpi/api/Entity/0"
}, {
"rel": "Location",
"href": "http://path/to/glpi/api/Location/3"
}, {
"rel": "Domain",
"href": "http://path/to/glpi/api/Domain/18"
}, {
"rel": "ComputerModel",
"href": "http://path/to/glpi/api/ComputerModel/11"
}, {
"rel": "ComputerType",
"href": "http://path/to/glpi/api/ComputerType/3"
}, {
"rel": "Manufacturer",
"href": "http://path/to/glpi/api/Manufacturer/260"
}, {
"rel": "User",
"href": "http://path/to/glpi/api/User/27"
}, {
"rel": "State",
"href": "http://path/to/glpi/api/State/1"
}]
}
Note: To download a document see Download a document file.
Description: Return a collection of rows of the itemtype.
Method: GET
Parameters: (Headers)
Parameters: (query string)
Returns:
and theses headers: * Content-Range offset – limit / count * Accept-Range itemtype max
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/Computer/?expand_dropdowns=true'
< 206 OK
< Content-Range: 0-49/200
< Accept-Range: 990
< [
{
"id": 34,
"entities_id": "Root Entity",
"name": "glpi",
"serial": "VMware-42 01 f4 65 27 59 a9 fb-11 bc cd b8 64 68 1f 4b",
"otherserial": null,
"contact": "teclib",
"contact_num": null,
"users_id_tech": " ",
"groups_id_tech": " ",
"comment": "x86_64/00-09-15 08:03:28",
"date_mod": "2011-12-16 17:52:55",
"autoupdatesystems_id": "FusionInventory",
"locations_id": " ",
"networks_id": " ",
"computermodels_id": "VMware Virtual Platform",
"computertypes_id": "Other",
"is_template": 0,
"template_name": null,
"manufacturers_id": "VMware, Inc.",
"is_deleted": 0,
"is_dynamic": 1,
"users_id": " ",
"groups_id": " ",
"states_id": "Production",
"ticket_tco": "0.0000",
"uuid": "4201F465-2759-A9FB-11BC-CDB864681F4B",
"links": [{
"rel": "Entity",
"href": "http://path/to/glpi/api/Entity/0"
}, {
"rel": "AutoUpdateSystem",
"href": "http://path/to/glpi/api/AutoUpdateSystem/1"
}, {
"rel": "Domain",
"href": "http://path/to/glpi/api/Domain/12"
}, {
"rel": "ComputerModel",
"href": "http://path/to/glpi/api/ComputerModel/1"
}, {
"rel": "ComputerType",
"href": "http://path/to/glpi/api/ComputerType/2"
}, {
"rel": "Manufacturer",
"href": "http://path/to/glpi/api/Manufacturer/1"
}, {
"rel": "State",
"href": "http://path/to/glpi/api/State/1"
}]
},
{
"id": 35,
"entities_id": "Root Entity",
"name": "mavm1",
"serial": "VMware-42 20 d3 04 ac 49 ed c8-ea 15 50 49 e1 40 0f 6c",
"otherserial": null,
"contact": "teclib",
"contact_num": null,
"users_id_tech": " ",
"groups_id_tech": " ",
"comment": "x86_64/01-01-04 19:50:40",
"date_mod": "2012-05-24 06:43:35",
...
}
]
Description: Return a collection of rows of the sub_itemtype for the identified item.
Method: GET
Parameters: (Headers)
Parameters: (query string)
Returns:
and theses headers: * Content-Range offset – limit / count * Accept-Range itemtype max
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/User/2/Log'
< 200 OK
< Content-Range: 0-49/200
< Accept-Range: 990
< [
{
"id": 22117,
"itemtype": "User",
"items_id": 2,
"itemtype_link": "Profile",
"linked_action": 17,
"user_name": "glpi (27)",
"date_mod": "2015-10-13 10:00:59",
"id_search_option": 0,
"old_value": "",
"new_value": "super-admin (4)"
}, {
"id": 22118,
"itemtype": "User",
"items_id": 2,
"itemtype_link": "",
"linked_action": 0,
"user_name": "glpi (2)",
"date_mod": "2015-10-13 10:01:22",
"id_search_option": 80,
"old_value": "Root entity (0)",
"new_value": "Root entity > my entity (1)"
}, {
...
}
]
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"items": [{"itemtype": "User", "items_id": 2}, {"itemtype": "Entity", "items_id": 0}]}' \
'http://path/to/glpi/apirest.php/getMultipleItems?items\[0\]\[itemtype\]\=User&items\[0\]\[items_id\]\=2&items\[1\]\[itemtype\]\=Entity&items\[1\]\[items_id\]\=0'
< 200 OK
< Content-Range: 0-49/200
< Accept-Range: 990
< [{
"id": 2,
"name": "glpi",
...
}, {
"id": 0,
"name": "Root Entity",
...
}]
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/listSearchOptions/Computer'
< 200 OK
< {
"common": "Characteristics",
1: {
'name': 'Name'
'table': 'glpi_computers'
'field': 'name'
'linkfield': 'name'
'datatype': 'itemlink'
'uid': 'Computer.name'
},
2: {
'name': 'ID'
'table': 'glpi_computers'
'field': 'id'
'linkfield': 'id'
'datatype': 'number'
'uid': 'Computer.id'
},
3: {
'name': 'Location'
'table': 'glpi_locations'
'field': 'completename'
'linkfield': 'locations_id'
'datatype': 'dropdown'
'uid': 'Computer.Location.completename'
},
...
}
Description: Expose the GLPI searchEngine and combine criteria to retrieve a list of elements of specified itemtype.
Note: you can use 'AllAssets' itemtype to retrieve a combination of all asset's types.
Method: GET
Parameters: (Headers)
Parameters: (query string)
criteria: array of criterion objects to filter search. Optional.
You can optionally precise meta=true to pass a searchoption of another itemtype (meta-criteria).
Each criterion object must provide at least:
And you can pass a direct searchoption usage :
Or a list of sub-nodes with the key:
Ex:
...
"criteria":
[
{
"field": 1,
"searchtype": 'contains',
"value": ''
}, {
"link": 'AND',
"field": 31,
"searchtype": 'equals',
"value": 1
}, {
"link": 'AND',
"meta": true,
"itemtype": 'User',
"field": 1,
"searchtype": 'equals',
"value": 1
}, {
"link": 'AND',
"criteria" : [
{
"field": 34,
"searchtype": 'equals',
"value": 1
}, {
"link": 'OR',
"field": 35,
"searchtype": 'equals',
"value": 1
}
]
}
]
...
metacriteria (optional): array of meta-criterion objects to filter search. Optional. A meta search is a link with another itemtype (ex: Computer with software). Deprecated: Now criteria support meta flag, you should use it instead direct metacriteria option.
Each meta-criterion object must provide: * link: logical operator in [AND, OR, AND NOT, OR NOT]. Mandatory. * itemtype: second itemtype to link. * field: id of the searchoption. * searchtype: type of search in [contains¹, equals², notequals², lessthan, morethan, under, notunder]. * value: the value to search.
Ex:
...
"metacriteria":
[
{
"link": 'AND',
"itemtype": 'Monitor',
"field": 2,
"searchtype": 'contains',
"value": ''
}, {
"link": 'AND',
"itemtype": 'Monitor',
"field": 3,
"searchtype": 'contains',
"value": ''
}
]
...
sort (default 1): id of the searchoption to sort by. Optional.
order (default ASC): ASC - Ascending sort / DESC Descending sort. Optional.
range (default 0-49): a string with a couple of number for start and end of pagination separated by a '-'. Ex: 150-199. Optional.
forcedisplay: array of columns to display (default empty = use display preferences and searched criteria). Some columns will be always presents (1: id, 2: name, 80: Entity). Optional.
rawdata (default false): a boolean for displaying raws data of the Search engine of GLPI (like SQL request, full searchoptions, etc)
withindexes (default false): a boolean to retrieve rows indexed by items id. By default this option is set to false, because order of JSON objects (which are identified by index) cannot be garrantued (from http://json.org/ : An object is an unordered set of name/value pairs). So, we provide arrays to guarantying sorted rows.
uid_cols (default false): a boolean to identify cols by the 'uniqid' of the searchoptions instead of a numeric value (see List searchOptions and 'uid' field)
giveItems (default false): a boolean to retrieve the data with the html parsed from core, new data are provided in data_html key.
¹ - contains will use a wildcard search per default. You can restrict at the beginning using the ^ character, and/or at the end using the $ character.
² - equals and notequals are designed to be used with dropdowns. Do not expect those operators to search for a strictly equal value (see ¹ above).
Returns:
200 (OK) with all rows data with this format:
{
"totalcount": ":numberofresults_without_pagination",
"range": ":start-:end",
"data": [
{
":searchoptions_id": "value",
...
},
{
...
}
],
"rawdata": {
...
}
}
206 (PARTIAL CONTENT) with rows data (pagination doesn't permit to display all rows).
401 (UNAUTHORIZED).
and theses headers:
Example usage (CURL):
curl -g -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/search/Monitor?\
criteria\[0\]\[link\]\=AND\
\&criteria\[0\]\[itemtype\]\=Monitor\
\&criteria\[0\]\[field\]\=23\
\&criteria\[0\]\[searchtype\]\=contains\
\&criteria\[0\]\[value\]\=GSM\
\&criteria\[1\]\[link\]\=AND\
\&criteria\[1\]\[itemtype\]\=Monitor\
\&criteria\[1\]\[field\]\=1\
\&criteria\[1\]\[searchtype\]\=contains\
\&criteria\[1\]\[value\]\=W2\
\&range\=0-2\&&forcedisplay\[0\]\=1'
< 200 OK
< Content-Range: 0-2/2
< Accept-Range: 990
< {"totalcount":2,"count":2,"data":{"11":{"1":"W2242","80":"Root Entity","23":"GSM"},"7":{"1":"W2252","80":"Root Entity","23":"GSM"}}}%
URL: apirest.php/:itemtype/
Description: Add an object (or multiple objects) into GLPI.
Method: POST
Parameters: (Headers)
Parameters: (JSON Payload)
Important: In case of 'multipart/data' content_type (aka file upload), you should insert your parameters into a 'uploadManifest' parameter. Theses serialized data should be a JSON string.
Returns:
Examples usage (CURL):
$ curl -X POST \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": {"name": "My single computer", "serial": "12345"}}' \
'http://path/to/glpi/apirest.php/Computer/'
< 201 OK
< Location: http://path/to/glpi/api/Computer/15
< {"id": 15}
$ curl -X POST \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": [{"name": "My first computer", "serial": "12345"}, {"name": "My 2nd computer", "serial": "67890"}, {"name": "My 3rd computer", "serial": "qsd12sd"}]}' \
'http://path/to/glpi/apirest.php/Computer/'
< 207 OK
< Link: http://path/to/glpi/api/Computer/8,http://path/to/glpi/api/Computer/9
< [ {"id":8, "message": ""}, {"id":false, "message": "You don't have permission to perform this action."}, {"id":9, "message": ""} ]
Note: To upload a document see Upload a document file.
Example usage (CURL):
$ curl -X PUT \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": {"otherserial": "xcvbn"}}' \
'http://path/to/glpi/apirest.php/Computer/10'
< 200 OK
[{"10":true, "message": ""}]
$ curl -X PUT \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": {"id": 11, "otherserial": "abcde"}}' \
'http://path/to/glpi/apirest.php/Computer/'
< 200 OK
[{"11":true, "message": ""}]
$ curl -X PUT \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": [{"id": 16, "otherserial": "abcde"}, {"id": 17, "otherserial": "fghij"}]}' \
'http://path/to/glpi/apirest.php/Computer/'
< 207 OK
[{"8":true, "message": ""},{"2":false, "message": "Item not found"}]
URL: apirest.php/:itemtype/:id
Description: Delete an object existing in GLPI.
Method: DELETE
Parameters: (Headers)
Parameters: (query string)
id parameter has precedence over input payload.
Returns:
Example usage (CURL):
$ curl -X DELETE \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/Computer/16?force_purge=true'
< 200 OK
[{"16":true, "message": ""}]
$ curl -X DELETE \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": {"id": 11}, "force_purge": true}' \
'http://path/to/glpi/apirest.php/Computer/'
< 200 OK
[{"11":true, "message": ""}]
$ curl -X DELETE \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": [{"id": 16}, {"id": 17}]}' \
'http://path/to/glpi/apirest.php/Computer/'
< 207 OK
[{"16":true, "message": ""},{"17":false, "message": "Item not found"}]
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getMassiveActions/Computer'
< 200 OK
[
{
"key": "MassiveAction:update",
"label": "Update"
},
{
"key": "MassiveAction:clone",
"label": "Clone"
},
{
"key": "Infocom:activate",
"label": "Enable the financial and administrative information"
},
{
"key": "MassiveAction:delete",
"label": "Put in trashbin"
},
{
"key": "Appliance:add_item",
"label": "Associate to an appliance"
},
{
"key": "Item_OperatingSystem:update",
"label": "Operating systems"
},
{
"key": "Glpi\\Asset\\Asset_PeripheralAsset:add",
"label": "Connect"
},
{
"key": "Item_SoftwareVersion:add",
"label": "Install"
},
{
"key": "KnowbaseItem_Item:add",
"label": "Link knowledgebase article"
},
{
"key": "Document_Item:add",
"label": "Add a document"
},
{
"key": "Document_Item:remove",
"label": "Remove a document"
},
{
"key": "Contract_Item:add",
"label": "Add a contract"
},
{
"key": "Contract_Item:remove",
"label": "Remove a contract"
},
{
"key": "MassiveAction:amend_comment",
"label": "Amend comment"
},
{
"key": "MassiveAction:add_note",
"label": "Add note"
},
{
"key": "Lock:unlock",
"label": "Unlock components"
}
]
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getMassiveActions/Computer?is_deleted=1'
< 200 OK
[
{
"key": "MassiveAction:purge_item_but_devices",
"label": "Delete permanently but keep devices"
},
{
"key": "MassiveAction:purge",
"label": "Delete permanently and remove devices"
},
{
"key": "MassiveAction:restore",
"label": "Restore"
},
{
"key": "Lock:unlock",
"label": "Unlock components"
}
]
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getMassiveActions/Computer/3'
< 200 OK
[
{
"key": "MassiveAction:update",
"label": "Update"
},
{
"key": "MassiveAction:clone",
"label": "Clone"
},
{
"key": "Infocom:activate",
"label": "Enable the financial and administrative information"
},
{
"key": "MassiveAction:delete",
"label": "Put in trashbin"
},
{
"key": "Appliance:add_item",
"label": "Associate to an appliance"
},
{
"key": "Item_OperatingSystem:update",
"label": "Operating systems"
},
{
"key": "Glpi\\Asset\\Asset_PeripheralAsset:add",
"label": "Connect"
},
{
"key": "Item_SoftwareVersion:add",
"label": "Install"
},
{
"key": "KnowbaseItem_Item:add",
"label": "Link knowledgebase article"
},
{
"key": "Document_Item:add",
"label": "Add a document"
},
{
"key": "Document_Item:remove",
"label": "Remove a document"
},
{
"key": "Contract_Item:add",
"label": "Add a contract"
},
{
"key": "Contract_Item:remove",
"label": "Remove a contract"
},
{
"key": "MassiveAction:amend_comment",
"label": "Amend comment"
},
{
"key": "MassiveAction:add_note",
"label": "Add note"
},
{
"key": "Lock:unlock",
"label": "Unlock components"
}
]
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getMassiveActions/Computer/4'
< 200 OK
[
{
"key": "MassiveAction:purge_item_but_devices",
"label": "Delete permanently but keep devices"
},
{
"key": "MassiveAction:purge",
"label": "Delete permanently and remove devices"
},
{
"key": "MassiveAction:restore",
"label": "Restore"
},
{
"key": "Lock:unlock",
"label": "Unlock components"
}
]
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getMassiveActionParameters/Computer/MassiveAction:add_note'
< 200 OK
[
{
"name": "add_note",
"type": "text"
}
]
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getMassiveActionParameters/Computer/Contract_Item:add'
< 200 OK
[
{
"name": "peer_contracts_id",
"type": "dropdown"
}
]
Example usage (CURL):
$ curl -X POST \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"ids": [2, 3], "input": {"amendment": "newtext"}}'
'http://path/to/glpi/apirest.php/applyMassiveAction/Computer/MassiveAction:amend_comment'
< 200 OK
{
"ok": 2,
"ko": 0,
"noright": 0,
"messages": []
}
See Add item(s) and apply specific instructions below.
Uploading a file requires use of 'multipart/data' content_type. The input data must be send in a 'uploadManifest' parameter and use the JSON format.
Examples usage (CURL):
$ curl -X POST \
-H 'Content-Type: multipart/form-data' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-F 'uploadManifest={"input": {"name": "Uploaded document", "_filename" : ["file.txt"]}};type=application/json' \
-F 'filename[0]=@file.txt' \
'http://path/to/glpi/apirest.php/Document/'
< 201 OK
< Location: http://path/to/glpi/api/Document/1
< {"id": 1, "message": "Document move succeeded.", "upload_result": {...}}
URL: apirest.php/Document/:id
Description: Download a document.
Method: GET
Parameters: (Headers)
Parameters: (query string)
id parameter has precedence over input payload.
Returns:
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-H "Accept: application/octet-stream" \
-d '{"input": {"id": 11}}' \
'http://path/to/glpi/apirest.php/Document/'
< 200 OK
The body of the answer contains the raw file attached to the document.
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": {"id": 11}}' \
'http://path/to/glpi/apirest.php/Document/&alt=media'
< 200 OK
The body of the answer contains the raw file attached to the document.
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/User/2/Picture/'
< 200 OK
The body of the answer contains the raw image.
The desired resource (itemtype-id) was not found in the GLPI database.
The HTTP body must be an an array of objects.
You specified an inexistent or not not allowed resource.
The current logged user miss rights in his profile to do the provided action. Alter this profile or choose a new one for the user in GLPI main interface.
The Session-Token provided in header is invalid. You should redo an Init session request.
You miss to provide Session-Token in header of your HTTP request.
The current API requires an App-Token header for using its methods.
It seems the provided application token doesn't exists in GLPI API configuration.
You must mark the item for deletion before actually deleting it
We can't find an active client defined in configuration for your IP. Go to the GLPI Configuration > Setup menu and API tab to check IP access.
One of theses parameter(s) is missing:
The GLPI setup forbid the login with credentials, you must login with your user_token instead. See your personal preferences page or setup API access in GLPI main interface.
The provided user_token seems invalid. Check your personal preferences page in GLPI main interface.
We cannot login you into GLPI. This error is not relative to API but GLPI core. Check the user administration and the GLPI logs files (in files/_logs directory).
You asked a inexistent resource (endpoint). It's not a predefined (initSession, getFullSession, etc) nor a GLPI CommonDBTM resources.
We suspect an SQL error. This error is not relative to API but to GLPI core. Check the GLPI logs files (in files/_logs directory).
The range parameter you provided is superior to the total count of available data.
We cannot add the object to GLPI. This error is not relative to API but to GLPI core. Check the GLPI logs files (in files/_logs directory).
Some of the object you wanted to add triggers an error. Maybe a missing field or rights. You'll find with this error a collection of results.
We cannot update the object to GLPI. This error is not relative to API but to GLPI core. Check the GLPI logs files (in files/_logs directory).
Some of the object you wanted to update triggers an error. Maybe a missing field or rights. You'll find with this error a collection of results.
We cannot delete the object to GLPI. This error is not relative to API but to GLPI core. Check the GLPI logs files (in files/_logs directory).
Some of the objects you want to delete triggers an error, maybe a missing field or rights. You'll find with this error, a collection of results.
Missing or invalid massive action key. Run 'getMassiveActions' endpoint to see available keys.
No ids supplied when trying to run a massive action.
The field specified as the key for the searchText parameter does not exist. This field must refer to a column in the table corresponding to the element in the query.
An unknown error has occurred. This may be due to an unexpected condition encountered by the server or an issue that does not fit into any of the predefined error categories. Check the server logs for more details or contact the support team.
By default, you can use http://path/to/glpi/apirest.php without any additional configuration.
You'll find below some examples to configure your web server to redirect your http://.../glpi/api/ URL to the apirest.php file.
We provide in root .htaccess of GLPI an example to enable API URL rewriting.
You need to uncomment (removing #) theses lines:
#<IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule api/(.*)$ apirest.php/$1
#</IfModule>
By enabling URL rewriting, you could use API with this URL : http://path/to/glpi/api/. You need also to enable rewrite module in apache httpd and permit GLPI's .htaccess to override server configuration (see AllowOverride directive).
Note for apache+fpm users:
You may have difficulties to pass Authorization header in this configuration. You have two options :
user_token or credentials (login/password) in the http query (as GET parameters).SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1.This example of configuration was achieved on ubuntu with php7 fpm.
server {
listen 80 default_server;
listen [::]:80 default_server;
# change here to match your GLPI directory
root /var/www/html/glpi/;
index index.html index.htm index.nginx-debian.html index.php;
server_name localhost;
location / {
try_files $uri $uri/ =404;
autoindex on;
}
location /api {
rewrite ^/api/(.*)$ /apirest.php/$1 last;
}
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# # see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
# allow directory index
fastcgi_index index.php;
}
}