> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clearline.me/llms.txt
> Use this file to discover all available pages before exploring further.

# Post-purchase transaction to CMC

# Post transaction data upon tender in real-time to CMC

To send real-time post-tender (post-purchase) transaction data to CMC, 2 endpoints need to be called in sequence:

1. StartInteraction endpoint, get the sessionId from there
2. Call SendTransaction endpoint with the received sessionId

<img src="https://mintcdn.com/allmatics-7a6fd95a/vl0uc5llcrBHxF7x/images/api/pos-integration/post-purchase-transaction-to-cmc/image_ecf927f1.svg?fit=max&auto=format&n=vl0uc5llcrBHxF7x&q=85&s=05d237f263a6b6dfb9d8690999baeaf1" alt="post_transaction_SD.svg" width="630" height="703" data-path="images/api/pos-integration/post-purchase-transaction-to-cmc/image_ecf927f1.svg" />

## StartInteraction

**POST** [https://apitest.clearline.me/pos/\{posSystemId}/startInteraction](https://apitest.clearline.me/pos/\{posSystemId}/startInteraction)

### Input request

```
{
  "terminalId": "string",
  "posLocationId": "string",
  "posCompanyId": "string"
}
```

### Input parameters

| Field name    | Description                                            |
| ------------- | ------------------------------------------------------ |
| terminalId    | ID of the terminal on which the transaction was made\* |
| posLocationId | ID of the location where the transaction was made      |
| posCompanyId  | ID of the company where the transaction was made       |

\*This Terminal ID must be added to a CFS Terminal in ClearLine

### Response

```
{
  "data": {
    "terminalId": "string",
    "posLocationId": "string",
    "sessionId": "string",
    "posStatus": "Accepted"
  }
}
```

### Response parameters

| Field name    | Description                                                                                                |
| ------------- | ---------------------------------------------------------------------------------------------------------- |
| data          | Data block                                                                                                 |
| terminalId    | ID of the terminal on which the transaction was made                                                       |
| posLocationId | ID of the location where the transaction was made                                                          |
| sessionId     | Session Id, call SendTransaction endpoint with the received sessionId                                      |
| posStatus     | Only "Accepted" POS can send a transaction (POS must be registered with CMC in order to use this endpoint) |

## SendTransaction

**POST** [https://apitest.clearline.me/pos/\{posSystemId}/transaction](https://apitest.clearline.me/pos/\{posSystemId}/transaction)

### Input request

```
{
  "sessionId": "string",
  "customer": {
    "id": "string",
    "firstName": "string",
    "lastName": "string",
    "birthDate": "2024-04-11T12:30:55.582Z",
    "contacts": [
      {
        "email": "string",
        "phone": "string"
      }
    ]
  },
  "salesPerson": {
    "id": "string",
    "firstName": "string",
    "lastName": "string"
  },
  "purchaseName": "string",
  "purchaseId": "string",
  "purchaseQuantity": 0,
  "purchasePrice": "string",
  "transactionId": "string",
  "transactionType": "Undefined",
  "transactionAmount": 0,
  "transactionDate": "2024-04-11T12:30:55.582Z",
  "products": [
    {
      "productId": "string",
      "productName": "string",
      "manufacturer": "string",
      "productCategory": "string",
      "quantity": 0
    }
  ],
  "loyalty": {
    "cardNumber": "string"
  }
}
```

### Input parameters

| Field name        | Description                                                           |
| ----------------- | --------------------------------------------------------------------- |
| sessionId         | Session ID form startInteraction endpoint                             |
| customer          | Customer data block                                                   |
| Id                | Customer id in third party system (POS)                               |
| firstName         | Customer first name                                                   |
| lastName          | Customer Last name                                                    |
| birthDate         | Customer birthdate                                                    |
| contacts          | Customer contacts data block                                          |
| email             | Customer email                                                        |
| phone             | Customer phone                                                        |
| salesPerson       | Sales person data block                                               |
| Id                | Sales person id in third party system (POS)                           |
| firstName         | Sales person first name                                               |
| lastName          | Sales person Last name                                                |
| purchaseName      | deprecated                                                            |
| purchaseId        | deprecated                                                            |
| purchaseQuantity  | deprecated                                                            |
| purchasePrice     | deprecated                                                            |
| transactionId     | Transaction ID received from third party system (POS)                 |
| transactionType   | Transaction type (from third party system)                            |
| transactionAmount | Amount of transaction                                                 |
| transactionDate   | Transaction date                                                      |
| products          | Products data block                                                   |
| productId         | Product ID from third party system (POS)                              |
| productName       | Product Name                                                          |
| manufacturer      | Product manufacturer                                                  |
| productCategory   | Product category from                                                 |
| quantity          | Number of products in the transaction (number of product identifiers) |
| cardNumber        | Loyalty card number                                                   |

### Response

```
{
  "data": {
    "id": "string",
    "qrCodeWidget": {
      "shortLinkUrl": "string",
      "qrCodeLinkUrl": "string",
      "qrCodeHtmlLinkUrl": "string",
      "notificationMessageId": "string",
      "profile": {
        "id": "string",
        "firstName": "string",
        "lastName": "string",
        "customerEmail": "string",
        "customerPhone": "string",
        "salesPerson": "string",
        "purchaseName": "string",
        "purchaseId": "string",
        "purchaseCategory": "string",
        "purchasePrice": "string",
        "gender": "string"
      }
    },
    "cfsTemplate": {
      "accountTemplateId": 0,
      "cfsCarouselUrl": "string"
    },
    "posStatus": "Accepted"
  }
}
```

### Response parameters

| Field name            | Description                                                                                                |
| --------------------- | ---------------------------------------------------------------------------------------------------------- |
| data                  | Data block                                                                                                 |
| id                    | Internal Transaction Id                                                                                    |
| qrCodeWidget          | QR code widget data block (QR code is available if the POS Rule was triggered for this transaction)\*\*    |
| shortLinkUrl          | Short link url for QR code generation                                                                      |
| qrCodeLinkUrl         | Link to the generated QR code image                                                                        |
| qrCodeHtmlLinkUrl     | Link to the generated QR code in HTML format                                                               |
| qrCodePreviewLinkUrl  | Link to the generated QR code for Preview                                                                  |
| notificationMessageId | Represent an ID to identify the message sent via email or SMS channels                                     |
| profile               | Customer profile data block, Represent recipient profile                                                   |
| Id                    | Internal Customer profile Id                                                                               |
| firstName             | Customer first name                                                                                        |
| lastName              | Customer Last name                                                                                         |
| customerEmail         | Customer email                                                                                             |
| customerPhone         | Customer phone                                                                                             |
| salesPerson           | Sales person name                                                                                          |
| purchaseName          | deprecated                                                                                                 |
| purchaseId            | deprecated                                                                                                 |
| purchaseCategory      | deprecated                                                                                                 |
| purchasePrice         | deprecated                                                                                                 |
| gender                | Customer gender                                                                                            |
| sessionId             | Session ID with which the transaction was created                                                          |
| cfsTemplate           | CFS Template data block (CFS Template is available if the POS Rule was triggered for this transaction)\*\* |
| accountTemplateId     | Id of Account level Template for CFS                                                                       |
| cfsCarouselUrl        | Url for Customer Facing screen (CFS)                                                                       |
| posStatus             | Pos Status, possible values: Accepted, Disabled                                                            |

\*\*If the POS Rule was triggered for this transaction, the response to the transaction POST may contain either a QR code or a CFS Template.

### Response example

```
{
    "data": {
        "id": "661e83aa055b1e0001df1ace",
        "qrCodeWidget": {
            "shortLinkUrl": "https://shorttest.clearline.me/0619-Zj1Eh?sessionId=ad90306d-dec4-4ded-986e-0b774b8eb9b5",
            "qrCodeLinkUrl": "https://webtest.clearline.me:443/qrcode/Png?sizeType=Undefined&templateName=NORMAL&data=https%3A%2F%2Fshorttest.clearline.me%2F0619-Zj1Eh%3FsessionId%3Dad90306d-dec4-4ded-986e-0b774b8eb9b5&backgroundColor=%23F6F6FC&primaryText=Connect+with+our+smart+page+%26+see+all+our+marketing+offers+and+promotions+on+one+page.<br>+Scan+the+QR+Code+to+start.&secondaryText=SCAN+ME&hasFrame=True&primaryColor=%23190DB5&secondaryColor=%23740883&primaryTextColor=%23190DB5&secondaryTextColor=%23740883&logo=https%3A%2F%2Fstorage.googleapis.com%2Fclearline-test-images%2Fbrands%2F227%2Fe0150f94-b426-49e3-8df5-299781125b1d.png&width=300&height=300&hasPrintId=False&printId=0&hash=gujWO6EnV8Sqdd7bGuNlKu%2BXSihNt9eT1NNkx74Q2gY0twJjR711OFICI%2Ft0ubTZDXzTJTC%2BzXM294fJ0IcAC7n03fifFsbNnnovtVLInqHATkrV7W1IjnCPCC2S1Knat3UaCbpzaTAHY5ChQIWHm5MccQvLFOvOuugOwQWb1HaarrfErN14twmLtHmwr8Geh4ZBwL31HGHJDA18Vd5Dxr5VGLWTdS2ZEHl1cKp%2FzlN%2F%2FQID%2FtfdxDs0x%2F%2BqxQuvyXhdbDy%2BSnArk77svelUpvx%2F4zO%2FKklDjOeNwyY6d92lLkqNMeK7XiBBw1gIni9cIy2LPNq%2B4KLByr4bw8%2FzGw%3D%3D",
            "qrCodeHtmlLinkUrl": "https://webtest.clearline.me:443/qrcode/Html?sizeType=Undefined&templateName=NORMAL&data=https%3A%2F%2Fshorttest.clearline.me%2F0619-Zj1Eh%3FsessionId%3Dad90306d-dec4-4ded-986e-0b774b8eb9b5&backgroundColor=%23F6F6FC&primaryText=Connect+with+our+smart+page+%26+see+all+our+marketing+offers+and+promotions+on+one+page.<br>+Scan+the+QR+Code+to+start.&secondaryText=SCAN+ME&hasFrame=True&primaryColor=%23190DB5&secondaryColor=%23740883&primaryTextColor=%23190DB5&secondaryTextColor=%23740883&logo=https%3A%2F%2Fstorage.googleapis.com%2Fclearline-test-images%2Fbrands%2F227%2Fe0150f94-b426-49e3-8df5-299781125b1d.png&width=300&height=300&hasPrintId=False&printId=0&hash=gujWO6EnV8Sqdd7bGuNlKu%2BXSihNt9eT1NNkx74Q2gY0twJjR711OFICI%2Ft0ubTZDXzTJTC%2BzXM294fJ0IcAC7n03fifFsbNnnovtVLInqHATkrV7W1IjnCPCC2S1Knat3UaCbpzaTAHY5ChQIWHm5MccQvLFOvOuugOwQWb1HaarrfErN14twmLtHmwr8Geh4ZBwL31HGHJDA18Vd5Dxr5VGLWTdS2ZEHl1cKp%2FzlN%2F%2FQID%2FtfdxDs0x%2F%2BqxQuvyXhdbDy%2BSnArk77svelUpvx%2F4zO%2FKklDjOeNwyY6d92lLkqNMeK7XiBBw1gIni9cIy2LPNq%2B4KLByr4bw8%2FzGw%3D%3D",
            "qrCodePreviewLinkUrl": null,
            "notificationMessageId": null,
            "profile": {
                "id": "643692fe562d480001b5a750",
                "firstName": "Philip",
                "lastName": "Moriss",
                "customerEmail": "mailto:emmail@data.com",
                "customerPhone": "+13800522333",
                "salesPerson": null,
                "purchaseName": null,
                "purchaseId": null,
                "purchaseCategory": null,
                "purchasePrice": null,
                "gender": "False"
            },
            "sessionId": null
        },
        "cfsTemplate": {
            "accountTemplateId": 0,
            "cfsCarouselUrl": null
        },
        "posStatus": "Accepted"
    }
}
```
