# Create Transaction

{% stepper %}
{% step %}

### Whitelist Server IP Address

Before initiating the transaction process, ensure that your server’s IP address is whitelisted in the Tutelar Panel. This step is crucial as it authorizes your server to communicate with the Tutelar Server.
{% endstep %}

{% step %}

### Generate API Keys

Generate the necessary API keys from the Tutelar Panel. These keys will be used to authenticate your API requests to the Tutelar Server, ensuring secure and verified communication.
{% endstep %}

{% step %}

### Submit Transaction via Create Transaction API

Utilize the Create Transaction API to submit a new transaction to the Tutelar Server. Ensure that all relevant transaction details are included in your request. The Tutelar Server will validate the submitted transaction data.
{% endstep %}

{% step %}

### Receive Transaction Validation Response

After validation, you will receive a response from the Tutelar Server containing the following critical pieces of information:

* **Risk Score**: A numerical value indicating the risk level of the transaction.
* **Risk Status**: A status indicator (e.g., high, medium, low) that reflects the assessed risk.
* **Reference Number**: A unique identifier for the transaction, useful for tracking and reference purposes.
* **Customer Information**: Details about the customer involved in the transaction.
  {% endstep %}

{% step %}

### Decision Making Based on Risk Assessment

Use the risk score, risk status, reference number, and customer information to decide whether to allow or deny the customer's payment. This decision is vital for fraud prevention and ensuring the security of transactions.
{% endstep %}

{% step %}

### Update Transaction Status

Upon successful or failed payment, it is imperative to call the Transaction Status API to update the status of the previously completed transaction. This step ensures that the transaction records are accurate and up-to-date.
{% endstep %}
{% endstepper %}

By following these steps, you can effectively manage and assess transaction risks, making informed decisions to approve or deny payments, thereby maintaining a secure and reliable payment process.

### Create a transaction

**post**

`https://secctrl.tutelar.io/api/v1/fraud-detector/transaction/create`

#### Body

`application/json`

* `deviceFingerPrint` string Optional\
  Encoded device fingerprint information\
  Example: `ewogICJpcEFkZHJlc3MiOiAiNDkuMjQ5LjYyLjE5OCIsCiAgImJyb3dz`
* `orderId` string · max: 40 Required\
  Unique order ID to identify the transaction\
  Example: `ORD_10726`
* `customer_ip` string Optional\
  The customer IP address involved in the transaction\
  Example: `49.207.180.255`
* `customer` object Required\
  Contains detailed information about the customer involved in the transaction, including their name, email address, phone number, and the country code associated with their phone number.
* `amount` number · float Required\
  The total amount of the transaction\
  Example: `299.99`
* `currencyCode` string Required\
  The currency code in which the transaction is conducted (e.g., INR, USD, EUR).\
  Example: `INR`
* `merchant` object Required\
  Contains detailed information about the merchant processing the transaction, including a unique identifier, name, email address, website URL, business name, phone number and risk level.
* `riskCode` string Optional\
  A code representing the risk level of the transaction\
  Example: `CL00001`
* `productType` string Optional\
  The type of product being purchased\
  Example: `Ecommerce`
* `productDescription` string Optional\
  A description of the product being purchased\
  Example: `Table`
* `billing` object Optional\
  The billing details for the transaction
* `shipping` object Optional\
  The shipping details for the transaction
* `paymentChannel` string · enum Optional\
  Indicates the channel through which the payment is processed, such as a payment gateway (pg), quick\_collect, or other supported payment channels.\
  Example: `pg`\
  Possible values: `pg` `quick_collect` `e_collect` `banking` `others`
* `paymentOption` string · enum Optional\
  Represents the specific payment option selected by the customer, such as payment link, EMI, or other supported payment options.\
  Example: `payment_link`\
  Possible values: `payment_link` `pay_out` `emi`
* `paymentInstrument` string · enum Required\
  The type of payment instrument used (card, netbanking, upi etc)\
  Example: `card`\
  Possible values: `card` `upi` `wallet` `ft` `nb`
* `paymentData` object Required\
  Contains specific details related to the payment method used for the transaction, including the name on the payment instrument, a secure token hash for the payment data, and the Bank Identification Number (BIN) of the payment instrument.
* `mcc` object Optional\
  The Merchant Category Code, which classifies the type of business.
