# 1. Create Session

## Create Session

<mark style="color:green;">`POST`</mark> `{{Base Address}}/api/paywall/masterpass/session`

It will be sufficient to send a request to the address provided above. You can use the 'Base Address' for both the Test environment and the Production environment as you wish.

{% hint style="info" %}
Important: To use the Masterpass - Create Session service, you must include the parameters **'apikeyprivate'** and **'apiclientprivate'** in the 'Header' field.\
\
[<mark style="color:green;">**PaymentAPI Address**</mark>](https://developer.paywall.one/payment-orchestration-integration-document/environment)
{% endhint %}

<table><thead><tr><th width="182">Parameter</th><th width="106.33333333333331">Type</th><th width="140.18359375">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td>apikeyprivate</td><td>string</td><td>Yes</td><td>The Private Key obtained from the merchant panel.</td></tr><tr><td>apiclientprivate</td><td>string</td><td>Yes</td><td>The Private Client obtained from the merchant panel.</td></tr></tbody></table>

**The parameters that need to be sent to the service are as follows:**

<table><thead><tr><th width="228">Parameter</th><th width="106">Type</th><th width="175">Mandotory</th><th>Description</th></tr></thead><tbody><tr><td>ReferenceCode</td><td>string</td><td>Yes</td><td>The unique tracking number of the related session.</td></tr><tr><td>UserId</td><td>string</td><td>Yes</td><td>The unique identity number of the user in your system on the payment screen.</td></tr><tr><td>UserPhone</td><td>string</td><td>Yes</td><td>The verified phone number of the user on the payment screen.</td></tr><tr><td>Force3D</td><td>bool</td><td>No</td><td>If the relevant parameter is sent as true, all payment processes will proceed with 3D Secure.</td></tr><tr><td>PhoneVerifiedByMerchant</td><td>bool</td><td>No</td><td>If the relevant phone number has been verified in your system, this parameter should be sent as <code>true.</code>This way, Masterpass will not perform the phone number verification again.</td></tr></tbody></table>

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

```json5
{
    "ReferenceCode": "{{$guid}}",
    "UserId": "72812393211", // Kullanıcının sisteminizdeki tekil kimlik bilgisi
    "UserPhone": "905123456710", // Kullanıcının sisteminizdeki doğrulanmış telefon numarası
    "Force3D": false, // Kullanıcı tüm ödeme akışında 3D'ye zorlansın mı?
    "PhoneVerifiedByMerchant": true // Telefon doğrulaması yapıldı mı?
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
// Soon
```

{% endtab %}

{% tab title="GO" %}

```go
// Soon
```

{% endtab %}

{% tab title="Java" %}

```java
// Soon
```

{% endtab %}

{% tab title="PHP" %}

```php
// Soon
```

{% endtab %}

{% tab title="Python" %}

```python
// Soon
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
// Soon
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
// Soon
```

{% endtab %}

{% tab title="Curl" %}

```sh
// Soon
```

{% endtab %}
{% endtabs %}

**Response returned from the service:**

<table><thead><tr><th width="156">Parameter</th><th width="83.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>Body</td><td><mark style="color:blue;">Body</mark></td><td>JSON containing payment details (optional)</td></tr><tr><td>ErrorCode</td><td>int</td><td>Error code. Returns '0' if the transaction is successful.</td></tr><tr><td>Result</td><td>bool</td><td>Returns either true or false. If the transaction is successful, it returns true.</td></tr><tr><td>Message</td><td>string</td><td>If the transaction fails, this is the error message provided, with language support according to the locale parameter.</td></tr></tbody></table>

**Response returned from the service (**<mark style="color:blue;">**Body**</mark>**):**

<table><thead><tr><th width="181">Parameter</th><th width="83.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>SessionId</td><td><mark style="color:$primary;">Guid</mark></td><td>This is the identifier of the relevant session. It is used for authorization throughout the entire process. This information must be stored on your side until the process is completed.</td></tr><tr><td>SessionExpiryDate</td><td>DateTime</td><td>The expiration date of the session. When it is automatically renewed, the response objects of other Masterpass services will include the new SessionId and new SessionExpiryDate information.</td></tr></tbody></table>

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

```json5
{
    "ErrorCodeType": 1,
    "ErrorMessage": null,
    "ErrorCode": 0,
    "Result": true,
    "Message": "",
    "Body": {
        "SessionId": "9b27433e-f36b-1410-80e5-004205aa382d",
        "SessionExpiryDate": "2025-07-27T11:24:57"
    }
}
```

{% endtab %}
{% endtabs %}
