β›³Creating and Updating Sessions

This page explains how you can both create, and update sessions in a single request.

In order to create and update sessions, the request needs to include a JSON array body that has the session objects. The objects can be of type CreateSession or UpdateSession.

circle-info

The same endpoint handles both create and update operations for sessions. The operation type is determined by the presence of the session_guid parameter in the request body. Including session_guid indicates an update operation, while omitting it indicates a create operation.


Example Request:

circle-exclamation
curl -L -X POST 'https:https://<DOMAIN>/xapi/v2/session/batch' \
-H 'Content-Type: application/json' \
-d '[
    // Insert session
    {
        "name": "CS201",
        "description": "Let's learn the fundemental technologies used in Web Development",
        "start_date": "2025-08-05T12:00:00Z",
        "duration": 120,
        "lang": "en-US"
    },
    // Insert session with an incorrect start_date
    {
        "name": "TR102",
        "start_date": "2020-08-05T14:00:00Z",
        "duration": 120,
        "lang": "tr-TR",
        "options": {
            "allow_rating": false
        }
    },
    // Update session
    {
        "session_guid": "61E3D504-13EE-447F-9B36-6686C5C39FEB",
        "duration": 100
    },
    // Update session that doesn't exists
    {
        "session_guid": "8293D504-13EE-447F-9B36-6686C5C39FEB",
        "duration": 100
    }
]'

Example Response:

The response for this operation includes a json object like so:

circle-info

Response Status Codes will vary depending on how the operations went:

  • 200 OK: All operations completed successfully

  • 207 Multi-Status: Partial success - some operations failed

  • 400 Bad Request: All operations failed

Last updated

Was this helpful?