# Channels

#### Creat channel

## Create channel

<mark style="color:green;">`POST`</mark> `{base url}/v1/accounting/channel`

create a new channel

**Headers**

<table><thead><tr><th width="302">Name</th><th width="156">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>Authorization header</code><mark style="color:red;">*</mark></td><td><code>String</code></td><td><code>API user secret key</code></td></tr></tbody></table>

**Body**

<table><thead><tr><th width="218">Name</th><th width="169">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code> <mark style="color:red;">*</mark></td><td>string</td><td>name of channel</td></tr><tr><td><code>glAccountId</code> <mark style="color:red;">*</mark></td><td>string</td><td>id of the ledger attached to this channel</td></tr><tr><td><code>channelUserType</code> <mark style="color:red;">*</mark></td><td>array</td><td>channel user type (loans, deposits)</td></tr><tr><td><code>branch</code> <mark style="color:red;">*</mark></td><td>array</td><td>id or the branch or all_branches</td></tr><tr><td><code>status</code></td><td>string</td><td>status of the channel (active/inactive)</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200: OK channel created successfully " %}
```json
{
    "message": "channel successfully created",
    "data": {
        "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
        "name": "name of the channel",
        "glAccountId": "08f743a6-757f-4e06-a729-dc3989001e30",
        "channelUserType": [
            "loans"
        ],
        "branch": [
            "all_branches"
        ],
        "status": "active",
        "id": "d8da13a4-3eed-4383-8f1e-2dd945881bc9",
        "created_at": "2024-04-02T08:25:41.884Z",
        "updated_at": "2024-04-02T08:25:41.884Z"
    }
}
```
{% endtab %}

{% tab title="400: Forbidden unauthorised " %}
```json
{
    "message": "No authorization token found",
    "code": 90
}
```
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Sample request" %}
```
{
    "name": "name of the channel",
    "glAccountId": "08f743a6-757f-4e06-a729-dc3989001e30",
    "channelUserType":[ "loans"],
    "branch": ["all_branches"],
    "status": "active"
}
```
{% endtab %}

{% tab title="Sample response" %}
```
{
    "message": "channel successfully created",
    "data": {
        "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
        "name": "name of the channel",
        "glAccountId": "08f743a6-757f-4e06-a729-dc3989001e30",
        "channelUserType": [
            "loans"
        ],
        "branch": [
            "all_branches"
        ],
        "status": "active",
        "id": "d8da13a4-3eed-4383-8f1e-2dd945881bc9",
        "created_at": "2024-04-02T08:25:41.884Z",
        "updated_at": "2024-04-02T08:25:41.884Z"
    }
}
```
{% endtab %}
{% endtabs %}

#### get channels

## Get channels

<mark style="color:green;">`GET`</mark> `{base url}/v1/accounting/channel`

get channels

**Headers**

<table><thead><tr><th width="302">Name</th><th width="156">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>Authorization header</code><mark style="color:red;">*</mark></td><td><code>String</code></td><td><code>API user secret key</code></td></tr></tbody></table>

Query parameters&#x20;

| Name      | Type   | Description              |
| --------- | ------ | ------------------------ |
| `page`    | number | page to fetch            |
| `perPage` | number | number of items per page |

**Response**

{% tabs %}
{% tab title="200: Ok channels fetched successfully " %}
```json
{
    "data": [
        {
            "id": "6de54c04-12e7-4b5e-afc2-9c528a087d15",
            "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
            "glAccountId": "08f743a6-757f-4e06-a729-dc3989001e30",
            "name": "new channel",
            "channelUserType": [
                "deposits",
                "loans"
            ],
            "branch": [
                "all_branches"
            ],
            "status": "active",
            "created_at": "2024-02-06T06:25:21.684Z",
            "updated_at": "2024-02-06T06:25:21.684Z"
        }
    ],
    "pagination": {
        "currentPage": 1,
        "perPage": 15,
        "totalCount": 1,
        "totalPages": 1,
        "previousPage": 0,
        "nextPage": 1
    }
}
```
{% endtab %}

{% tab title="400: Forbidden unauthorised " %}
```json
{
    "message": "No authorization token found",
    "code": 90
}
```
{% endtab %}
{% endtabs %}

#### get channel by id

## Get channel by id

<mark style="color:green;">`GET`</mark>  `{base url}/v1/accounting/channel/{channelId}`

get a single channel by id

**Headers**

<table><thead><tr><th width="302">Name</th><th width="156">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>Authorization header</code><mark style="color:red;">*</mark></td><td><code>String</code></td><td><code>API user secret key</code></td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200: Ok channel fetched successfully" %}
```json
{
    "data": {
        "id": "6de54c04-12e7-4b5e-afc2-9c528a087d15",
        "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
        "glAccountId": "08f743a6-757f-4e06-a729-dc3989001e30",
        "name": "new channel",
        "channelUserType": [
            "deposits",
            "loans"
        ],
        "branch": [
            "all_branches"
        ],
        "status": "active",
        "created_at": "2024-02-06T06:25:21.684Z",
        "updated_at": "2024-02-06T06:25:21.684Z"
    }
}
```
{% endtab %}

{% tab title="400: Forbidden unauthorised " %}
```json
{
    "message": "No authorization token found",
    "code": 90
}
```
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Sample response" %}
```
{
    "data": {
        "id": "6de54c04-12e7-4b5e-afc2-9c528a087d15",
        "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
        "glAccountId": "08f743a6-757f-4e06-a729-dc3989001e30",
        "name": "new channel",
        "channelUserType": [
            "deposits",
            "loans"
        ],
        "branch": [
            "all_branches"
        ],
        "status": "active",
        "created_at": "2024-02-06T06:25:21.684Z",
        "updated_at": "2024-02-06T06:25:21.684Z"
    }
}
```
{% endtab %}
{% endtabs %}

#### update channel

## Update channel

<mark style="color:green;">`PATCH`</mark> `{base url}/v1/accounting/channel/{channelId}`

Update channel

**Headers**

<table><thead><tr><th width="302">Name</th><th width="156">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>Authorization header</code><mark style="color:red;">*</mark></td><td><code>String</code></td><td><code>API user secret key</code></td></tr></tbody></table>

**Body**

<table><thead><tr><th width="207">Name</th><th width="168">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>channelUserType</code></td><td>array</td><td>channel user type (loans, deposits)</td></tr><tr><td><code>branch</code></td><td>array</td><td>id or the branch or all_branches</td></tr><tr><td>status</td><td>string</td><td>status of branch</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200: Ok channel successfully updated" %}
```json
{
    "message": "channel successfully updated"
}

```
{% endtab %}

{% tab title="400: Forbidden unauthorised " %}
```json
{
    "message": "No authorization token found",
    "code": 90
}
```
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Sample request" %}
```
{
    "channelUserType": ["loans"],
    "branch": ["all_branches"],
    "status": "inactive"
}
```
{% endtab %}

{% tab title="Sample response" %}
```
{
    "message": "No authorization token found",
    "code": 90
}
```
{% endtab %}
{% endtabs %}
