---
title: "Create a flow"
description: "Create a session that spans multiple requests."
url: "https://docs.adyen.com/point-of-sale/shopper-engagement/create-session"
source_url: "https://docs.adyen.com/point-of-sale/shopper-engagement/create-session.md"
canonical: "https://docs.adyen.com/point-of-sale/shopper-engagement/create-session"
last_modified: "2022-12-27T10:00:00+01:00"
language: "en"
---

# Create a flow

Create a session that spans multiple requests.

[View source](/point-of-sale/shopper-engagement/create-session.md)

You can create a flow that spans multiple requests, including input, display, and payment requests. To do so, you send an admin request to start a session. The terminal shows the waiting screen after every input, display, and payment request until you end the session. This solves the issue that customers may think something is wrong if they provide input and then do not see anything happening on the terminal. The waiting screen is shown for a set amount of time, or until the next request is sent to the terminal.

This is useful for payment flows where someone needs to interact with a terminal, like [Pay at Table](/point-of-sale/pay-at-x). It shows that the POS system is not unresponsive, it is just busy doing something that takes a bit of time.

## How it works

You need to send two separate admin requests to mark the start and the end of a session. All requests in between belong to a single session.

To include multiple requests in one session:

1. Before you send the first request, [send an admin request to start the session](#start-session).

2. [Send multiple requests, including input, display, and payment requests](#send-input-requests).\
   When you send an input request, after the user provides input on the terminal, the waiting screen shows for the set amount of time. With display and payment requests, after showing your data on the screen, the waiting screen shows. If you send another request before the waiting screen expires, the waiting screen disappears.

   ![WaitingScreen](/images/d/f/4/8/9/df4897ce9491c6b047c08683fe7d613dff97ebb4-screen-enwaitingscreen.png)

3. After the last request, [send an admin request to end the session](#end-session).

## Step 1: Start the session

1. Create a JSON object with the following data elements:

   | Parameter   | Required                                                                                    | Description                                                                                                                                                                                                                                                                                             |
   | ----------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
   | `Session`   | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | An object with:- `ID`: the unique reference of the session.
   - `Type`: set the value to **Begin** to start the session.                                                                                                                                                                                  |
   | `Operation` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | An object with:- `Type`: the type of request after which the waiting screen shows: **InputRequest**, **DisplayRequest**, and **Payment** .
   - `Variant`: **WaitingScreen**.
   - `UserInterfaceData.WaitingScreenTimeoutMs`: how long the waiting screen is shown on the terminal display, in milliseconds. |

   **Data elements in JSON format**

   ```json
   {
       "Session": {
           "Id": 12345,
           "Type": "Begin"
       },
       "Operation": [
           {
               "Type": "InputRequest",
               "Variant": "WaitingScreen",
               "UserInterfaceData": {
                   "WaitingScreenTimeoutMs": 15000
               }
           },
           {
               "Type": "DisplayRequest",
               "Variant": "WaitingScreen",
               "UserInterfaceData": {
                   "WaitingScreenTimeoutMs": 10000
               }
           }
       ]
   }
   ```

   For now, the `Operation.Variant` can only have **WaitingScreen** as value. This shows the waiting screen animation on the terminal after every request until you end the session.

2. Encode the JSON object to Base64.

   **Base64 encoded message**

   ```raw
    
   ```

3. Make a [Terminal API](/point-of-sale/design-your-integration/terminal-api) admin request, specifying:

   * The standard [`SaleToPOIRequest.MessageHeader` ](/point-of-sale/design-your-integration/terminal-api#request-message-header)object, with `MessageClass` set to **Service** and `MessageCategory` set to **Admin**.

     | Parameter         | Required                                                                                    | Description                                                                                                                                                 |
     | ----------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
     | `ProtocolVersion` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | **3.0**                                                                                                                                                     |
     | `MessageClass`    | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | **Service**                                                                                                                                                 |
     | `MessageCategory` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | **Admin**                                                                                                                                                   |
     | `MessageType`     | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | **Request**                                                                                                                                                 |
     | `ServiceID`       | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | Your unique ID for this request, consisting of 1-10 alphanumeric characters. Must be unique within the last 48 hours for the terminal (`POIID`) being used. |
     | `SaleID`          | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | Your unique ID for the POS system component to send this request from.                                                                                      |
     | `POIID`           | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The unique ID of the terminal to send this request to. Format: *\[device model]-\[serial number]*.                                                          |

   - The [AdminRequest](https://docs.adyen.com/api-explorer/terminal-api/latest/post/admin) object, including:
     * `ServiceIdentification`: The Base64-encoded JSON object to begin the session.

   **Admin request - start session**

   ```json
   {
      "SaleToPOIRequest": {
         "MessageHeader": {
            "ProtocolVersion": "3.0",
            "MessageClass": "Service",
            "MessageCategory": "Admin",
            "MessageType": "Request",
            "ServiceID": "POSSystemID12345",
            "SaleID": "S00101",
            "POIID": "V400m-324688179"
         },
         "AdminRequest": {
            "ServiceIdentification": "ewogICAiU2Vzc2lvbiI6ewogICAgICAiSWQiOjEyMzQ1LAogICAgICAiVHlwZSI6IkJlZ2luIgogICB9LAogICAiT3BlcmF0aW9uIjpbCiAgICAgIHsKICAgICAgICAgIlR5cGUiOiJJbnB1dFJlcXVlc3QiLAogICAgICAgICAiVmFyaWFudCI6IldhaXRpbmdTY3JlZW4iLAogICAgICAgICAiVXNlckludGVyZmFjZURhdGEiOnsKICAgICAgICAgICAgIldhaXRpbmdTY3JlZW5UaW1lb3V0TXMiOjE1MDAwCiAgICAgICAgIH0KICAgICAgfQogICBdCn0="
          }
      }
   }
   ```

4. Check that the [AdminResponse](https://docs.adyen.com/api-explorer/terminal-api/latest/post/admin#responses-200-Response) shows `Response.Result` **Success**.\
   []()

   **Admin request - response**

   ```json
   {
       "SaleToPOIResponse": {
           "AdminResponse": {
               "Response": {
                   "Result": "Success"
               }
           },
           "MessageHeader": {
               "MessageCategory": "Admin",
               "MessageClass": "Service",
               "MessageType": "Response",
               "POIID": "V400m-324688179",
               "ProtocolVersion": "3.0",
               "SaleID": "POSSystemID12345",
               "ServiceID": "S00101"
           }
       }
   }
   ```

## Step 2: Send requests

1. Start sending the requests that you specified in the `operation.type`, including [input](/point-of-sale/shopper-engagement/shopper-input), [display](/point-of-sale/shopper-engagement/display-data), and [payment](/point-of-sale/basic-tapi-integration/make-a-payment) requests.
2. After every request sent, the screen shows the waiting screen for the amount of time specified in milliseconds in `UserInterfaceData.WaitingScreenTimeoutMs`.
3. Every new request interrupts the waiting screen.

## Step 3: End the session

1. Create a JSON object with the following data elements:

   | Parameter                       | Required                                                                                    | Description                                                                                                                                                         |
   | ------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
   | `ServiceIdentification.Session` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | An object with:- `Id`: the unique reference of the session. This must be the same `Id` as in the start session `AdminRequest`).
   - `Type`: set the value to **End**. |

   **Data elements in JSON format**

   ```json
   {
       "Session": {
           "Id": 12345,
           "Type": "End"
       }
   }
   ```

2. Encode the JSON object to Base64.

   **Base64 encoded message**

   ```raw
   ewogICAgIlNlc3Npb24iOiB7CiAgICAgICAgIklkIjogMTIzNDUsCiAgICAgICAgIlR5cGUiOiAiRW5kIgogICB9Cn0=
   ```

3. Make a [Terminal API](/point-of-sale/design-your-integration/terminal-api) admin request like you did in [Step 1](#admin-response), including:

   * The [AdminRequest](https://docs.adyen.com/api-explorer/terminal-api/latest/post/admin) object with:
     * `ServiceIdentification`: The Base64-encoded JSON object to end the session.

   **Admin request - end session**

   ```json
   {
      "SaleToPOIRequest":{
         "MessageHeader":{
            "ProtocolVersion": "3.0",
            "MessageClass": "Service",
            "MessageCategory": "Admin",
            "MessageType": "Request",
            "ServiceID": "S00101",
            "SaleID": "POSSystemID12345",
            "POIID": "V400m-324688179"
         },
         "AdminRequest":{
            "ServiceIdentification": "ewogICAgIlNlc3Npb24iOiB7CiAgICAgICAgIklkIjogMTIzNDUsCiAgICAgICAgIlR5cGUiOiAiRW5kIgogICB9Cn0="
          }
      }
   }
   ```

4. Check that the [AdminResponse](https://docs.adyen.com/api-explorer/terminal-api/latest/post/admin#responses-200-Response) shows `Response.Result` **Success** (see [Step 1](#admin-response)).

You can send an admin request to end the session while the waiting screen is still on the display. This does not interrupt the waiting screen like other requests.\
After the session ends, the waiting screen no longer shows after sent input, display, or payment requests.

## See also

* [Get input on the terminal](/point-of-sale/shopper-engagement/shopper-input)
