# Oturumları Yaratma ve Güncelleme

Oturum yaratmak ve güncellemek için göndereceğiniz istek, gövdesinde geçerli oturum objelerini içeren bir JSON array'i olmalıdır. Oturum objeleri [CreateSession](https://developer.perculus.com/v2-tr/servisler/oturum-yonetimi/oturumlari-yaratma-ve-guncelleme/create-session-objesi) veya [UpdateSession](https://developer.perculus.com/v2-tr/servisler/oturum-yonetimi/oturumlari-yaratma-ve-guncelleme/update-session-objesi) objeleri tipinde olabilir.

{% hint style="info" %}
Aynı uç, oturumlar için hem oluşturma hem de güncelleme işlemlerini gerçekleştirir. İşlem türü, istek gövdesindeki `session_guid` parametresinin varlığına göre belirlenir. `session_guid`'in dahil edilmesi bir **güncelleme işlemi** anlamına gelirken, atlanması bir **oluşturma işlemi** anlamına gelir.
{% endhint %}

***

**Örnek istek:**

{% hint style="warning" %}
Tek tek API çağrıları yapmaktan kaçının, bu uç  tek bir istekte birden fazla oturum nesnesi (hem oluşturma hem güncelleme işlemleri) kabul eder.
{% endhint %}

{% tabs %}
{% tab title="CURL" %}

```bash
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
    }
]'
```

{% endtab %}

{% tab title="NodeJS" %}

```
client.sessions.upsertSessions([
        // 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 exist
        {
            "session_guid": "8293D504-13EE-447F-9B36-6686C5C39FEB",
            "duration": 100
        }
    ]);
```

{% endtab %}
{% endtabs %}

**Örnek yanıt:**

Bu operasyonun yanıtı şu şekilde bir json nesnesi içerir:&#x20;

```json
{ 
"approved": [ // Oturum için JSON nesneleri ],
"rejected": [ // Oturum için JSON nesneleri ] 
}
```

{% hint style="info" %}
Yanıt Durum Kodları, operasyonların nasıl gittiğine bağlı olarak değişecektir:

* <mark style="color:green;">**200 OK**</mark><mark style="color:green;">:</mark> Tüm işlemler başarıyla tamamlandı
* <mark style="color:green;">**207 Multi-Status**</mark><mark style="color:green;">:</mark> Kısmi başarı - bazı işlemler başarısız oldu
* <mark style="color:red;">**400 Bad Request**</mark><mark style="color:red;">:</mark> Tüm işlemler başarısız oldu
  {% endhint %}