* `industry` object Optional\
  The industry in which the merchant operates.
* `device` object Optional\
  Used when the encoded deviceFingerPrint field is absent. Use Case:- Server-to-server API calls
* `udf1` object Optional\
  UDF (User Defined Fields) allow for custom data storage: udf1-udf8 are customizable fields. **name**: Label of the field. **value**: Content of the field, tailored to user needs.
* `udf2` object Optional
* `udf3` object Optional
* `udf4` object Optional
* `udf5` object Optional
* `udf6` object Optional
* `udf7` object Optional
* `udf8` object Optional
* `udf9` object Optional
* `udf10` object Optional

#### Responses

**106 — Duplicate order id received**

```json
{
  "success": false,
  "message": "Duplicate order id received",
  "code": 106
}
```

**200 — Successful transaction creation**

**401 — Invalid authentication credentials**

**422 — Merchant status issues**

**500 — Product is unsubscribed**

{% hint style="info" %}
The Customer object is optional. If values are provided, they will be validated.
{% endhint %}

{% hint style="info" %}
The maximum length of request parameters

```
orderId: 40 characters,
customer.name: 120 characters,
merchant.id: 20 characters,
merchant.name: 120 characters,
merchant.email: 40 characters,
merchant.business_name: 120 characters,
merchant.website_url: 200 characters,
```

{% endhint %}

{% hint style="info" %}
**Request Parameter Validation Rules**

```json
{
  "merchant": {
    "id": "Alphanumeric characters (A-Z, a-z, 0-9) and special characters (@ $ _ -) with spaces allowed.",
    "email": "Valid email format (e.g., example@domain.com). The domain extension must be 2 or 3 characters long (e.g: .com, .in, .org, .net).",
    "name": "Alphanumeric characters, spaces, and special characters (. - & ' + ! @) allowed.",
    "business_name": "Alphanumeric characters, spaces, and special characters (. - & ' + ! @) allowed.",
    "website_url": "Valid URL format supporting http, https, and www (e.g., https://example.com or www.example.com).",
    "phone": "Only numeric values allowed (0-9), no spaces or special characters."
  }
}
```

{% endhint %}

{% hint style="info" %}
MCC API

```
https://secctrl.tutelar.io/api/v1/tutler/properties/open/mcc
```

Industry API

```
https://secctrl.tutelar.io/api/v1/tutler/properties/open/industry-type-list
```

{% endhint %}

### Pre Auth and Post Auth

The Transaction Create API has been enhanced to support both pre-authorization (pre-auth) and post-authorization (post-auth) transaction flows.

**API Description**

The Create API handles the creation of transactions in the pre-auth flow. For the post-auth flow, it also updates transaction details if `transactionId` and `status` are present in the request payload (`postData`).

**API Endpoint**: `https://stgsecctrl.tutelar.io/api/v1/fraud-detector-onstream/transaction/create`

#### Process Flow

**Pre-Auth Flow**:

The API performs the standard transaction creation logic.

**Post-Auth Flow**:

* The API performs the standard transaction creation logic.
* Additionally,
  1. It updates the transaction status, velocity, and risk results.
  2. It calculates SLA durations and schedules jobs to update SLA transactions if required.

#### Post Data

The request payload should be a JSON object containing the necessary transaction details.\
For post-auth flows, it should include `transactionId`, `status`, and optionally `statusReason`.

If the transaction is made in the post-auth flow, add the following data to the create API post data:

```json
{
  "status": "success",
  "transactionId": "trans_6789",
  "statusReason": "Payment Completed Successfully"
}
```

#### Use Cases

* **Valid Transaction ID and Status**
  * **Scenario**: Providing both a valid transactionId and status.
  * **Expected Result:** The API creates the transaction & updates the transaction details.
* **Invalid Status With Transaction ID**
  * **Scenario:** Providing an invalid status.
  * **Expected Result:** The API processes the request as a standard pre-auth transaction creation, ignoring the status and transactionId.
* **Status Without Transaction ID**
  * **Scenario:** Providing a status without a transactionId.
  * **Expected Result:** The API processes the request as a standard pre-auth transaction creation, ignoring the status.
* **Existing Transaction ID**
  * **Scenario:** Providing an existing transactionId.
  * **Expected Result:** The API creates the transaction & doesn’t update the transaction details.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.v2.tutelar.io/create-transaction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
