# Add Transaction

## How this example works

In this example, we will create a sample transaction to trigger the previously created campaign.

***

## Try yourself <a href="#to-try-it-yourself" id="to-try-it-yourself"></a>

* Input the previous saved [token](https://help.openloyalty.io/technical-guide/getting-started-guide/authentication) and [storeCode](https://help.openloyalty.io/technical-guide/member-registartion-configuration#to-try-it-yourself) in the request header
* Add a transaction\
  Endpoint: `POST /api/{storeCode}/transaction`

  ```postman_json
  {
      "transaction": {
          "items": [
              {
                  "sku": "12AB",
                  "name": "Restaurant",
                  "quantity": 1,
                  "grossValue": 500,
                  "category": "dine"
              }
          ],
          "header": {
              "documentType": "sell",
              "documentNumber": "12345",
              "purchasePlace": "onsite",
              "purchasedAt": "2024-05-01T00:00:00", // add current time
              "labels": []
          },
          "customerData": {
              "email": "john.smith@example.com"
          }
      }
  }
  ```
* This action should trigger `CampaignEffectWasApplied` [webhook](https://help.openloyalty.io/technical-guide/add-webhook#to-try-it-yourself)

***

## Endpoints used

{% openapi src="<https://content.gitbook.com/content/gIv2CyIIYf7vRfuhMKQ6/blobs/2xnMWXnOETp8Vxl2YZoi/openapi-5.61.0%20(1).json>" path="/api/{storeCode}/transaction" method="post" %}
[openapi-5.61.0 (1).json](https://content.gitbook.com/content/gIv2CyIIYf7vRfuhMKQ6/blobs/2xnMWXnOETp8Vxl2YZoi/openapi-5.61.0%20\(1\).json)
{% endopenapi %}

***

## More resources

For a detailed overview and description of the creation and management of the transaction, please refer to these series of articles:

{% content-ref url="<https://app.gitbook.com/s/cNVX03KZzmrGwJihLiEx/main-features/transactions>" %}
[Transactions](https://app.gitbook.com/s/cNVX03KZzmrGwJihLiEx/main-features/transactions)
{% endcontent-ref %}


---

# 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://help.openloyalty.io/technical-guide/getting-started-guide/add-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.