<pre class="language-json"><code class="lang-json">{
    "approved": [
        {
            "session_guid": "1B27EB7F-6ECD-42B1-8CEC-4FE78B53A468",
            "name": "CS201",
            "description": null,
            "tags": null,
            "start_date": "2025-08-05T12:00:00+03:00",
            "timezone": "Europe/Istanbul",
            "duration": 120,
            "lang": "en-US",
            "status": 1,
            "replay_status": 0,
            "options": {
                "allow_rating": true,
                "preparation_time": 15,
                "session_duration": 120,
                "chat": {
                    "offMessageModule": false,
                    "offGeneralMsging": false,
                    "offGeneralMsgLimitForUser": false,
                    "offSpecialMsging": false,
                    "offSpecialMsgToAdmin": false,
                    "offSpecialMsgToUser": false,
                    "offNewMsgSound": false,
                    "offClearForReplay": false,
                    "onNewMsgSoundInAll": false,
                    "onNewMsgNotifyInAll": false
                },
                "duration": {
                    "allowExtendTime": true,
                    "useRemainingTime": false
                },
                "allow_users_stream_self_cam_mic": true,
                "hide_user_streams": false,
                "enable_attendance_check": true,
                "enable_simultaneous_interpretation": false,
                "enable_simultaneous_interpretation_for_users": false,
                "start_active": false,
                "return_url": "",
                "allow_reactions": true,
                "enable_recording_auto_start": null,
                "skip_approval_on_join": null,
                "enable_session_auto_start": null,
                "enable_session_auto_finish": null
            },
            "creation_date": "2025-02-06T16:07:35.488565+03:00",
            "updating_date": "2025-02-06T16:07:35.488565+03:00"
        },
        {
            "session_guid": "61E3D504-13EE-447F-9B36-6686C5C39FEB",
            "name": "Web Development 101",
            "description": null,
            "tags": null,
            "start_date": "2025-08-05T12:00:00+03:00",
            "timezone": "Europe/Istanbul",
            "duration": 100,
            "lang": "en-US",
            "status": 1,
            "replay_status": 0,
            "options": {
                "allow_rating": true,
                "preparation_time": 15,
                "session_duration": 100,
                "chat": {
                    "offMessageModule": false,
                    "offGeneralMsging": false,
                    "offGeneralMsgLimitForUser": false,
                    "offSpecialMsging": false,
                    "offSpecialMsgToAdmin": false,
                    "offSpecialMsgToUser": false,
                    "offNewMsgSound": false,
                    "offClearForReplay": false,
                    "onNewMsgSoundInAll": false,
                    "onNewMsgNotifyInAll": false
                },
                "duration": {
                    "allowExtendTime": true,
                    "useRemainingTime": false
                },
                "allow_users_stream_self_cam_mic": true,
                "hide_user_streams": false,
                "enable_attendance_check": true,
                "enable_simultaneous_interpretation": false,
                "enable_simultaneous_interpretation_for_users": false,
                "start_active": false,
                "return_url": "",
                "allow_reactions": true,
                "enable_recording_auto_start": null,
                "skip_approval_on_join": null,
                "enable_session_auto_start": null,
                "enable_session_auto_finish": null
            },
            "creation_date": "2025-02-06T15:23:48.490759+03:00",
            "updating_date": "2025-02-06T16:07:35.488565+03:00"
        }
    ],
    "rejected": [
        {
<strong>            "model": {
</strong>                "session_id": 0,
                "string_session_id": null,
                "the_guid": "8293D504-13EE-447F-9B36-6686C5C39FEB",
                "name": null,
                "description": null,
                "tags": null,
                "start_date": "1970-01-01T00:00:00+00:00",
                "duration": 100,
                "lang": "en-US",
                "account_id": 1329,
                "realtime_server": null,
                "conference_server": null,
                "file_server": null,
                "status": 1,
                "replay_status": 0,
                "ui_options": "{\"allow_rating\":true,\"preparation_time\":15,\"session_duration\":100,\"Chat\":{\"OffMessageModule\":false,\"OffGeneralMsging\":false,\"OffGeneralMsgLimitForUser\":false,\"OffSpecialMsging\":false,\"OffSpecialMsgToAdmin\":false,\"OffSpecialMsgToUser\":false,\"OffNewMsgSound\":false,\"OffClearForReplay\":false,\"OnNewMsgSoundInAll\":false,\"OnNewMsgNotifyInAll\":false},\"Duration\":{\"AllowExtendTime\":true,\"UseRemainingTime\":false},\"allow_users_stream_self_cam_mic\":true,\"hide_user_streams\":false,\"enable_attendance_check\":true,\"enable_simultaneous_interpretation\":false,\"enable_simultaneous_interpretation_for_users\":false,\"start_active\":false,\"return_url\":\"\",\"allow_reactions\":true,\"enable_recording_auto_start\":null,\"skip_approval_on_join\":null,\"enable_session_auto_start\":null,\"enable_session_auto_finish\":null}",
                "user_started": null,
                "user_finished": null,
                "user_added": 4490,
                "user_updated": 4490,
                "creation_date": null,
                "updating_date": null,
                "custom_field1": null,
                "custom_field2": null,
                "custom_field3": null,
                "custom_field4": null,
                "custom_field5": null,
                "repeating_options": null,
                "replay_access": "on",
                "allow_recording": true,
                "planned_duration": 100,
                "timezone": "Europe/Istanbul",
                "groups": [],
                "attendees": [],
                "owner": null,
                "files": [],
                "questions": [],
                "enrollOptions": null,
                "sessionGroups": [],
                "_isValid": null,
                "_errors": null
            },
            "state": {
                "code": 30,
                "details": "session_not_found"
            }
        },
        {
            "model": {
                "session_guid": null,
                "name": "TR102",
                "description": null,
                "tags": null,
                "start_date": "2020-08-05T14:00:00+00:00",
                "duration": 120,
                "lang": "tr-TR",
                "allow_recording": true,
                "inaccessible_replay": false,
                "options": {
                    "allow_rating": false,
                    "preparation_time": null,
                    "session_duration": null,
                    "chat": null,
                    "duration": null,
                    "allow_users_stream_self_cam_mic": null,
                    "hide_user_streams": null,
                    "enable_attendance_check": null,
                    "enable_simultaneous_interpretation": null,
                    "enable_simultaneous_interpretation_for_users": null,
                    "start_active": null,
                    "return_url": null,
                    "allow_reactions": null,
                    "enable_recording_auto_start": null,
                    "skip_approval_on_join": null,
                    "enable_session_auto_start": null,
                    "enable_session_auto_finish": null
                },
                "timezone": "Europe/Istanbul"
            },
            "state": {
                "code": 12,
                "details": [
                    "Invalid session start date."
                ]
            }
        }
    ]
}
</code></pre>
