# Transactions

## List all transactions

<mark style="color:blue;">`GET`</mark> `https://app.gem-books.com/api/transactions`

This endpoint allows you to get the list of your transactions. \
The transactions are returned sorted by creation date, with the most recent transaction appearing first.

#### Headers

| Name             | Type   | Description                   |
| ---------------- | ------ | ----------------------------- |
| Authentification | string | Bearer token.                 |
| Accept           | string | Should be `application/json`. |

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

```
{
    "data": [
        {
            "id": 13033,
            "number": "13017",
            "reference": "test",
            "date": "2020-08-17",
            "user": "AAA",
            "creation_date": "2020-08-18",
            "creation_time": "11:18:31",
            "description": "This is a test!",
            "name": "test",
            "period": "Current",
            "code": null,
            "details": [
                {
                    "account": "1200",
                    "reference": "test",
                    "amount": "10.00",
                    "currency": "CAD",
                    "credit": "C"
                },
                {
                    "account": "4020",
                    "reference": "test",
                    "amount": "10.00",
                    "currency": "CAD",
                    "credit": "D"
                }
            ]
        },
        {
            "id": 13032,
            "number": "13016",
            "reference": "test",
            "date": "2020-08-17",
            "user": "AAA",
            "creation_date": "2020-08-18",
            "creation_time": "11:17:54",
            "description": "This is a test!",
            "name": "Test",
            "period": "Current",
            "code": null,
            "details": [
                {
                    "account": "1200",
                    "reference": "test",
                    "amount": "10.00",
                    "currency": "CAD",
                    "credit": "C"
                },
                {
                    "account": "4020",
                    "reference": "test",
                    "amount": "10.00",
                    "currency": "CAD",
                    "credit": "D"
                }
            ]
        }
    ],
    "meta": {
        "current_page": 1,
        "last_page": 521,
        "per_page": 25,
        "total": 13021
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

## Retrieve a transaction

<mark style="color:blue;">`GET`</mark> `https://app.gem-books.com/api/transactions/:id`

This endpoint allows you to access a specific transaction by its ID.

#### Path Parameters

| Name | Type   | Description        |
| ---- | ------ | ------------------ |
| id   | string | ID of transaction. |

#### Headers

| Name             | Type   | Description                   |
| ---------------- | ------ | ----------------------------- |
| Authentification | string | Bearer token.                 |
| Accept           | string | Should be `application/json`. |

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

```
{
    "data": {
        "id": 13033,
        "number": "13017",
        "reference": "test",
        "date": "2020-08-17",
        "user": "AAA",
        "creation_date": "2020-08-18",
        "creation_time": "11:18:31",
        "description": "This is a test!",
        "name": "test",
        "period": "99999",
        "code": null,
        "details": [
            {
                "account": "1200",
                "reference": "test",
                "amount": "10.00",
                "currency": "CAD",
                "credit": "C"
            },
            {
                "account": "4020",
                "reference": "test",
                "amount": "10.00",
                "currency": "CAD",
                "credit": "D"
            }
        ]
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

## Create a transaction

<mark style="color:green;">`POST`</mark> `https://app.gem-books.com/api/transactions`

This endpoint allows you to create a new transaction. \
The new transaction will be returned.

#### Headers

| Name             | Type   | Description                   |
| ---------------- | ------ | ----------------------------- |
| Authentification | string | Bearer token.                 |
| Accept           | string | Should be `application/json`. |
| Content-Type     | string | Should be `application/json`. |

#### Request Body

| Name        | Type   | Description                                                                                                                                                        |
| ----------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| code        | string | Provider or client code, this will be applied to all details using the provider or client's account. Only one provider or one client can be sent in a single call. |
| reference   | string | Transaction reference.                                                                                                                                             |
| date        | string | Transaction date.                                                                                                                                                  |
| details     | array  | All transaction legs (account,amount,currency,credit,reference,projet\_id).                                                                                        |
| description | string | Transaction description.                                                                                                                                           |

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

```
{
    "data": {
        "id": 13033,
        "number": "13017",
        "reference": "test",
        "date": "2020-08-17",
        "user": "AAA",
        "creation_date": "2020-08-18",
        "creation_time": "11:18:31",
        "description": "This is a test!",
        "name": "test",
        "period": "99999",
        "code": null,
        "details": [
            {
                "account": "1200",
                "reference": "test",
                "amount": "10.00",
                "currency": "CAD",
                "credit": "C"
            },
            {
                "account": "4020",
                "reference": "test",
                "amount": "10.00",
                "currency": "CAD",
                "credit": "D"
            }
        ]
    },
    "success": true
}
```

{% endtab %}
{% endtabs %}

#### Body example

```
{
    "reference": "test",
    "date": "2020-08-17",
    "description": "This is a test!",
    "code": "TEST",
    "labels": "1,2,3"
    "details": [
        {
            "account" : "1200",
            "reference" : "test",
            "amount" : "10.00",
            "credit" : "C",
            "currency" : "CAD",
            "projet_id" : "0"
        },
        {
            "account" : "4020",
            "reference" : "test",
            "amount" : "10.00",
            "credit" : "D",
            "currency" : "CAD",
            "projet_id" : "0"
        }
    ]
}
```


---

# 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.gem-suite.com/api-reference/resources/transactions.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.
