# Introduction

How to connect our API into your application.

### Getting Started

{% hint style="info" %}
**Note:** To use our APIs, you need to have an [XtraKit account](https://xtrakit.com). On the XtraKit dashboard, we will generate any API for you.
{% endhint %}

## Overview

Our APIs are designed to integrate seamlessly with your systems and applications. This document serves as a comprehensive reference for all the features accessible to you through our APIs for adding and fetching data. It's designed around the primary resources you'll need most frequently and is made with RESTful standards in mind.

### HTTP Methods <a href="#api-basics-1" id="api-basics-1"></a>

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><mark style="color:yellow;"><strong><code>POST</code></strong></mark></td><td>To add new business data to the system, use this request.</td></tr><tr><td><mark style="color:green;"><strong><code>GET</code></strong></mark></td><td>To add and retrieve business data from the system, use this request.</td></tr><tr><td><mark style="color:purple;"><strong><code>PUT</code></strong></mark></td><td>To update an existing business record in the system, use this request.</td></tr><tr><td><mark style="color:red;"><strong><code>DELETE</code></strong></mark></td><td>To remove business records from the system, use this request. Removal is permanent.</td></tr></tbody></table>

## Authentication

Place your API key in the Authorisation header of each request you make to ensure the authenticity of your API calls. From your [API settings](https://app.xtrakit.com/settings/apis) page, you can manage your API key.

However, the API key must remain confidential. You can reset your API key or, if you think it has been compromised for any reason, change it from the [API settings](https://app.xtrakit.com/settings/apis) page.

The following format should be used for authorisation headers:

`Authorization: Bearer API_KEY`

{% hint style="info" %}
**Sample Authorization Header**

Authorization: Bearer 92857043717beff382ae75c8dc7514162f04
{% endhint %}

```php
curl -H "Authorization: Bearer API_KEY" \
     https://api.xtrakit.com/api/v1/user/authenticate
```

## Requests and Response <a href="#authentication-1" id="authentication-1"></a>

The format of the response and request payloads is JSON. Responses will always have `application/json` as their content type. Each response will typically follow this format:

## Response Formats

| Response | Data type | Description                                                                                      |
| -------- | --------- | ------------------------------------------------------------------------------------------------ |
| status   | number    | The HTTP status code indicating a status operation.                                              |
| message  | string    | This gives you detailed explaination on the request sent. The interpretation of the status code. |
| data     | object    | An object holding any data that the API returned after receiving the request.                    |

## **Status Codes and Interpretation**

| Status Code | Interpretation                                            |
| ----------- | --------------------------------------------------------- |
| `200`       | Standard for successful request.                          |
| `201`       | Used for requests as a result of creation.                |
| `204`       | Indicates that a request has succeeded or been processed. |
| `400`       | For bad requests.                                         |
| `401`       | For unathorized.                                          |
| `402`       | For payment required.                                     |
| `404`       | For not found.                                            |
| `500`       | For internal server errors.                               |


# Sales

XtraKit's Sales API allows you to programmatically handle sales data. Sales management may be easily integrated into your applications by using it to retrieve, add, change, or manage sales.

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>List Sale </strong><mark style="color:green;"><strong><code>GET</code></strong></mark></td><td>Retrieve a list of all sales and you can also filter your results.</td><td></td><td><a href="/overview/sales/list-sales">List Sales</a></td></tr><tr><td><strong>Fetch Sale </strong><mark style="color:green;"><strong><code>GET</code></strong></mark></td><td>Retrieve a specific sale using the invoice code. To retrieve complete sale details.</td><td></td><td><a href="/overview/sales/fetch-sale">Fetch Sale</a></td></tr><tr><td> <strong>Add Sale </strong><mark style="color:yellow;"><strong><code>POST</code></strong></mark></td><td>Allows you to add a new sales record such as an invoice or receipt. </td><td></td><td><a href="/overview/sales/add-sale">Add Sale</a></td></tr><tr><td> <strong>Edit Sale </strong><mark style="color:purple;"><strong><code>PUT</code></strong></mark></td><td>Modify an existing sale's information. In an unfinalized sale, this endpoint can be used to change pricing, goods, or quantities.</td><td></td><td><a href="/overview/sales/edit-sale">Edit Sale</a></td></tr></tbody></table>


# List Sales

A list of all sales may be obtained using this endpoint. For emphasis on specific results, you can add filters based on date, status, customer, and other variables.

## Endpoint

<mark style="color:green;">**`GET`**</mark> `https://api.xtrakit.com/api/v1/sales`

## Headers

`Authorization: Bearer API_KEY`

## **Query Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>invoice_code </p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>Specify invoice code to retreive</td></tr><tr><td><p>customer_id </p><p><em><strong>number</strong></em></p></td><td>Optional</td><td>Filter sales by customer ID</td></tr><tr><td><p>invoice_type </p><p><em><strong>string</strong></em></p></td><td>Optional</td><td><p>Filter sales based on the invoice type</p><p><code>(pos, invoice, storefront)</code></p></td></tr><tr><td><p>payment_date </p><p><em><strong>date</strong></em></p></td><td>Optional</td><td>Filter sales by payment date</td></tr><tr><td><p>payment_status </p><p><em><strong>string</strong></em></p></td><td>Optional</td><td><p>Filter sales by payment status </p><p><code>(paid, partial, draft)</code></p></td></tr><tr><td><p>created_at </p><p><em><strong>datetime</strong></em></p></td><td>Optional</td><td><p>Start date for filtering sales records</p><p><code>(format: YYYY-MM-DD H:m:s)</code></p></td></tr><tr><td><p>due_date </p><p><em><strong>date</strong></em></p></td><td>Optional</td><td><p>End date for filtering sales records</p><p><code>(format: YYYY-MM-DD)</code></p></td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.xtrakit.com/api/v1/sales',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const config = {
    method: 'get',
    url: 'https://api.xtrakit.com/api/v1/sales',
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.xtrakit.com/api/v1/sales"
headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

response = requests.get(url, headers=headers)
print(response.json())
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Sales found: 20",
    "data": {
        "sales": {
            "id": 32,
            "invoice_code": 324232,
            "invoice_number": "INV-000001",
            "customer_id": "42",
            "sub_total_amount": "100.00",
            "total_amount": "200.00",
            "amount_paid": "200.00",
            "discount": "0.00",
            "invoice_type": "pos",
            "invoice_colour": "#FFFFFF",
            "invoice_note": null,
            "invoice_terms": "Thanks for doing business",
            "payment_internal_note": null,
            "payment_date": "2024-08-04",
            "payment_type": "2024-08-04",
            "payment_status": "paid",
            "issued_by": "Jones Nathal",
            "due_date": "2024-08-30",
            "reminder_date": "2024-08-25",
            "reminder_message": null,
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        },
        ...
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Fetch Sale

Retrieve a single invoice using this endpoint. By passing the invoice\_code to the endpoint.

## Endpoint

<mark style="color:green;">**`GET`**</mark> `https://api.xtrakit.com/api/v1/sales/{invoice_code}`

## Headers

`Authorization: Bearer API_KEY`

## **Path Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>invoice_code </p><p><em><strong>string</strong></em></p></td><td>Required</td><td>An invoice code is a unique code to retrieve a single sale. Should be passed through the URL</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

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

<pre class="language-php" data-full-width="true"><code class="lang-php">&#x3C;?php
<strong>$invoice_code = 'YOUR_INVOICE_CODE'; // Replace 'YOUR_INVOICE_CODE' with your actual invoice Code
</strong>
$url = 'https://api.xtrakit.com/api/v1/sales/' . $invoice_code;

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
</code></pre>

{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const invoice_code = 'YOUR_INVOICE_CODE'; // Replace 'YOUR_INVOICE_CODE' with your actual invoice Code

const config = {
    method: 'get',
    url: `https://api.xtrakit.com/api/v1/sales/{invoice_code}`,
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

invoice_code = 'YOUR_INVOICE_CODE' # Replace 'YOUR_INVOICE_CODE' with your actual invoice Code

url = f'https://api.xtrakit.com/api/v1/sales/{invoice_code}'

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

try:
    response = requests.get(url, headers=headers)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Sale found",
    "data": {
        "sales": {
            "id": 32,
            "invoice_code": 324232,
            "invoice_number": "INV-000001",
            "customer_id": "42",
            "sub_total_amount": "100.00",
            "total_amount": "200.00",
            "amount_paid": "200.00",
            "discount": "0.00",
            "invoice_type": "pos",
            "invoice_colour": "#FFFFFF",
            "invoice_note": null,
            "invoice_terms": "Thanks for doing business",
            "payment_internal_note": null,
            "payment_date": "2024-08-04",
            "payment_type": "2024-08-04",
            "payment_status": "paid",
            "issued_by": "Jones Nathal",
            "due_date": "2024-08-30",
            "reminder_date": "2024-08-25",
            "reminder_message": null,
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        },
        "sales-item": [
            {
                "id": 45,
                "invoice_code": "324232",
                "invoice_number": "INV-000001",
                "item_name": "Web Design",
                "description": "Including hosting",
                "unit_price": "100.00",
                "quantity": "2",
                "tax": "0.00",
                "created_at": "2024-08-04 08:23:45",
                "updated_at": "2024-08-04 02:00:43"
            },
            ...
        ],
        "sales-payment": [
            {
                "invoice_code": "324232",
                "customer_name": "Peter Amos",
                "amount_paid": "200.00",
                "payment_method": "Cash",
                "internal_payment_note": null,
                "issued_by": "Jones Nathal",
                "payment_at": "2024-08-04 08:23:45",
                "created_at": "2024-08-04 08:23:45",
                "updated_at": "2024-08-04 02:00:43"
            },
            ...
        ]
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Add Sale

Adding new sales may be obtained using this endpoint. For emphasis on specific results, you can add the following parameters when creating new sales.

## Endpoint

<mark style="color:yellow;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/sales/add`

## Headers

`Authorization: Bearer API_KEY`

## **Body Parameters**

<table><thead><tr><th width="336">Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>invoice_code </p><p><em><strong>string</strong></em></p></td><td>Required</td><td>An invoice code is a unique 6-digit code to generate. </td></tr><tr><td><p>invoice_number </p><p><em><strong>string</strong></em></p></td><td>Required</td><td>An invoice number is a unique 6-digit code to generate.  Prefix depends on the one you set on the system which would be appended automatically. <code>Example: INV-000001</code></td></tr><tr><td><p>customer_id </p><p><em><strong>int</strong></em></p></td><td>Required</td><td>You can retrieve customer IDs from customers created and pull their primary ID here.</td></tr><tr><td><p>sub_total_amount </p><p><em><strong>decimal (10,2)</strong></em></p></td><td>Required</td><td>Subtotal amount of your sales in this format: <code>10.00</code></td></tr><tr><td><p>total_amount </p><p><em><strong>decimal (10,2)</strong></em></p></td><td>Required</td><td>The total amount of your sales after adding everything including tax, discount, etc. In this format: <code>10.00</code></td></tr><tr><td><p>amount_paid </p><p><em><strong>decimal (10,2)</strong></em></p></td><td>Required</td><td>The amount received from the customer when creating this sale. If the amount is zero (0) and the payment method is none, it means the invoice status is <code>DRAFT</code></td></tr><tr><td><p>discount </p><p><em><strong>decimal (10,2)</strong></em></p></td><td>Optional</td><td>Discounts given to the customer on sale can be <code>null.</code> Discount is in value not percentage. <code>Example: 10.00</code></td></tr><tr><td><p>invoice_type </p><p><em><strong>string</strong></em></p></td><td>Required</td><td>We have 3 types of invoices in our system, with 3 Statuses: <code>main</code>, <code>pos</code>, and <code>order</code>. So, the main is the XtraKit dashboard, pos is the XtraPOS, and order is the Storefront.</td></tr><tr><td><p>invoice_colour </p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>To set your custom invoice colour, you need to put colour by using a colour code like this: <code>#FFFFFF</code></td></tr><tr><td><p>invoice_note </p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>If you want to add a message to your invoice.</td></tr><tr><td><p>invoice_terms</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>What terms and conditions do you want to add to the invoice? Maybe half payment should be made before work.</td></tr><tr><td><p>payment_type</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>Payment method or type can be of these options: <code>None</code>, <code>Mobile Money</code>, <code>Cash</code>, <code>Bank Transfer / Deposit</code>, <code>Cheque</code>, <code>Card Payment, Digital Payment</code> and <code>Other Payment</code></td></tr><tr><td><p>payment_internal_note</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>You want to add any payment message for internal use only. The customer won't see this message.</td></tr><tr><td><p>issued_by</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>Name of the person who issued the invoice. Example: <code>Jones Nathal</code></td></tr><tr><td><p>due_date</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The latest date for when you must pay your invoice. Date format: <code>2024-08-30</code></td></tr><tr><td><p>reminder_date</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>The date you want us to send a reminder to the client on invoice payment. Date format: <code>2024-08-30</code></td></tr><tr><td><p>reminder_message</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>The reminder message you want us to send to the customer on the reminder date.</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php

$curl = curl_init();

$data = [
    "invoice_number" => "INV-000001",
    "customer_id" => "42",
    "sub_total_amount" => "100.00",
    "total_amount" => "200.00",
    "amount_paid" => "200.00",
    "discount" => "0.00",
    "invoice_type" => "pos",
    "invoice_colour" => "#FFFFFF",
    "invoice_note" => "Thanks for doing business",
    "invoice_terms" => "60% payment before work commerce",
    "payment_date" => "2024-08-04",
    "payment_type" => "None",
    "payment_status" => "paid",
    "issued_by" => "Jones Nathal",
    "due_date" => "2024-08-30",
    "reminder_date" => "2024-08-25",
    "reminder_message" => ""
];
$url = 'https://api.xtrakit.com/api/v1/sales/add';

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const data = {
    "invoice_number": "INV-000001",
    "customer_id": "42",
    "sub_total_amount": "100.00",
    "total_amount": "200.00",
    "amount_paid": "200.00",
    "discount": "0.00",
    "invoice_type": "pos",
    "invoice_colour": "#FFFFFF",
    "invoice_note": "Thanks for doing business",
    "invoice_terms": "60% payment before work commerce",
    "payment_date" : "2024-08-04",
    "payment_type": "None",
    "payment_status": "paid",
    "issued_by": "Jones Nathal",
    "due_date": "2024-08-30",
    "reminder_date": "2024-08-25",
    "reminder_message": ""
};

const config = {
    method: 'post',
    url: `https://api.xtrakit.com/api/v1/sales/add`,
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    },
    data: data 
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

data = {
    "invoice_number": "INV-000001",
    "customer_id": "42",
    "sub_total_amount": "100.00",
    "total_amount": "200.00",
    "amount_paid": "200.00",
    "discount": "0.00",
    "invoice_type": "pos",
    "invoice_colour": "#FFFFFF",
    "invoice_note": "Thanks for doing business",
    "invoice_terms": "60% payment before work commerce",
    "payment_date" : "2024-08-04",
    "payment_type": "None",
    "payment_status": "paid",
    "issued_by": "Jones Nathal",
    "due_date": "2024-08-30",
    "reminder_date": "2024-08-25",
    "reminder_message": ""
}

url = f'https://api.xtrakit.com/api/v1/sales/add'
headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

try:
    response = requests.post(url, headers=headers, json=data)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Sale added successfully",
    "data": {
        "sales": {
            "id": 32,
            "invoice_code": 324232,
            "invoice_number": "INV-000001",
            "customer_id": "42",
            "sub_total_amount": "100.00",
            "total_amount": "200.00",
            "amount_paid": "200.00",
            "discount": "0.00",
            "invoice_type": "pos",
            "invoice_colour": "#FFFFFF",
            "invoice_note": "Thanks for doing business",
            "invoice_terms": null,
            "payment_internal_note": null,
            "payment_date": "2024-08-04",
            "payment_type": "None",
            "payment_status": "paid",
            "issued_by": "Jones Nathal",
            "due_date": "2024-08-30",
            "reminder_date": "2024-08-25",
            "reminder_message": null,
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        },
        "sales-item": [
            {
                "id": 45,
                "invoice_code": "324232",
                "invoice_number": "INV-000001",
                "item_name": "Web Design",
                "description": "Including hosting",
                "unit_price": "100.00",
                "quantity": "2",
                "tax": "0.00",
                "created_at": "2024-08-04 08:23:45",
                "updated_at": "2024-08-04 02:00:43"
            },
            ...
        ],
        "sales-payment": [
            {
                "invoice_code": "324232",
                "customer_name": "Peter Amos",
                "amount_paid": "200.00",
                "payment_method": "Cash",
                "internal_payment_note": null,
                "issued_by": "Jones Nathal",
                "payment_at": "2024-08-04 08:23:45",
                "created_at": "2024-08-04 08:23:45",
                "updated_at": "2024-08-04 02:00:43"
            },
            ...
        ]
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Edit Sale

Updates an existing sale record . This endpoint allows modification of any of the sales details, including customer id , invoice code , invoice number , total amount   and other variables.

## Endpoint

<mark style="color:purple;">**`PUT`**</mark> `https://api.xtrakit.com/api/v1/sales/edit/{invoice_code}`

## Headers

`Authorization: Bearer API_KEY`

## Path Parameters

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>invoice_code </p><p><em><strong>string</strong></em></p></td><td>Required</td><td>An invoice code is a unique code to retrieve a single sale. Should be passed through the URL</td></tr></tbody></table>

## Body Parameters

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>invoice_code </p><p><em><strong>string</strong></em></p></td><td>Required</td><td>An invoice code is a unique 6-digit code to generate. </td></tr><tr><td><p>invoice_number </p><p><em><strong>string</strong></em></p></td><td>Required</td><td>An invoice number is a unique 6-digit code to generate.  Prefix depends on the one you set on the system which would be appended automatically. <code>Example: INV-000001</code></td></tr><tr><td><p>customer_id </p><p><em><strong>int</strong></em></p></td><td>Required</td><td>You can retrieve customer IDs from customers created and pull their primary ID here.</td></tr><tr><td><p>sub_total_amount </p><p><em><strong>decimal (10,2)</strong></em></p></td><td>Required</td><td>Subtotal amount of your sales in this format: <code>10.00</code></td></tr><tr><td><p>total_amount </p><p><em><strong>decimal (10,2)</strong></em></p></td><td>Required</td><td>The total amount of your sales after adding everything including tax, discount, etc. In this format: <code>10.00</code></td></tr><tr><td><p>amount_paid </p><p><em><strong>decimal (10,2)</strong></em></p></td><td>Required</td><td>The amount received from the customer when creating this sale. If the amount is zero (0) and the payment method is none, it means the invoice status is <code>DRAFT</code></td></tr><tr><td><p>discount </p><p><em><strong>decimal (10,2)</strong></em></p></td><td>Optional</td><td>Discounts given to the customer on sale can be <code>null.</code> Discount is in value not percentage. <code>Example: 10.00</code></td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$invoice_code = 'YOUR_INVOICE_CODE' # Replace 'YOUR_INVOICE_CODE' with your actual invoice Code

$data = [
    "invoice_number" => "INV-000001",
    "customer_id" => "42",
    "sub_total_amount" => "100.00",
    "total_amount" => "200.00",
    "amount_paid" => "200.00",
    "discount" => "0.00",
    "invoice_type" => "pos",
    "invoice_colour" => "#FFFFFF",
    "invoice_terms" => "Thanks for doing business",
    "payment_date" => "2024-08-04",
    "payment_type" => "2024-08-04",
    "payment_status" => "paid",
    "issued_by" => "Jones Nathal",
    "due_date" => "2024-08-30",
    "reminder_date" => "2024-08-25"
];

$curl = curl_init();

$url = 'https://api.xtrakit.com/api/v1/sales/edit/' . $invoice_code;

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const data = {
    "invoice_number": "INV-000001",
    "customer_id": "42",
    "sub_total_amount": "100.00",
    "total_amount": "200.00",
    "amount_paid": "200.00",
    "discount": "0.00",
    "invoice_type": "pos",
    "invoice_colour": "#FFFFFF",
    "invoice_terms": "Thanks for doing business",
    "payment_date": "2024-08-04",
    "payment_type": "2024-08-04",
    "payment_status": "paid",
    "issued_by": "Jones Nathal",
    "due_date": "2024-08-30",
    "reminder_date": "2024-08-25"
};

const config = {
    method: 'put',
    url: 'https://api.xtrakit.com/api/v1/sales/edit/{invoice_code}',
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    },
    data: data 
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = 'https://api.xtrakit.com/api/v1/sales/edit/{invoice_code}'

data = {
    "invoice_number": "INV-000001",
    "customer_id": "42",
    "sub_total_amount": "100.00",
    "total_amount": "200.00",
    "amount_paid": "200.00",
    "discount": "0.00",
    "invoice_type": "pos",
    "invoice_colour": "#FFFFFF",
    "invoice_terms": "Thanks for doing business",
    "payment_date": "2024-08-04",
    "payment_type": "2024-08-04",
    "payment_status": "paid",
    "issued_by": "Jones Nathal",
    "due_date": "2024-08-30",
    "reminder_date": "2024-08-25"
}

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

try:
    response = requests.put(url, headers=headers, json=data)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Sale updated successfully",
    "data": {
        "sales": {
            "id": 32,
            "invoice_code": 324232,
            "invoice_number": "INV-000001",
            "customer_id": "42",
            "sub_total_amount": "100.00",
            "total_amount": "200.00",
            "amount_paid": "200.00",
            "discount": "0.00",
            "invoice_type": "pos",
            "invoice_colour": "#FFFFFF",
            "invoice_note": null,
            "invoice_terms": "Thanks for doing business",
            "payment_internal_note": null,
            "payment_date": "2024-08-04",
            "payment_type": "2024-08-04",
            "payment_status": "paid",
            "issued_by": "Jones Nathal",
            "due_date": "2024-08-30",
            "reminder_date": "2024-08-25",
            "reminder_message": null,
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        },
        "sales-item": [
            {
                "id": 45,
                "invoice_code": "324232",
                "invoice_number": "INV-000001",
                "item_name": "Web Design",
                "description": "Including hosting",
                "unit_price": "100.00",
                "quantity": "2",
                "tax": "0.00",
                "created_at": "2024-08-04 08:23:45",
                "updated_at": "2024-08-04 02:00:43"
            },
            ...
        ],
        "sales-payment": [
            {
                "invoice_code": "324232",
                "customer_name": "Peter Amos",
                "amount_paid": "200.00",
                "payment_method": "Cash",
                "internal_payment_note": null,
                "issued_by": "Jones Nathal",
                "payment_at": "2024-08-04 08:23:45",
                "created_at": "2024-08-04 08:23:45",
                "updated_at": "2024-08-04 02:00:43"
            },
            ...
        ]
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Expenses

XtraKit's Expense API allows you to programmatically handle expenses data. Expense management may be easily integrated into your applications by using it to retrieve, add, change, or manage expenses.

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>List Expenses </strong><mark style="color:green;"><strong><code>GET</code></strong></mark></td><td>Retrieve a list of all expenses and you can also filter your results.</td><td></td><td><a href="/overview/expenses/list-expenses">List Expenses</a></td></tr><tr><td><strong>Fetch Expense </strong><mark style="color:green;"><strong><code>GET</code></strong></mark></td><td>Retrieve a specific expense using the invoice code. To retrieve complete expense details.</td><td></td><td><a href="/overview/expenses/fetch-expense">Fetch Expense</a></td></tr><tr><td> <strong>Add Expense </strong><mark style="color:yellow;"><strong><code>POST</code></strong></mark></td><td>Allows you to add a new expense record such as things you spend on. </td><td></td><td><a href="/overview/expenses/add-expense">Add Expense</a></td></tr><tr><td> <strong>Edit Expense </strong><mark style="color:purple;"><strong><code>PUT</code></strong></mark></td><td>Modify an existing expense's information.</td><td></td><td><a href="/overview/expenses/edit-expense">Edit Expense</a></td></tr></tbody></table>


# List Expenses

A list of all expenses may be obtained using this endpoint. For emphasis on specific results, you can add filters based on business code, expense type,  and other variables.

## Endpoint

<mark style="color:green;">**`GET`**</mark> `https://api.xtrakit.com/api/v1/expenses`

## Headers

`Authorization: Bearer API_KEY`

## **Query Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>expense_type </p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>Filter expenses by expense type.</td></tr><tr><td><p>created_at </p><p><em><strong>datetime</strong></em></p></td><td>Optional</td><td><p>Start date for filtering expenses records</p><p><code>(format: YYYY-MM-DD H:m:s)</code></p></td></tr><tr><td><p>updated_at </p><p><em><strong>date</strong></em></p></td><td>Optional</td><td><p>End date for filtering expenses records</p><p><code>(format: YYYY-MM-DD)</code></p></td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.xtrakit.com/api/v1/expenses',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const config = {
    method: 'get',
    url: 'https://api.xtrakit.com/api/v1/expenses',
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.xtrakit.com/api/v1/expenses"

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

response = requests.get(url, headers=headers)
print(response.json())
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Expenses found: 20",
    "data": {
        "expenses": {
            "id": 1,
            "expense_type": "Travel",
            "expense_description": "Flight ticket to Kumasi",
            "expense_amount": "200.00",
            "payment_method": "MOMO",
            "expense_image": "https://url-to-image.com/image.jpg",
            "created_by": "Edward",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        },
        ...
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Authentication invalid"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Fetch Expense

Retrieves detailed information about a specific expense identified by its unique ID. This endpoint is useful for viewing or verifying details of a particular expense record.

## Endpoint

<mark style="color:green;">**`GET`**</mark> `https://api.xtrakit.com/api/v1/expenses/{id}`

## Headers

`Authorization: Bearer API_KEY`

## **Path Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>id </p><p><em><strong>int</strong></em></p></td><td>Required</td><td>The unique ID of the expense to retrieve a single expense. Should be passed through the URL</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

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

<pre class="language-php" data-full-width="true"><code class="lang-php">&#x3C;?php
<strong>$id = 'YOUR_EXPENSE_ID'; // Replace 'YOUR_EXPENSE_ID' with your actual expense ID
</strong>$url = 'https://api.xtrakit.com/api/v1/expenses/' . $id;

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
</code></pre>

{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const id = 'YOUR_EXPENSE_ID'; // Replace 'YOUR_EXPENSE_ID' with your actual expense ID

const config = {
    method: 'get',
    url: `https://api.xtrakit.com/api/v1/expenses/{id}`,
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

<pre class="language-python"><code class="lang-python">import requests

id = 'YOUR_EXPENSE_ID' # Replace 'YOUR_EXPENSE_ID' with your actual expense ID

url = f'https://api.xtrakit.com/api/v1/expenses/{id}'
<strong>
</strong><strong>headers = {
</strong>    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

try:
    response = requests.get(url, headers=headers)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
</code></pre>

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Expense found",
    "data": {
       "expense": {
            "id": 1,
            "expense_type": "Travel",
            "expense_description": "Flight ticket to Kumasi",
            "expense_amount": "200.00",
            "payment_method": "MOMO",
            "expense_image": "https://url-to-image.com/image.jpg",
            "created_by": "Edward",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        }
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Authentication invalid"
}, 

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Add Expense

Adding new expenses may be obtained using this endpoint. For emphasis on specific results, you can add the following parameters when creating new expenses.

## Endpoint

<mark style="color:yellow;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/expenses/add`

## Headers

`Authorization: Bearer API_KEY`

## **Body Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>expense_type</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The type of the expense.</td></tr><tr><td><p>expense_description</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>A detailed description of the expense.</td></tr><tr><td><p>expense_amount</p><p><em><strong>decimal(10,2)</strong></em></p></td><td>Required</td><td>The amount of the expense  in this format: <code>10.00</code></td></tr><tr><td><p>payment_method</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The method used for payment.</td></tr><tr><td><p>expense_image</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>URL to an image or receipt associated with the expense.</td></tr><tr><td><p>created_by</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The user who created the record.</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php

$data = [
  'expense_type' => "Office Supplies",
  'expense_description' => 'Purchased new printer ink'
  'expense_amount' => "200.00", 
  'payment_method' => "MOMO", 
  'expense_image' => "https://url-to-image.com/image.jpg", 
  'created_by' => "Benjamin" 
  ];

$url = 'https://api.xtrakit.com/api/v1/expenses/add';

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY',  // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json' 
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>

```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const data = {
  'expense_type': "Office Supplies",
  'expense_description': 'Purchased new printer ink'
  'expense_amount': "200.00", 
  'payment_method': "MOMO", 
  'expense_image': "https://url-to-image.com/image.jpg", 
  'created_by': "Benjamin" 
  };

const config = {
    method: 'post',
    url: `https://api.xtrakit.com/api/v1/expenses/add`,
    headers: {
        'Authorization': 'Bearer API_KEY', // Replace 'API_KEY' with your actual API key
        "Content-Type": "application/json"
    },
    data: data 
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

data = {
  'expense_type': "Office Supplies",
  'expense_description': 'Purchased new printer ink'
  'expense_amount': "200.00", 
  'payment_method': "MOMO", 
  'expense_image': "https://url-to-image.com/image.jpg", 
  'created_by': "Benjamin" 
  }

url = f'https://api.xtrakit.com/api/v1/expenses/add'

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
    "Content-Type": "application/json"
}

try:
    response = requests.post(url, headers=headers, json=data)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Expense added successfully",
    "data": {
        "expense": {
            "id": 2,
            "expense_type": "Office Supplies",
            "expense_description": "Purchased new printer ink",
            "expense_amount": "200.00",
            "payment_method": "MOMO",
            "expense_image": "https://url-to-image.com/image.jpg",
            "created_by": "Benjamin",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        }
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Authentication invalid"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Edit Expense

Updates an existing expense record identified by its unique ID. This endpoint allows modification of any of the expense details, including expense type, description, and image URL.

## Endpoint

<mark style="color:purple;">**`PUT`**</mark> `https://api.xtrakit.com/api/v1/expenses/{id}`

## Headers

`Authorization: Bearer API_KEY`

## **Path Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>id </p><p><em><strong>int</strong></em></p></td><td>Required</td><td>The unique ID of the expense to edit a single expense. Should be passed through the URL</td></tr></tbody></table>

## **Body Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>expense_type</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The type of the expense.</td></tr><tr><td><p>expense_description</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>A detailed description of the expense.</td></tr><tr><td><p>expense_amount</p><p><em><strong>decimal(10,2)</strong></em></p></td><td>Required</td><td>The amount of the expense  in this format: <code>10.00</code></td></tr><tr><td><p>payment_method</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The method used for payment.</td></tr><tr><td><p>expense_image</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>URL to an image or receipt associated with the expense.</td></tr><tr><td><p>created_by</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The user who created the record.</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$id = 'YOUR_EXPENSE_ID'; // Replace 'YOUR_EXPENSE_ID' with your actual expense ID

$data = [
  'expense_type' => "Office Supplies",
  'expense_description' => 'Purchased new printer ink - Updated'
  'expense_amount' => "200.00", 
  'payment_method' => "MOMO", 
  'expense_image' => "https://url-to-image.com/updated_image.jpg", 
  'created_by' => "Edward" 
  ];

$url = 'https://api.xtrakit.com/api/v1/expenses/' . $id;

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

<pre class="language-javascript"><code class="lang-javascript">const axios = require('axios');

const id = 'YOUR_EXPENSE_ID'; // Replace 'YOUR_EXPENSE_ID' with your actual expense ID

const data = {
  'expense_type': "Office Supplies",
  'expense_description': 'Purchased new printer ink - Updated'
  'expense_amount': "200.00", 
  'payment_method': "MOMO", 
  'expense_image': "https://url-to-image.com/updated_image.jpg", 
  'created_by': "Edward" 
  };
  
<strong>const config = {
</strong>    method: 'put',
    url: `https://api.xtrakit.com/api/v1/expenses/{id}`,
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    },
    data: data 
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});

</code></pre>

{% endtab %}

{% tab title="Python" %}

```python
import requests

id = 'YOUR_EXPENSE_ID' # Replace 'YOUR_EXPENSE_ID' with your actual expense ID

data = {
  'expense_type': "Office Supplies",
  'expense_description': 'Purchased new printer ink - Updated'
  'expense_amount': "200.00", 
  'payment_method': "MOMO", 
  'expense_image': "https://url-to-image.com/updated_image.jpg", 
  'created_by': "Edward" 
  }
  
url = f'https://api.xtrakit.com/api/v1/expenses/{id}'

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

try:
    response = requests.put(url, headers=headers, json=data)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

<pre class="language-json"><code class="lang-json">{
    "status": 200,
    "message": "Expense updated successfully",
    "data": {
        "expenses": {
            "id": 2,
            "expense_type": "Office Supplies",
            "expense_description": "Purchased new printer ink - Updated",
            "expense_amount": "200.00",
            "payment_method": "MOMO",
            "expense_image": "https://url-to-image.com/updated_image.jpg",
            "created_by": "Edward",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
<strong>        }
</strong>    }
}
</code></pre>

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Authentication invalid"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Inventory

XtraKit's Inventory API allows you to programmatically handle items data. Items management may be easily integrated into your applications by using it to retrieve, add, change, or manage items.

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>List Items </strong><mark style="color:green;"><strong><code>GET</code></strong></mark></td><td>Retrieve a list of all items and you can also filter your results.</td><td></td><td><a href="/overview/inventory/list-items">List Items</a></td></tr><tr><td><strong>Fetch Item </strong><mark style="color:green;"><strong><code>GET</code></strong></mark></td><td>Retrieve a specific item using the item code. To retrieve complete item details.</td><td></td><td><a href="/overview/inventory/fetch-item">Fetch Item</a></td></tr><tr><td> <strong>Add Item </strong><mark style="color:yellow;"><strong><code>POST</code></strong></mark></td><td>Allows you to add a new item record such as a product or service. </td><td></td><td><a href="/overview/inventory/add-item">Add Item</a></td></tr><tr><td> <strong>Edit Item </strong><mark style="color:purple;"><strong><code>PUT</code></strong></mark></td><td>Modify an existing item's information. In an unfinalized item, this endpoint can be used to change pricing, status, or quantities.</td><td></td><td><a href="/overview/inventory/edit-item">Edit Item</a></td></tr></tbody></table>


# List Items

A list of all items available in the inventory may be obtained using this endpoint. For emphasis on specific results, you can add filters based on user, business, or category.

## Endpoint

<mark style="color:green;">**`GET`**</mark> `https://api.xtrakit.com/api/v1/inventory/items`

## Headers

`Authorization: Bearer API_KEY`

## **Query Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>category_id</p><p>int</p></td><td>Optional</td><td>Filters items by the category.</td></tr><tr><td><p>created_at </p><p><em><strong>datetime</strong></em></p></td><td>Optional</td><td><p>Start date for filtering items records</p><p><code>(format: YYYY-MM-DD H:m:s)</code></p></td></tr><tr><td><p>updated_at </p><p><em><strong>date</strong></em></p></td><td>Optional</td><td><p>End date for filtering items records</p><p><code>(format: YYYY-MM-DD)</code></p></td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.xtrakit.com/api/v1/inventory/items',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const config = {
    method: 'get',
    url: 'https://api.xtrakit.com/api/v1/inventory/items',
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

<pre class="language-python"><code class="lang-python">import requests

url = "https://api.xtrakit.com/api/v1/inventory/items"
<strong>
</strong><strong>headers = {
</strong>    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

response = requests.get(url, headers=headers)
print(response.json())
</code></pre>

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Items found: 20",
    "data": {
        "items": {
            "id": 1,
            "item_code": " Jce84a50",
            "item_name": "HP Laptop",
            "item_images": [
                    {
                        "id": 11,
                        "image_url": "https://pub-60b577bb37f54e02b085ea3d4d65a159.r2.dev/items/33123516/image1.jpg"
                    },
                    {
                        "id": 14,
                        "image_url": "https://pub-60b577bb37f54e02b085ea3d4d65a159.r2.dev/items/33123516/image2.jpg"
                    },
                    {
                        "id": 15,
                        "image_url": "https://pub-60b577bb37f54e02b085ea3d4d65a159.r2.dev/items/33123516/image3.jpg"
                    }
                ],
            "category_id": 1,
            "unit": "pcs",
            "description": "High-end gaming laptop with advanced graphics and processing power.",
            "unit_cost": 1000.00,
            "item_price": 1500.00,
            "previous_price": 1400.00,
            "quantity": "20",
            "minimum_qty_alert": "5",
            "online": 1,
            "status": "in-stock",
            "barcode": "123456789",
            "sku": "LAPTOP001",
            "warehouse_id": 2,
            "item_location": "A1",
            "item_slug": "laptop",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        },
        ...
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Authentication invalid"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# List Item Categories

This endpoint allows you to obtain a list of all item categories available in the inventory. To emphasise specific results, you can add filters based on category name.

## Endpoint

<mark style="color:green;">**`GET`**</mark> `https://api.xtrakit.com/api/v1/inventory/categories`

## Headers

`Authorization: Bearer API_KEY`

## **Query Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>category_name</p><p>string</p></td><td>Optional</td><td>Filters items by the category name.</td></tr><tr><td><p>created_at </p><p><em><strong>datetime</strong></em></p></td><td>Optional</td><td><p>Start date for filtering items records</p><p><code>(format: YYYY-MM-DD H:m:s)</code></p></td></tr><tr><td><p>updated_at </p><p><em><strong>date</strong></em></p></td><td>Optional</td><td><p>End date for filtering items records</p><p><code>(format: YYYY-MM-DD)</code></p></td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.xtrakit.com/api/v1/inventory/categories',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const config = {
    method: 'get',
    url: 'https://api.xtrakit.com/api/v1/inventory/categories',
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

<pre class="language-python"><code class="lang-python">import requests

url = "https://api.xtrakit.com/api/v1/inventory/categories"
<strong>
</strong><strong>headers = {
</strong>    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

response = requests.get(url, headers=headers)
print(response.json())
</code></pre>

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Item categories found",
    "data": {
        "item-categories": [
            {
                "id": 14,
                "category_name": "Protein",
                "created_at": "2023-11-27 07:49:27",
                "updated_at": "2023-11-27 07:49:27"
            },
            {
                "id": 15,
                "category_name": "Creatine",
                "created_at": "2023-11-27 07:49:47",
                "updated_at": "2023-11-27 07:49:47"
            },
            {
                "id": 26,
                "category_name": "Supplement",
                "created_at": "2025-01-07 21:53:50",
                "updated_at": "2025-01-07 21:53:50"
            },
            {
                "id": 27,
                "category_name": "Supplement 2",
                "created_at": "2025-01-07 22:56:53",
                "updated_at": "2025-01-07 22:56:53"
            }
        ]
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Authentication invalid"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Fetch Item

Retrieves the full details of a specific item based on the item's unique ID(item\_code). This is useful when you need in-depth information on a particular item, including its name, category and others.

## Endpoint

<mark style="color:green;">**`GET`**</mark>` ``https://api.xtrakit.com/api/v1/inventory/items/{item_code}`

## Headers

`Authorization: Bearer API_KEY`

## **Path Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>item_code</p><p>string</p></td><td>Required</td><td>The unique ID of the item to retrieve a single item. Should be passed through the URL. <code>(eg: Jce84a50)</code></td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$item_code = 'YOUR_ITEM_CODE'; // Replace 'YOUR_ITEM_CODE' with your actual item code
$url = 'https://api.xtrakit.com/api/v1/inventory/items/' . $item_code;

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const item_code = 'YOUR_ITEM_CODE'; // Replace 'YOUR_ITEM_CODE' with your actual item code
const config = {
    method: 'get',
    url: `https://api.xtrakit.com/api/v1/inventory/items/{item_code}`,
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

item_code = 'YOUR_ITEM_CODE' # Replace 'YOUR_ITEM_CODE' with your actual item code
url = f'https://api.xtrakit.com/api/v1/inventory/items/{item_code}'

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

try:
    response = requests.get(url, headers=headers)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

<pre class="language-json"><code class="lang-json">{
    "status": 200,
    "message": "Item found",
    "data": {
        "item": {
            "id": 1,
            "item_code": " Jce84a50",
            "item_name": "HP Laptop",
            "item_images": [
                    {
                        "id": 11,
                        "image_url": "https://pub-60b577bb37f54e02b085ea3d4d65a159.r2.dev/items/33123516/image1.jpg"
                    },
                    {
                        "id": 14,
                        "image_url": "https://pub-60b577bb37f54e02b085ea3d4d65a159.r2.dev/items/33123516/image2.jpg"
                    },
                    {
                        "id": 15,
                        "image_url": "https://pub-60b577bb37f54e02b085ea3d4d65a159.r2.dev/items/33123516/image3.jpg"
                    }
                ],
            "category_id": 1,
            "unit": "pcs",
            "description": "High-end gaming laptop with advanced graphics and processing power.",
            "unit_cost": 1000.00,
            "item_price": 1500.00,
            "previous_price": 1400.00,
            "quantity": "20",
            "minimum_qty_alert": "5",
            "online": 1,
            "status": "in-stock",
            "barcode": "123456789",
            "sku": "LAPTOP001",
            "warehouse_id": 2,
            "item_location": "A1",
            "item_slug": "laptop",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
<strong>        },
</strong>        "item-category": [  
            {
                "id": 1,
                "category_name": "Electronics",
                "created_at": "2024-08-04 08:23:45",
                "updated_at": "2024-08-04 02:00:43",
            },
            ...
        ],
    }
}
</code></pre>

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Authentication invalid"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Add Item

Allows you to add a new item to the inventory. This endpoint is used when introducing new products to your stock. You’ll need to provide essential details such as the item name, price and others.

## Endpoint

<mark style="color:yellow;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/inventory/items/add`

## Headers

`Authorization: Bearer API_KEY`

## **Body Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>item_name</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The name or title of the item.</td></tr><tr><td><p>category_id</p><p><em><strong>int</strong></em></p></td><td>Required</td><td>The ID representing the category this item belongs to.</td></tr><tr><td><p>unit</p><p><em><strong>string</strong></em></p></td><td>Required</td><td><p>The unit of measure for the item.</p><p><code>(pcs, kg, liters,...)</code></p></td></tr><tr><td><p>description</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>A detailed description of the item, providing more information about its features.</td></tr><tr><td><p>unit_cost</p><p><em><strong>decimal(10,2)</strong></em></p></td><td>Required</td><td>The cost price of a single unit of the item in this format: <code>10.00</code></td></tr><tr><td><p>item_price</p><p><em><strong>decimal(10,2)</strong></em></p></td><td>Required</td><td>The selling price of the item in this format: <code>10.00</code></td></tr><tr><td><p>previous_price</p><p><em><strong>decimal(10,2)</strong></em></p></td><td>Optional</td><td>The previous selling price of the item in this format: <code>10.00</code></td></tr><tr><td><p>quantity</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The available stock or quantity of the item.</td></tr><tr><td><p>minimum_qty_alert</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>A threshold quantity that triggers an alert when stock falls below this level.</td></tr><tr><td><p>online</p><p>int</p></td><td>Required</td><td><p>Indicator whether the item is available online. </p><p><code>Accepts 1 (true) or 0 (false)</code></p></td></tr><tr><td><p>status</p><p><em><strong>string</strong></em></p></td><td>Required</td><td><p>The availability status of the item. </p><p><code>(available, out of stock).</code></p></td></tr><tr><td><p>barcode</p><p>string</p></td><td>Optional</td><td>The barcode assigned to the item.</td></tr><tr><td><p>sku</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>The Stock Keeping Unit (SKU) for tracking inventory.</td></tr><tr><td><p>warehouse_id</p><p>int</p></td><td>Optional</td><td>The ID of the warehouse where the item is stored.</td></tr><tr><td><p>item_location</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>The physical location of the item within the warehouse.</td></tr><tr><td><p>item_slug</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>A URL-friendly version of the item name used in links and routes.</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php

$data = [
  'item_name' => "Dining Table", 
  'category_id' => 2, 
  'unit' => "kg", 
  'description' => "Wooden dining table with a polished finish.", 
  'unit_cost' => 200.00, 
  'item_price' => 300.00, 
  'previous_price' => 250.00, 
  'quantity' => "50", 
  'minimum_qty_alert' => "5", 
  'online' => 1, 
  'status' => "in-stock", 
  'barcode' => "YOUR ITEM BARCODE",  // Replace 'YOUR ITEM BARCODE' with your actual item barcode
  'sku' => "TABLE001",
  'warehouse_id' => 2,
  'item_location' => "A1",
  'item_slug' => "table"
];

$url = 'https://api.xtrakit.com/api/v1/inventory/items/add';

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY',  // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'  
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>

```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const data = {
  'item_name': "Dining Table", 
  'category_id': 2, 
  'unit': "kg", 
  'description': "Wooden dining table with a polished finish.", 
  'unit_cost': 200.00, 
  'item_price': 300.00, 
  'previous_price': 250.00, 
  'quantity': "50", 
  'minimum_qty_alert': "5", 
  'online': 1, 
  'status': "in-stock", 
  'barcode': "YOUR ITEM BARCODE", 
  'sku': "TABLE001",
  'warehouse_id': 2,
  'item_location': "A1",
  'item_slug': "table",
};

const config = {
  method: 'post',
  url: `https://api.xtrakit.com/api/v1/inventory/items/add`,
  headers: {
    'Authorization': 'Bearer API_KEY',  // Replace 'API_KEY' with your actual API key
    'Content-Type': 'application/json'  
  },
  data: data
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.error(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

data = { 
    'item_name': "Dining Table", 
    'category_id': 2, 
    'unit': "kg", 
    'description': "Wooden dining table with a polished finish.", 
    'unit_cost': 200.00, 
    'item_price': 300.00, 
    'previous_price': 250.00, 
    'quantity': "50", 
    'minimum_qty_alert': "5", 
    'online': 1, 
    'status': "in-stock", 
    'barcode': "YOUR ITEM BARCODE", # Replace 'YOUR ITEM BARCODE' with your actual item barcode
    'sku': "TABLE001",
    'warehouse_id': 2,
    'item_location': "A1",
    'item_slug': "table",
  }

url = f'https://api.xtrakit.com/api/v1/inventory/items/add'

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
    "Content-Type": "application/json"
}

try:
    response = requests.post(url, headers=headers, json=data)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Item added successfully",
    "data": {
        "item": {
            "id": 2,
            "item_code": " Jce84a60",
            "item_name": "Dining Table",
            "category_id": 2,
            "unit": "kg",
            "description": "Wooden dining table with a polished finish.",
            "unit_cost": 200.00,
            "item_price": 300.00,
            "previous_price": 250.00,
            "quantity": "50",
            "minimum_qty_alert": "5",
            "online": 1,
            "status": "in-stock",
            "barcode": null,
            "sku": "TABLE001",
            "warehouse_id": 2,
            "item_location": "A1",
            "item_slug": "table",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        },
        "item-category": [  
            {
                "id": 2,
                "category_name": "Furnitures",
                "created_at": "2024-08-04 08:23:45",
                "updated_at": "2024-08-04 02:00:43",
            },
            ...
        ],
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Authentication invalid"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Edit Item

Updates the details of an existing item in the inventory. This endpoint is used to modify any of the item’s attributes such as item name, price, quantity, or description.

## Endpoint

<mark style="color:purple;">**`PUT`**</mark> `https://api.xtrakit.com/api/v1/inventory/items/{item_code}`

## Headers

`Authorization: Bearer API_KEY`

## **Path Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>item_code</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The unique code for identifying the item in the inventory system. Should be passed through the URL.(<code>Jce84a50)</code></td></tr></tbody></table>

## Body Parameters

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>item_name</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The name or title of the item.</td></tr><tr><td><p>category_id</p><p><em><strong>int</strong></em></p></td><td>Required</td><td>The ID representing the category this item belongs to.</td></tr><tr><td><p>unit</p><p><em><strong>string</strong></em></p></td><td>Required</td><td><p>The unit of measure for the item.</p><p><code>(pcs, kg, liters,...)</code></p></td></tr><tr><td><p>description</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>A detailed description of the item, providing more information about its features.</td></tr><tr><td><p>unit_cost</p><p><em><strong>decimal(10,2)</strong></em></p></td><td>Required</td><td>The cost price of a single unit of the item in this format: <code>10.00</code></td></tr><tr><td><p>item_price</p><p><em><strong>decimal(10,2)</strong></em></p></td><td>Required</td><td>The selling price of the item in this format: <code>10.00</code></td></tr><tr><td><p>previous_price</p><p><em><strong>decimal(10,2)</strong></em></p></td><td>Optional</td><td>The previous selling price of the item in this format: <code>10.00</code></td></tr><tr><td><p>quantity</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The available stock or quantity of the item.</td></tr><tr><td><p>minimum_qty_alert</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>A threshold quantity that triggers an alert when stock falls below this level.</td></tr><tr><td><p>online</p><p>int</p></td><td>Required</td><td><p>Indicator whether the item is available online. </p><p><code>Accepts 1 (true) or 0 (false)</code></p></td></tr><tr><td><p>status</p><p><em><strong>string</strong></em></p></td><td>Required</td><td><p>The availability status of the item. </p><p><code>(available, out of stock).</code></p></td></tr><tr><td><p>barcode</p><p>string</p></td><td>Optional</td><td>The barcode assigned to the item.</td></tr><tr><td><p>sku</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>The Stock Keeping Unit (SKU) for tracking inventory.</td></tr><tr><td><p>warehouse_id</p><p>int</p></td><td>Optional</td><td>The ID of the warehouse where the item is stored.</td></tr><tr><td><p>item_location</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>The physical location of the item within the warehouse.</td></tr><tr><td><p>item_slug</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>A URL-friendly version of the item name used in links and routes.</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$item_code = 'YOUR_ITEM_CODE'; // Replace 'YOUR_ITEM_CODE' with your actual item code

$data = [
  'item_name' => "Recliner Sofa", 
  'category_id' => 2, 
  'unit' => "kg", 
  'description' => "Sofa with one or more seats that recline like a recliner chair.", 
  'unit_cost' => 300.00, 
  'item_price' => 450.00, 
  'previous_price' => 350.00, 
  'quantity' => "50", 
  'minimum_qty_alert' => "5", 
  'online' => 1, 
  'status' => "in-stock", 
  'barcode' => "YOUR ITEM BARCODE",  // Replace 'YOUR ITEM BARCODE' with your actual item barcode
  'sku' => "TABLE001",
  'warehouse_id' => 2,
  'item_location' => "A1",
  'item_slug' => "table"
];

$url = 'https://api.xtrakit.com/api/v1/inventory/items/' . $item_code;

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const item_code = 'YOUR_ITEM_CODE'; // Replace 'YOUR_ITEM_CODE' with your actual item code

const data = {
  'item_name': "Recliner Sofa", 
  'category_id': 2, 
  'unit': "kg", 
  'description': "Sofa with one or more seats that recline like a recliner chair.", 
  'unit_cost': 300.00, 
  'item_price': 450.00, 
  'previous_price': 350.00, 
  'quantity': "50", 
  'minimum_qty_alert': "5", 
  'online': 1, 
  'status': "in-stock", 
  'barcode': "YOUR ITEM BARCODE",  // Replace 'YOUR ITEM BARCODE' with your actual item barcode
  'sku': "TABLE001",
  'warehouse_id': 2,
  'item_location': "A1",
  'item_slug': "table"
};

const config = {
    method: 'put',
    url: `https://api.xtrakit.com/api/v1/inventory/items/{item_code}`,
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    },
    data: data 
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

item_code = 'YOUR_ITEM_CODE' # Replace 'YOUR_ITEM_CODE' with your actual item code

data = {
  'item_name': "Recliner Sofa", 
  'category_id': 2, 
  'unit': "kg", 
  'description': "Sofa with one or more seats that recline like a recliner chair.", 
  'unit_cost': 300.00, 
  'item_price': 450.00, 
  'previous_price': 350.00, 
  'quantity': "50", 
  'minimum_qty_alert': "5", 
  'online': 1, 
  'status': "in-stock", 
  'barcode': "YOUR ITEM BARCODE",  # Replace 'YOUR ITEM BARCODE' with your actual item barcode
  'sku': "TABLE001",
  'warehouse_id': 2,
  'item_location': "A1",
  'item_slug': "table"
}

url = f'https://api.xtrakit.com/api/v1/inventory/items/{item_code}'

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

try:
    response = requests.put(url, headers=headers, json=data)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Item updated successfully",
    "data": {
        "item": {
            "id": 2,
            "item_code": "Jce84a60",
            "item_name": "Recliner Sofa",
            "category_id": 2,
            "unit": "kg",
            "description": "Sofa with one or more seats that recline like a recliner chair.",
            "unit_cost": 300.00,
            "item_price": 450.00,
            "previous_price": 250.00,
            "quantity": "50",
            "minimum_qty_alert": "5",
            "online": 1,
            "status": "in-stock",
            "barcode": null,
            "sku": "TABLE001",
            "warehouse_id": 2,
            "item_location": "A1",
            "item_slug": "table",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        },
        "item-category": [  
            {
                "id": 2,
                "category_name": "Furnitures",
                "created_at": "2024-08-04 08:23:45",
                "updated_at": "2024-08-04 02:00:43",
            },
            ...
        ],
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Authentication invalid"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Storefront

XtraKit's Storefront API allows you to programmatically handle stores data. Stores management may be easily integrated into your applications by using it to retrieve, add, change, or manage stores.

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>List Stores </strong><mark style="color:green;"><strong><code>GET</code></strong></mark></td><td>Retrieve a list of all stores and you can also filter your results.</td><td></td><td><a href="/overview/storefront/fetch-store-orders">Fetch Store Orders</a></td></tr><tr><td><strong>Fetch Store </strong><mark style="color:green;"><strong><code>GET</code></strong></mark></td><td>Retrieve a specific store using the store id. To retrieve complete store details.</td><td></td><td><a href="/overview/storefront/fetch-store-orders">Fetch Store Orders</a></td></tr><tr><td> <strong>Add Store </strong><mark style="color:yellow;"><strong><code>POST</code></strong></mark></td><td>Allows you to add a new store record. </td><td></td><td><a href="/overview/storefront/create-store">Create Store</a></td></tr><tr><td> <strong>Edit Store </strong><mark style="color:purple;"><strong><code>PUT</code></strong></mark></td><td>Modify an existing store's information. In an unfinalized store, this endpoint can be used to change store name and others.</td><td></td><td><a href="/overview/storefront/edit-store">Edit Store</a></td></tr></tbody></table>


# Create Store

Allows you to add a new store record using this endpoint. This endpoint is used when introducing new stores.

## Endpoint

<mark style="color:yellow;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/stores/add`

## Headers

`Authorization: Bearer API_KEY`

## **Query Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>invoice_code </p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>Specify invoice code to retreive</td></tr><tr><td><p>customer_id </p><p><em><strong>number</strong></em></p></td><td>Optional</td><td>Filter sales by customer ID</td></tr><tr><td><p>invoice_type </p><p><em><strong>string</strong></em></p></td><td>Optional</td><td><p>Filter sales based on the invoice type</p><p><code>(pos, invoice, storefront)</code></p></td></tr><tr><td><p>payment_date </p><p><em><strong>date</strong></em></p></td><td>Optional</td><td>Filter sales by payment date</td></tr><tr><td><p>payment_status </p><p><em><strong>string</strong></em></p></td><td>Optional</td><td><p>Filter sales by payment status </p><p><code>(paid, partial, draft)</code></p></td></tr><tr><td><p>created_at </p><p><em><strong>datetime</strong></em></p></td><td>Optional</td><td><p>Start date for filtering sales records</p><p><code>(format: YYYY-MM-DD H:m:s)</code></p></td></tr><tr><td><p>due_date </p><p><em><strong>date</strong></em></p></td><td>Optional</td><td><p>End date for filtering sales records</p><p><code>(format: YYYY-MM-DD)</code></p></td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.xtrakit.com/api/v1/stores/add',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const config = {
    method: 'get',
    url: 'https://api.xtrakit.com/api/v1/stores/add',
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.xtrakit.com/api/v1/stores/add"
headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

response = requests.get(url, headers=headers)
print(response.json())
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Store added successfully",
    "data": {
        "store": {
            "id": 32,
            "invoice_code": 324232,
            "invoice_number": "INV-000001",
            "customer_id": "42",
            "sub_total_amount": "100.00",
            "total_amount": "200.00",
            "amount_paid": "200.00",
            "discount": "0.00",
            "invoice_type": "pos",
            "invoice_colour": "#FFFFFF",
            "invoice_note": null,
            "invoice_terms": "Thanks for doing business",
            "payment_internal_note": null,
            "payment_date": "2024-08-04",
            "payment_type": "2024-08-04",
            "payment_status": "paid",
            "issued_by": "Jones Nathal",
            "due_date": "2024-08-30",
            "reminder_date": "2024-08-25",
            "reminder_message": null,
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        },
        ...
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Fetch Store Orders

Retrieve a specific store using the store id. To retrieve complete store details, use this endpoint. For emphasis on specific results, you can add filters based on other variables.

## Endpoint

<mark style="color:green;">**`GET`**</mark> `https://api.xtrakit.com/api/v1/stores/{id}`

## Headers

`Authorization: Bearer API_KEY`

## **Path Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>id</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The unique identifier of the store. Should be passed through the URL</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

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

<pre class="language-php" data-full-width="true"><code class="lang-php">&#x3C;?php
<strong>$store_id = 'STORE_ID'; // Replace 'STORE_ID' with your actual store ID
</strong>$url = 'https://api.xtrakit.com/api/v1/stores/' . $store_id;

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
</code></pre>

{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const store_id = 'STORE_ID'; // Replace 'STORE_ID' with your actual store ID

const config = {
    method: 'get',
    url: `https://api.xtrakit.com/api/v1/stores/{store_id}`,
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

store_id = 'STORE_ID' # Replace 'STORE_ID' with your actual store ID

url = f'https://api.xtrakit.com/api/v1/stores/{store_id}'
headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

try:
    response = requests.get(url, headers=headers)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Store found",
    "data": {
        "store": {
            "id": 32,
            "invoice_code": 324232,
            "invoice_number": "INV-000001",
            "customer_id": "42",
            "sub_total_amount": "100.00",
            "total_amount": "200.00",
            "amount_paid": "200.00",
            "discount": "0.00",
            "invoice_type": "pos",
            "invoice_colour": "#FFFFFF",
            "invoice_note": null,
            "invoice_terms": "Thanks for doing business",
            "payment_internal_note": null,
            "payment_date": "2024-08-04",
            "payment_type": "2024-08-04",
            "payment_status": "paid",
            "issued_by": "Jones Nathal",
            "due_date": "2024-08-30",
            "reminder_date": "2024-08-25",
            "reminder_message": null,
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        }
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Edit Store

Modify an existing store's information using this endpoint. For emphasis on specific results, you can add filters based on  other variables.

## Endpoint

<mark style="color:purple;">**`PUT`**</mark> `https://api.xtrakit.com/api/v1/stores/{id}`

## Headers

`Authorization: Bearer API_KEY`

## **Path Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>id</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The unique identifier of the store. Should be passed through the URL</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$id = 'STORE_ID'; // Replace 'STORE_ID' with your actual store ID

$url = 'https://api.xtrakit.com/api/v1/stores/' . $id;

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

<pre class="language-javascript"><code class="lang-javascript">const axios = require('axios');

const id = 'STORE_ID'; // Replace 'STORE_ID' with your actual store ID
<strong>
</strong><strong>const config = {
</strong>    method: 'put',
    url: `https://api.xtrakit.com/api/v1/stores/{id}`,
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
</code></pre>

{% endtab %}

{% tab title="Python" %}

```python
import requests

id = 'STORE_ID' # Replace 'STORE_ID' with your actual store ID

url = f'https://api.xtrakit.com/api/v1/stores/{id}'
headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

try:
    response = requests.put(url, headers=headers)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Store updated successfully",
    "data": {
        "store": {
            "id": 32,
            "invoice_code": 324232,
            "invoice_number": "INV-000001",
            "customer_id": "42",
            "sub_total_amount": "100.00",
            "total_amount": "200.00",
            "amount_paid": "200.00",
            "discount": "0.00",
            "invoice_type": "pos",
            "invoice_colour": "#FFFFFF",
            "invoice_note": null,
            "invoice_terms": "Thanks for doing business",
            "payment_internal_note": null,
            "payment_date": "2024-08-04",
            "payment_type": "2024-08-04",
            "payment_status": "paid",
            "issued_by": "Jones Nathal",
            "due_date": "2024-08-30",
            "reminder_date": "2024-08-25",
            "reminder_message": null,
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        },
        
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Customers

XtraKit's Customer API allows you to programmatically handle customers data. Customers management may be easily integrated into your applications by using it to retrieve, add, or manage customers.

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>List Customers </strong><mark style="color:green;"><strong><code>GET</code></strong></mark></td><td>Retrieve a list of all c<strong>ustomers</strong> and you can also filter your results.</td><td></td><td><a href="/overview/customers/list-customers">List Customers</a></td></tr><tr><td><strong>Fetch Customer </strong><mark style="color:green;"><strong><code>GET</code></strong></mark></td><td>Retrieve a specific c<strong>ustomer</strong> using the c<strong>ustomer</strong> id. To retrieve complete c<strong>ustomer</strong> details.</td><td></td><td><a href="/overview/customers/fetch-customer">Fetch Customer</a></td></tr><tr><td> <strong>Add Customer </strong><mark style="color:yellow;"><strong><code>POST</code></strong></mark></td><td>Allows you to add a new c<strong>ustomer</strong> record. </td><td></td><td><a href="/overview/customers/add-customer">Add Customer</a></td></tr><tr><td> <strong>Edit Customer </strong><mark style="color:purple;"><strong><code>PUT</code></strong></mark></td><td>Modify an existing c<strong>ustomer's</strong> information. In an unfinalized c<strong>ustomer</strong>, this endpoint can be used to change customer name, customer phone, or customer email'</td><td></td><td><a href="/overview/customers/edit-customer">Edit Customer</a></td></tr></tbody></table>

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>List Customer Group </strong><mark style="color:green;"><strong><code>GET</code></strong></mark></td><td>Retrieve a list of all c<strong>ustomer groups</strong> and you can also filter your results.</td><td></td><td><a href="/overview/customers/list-customer-group">List Customer Group</a></td></tr><tr><td><strong>Fetch Customer Group </strong><mark style="color:green;"><strong><code>GET</code></strong></mark></td><td>Retrieve a specific c<strong>ustomer group</strong> using the group id. To retrieve complete group details.</td><td></td><td><a href="/overview/customers/fetch-customer-group">Fetch Customer Group</a></td></tr><tr><td> <strong>Add Customer Group </strong><mark style="color:yellow;"><strong><code>POST</code></strong></mark></td><td>Allows you to add a new c<strong>ustomer</strong> group record. </td><td></td><td><a href="/overview/customers/add-customer-group">Add Customer Group</a></td></tr><tr><td> <strong>Edit Customer Group </strong><mark style="color:purple;"><strong><code>PUT</code></strong></mark></td><td>Modify an existing c<strong>ustomer group's</strong> information. In an unfinalized c<strong>ustomer group</strong>, this endpoint can be used to change group name and group description.</td><td></td><td><a href="/overview/customers/edit-customer-group">Edit Customer Group</a></td></tr></tbody></table>


# List Customers

A list of all customers may be obtained using this endpoint. For emphasis on specific results, you can add filters based on customer's group id and other variables.

## Endpoint

<mark style="color:green;">**`GET`**</mark> `https://api.xtrakit.com/api/v1/customers`

## Headers

`Authorization: Bearer API_KEY`

## **Query Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>customer_group_id</p><p>int</p></td><td>Optional</td><td>Filters customers by the  group to which this customer belongs.</td></tr><tr><td><p>created_at </p><p><em><strong>datetime</strong></em></p></td><td>Optional</td><td><p>Start date for filtering customers records.</p><p><code>(format: YYYY-MM-DD H:m:s)</code></p></td></tr><tr><td><p>updated_at </p><p><em><strong>date</strong></em></p></td><td>Optional</td><td><p>End date for filtering customers records.</p><p><code>(format: YYYY-MM-DD)</code></p></td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.xtrakit.com/api/v1/customers',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const config = {
    method: 'get',
    url: 'https://api.xtrakit.com/api/v1/customers',
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.xtrakit.com/api/v1/customers"
headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

response = requests.get(url, headers=headers)
print(response.json())
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Customers found: 20",
    "data": {
        "customers": {
            "id": 1,
            "customer_group_id": 1,
            "customer_name": "Jane Doe",
            "customer_email": "jane.doe@example.com",
            "customer_phone": "+233244567890",
            "customer_whatsapp": "+233244567890",
            "customer_country": "Ghana",
            "customer_city": "Accra",
            "customer_state": "Greater Accra",
            "customer_zip": "00233",
            "address1": "123 Main Street",
            "address2": "Apt 4B, Downtown Complex",
            "customer_profile": "https://example.com/profiles/customer123.jpg",
            "created_by": "Edward",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        },
        ...
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Fetch Customer

Retrieves detailed information for a specific customer based on the customer ID provided in the request URL. This is useful when you need in-depth information on a particular customer.

## Endpoint

<mark style="color:green;">**`GET`**</mark> `https://api.xtrakit.com/api/v1/customers/{id}`

## Headers

`Authorization: Bearer API_KEY`

## **Path Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>id</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The unique identifier of the customer. Should be passed through the URL</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

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

<pre class="language-php" data-full-width="true"><code class="lang-php">&#x3C;?php
<strong>$id = 'CUSTOMER_ID'; // Replace 'CUSTOMER_ID' with your actual customer ID
</strong>$url = 'https://api.xtrakit.com/api/v1/customers/' . $id;

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
</code></pre>

{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const id = 'CUSTOMER_ID'; // Replace 'CUSTOMER_ID' with your actual customer ID
const config = {
    method: 'get',
    url: `https://api.xtrakit.com/api/v1/customers/{id}`,
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

id = 'CUSTOMER_ID' # Replace 'CUSTOMER_ID' with your actual customer ID

url = f'https://api.xtrakit.com/api/v1/customers/{id}'

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

try:
    response = requests.get(url, headers=headers)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Customer found",
    "data": {
        "customer": {
            "id": 1,
            "customer_group_id": 1,
            "customer_name": "Jane Doe",
            "customer_email": "jane.doe@example.com",
            "customer_phone": "+233244567890",
            "customer_whatsapp": "+233244567890",
            "customer_country": "Ghana",
            "customer_city": "Accra",
            "customer_state": "Greater Accra",
            "customer_zip": "00233",
            "address1": "123 Main Street",
            "address2": "Apt 4B, Downtown Complex",
            "customer_profile": "https://example.com/profiles/customer123.jpg",
            "created_by": "Edward",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"        
        },
        "customer-group": [  
            {
                "id": 1,
                "group_name": "Premium Customers",
                "group_description": "Customers who have spent over $1000 and have been with the business for over a year.",
                "created_at": "2024-08-04 08:23:45",
                "updated_at": "2024-08-04 02:00:43"
            },
            ...
        ],
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Fetch Customer Group

Retrieves detailed information about a specific customer group by ID. This can be useful for viewing the details of an existing customer group.

## Endpoint

<mark style="color:green;">**`GET`**</mark> `https://api.xtrakit.com/api/v1/customer-groups/{id}`

## Headers

`Authorization: Bearer API_KEY`

## **Path Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>id </p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The unique identifier of the customer group. Should be passed through the URL</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

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

<pre class="language-php" data-full-width="true"><code class="lang-php">&#x3C;?php
<strong>$id = 'CUSTOMER_GROUP_ID'; // Replace 'CUSTOMER_GROUP_ID' with your actual customer group ID
</strong>$url = 'https://api.xtrakit.com/api/v1/customer-groups/' . $id;

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
</code></pre>

{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const id = 'CUSTOMER_GROUP_ID'; // Replace 'CUSTOMER_GROUP_ID' with your actual customer group ID

const config = {
    method: 'get',
    url: `https://api.xtrakit.com/api/v1/customer-groups/{id}`,
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

id = 'CUSTOMER_GROUP_ID' # Replace 'CUSTOMER_GROUP_ID' with your actual customer group ID

url = f'https://api.xtrakit.com/api/v1/customer-groups/{id}'

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

try:
    response = requests.get(url, headers=headers)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Group found",
    "data": {
        "group": {
            "id": 1,
            "group_name": "Premium Customers",
            "group_description": "Customers who have spent over $1000 and have been with the business for over a year.",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        }
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# List Customer Group

A list of all customer groups may be obtained using this endpoint. For emphasis on specific results, you can add filters based on business code, date created and other variables.

## Endpoint

<mark style="color:green;">**`GET`**</mark> `https://api.xtrakit.com/api/v1/customer-groups`

## Headers

`Authorization: Bearer API_KEY`

## **Query Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>business_code</p><p>int</p></td><td>Optional</td><td>Filters customer groups by the  unique business code associated with the customer group.</td></tr><tr><td><p>created_at </p><p><em><strong>datetime</strong></em></p></td><td>Optional</td><td><p>Start date for filtering customers records.</p><p><code>(format: YYYY-MM-DD H:m:s)</code></p></td></tr><tr><td><p>updated_at </p><p><em><strong>date</strong></em></p></td><td>Optional</td><td><p>End date for filtering customers records.</p><p><code>(format: YYYY-MM-DD)</code></p></td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.xtrakit.com/api/v1/customer-groups',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const config = {
    method: 'get',
    url: 'https://api.xtrakit.com/api/v1/customer-groups',
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.xtrakit.com/api/v1/customer-groups"
headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

response = requests.get(url, headers=headers)
print(response.json())
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Groups found: 20",
    "data": {
        "groups": {
            "id": 1,
            "group_name": "Premium Customers",
            "group_description": "Customers who have spent over $1000 and have been with the business for over a year.",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        },
        ...
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Add Customer

This endpoint allows you to add a new customer to the system. You can store customer details like name, email, phone, address, and other relevant information.

## Endpoint

<mark style="color:yellow;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/customers/add`

## Headers

`Authorization: Bearer API_KEY`

## **Body Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>customer_group_id</p><p><em><strong>int</strong></em></p></td><td>Optional</td><td>The ID of the group to which this customer belongs. </td></tr><tr><td><p>customer_name</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The full name of the customer, used for identification and personalization within the system.</td></tr><tr><td><p>customer_email</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>The email address of the customer, used for communications like receipts, notifications, or offers.</td></tr><tr><td><p>customer_phone</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The primary phone number for contacting the customer. It is useful for both communication and verification purposes.</td></tr><tr><td><p>customer_whatsapp</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>The customer's WhatsApp number. This is used for instant messaging or sending transactional notifications.</td></tr><tr><td><p>customer_country</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The country in which the customer resides. This is necessary for shipping, billing, or other region-specific activities.</td></tr><tr><td><p>customer_city</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The city where the customer is located. It helps in localizing deliveries, services, and communication.</td></tr><tr><td><p>customer_state</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The state or region where the customer is based. This is useful for regional identification within a country.</td></tr><tr><td><p>customer_zip</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td><p>The postal code for the customer's location. It is generally used for mailing, shipping, and regional classification.</p><p><code>(eg: 00233)</code></p></td></tr><tr><td><p>address1</p><p>string</p></td><td>Required</td><td>The primary address of the customer, typically used for billing or shipping purposes. It can contain house numbers, street names, etc.</td></tr><tr><td><p>address2</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>The secondary address, such as apartment numbers or additional details not covered in address1. This is helpful when the customer's address is complex.</td></tr><tr><td><p>customer_profile</p><p>string</p></td><td>Optional</td><td>A URL or path to the customer's profile image, typically used for identification or personalization within the user interface.</td></tr><tr><td><p>created_by</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The identifier or username of the person who created this customer entry in the system. This helps in tracking changes and updates.</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php

$data = [
  'customer_group_id' => 1, 
  'customer_name' => "John Doe", 
  'customer_email' => "john.doe@example.com", 
  'customer_phone' => "+233244567877", 
  'customer_whatsapp' => "+233244567877", 
  'customer_country' => "Ghana", 
  'customer_city' => "Kumasi", 
  'customer_state' => "Kumasi", 
  'customer_zip' => "00233", 
  'address1' => "Adum Main Street", 
  'address2' => "Apt 4B, Melcom Street", 
  'customer_profile' => "https://example.com/profiles/customer125.jpg",
  "created_by" => "Edward"
];

$url = 'https://api.xtrakit.com/api/v1/customers/add';

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY',  // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'  
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>

```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const data = {
  'customer_group_id': 1, 
  'customer_name': "Jane Doe", 
  'customer_email': "jane.doe@example.com", 
  'customer_phone': "+233244567877", 
  'customer_whatsapp': "+233244567877", 
  'customer_country': "Ghana", 
  'customer_city': "Kumasi", 
  'customer_state': "Kumasi", 
  'customer_zip': "00233", 
  'address1': "Adum Main Street", 
  'address2': "Apt 4B, Melcom Street", 
  'customer_profile': "https://example.com/profiles/customer125.jpg",
  "created_by": "Edward"
};

const config = {
  method: 'post',
  url: `https://api.xtrakit.com/api/v1/customers/add`,
  headers: {
    'Authorization': 'Bearer API_KEY',  // Replace 'API_KEY' with your actual API key
    'Content-Type': 'application/json'  
  },
  data: data
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.error(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

data = {
  'customer_group_id': 1, 
  'customer_name': "Jane Doe", 
  'customer_email': "jane.doe@example.com", 
  'customer_phone': "+233244567877", 
  'customer_whatsapp': "+233244567877", 
  'customer_country': "Ghana", 
  'customer_city': "Kumasi", 
  'customer_state': "Kumasi", 
  'customer_zip': "00233", 
  'address1': "Adum Main Street", 
  'address2': "Apt 4B, Melcom Street", 
  'customer_profile': "https://example.com/profiles/customer125.jpg",
  "created_by": "Edward"
}

url = f'https://api.xtrakit.com/api/v1/customers/add'

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
    "Content-Type": "application/json"
}

try:
    response = requests.post(url, headers=headers, json=data)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Customer added successfully",
    "data": {
        "customer": {
            "id": 2,
            "customer_group_id": 1,
            "customer_name": "John Doe",
            "customer_email": "john.doe@example.com",
            "customer_phone": "+233244567877",
            "customer_whatsapp": "+233244567877",
            "customer_country": "Ghana",
            "customer_city": "Kumasi",
            "customer_state": "Kumasi",
            "customer_zip": "00233",
            "address1": "Adum Main Street",
            "address2": "Apt 4B, Melcom Street",
            "customer_profile": "https://example.com/profiles/customer125.jpg",
            "created_by": "Edward",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"        
        }
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Add Customer Group

Creates a new customer group to categorize customers based on certain criteria. Each customer group will have a name and description.

## Endpoint

<mark style="color:yellow;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/customer-groups/add`

## Headers

`Authorization: Bearer API_KEY`

## **Body Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>group_name</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The name of the customer group. Typically short, identifying the purpose of the group.</td></tr><tr><td><p>group_description</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>A detailed description explaining the group and its purpose. Can include criteria and benefits.</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php

$data = [
  'group_name' => "Platinum Customers", 
  'group_description' => "Customers who have spent over $5000 and have been with the business for over a year."
];

$url = 'https://api.xtrakit.com/api/v1/customer-groups/add';

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY',  // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'  
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>

```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const data = {
  'group_name': "Platinum Customers", 
  'group_description': "Customers who have spent over $5000 and have been with the business for over a year."
};

const config = {
  method: 'post',
  url: `https://api.xtrakit.com/api/v1/customer-groups/add`,
  headers: {
    'Authorization': 'Bearer API_KEY',  // Replace 'API_KEY' with your actual API key
    'Content-Type': 'application/json'  
  },
  data: data
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.error(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

data = {
  'group_name': "Platinum Customers", 
  'group_description': "Customers who have spent over $5000 and have been with the business for over a year."
}

url = f'https://api.xtrakit.com/api/v1/customer-groups/add'

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
    "Content-Type": "application/json"
}

try:
    response = requests.post(url, headers=headers, json=data)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Group added successfully",
    "data": {
        "group": {
            "id": 2,
            "group_name": "Platinum Customers",
            "group_description": "Customers who have spent over $5000 and have been with the business for over a year.",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        }
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Edit Customer

Updates the information of an existing customer. You can modify various fields such as customer details, addresses, and status.

## Endpoint

<mark style="color:purple;">**`PUT`**</mark> `https://api.xtrakit.com/api/v1/customers/{id}`

## Headers

`Authorization: Bearer API_KEY`

## **Path Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>id</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The unique identifier of the customer. Should be passed through the URL</td></tr></tbody></table>

## Body Parameters

<table><thead><tr><th width="271">Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>customer_group_id</p><p><em><strong>int</strong></em></p></td><td>Optional</td><td>The ID of the group to which this customer belongs. </td></tr><tr><td><p>customer_name</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The full name of the customer, used for identification and personalization within the system.</td></tr><tr><td><p>customer_email</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>The email address of the customer, used for communications like receipts, notifications, or offers.</td></tr><tr><td><p>customer_phone</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The primary phone number for contacting the customer. It is useful for both communication and verification purposes.</td></tr><tr><td><p>customer_whatsapp</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>The customer's WhatsApp number. This is used for instant messaging or sending transactional notifications.</td></tr><tr><td><p>customer_country</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The country in which the customer resides. This is necessary for shipping, billing, or other region-specific activities.</td></tr><tr><td><p>customer_city</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The city where the customer is located. It helps in localizing deliveries, services, and communication.</td></tr><tr><td><p>customer_state</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The state or region where the customer is based. This is useful for regional identification within a country.</td></tr><tr><td><p>customer_zip</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td><p>The postal code for the customer's location. It is generally used for mailing, shipping, and regional classification.</p><p><code>(eg: 00233)</code></p></td></tr><tr><td><p>address1</p><p>string</p></td><td>Required</td><td>The primary address of the customer, typically used for billing or shipping purposes. It can contain house numbers, street names, etc.</td></tr><tr><td><p>address2</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>The secondary address, such as apartment numbers or additional details not covered in address1. This is helpful when the customer's address is complex.</td></tr><tr><td><p>customer_profile</p><p>string</p></td><td>Optional</td><td>A URL or path to the customer's profile image, typically used for identification or personalization within the user interface.</td></tr><tr><td><p>created_by</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The identifier or username of the person who created this customer entry in the system. This helps in tracking changes and updates.</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$id = 'CUSTOMER_ID'; // Replace 'CUSTOMER_ID' with your actual customer ID


$data = [
  'customer_group_id' => 1, 
  'customer_name' => "Jane Doe", 
  'customer_email' => "jane.doe@example.com", 
  'customer_phone' => "+233244567890", 
  'customer_whatsapp' => "+233244567890", 
  'customer_country' => "Ghana", 
  'customer_city' => "Accra", 
  'customer_state' => "Greater Accra", 
  'customer_zip' => "00233", 
  'address1' => "123 Main Street", 
  'address2' => "Apt 4B, Downtown Complex", 
  'customer_profile' => "https://example.com/profiles/customer123.jpg",
  "created_by" => "Edward"
];

$url = 'https://api.xtrakit.com/api/v1/customers/' . $id;

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const id = 'CUSTOMER_ID'; // Replace 'CUSTOMER_ID' with your actual customer ID


const data = {
  'customer_group_id': 1, 
  'customer_name': "Jane Doe", 
  'customer_email': "jane.doe@example.com", 
  'customer_phone': "+233244567890", 
  'customer_whatsapp': "+233244567890", 
  'customer_country': "Ghana", 
  'customer_city': "Accra", 
  'customer_state': "Greater Accra", 
  'customer_zip': "00233", 
  'address1': "123 Main Street", 
  'address2': "Apt 4B, Downtown Complex", 
  'customer_profile': "https://example.com/profiles/customer123.jpg",
  "created_by": "Edward"
};

const config = {
    method: 'put',
    url: `https://api.xtrakit.com/api/v1/customers/{id}`,
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    },
    data: data 
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

id = 'CUSTOMER_ID' # Replace 'CUSTOMER_ID' with your actual customer ID

data = {
  'customer_group_id': 1, 
  'customer_name': "Jane Doe", 
  'customer_email': "jane.doe@example.com", 
  'customer_phone': "+233244567890", 
  'customer_whatsapp': "+233244567890", 
  'customer_country': "Ghana", 
  'customer_city': "Accra", 
  'customer_state': "Greater Accra", 
  'customer_zip': "00233", 
  'address1': "123 Main Street", 
  'address2': "Apt 4B, Downtown Complex", 
  'customer_profile': "https://example.com/profiles/customer123.jpg",
  "created_by": "Edward"
}

url = f'https://api.xtrakit.com/api/v1/customers/{id}'

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

try:
    response = requests.put(url, headers=headers, json=data)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Customer updated successfully",
    "data": {
        "customer": {
            "id": 1,
            "customer_group_id": 1,
            "customer_name": "Jane Doe",
            "customer_email": "jane.doe@example.com",
            "customer_phone": "+233244567890",
            "customer_whatsapp": "+233244567890",
            "customer_country": "Ghana",
            "customer_city": "Accra",
            "customer_state": "Greater Accra",
            "customer_zip": "00233",
            "address1": "123 Main Street",
            "address2": "Apt 4B, Downtown Complex",
            "customer_profile": "https://example.com/profiles/customer123.jpg",
            "created_by": "Edward",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"        
        },
        "customer-group": [  
            {
                "id": 1,
                "group_name": "Premium Customers",
                "group_description": "Customers who have spent over $1000 and have been with the business for over a year.",
                "created_at": "2024-08-04 08:23:45",
                "updated_at": "2024-08-04 02:00:43"
            },
            ...
        ],
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Edit Customer Group

Updates the information of an existing customer group, allowing changes to the name, description, and other fields.

## Endpoint

<mark style="color:purple;">**`PUT`**</mark> `https://api.xtrakit.com/api/v1/customer-groups/{id}`

## Headers

`Authorization: Bearer API_KEY`

## **Path Parameters**

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>id </p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The unique identifier of the customer group. Should be passed through the URL</td></tr></tbody></table>

## Body Parameters&#x20;

<table><thead><tr><th>Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>group_name</p><p><em><strong>string</strong></em></p></td><td>Required</td><td>The name of the customer group. Typically short, identifying the purpose of the group.</td></tr><tr><td><p>group_description</p><p><em><strong>string</strong></em></p></td><td>Optional</td><td>A detailed description explaining the group and its purpose. Can include criteria and benefits.</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$id = 'CUSTOMER_GROUP_ID'; // Replace 'CUSTOMER_GROUP_ID' with your actual customer group ID

$data = [
  'group_name' => "Premium Customers", 
  'group_description' => "Customers who have spent over $1000 and have been with the business for over a year."
];

$url = 'https://api.xtrakit.com/api/v1/customer-groups/' . $id;

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const id = 'CUSTOMER_GROUP_ID'; // Replace 'CUSTOMER_GROUP_ID' with your actual customer group ID

const data = {
  'group_name': "Premium Customers", 
  'group_description': "Customers who have spent over $1000 and have been with the business for over a year."
};

const config = {
    method: 'put',
    url: `https://api.xtrakit.com/api/v1/customer-groups/{id}`,
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    },
    data: data 
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

id = 'CUSTOMER_GROUP_ID' # Replace 'CUSTOMER_GROUP_ID' with your actual customer group ID

data = {
  'group_name': "Premium Customers", 
  'group_description': "Customers who have spent over $1000 and have been with the business for over a year."
}

url = f'https://api.xtrakit.com/api/v1/customer-groups/{id}'

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

try:
    response = requests.put(url, headers=headers, json=data)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Group updated successfully",
    "data": {
        "group": {
            "id": 1,
            "group_name": "Premium Customers",
            "group_description": "Customers who have spent over $1000 and have been with the business for over a year.",
            "created_at": "2024-08-04 08:23:45",
            "updated_at": "2024-08-04 02:00:43"
        }
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Payments

Welcome to the XtraPay Mobile Money Payment API documentation.  The XtraPay API enables developers and businesses to seamlessly accept and verify Mobile Money payments within their websites and apps.

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Fetch Payment Methods </strong><mark style="color:$warning;"><strong><code>POST</code></strong></mark></td><td>Retrieve a list of all payment methods like MTN, AirtelTigo and Telecel</td><td></td><td><a href="/overview/payments/fetch-payment-methods">Fetch Payment Methods</a></td></tr><tr><td><strong>Pay with MoMo </strong><mark style="color:$warning;"><strong><code>POST</code></strong></mark></td><td>Allow users to make payments using MTN Ghana Momo, AirtelTigo and Vodafone (Telecel)</td><td></td><td><a href="/overview/payments/pay-with-momo">Pay with MoMo</a></td></tr><tr><td><strong>Send MoMo OTP </strong><mark style="color:$warning;"><strong><code>POST</code></strong></mark></td><td>Generate OTP when provided with the MOMO contact</td><td></td><td><a href="/overview/payments/send-momo-otp">Send MoMo OTP</a></td></tr><tr><td><strong>Query Transaction Status </strong><mark style="color:$warning;"><strong><code>POST</code></strong></mark></td><td>Query the status of specific transactions</td><td></td><td><a href="/overview/payments/query-transaction-status">Query Transaction Status</a></td></tr></tbody></table>

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Payout </strong><mark style="color:$warning;"><strong><code>POST</code></strong></mark></td><td>This is the request we make to make a withdrawal from our wallet</td><td></td><td><a href="/overview/payments/payout">Payout</a></td></tr><tr><td><strong>Get Wallets </strong><mark style="color:$warning;"><strong><code>POST</code></strong></mark></td><td>Get all your XtraPay wallets with their balances</td><td></td><td><a href="/overview/payments/get-wallets">Get Wallets</a></td></tr></tbody></table>

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Webhook </strong><mark style="color:$warning;"><strong><code>POST</code></strong></mark></td><td>This is the request we make to the callback URL you have sent on the merchant dashboard</td><td></td><td><a href="/overview/payments/webhook">Webhook</a></td></tr><tr><td><strong>Status Codes </strong><mark style="color:$warning;"><strong><code>POST</code></strong></mark></td><td>Our custom status codes guidelines</td><td></td><td><a href="/overview/payments/status-codes">Status Codes</a></td></tr></tbody></table>


# Fetch Payment Methods

This endpoint fetches the available payment methods supported by XtraPay based on the currency

## Endpoint

<mark style="color:$warning;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/momo/payment-methods`

Currency - Supported currencies : (GHS)

## Headers

`Authorization: Bearer API_KEY`

## **Request Body**

<table><thead><tr><th width="289">Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>currency</p><p><code>string</code></p></td><td>Required</td><td>The currency you are using to make a payment</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$curl = curl_init();

$data = [
  'currency' => "GHS",
];

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.xtrakit.com/api/v1/momo/payment-methods',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const data = {
  'currency': "GHS",
};

const config = {
    method: 'post',
    url: 'https://api.xtrakit.com/api/v1/momo/payment-methods',
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    },
    data: data
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "data": [
        {
            "id": "1",
            "name": "MTN Mobile Money GH",
            "fund_type": "momo",
            "description": "Mobile Money",
            "icon_url": "https://pub-60b577bb37f54e02b085ea3d4d65a159.r2.dev/bankLogos/mtn_momo.png",
            "bank_code": null
        },
        {
            "id": "2",
            "name": "AirtelTigo Cash GH",
            "fund_type": "momo",
            "description": "Mobile Money",
            "icon_url": "https://pub-60b577bb37f54e02b085ea3d4d65a159.r2.dev/bankLogos/airtel_tigo.png",
            "bank_code": null
        },
    ],
    "message": "Payment methods retrieved successfully"
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Pay with MoMo

Allow users to make payments using MTN Ghana Momo, AirtelTigo and Vodafone (Telecel)

The request process is asynchronous, meaning you receive an initial response indicating that the request is being processed. Once the payer completes the transaction, a callback response is sent to your configured callback URL.

## Endpoint

<mark style="color:$warning;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/momo/pay`

## Headers

`Authorization: Bearer API_KEY`

## **Request Body**

<table><thead><tr><th width="289">Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>transaction_id</p><p><code>string</code></p></td><td>Required</td><td>Merchants' transaction ID to uniquely identify the transaction</td></tr><tr><td><p>business_code</p><p><code>string</code></p></td><td>Required</td><td>Business code retrieved from the merchant dashboard</td></tr><tr><td><p>currency</p><p><code>string</code></p></td><td>Required</td><td>Currency you are receiving payment</td></tr><tr><td><p>payment_details </p><p><code>string</code></p></td><td>Required</td><td>Payment details unique to this collection channel</td></tr><tr><td><p>payment_details.momo_number</p><p><code>string</code></p></td><td>Required</td><td>Momo number to receive payment from. This is a field within payment_details.</td></tr><tr><td><p>payment_details.otp</p><p><code>string</code></p></td><td>Required</td><td>One Time Password sent to payer's phone number to authorize the transaction. This is a field within payment_details.</td></tr><tr><td><p>payment_details.customer_email</p><p><code>string</code></p></td><td>Required</td><td>Refers to the payer's email address e.g kofi@gmail.com</td></tr><tr><td><p>payment_details.customer_firstname</p><p><code>string</code></p></td><td>Required</td><td>Payer's First Name</td></tr><tr><td><p>payment_details.customer_lastname</p><p><code>string</code></p></td><td>Required</td><td>Payer's Last Name</td></tr><tr><td><p>payment_method_id</p><p><code>string</code></p></td><td>Required</td><td>The ID of the payment channel retrieved from get payment methods endpoint. eg. 8rf8788997</td></tr><tr><td><p>amount</p><p><code>float|numeric-string</code></p><p><br></p></td><td>Required</td><td>Amount to be received from the payer</td></tr><tr><td><p>voucher_code</p><p><code>string</code></p></td><td>Optional</td><td> <code>voucher_code</code> should be passed for Telecel Cash payments (<code>*110#</code>).</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$curl = curl_init();

$data = [
    'transaction_id' => 'TXN-202607020001',
    'business_code' => '25754643',
    'currency' => 'GHS',
    'payment_method_id' => 'mtnghana', //airteltigoghana, vodafoneghana
    'amount' => 100.00,
    'payment_details' => [
        'momo_number' => '+233240000000',
        'otp' => '123456',
        'customer_email' => 'kofi@example.com',
        'customer_firstname' => 'Kofi',
        'customer_lastname' => 'Narh',
    ],
];

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.xtrakit.com/api/v1/momo/pay',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require("axios");

const data = {
  transaction_id: "TXN-202607020001",
  business_code: "264356434",
  currency: "GHS",
  payment_method_id: 'mtnghana', //airteltigoghana, vodafoneghana
  amount: 100.00,
  payment_details: {
    momo_number: "+233240000000",
    otp: "123456",
    customer_email: "kofi@example.com",
    customer_firstname: "Kofi",
    customer_lastname: "Narh"
  }
};

axios.post("https://api.xtrakit.com/api/v1/momo/pay", data, {
  headers: {
    Authorization: `Bearer ${process.env.XTRAPAY_API_KEY}`,
    "Content-Type": "application/json"
  }
})
.then(response => {
  console.log(response.data);
})
.catch(error => {
  console.error(error.response?.data || error.message);
});
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": "000",
    "data": {
        "transaction_id": "TXN-202607020001",
        "merchant_transaction_id": "44b8daae-5e66-6280-8aa2-e41c73d5e43b",
        "momo_number": "+233539421088",
        "amount": "1.00",
        "currency": "GHS",
        "payment_method_name": "mtnghana", //airteltigoghana, vodafoneghana
        "status": "pending",
        "fee": "0.00",
        "created_at": "2026-07-02T22:12:37.000000Z"
    },
    "message": "Payment is being processed"
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Send MoMo OTP

Generate OTP when provided with the MOMO contact. MTN & AirtelTigo: Uses a handset prompt (no OTP/code needed). Telecel Cash: Requires the customer to dial \*110# to generate a voucher code and pass it

## Endpoint

<mark style="color:$warning;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/momo/send-otp`

## Headers

`Authorization: Bearer API_KEY`

## **Request Body**

<table><thead><tr><th width="289">Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>customer_contact</p><p><code>string</code></p></td><td>Required</td><td>The customer's number that will receive the OTP for payment</td></tr><tr><td><p>business_code</p><p><code>string</code></p></td><td>Required</td><td>Particular business for OTP</td></tr><tr><td><p>payment_method_id</p><p><code>string</code></p></td><td>Required</td><td>The selected payment method id</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$curl = curl_init();

$data = [
  'customer_contact' => '+233240000000',
];

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.xtrakit.com/api/v1/momo/send-otp',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const data = {
  'customer_contact' => '+233240000000',
};

const config = {
    method: 'post',
    url: 'https://api.xtrakit.com/api/v1/momo/send-otp',
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    },
    data: data
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": '200',
    "data": null,
    "message": "An OTP has been sent to +233240000000"
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Query Transaction Status

Query the status of specific transactions.

## Endpoint

<mark style="color:$warning;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/momo/transaction-status`

## Headers

`Authorization: Bearer API_KEY`

## **Request Body**

<table><thead><tr><th width="289">Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>business_code</p><p><code>string</code></p></td><td>Required</td><td>Your business code</td></tr><tr><td><p>transaction_id</p><p><code>string</code></p></td><td>Required</td><td>Transaction ID of transaction to query</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
<?php
$curl = curl_init();

$data = [
  'business_code' => "29841951",
  'transaction_id' => "TXN-202607020001",
];

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.xtrakit.com/api/v1/momo/transaction-status',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY', // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const data = {
  'business_code': "29841951",
  'transaction_id': "TXN-202607020001",
};

const config = {
    method: 'post',
    url: 'https://api.xtrakit.com/api/v1/momo/transaction-status',
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    },
    data: data
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "transaction_id": "kdfdsoin4",
    "business_code": "10031178",
    "amount": "0.10",
    "currency": "GHS",
    "message": "Payment being processed"
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Get Wallets

This api retrieves all wallets belonging to a business account

## Endpoint

<mark style="color:$success;">**`GET`**</mark> `https://api.xtrakit.com/api/v1/wallets`

## Headers

`Authorization: Bearer API_KEY`

## Sample Response

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

```json
{
   "status": 200,
   "data": [
      {
         'wallet_balance' => 1000,
         'wallet_currency' => 'NGN,
         'status' => 1 // 1 means Active
      }, 
      {
         'wallet_balance' => 100,
         'wallet_currency' => 'GHS',
         'status' => 1 // 1 means Active
      }
   ],
   "message": "Business wallets retrieved successfully"
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Payout

Steps to follow before using this payout API.

## Create XtraPay Account

To use this API, you need to create a business account on XtraPay or XtraKit (Central Account)**.**&#x20;

**Register Account:** [https://accounts.xtrakit.com](https://accounts.xtrakit.com/)

<figure><img src="https://2825261350-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVsPq4N6DniO1ALophteI%2Fuploads%2Fx549pTtUp4sA8rdpUFeO%2FScreenshot%202026-08-26%20at%208.20.59%E2%80%AFAM.png?alt=media&amp;token=f694820a-1de2-4ed9-a51d-676e8c663253" alt=""><figcaption></figcaption></figure>

## Generate API Key

Go to Settings > Developers > [API Keys](https://pay.xtrakit.com/settings/developers)

Configure your **callback URL (webhook)** to receive real-time notifications about your transactions' status. Your webhook endpoint **must support the HTTP POST method**, as XtraPay will send all transaction updates to this URL.

<figure><img src="https://2825261350-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVsPq4N6DniO1ALophteI%2Fuploads%2F8WOHHIMfViMj2oecI6Uk%2FScreenshot%202026-07-03%20at%208.59.15%E2%80%AFAM.png?alt=media&amp;token=2cef2f96-5658-4d28-b6bf-a7276efb9c27" alt=""><figcaption></figcaption></figure>

After completing the setup, include your generated **Live API Key** as a **Bearer token** in the `Authorization` header of every request you send to the XtraPay BPaaS API.


# Payout Methods

List payout channel for specified provider and currency.

To retrieve payout methods, use the endpoint below. Find possible options for the **provider** parameter explained below.

* ngbank - Nigerian banks
* ghbank - Ghanaian banks
* momo - Mobile money networks

### Get a list of payment channels (bank/momo)

## Endpoint

<mark style="color:$warning;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/payout/channels`

## Headers

`Authorization: Bearer API_KEY`

## **Request Body**

<table><thead><tr><th width="289">Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>currency</p><p><code>string</code></p></td><td>Required</td><td>NGN | KSH | GHS</td></tr><tr><td><p>provider</p><p><code>string</code></p></td><td>Required</td><td>ngbank | momo | xtrapaywallet | ghbank</td></tr></tbody></table>

## Sample Response

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

```json
{
    "status": 200,
    "data": [
        {
            "id": "mJ1wOmVdeE",
            "name": "MTN MoMo",
            "network": "mtnghana",
            "bankCode": "MTN"
        },
        {
            "id": "JQYZqjwaXm",
            "name": "Airtel Money",
            "network": "airteltigoghana",
            "bankCode": "AIRTELTIGO"
        },
        {
            "id": "vq1VK4Z7LJ",
            "name": "Telcel Cash",
            "network": "vodafoneghana",
            "bankCode": "VODAFONE"
        },
        {
            "id": "M7eZl2E8On",
            "name": "MTN MoMo",
            "network": "mtnghana",
            "bankCode": "GH-MTN-B2C"
        },
        {
            "id": "v3OZo02wML",
            "name": "AT Money",
            "network": "airteltigoghana",
            "bankCode": "GH-AIRTEL-B2C"
        },
        {
            "id": "oRpZn14V4n",
            "name": "Telecel Cash",
            "network": "vodafoneghana",
            "bankCode": "GH-VODAFONE-B2C"
        },
        {
            "id": "4N6VmEMVY5",
            "name": "MTN Voucher",
            "network": "mtngh",
            "bankCode": null
        }
    ],
    "message": "Payout Channels"
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Account Validation

Validates Mobile Money numbers and bank account details, returning the registered account holder's name before a transaction is initiated. MTN, Telecel, and AirtelTigo all support full real-time name.

## Endpoint

<mark style="color:$warning;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/payout/account/validate`

## Headers

`Authorization: Bearer API_KEY`

## **Request Body**

<table><thead><tr><th width="289">Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>payoutMethodId</p><p><code>string</code></p></td><td>Required</td><td></td></tr><tr><td><p>accountId</p><p><code>string</code></p></td><td>Required</td><td>MOMO Number/Bank Account</td></tr></tbody></table>

## Sample Response

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

```json
{
    "status": "1016",
    "data": {
        "accountId": "+23354xxxxxxxx",
        "accountName": "Kofi Amartey"
    },
    "message": "Account resolution results."
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Initiate Payout

This endpoint performs the following actions:

* Validates and resolves the account holder's name for both bank accounts and MTN Mobile Money numbers.
* Creates and logs the transaction, preparing it

### Initiate remittance transaction

## Endpoint

<mark style="color:$warning;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/payout/initiates`

## Headers

`Authorization: Bearer API_KEY`

## **Request Body**

{% tabs %}
{% tab title="MoMo Payout" %}

```php
//sample payout initiation request
//A. Mobile Money Payout (MoMo)
{
  "business_code": "YOUR_BUSINESS_CODE",
  "amount": 100.00,
  "currency": "GHS",
  "type": "momo",
  "payment_method_id": "MOMO_MTN",
  "payment_details": {
    "recipient_name": "Kofi Mensah",
    "account_number": "0240000000",
    "phone_number": "0240000000",
    "narration": "Payout for services"
  }
}


```

{% endtab %}

{% tab title="Bank Payout" %}

```php
//sample payout initiation request
// B. Bank Account Payout (GhIPSS Instant Pay)
{
  "business_code": "YOUR_BUSINESS_CODE",
  "amount": 500.00,
  "currency": "GHS",
  "type": "bank",
  "payment_method_id": "BANK",
  "payment_details": {
    "recipient_name": "Ama Serwaa",
    "account_number": "1023456789012",
    "bank_code": "300304",
    "phone_number": "0240000000",
    "narration": "Vendor invoice settlement"
  }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}

| Parameter                        | Type     | Required | Description                                                                 |
| -------------------------------- | -------- | -------- | --------------------------------------------------------------------------- |
| `business_code`                  | `string` | **Yes**  | Your business unique code from the merchant dashboard                       |
| `amount`                         | `number` | **Yes**  | Amount to send (minimum `1.00`)                                             |
| `currency`                       | `string` | No       | Currency code (defaults to `GHS`)                                           |
| `type`                           | `string` | **Yes**  | Target type: `momo` or `bank`                                               |
| `payment_method_id`              | `string` | **Yes**  | Method ID e.g. `MOMO_MTN`, `MOMO_TELECEL`, `MOMO_AT`, or Bank code `300304` |
| `payment_details`                | `object` | **Yes**  | Recipient and destination details                                           |
| `payment_details.recipient_name` | `string` | **Yes**  | Full name of the recipient / account holder                                 |
| `payment_details.account_number` | `string` | **Yes**  | Destination Mobile Money number or Bank account number                      |
| `payment_details.phone_number`   | `string` | No       | Recipient phone number (for SMS notification)                               |
| `payment_details.bank_code`      | `string` | No       | Bank routing code (required if `type` is `bank`, e.g. `300304` for GCB)     |
| `payment_details.narration`      | `string` | No       | Reason or note for the payout (e.g. `Payout for Invoice #102`)              |

## Sample Response

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

```json
//sample initiate payout momo payout response
{
    "status": "000",
    "data": {
        "transaction_id": "PAYOUT-K9F2L9P0X1",
        "interpay_trans_ref_no": "987654321",
        "business_code": "YOUR_BUSINESS_CODE",
        "amount": "100.00",
        "fee": "1.00",
        "currency": "GHS",
        "status": "pending",
        "created_at": "2026-08-22T11:15:00.000000Z"
    },
    "message": "Payout initiated and is being processed"
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Execute Payout Transaction

Executes previous initiate transaction  This endpoint completes the payout to the specified accountId provided in the initiate endpoint.

**NB: Ensure you use the transactionId from the payout initiation.**

## Endpoint

<mark style="color:$warning;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/payout/executes`

## Headers

`Authorization: Bearer API_KEY`

## **Request Body**

<table><thead><tr><th width="289">Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>transactionId</p><p><code>string</code></p></td><td>Required</td><td>Transaction reference generated by payout business</td></tr></tbody></table>

## Sample Response

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

```json
{
    "status": "1006",
    "data": {
        "xtrapayTransactionId": "BRJPAAS202509024xxxxxx",
        "transactiondId": "Merchant-Transaction-Id"
    },
    "message": "Payout transaction is being processed"
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Query Transaction

Get transaction status.

## Query transaction status using your generated XtraPay transaction ID

## Endpoint

<mark style="color:$warning;">**`POST`**</mark> `https://api.xtrakit.com/api/v1/`payout/transaction/statu`s/{Xtrapay-Transaction-Id}`

## Headers

`Authorization: Bearer API_KEY`

## Sample Response

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

```json
{
    "status": 200,
    "data": {
        "transaction_type": "api-payout",
        "transaction_id": "Partner-Transaction-Id",
        "interpay_trans_ref_no": "BRJPAAS2025xxxxxx",
        "amount": "1.00",
        "currency": "GHS",
        "status": "successful",
        "description": "Payout description",
        "transaction_date": "2026-07-03T19:40:50.000000Z"
    },
    "message": "Transaction fetched"
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Unauthorized: Missing Bearer Token"
},

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


# Webhook

This is the request we make to the callback URL you have sent on the merchant dashboard

## Endpoint

<mark style="color:$warning;">**`POST`**</mark> `{YOUR CALLBACK URL}`

**How to set up a signed webhook**

Log in to your [XtraPay Account ](https://pay.xtrakit.com/)and go to:

Settings → Developers → [API Keys & Webhooks](https://pay.xtrakit.com/settings/developers).

Find the Callback Secret field, click to update, enter your secret key (without spaces), and then click Save.

<figure><img src="https://2825261350-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVsPq4N6DniO1ALophteI%2Fuploads%2FTjiNDcvuNWg7SJxxQX2K%2FScreenshot%202026-07-03%20at%208.59.00%E2%80%AFAM.png?alt=media&amp;token=abbaba95-9570-4451-a515-060893724353" alt=""><figcaption></figcaption></figure>

<mark style="color:$warning;">**`NOTE:`**</mark> After configuring your webhook, every callback sent to your server will include an **HMAC-SHA256 signature**. You should verify this signature to confirm that the webhook originated from XtraPay and that the payload has not been altered during transmission.

## Headers

`Authorization: Bearer API_KEY`

<table><thead><tr><th width="210.1875">Name</th><th width="149.828125">Key</th><th>Description</th></tr></thead><tbody><tr><td>Signature</td><td><code>signature</code></td><td><p>The <mark style="color:$warning;"><strong>signature</strong></mark> is an HMAC SHA256 hash of the raw webhook payload, generated using your <mark style="color:$warning;"><strong>Merchant Callback Secret</strong></mark>. It is included in the request header to verify the source and integrity of the webhook.</p><p>The signature header is present <strong>only when a secret is configured</strong>; otherwise, it is not included.</p></td></tr><tr><td>Content Type</td><td>Content Type</td><td><code>application/json</code></td></tr></tbody></table>

## **Request Body**

<table><thead><tr><th width="289">Parameters</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><p>status</p><p><code>integer</code></p></td><td>Required</td><td>Custom Status Code. See <a href="https://docs.xtrakit.com/~/revisions/hMZmKtqdg32OuNOv1BWc/overview/payments/status-codes">Status Codes</a></td></tr><tr><td><p>message</p><p><code>string</code></p></td><td>Required</td><td>Payment Status Description</td></tr><tr><td><p>amount</p><p><code>string</code></p></td><td>Required</td><td>Payment Amount</td></tr><tr><td><p>transaction_id</p><p><code>string</code></p></td><td>Required</td><td>Payment Transaction ID</td></tr><tr><td><p>currency</p><p><code>string</code></p></td><td>Required</td><td>Payment Currency</td></tr><tr><td><p>business_code</p><p><code>string</code></p></td><td>Required</td><td>Your business code</td></tr></tbody></table>

## How to Validate Webhook <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}
{% code fullWidth="true" %}

```php
signature = request.headers["signature"]

if signature exists:
    payload = request.raw_body
    secret  = "YOUR_MERCHANT_CALLBACK_SECRET"

    computed = HMAC_SHA256(payload, secret)

    if secure_compare(computed, signature) is false:
        return HTTP 401 Unauthorized

process webhook
return HTTP 200 OK
```

{% endcode %}
{% endtab %}
{% endtabs %}


# Status Codes

Our custom status codes guidelines

## Status Codes

| Code | Message                                                                                            |
| ---- | -------------------------------------------------------------------------------------------------- |
| 001  | Failed Validation                                                                                  |
| 003  | Timed Out                                                                                          |
| 005  | Bad Request                                                                                        |
| 000  | Payment Completed Successfully                                                                     |
| 004  | Payment Failed                                                                                     |
| 002  | No Callback / Webhook URL found. **NB: Ensure you've set a callback URL on the Xtrapay dashboard** |
| 006  | Payment is being processed                                                                         |

## Payout Status Codes

| Status                          | Code |
| ------------------------------- | ---- |
| Transaction Initiate Successful | 1001 |
| Transaction Successful          | 1002 |
| Transaction Complete            | 1003 |
| Validation Failed               | 1004 |
| Transaction Initiate Failed     | 1005 |
| Transaction Pending             | 1006 |
| Transaction Failed              | 1007 |
| Transaction Method Unavailable  | 1008 |
| Account Resolution Failed       | 1009 |
| Transaction Unavailable         | 1010 |
| Duplicate Transaction ID        | 1011 |
| Insufficient Balance            | 1014 |
| Transaction Limit Reached       | 1015 |
| Account Resolution Successful   | 1016 |


