Skip to main content
The ITSM-NG REST API allows you to create new items using POST requests. You can add single items, multiple items in bulk, or upload files.

Add Item(s)

Create one or more items in ITSM-NG.

Endpoint

POST /apirest.php/:itemtype/

Headers

Session-Token
string
required
Session token obtained from initSession
App-Token
string
Optional authorization string from API configuration
Content-Type
string
required
Must be application/json for regular requests or multipart/form-data for file uploads

Request Body

input
object | array
required
For single item: an object with fields of the itemtype to be insertedFor multiple items: an array of objects, each containing fields for one item

Response

id
integer
The ID of the created item (for single item creation)
message
string
Status message about the operation
For bulk operations, returns an array of objects with id and message for each item.

Response Headers

  • Location: URL of the created item (single item creation)
  • Link: URLs of created items (bulk creation)

Response Codes

  • 201 Created - Item(s) created successfully
  • 207 Multi-Status - Bulk operation with some failures
  • 400 Bad Request - Invalid input parameters
  • 401 Unauthorized - Invalid or missing session token

Create Single Item

Add a single item to the system.

Example Request

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/'

Example Response

{
  "id": 15
}
Response headers:
HTTP/1.1 201 Created
Location: http://path/to/glpi/api/Computer/15

Create Multiple Items (Bulk)

Add multiple items in a single request.

Example Request

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/'

Example Response

[
  {
    "id": 8,
    "message": ""
  },
  {
    "id": false,
    "message": "You don't have permission to perform this action."
  },
  {
    "id": 9,
    "message": ""
  }
]
Response headers:
HTTP/1.1 207 Multi-Status
Link: http://path/to/glpi/api/Computer/8,http://path/to/glpi/api/Computer/9
When creating multiple items, the API returns a 207 Multi-Status response. Each item in the response array corresponds to the item at the same index in your request. Items with "id": false indicate creation failures.

Upload a Document File

Upload files by creating Document items with file attachments.

Special Requirements

File uploads require multipart/form-data content type. Input data must be sent in an uploadManifest parameter using JSON format.

Endpoint

POST /apirest.php/Document/

Headers

Session-Token
string
required
Session token obtained from initSession
App-Token
string
Optional authorization string from API configuration
Content-Type
string
required
Must be multipart/form-data

Form Data Parameters

uploadManifest
string
required
JSON string containing the input data with:
  • name - Document name
  • _filename - Array of filenames being uploaded
filename[0]
file
required
The file to upload. Use array notation for multiple files: filename[0], filename[1], etc.

Example Request

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][email protected]' \
'http://path/to/glpi/apirest.php/Document/'

Example Response

{
  "id": 1,
  "message": "Document move succeeded.",
  "upload_result": {
    "filename": "file.txt",
    "size": 1024,
    "mime": "text/plain"
  }
}
Response headers:
HTTP/1.1 201 Created
Location: http://path/to/glpi/api/Document/1

Upload Multiple Files

To upload multiple files in one document:
curl -X POST \
-H 'Content-Type: multipart/form-data' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-F 'uploadManifest={"input": {"name": "Multi-file document", "_filename": ["file1.txt", "file2.pdf"]}};type=application/json' \
-F 'filename[0][email protected]' \
-F 'filename[1][email protected]' \
'http://path/to/glpi/apirest.php/Document/'

Common Item Fields

Most itemtypes support these common fields:

Standard Fields

name
string
The name or title of the item
comment
string
Additional comments or description
entities_id
integer
The entity ID this item belongs to
is_recursive
boolean
default:false
Whether the item applies to sub-entities
is_deleted
boolean
default:false
Soft delete flag

Asset-Specific Fields

For asset types (Computer, Monitor, Printer, etc.):
serial
string
Serial number
otherserial
string
Inventory number or alternative serial
contact
string
Contact person
contact_num
string
Contact number
users_id_tech
integer
Technical manager user ID
groups_id_tech
integer
Technical manager group ID
locations_id
integer
Location ID
manufacturers_id
integer
Manufacturer ID
states_id
integer
State ID (e.g., Production, Stock)

ITIL Item Fields

For Ticket, Problem, and Change itemtypes:
content
string
Description or content of the ITIL item
priority
integer
Priority level (1-5)
urgency
integer
Urgency level (1-5)
impact
integer
Impact level (1-5)
status
integer
Status ID
requesttypes_id
integer
Request type ID (source of the request)
_users_id_requester
integer
Requester user ID (use underscore prefix for actors)
_users_id_assign
integer
Assigned technician user ID
_groups_id_assign
integer
Assigned group ID

Error Handling

Common Errors

ERROR_GLPI_ADD
error
Unable to add the item. Check GLPI logs for details.
ERROR_GLPI_PARTIAL_ADD
error
Some items in bulk operation failed. Check the response array for details on each item.
ERROR_RIGHT_MISSING
error
User lacks permission to create items of this type.
ERROR_BAD_ARRAY
error
The input must be an object (single item) or array of objects (multiple items).

Validation Errors

When creating items, validation may fail for:
  • Missing required fields: Each itemtype has mandatory fields
  • Invalid foreign keys: Referenced IDs must exist (e.g., entities_id, users_id)
  • Duplicate values: Unique constraints on certain fields
  • Permission issues: User profile must have create rights

Best Practices

Bulk Operations: When creating multiple items, use bulk creation instead of individual requests to reduce overhead and improve performance.
Field Validation: Validate required fields client-side before sending requests to avoid unnecessary API calls.
Entity Context: Always specify entities_id to ensure items are created in the correct organizational context.
Session Write Mode: Creating items requires write access to the session. By default, sessions are read-only. The API automatically enables write mode for POST operations, but parallel requests may be blocked.
File Size Limits: File uploads are subject to PHP and web server limits. Check your upload_max_filesize and post_max_size settings.

Build docs developers (and LLMs) love