---
# System prepended metadata

title: '**Profile API Document**'

---

# **Profile API Document**

- Profile Route is used for searching or updating user transaction information based on `user_ref`. An unique id string which you provided to us. It used it for connecting your system information with our system user information.

## **Pre-Requirements**

- There are some pre-requirements to meet to perform action for this route.

  1. A valid access token is required to access routes.

  2. Ensure that you have already finish setup the checkbox plugin.

## **Search All User Transactions:**

- Search all user transactions allow you to search transaction data by it's status. And it's default with pagination design which start with first pages. And each pages will only content at least and at most 10 datas.

### **Parameter in Search All User Transactions**

| Parameter             | Description                                                                                | Type         |
| --------              | --------                                                                                   | --------     |
| app_id(Required)      | App ID That Represent your Bot. Where you can find the information on system routes.       | string       |
| page_id(Required)     | Page ID That Represent your Bot. Where you can find the information on system routes.      | string       |
| app_type(Required)    | Type of your Bot. It can be either `line` or `messenger`.                                  | string       |
| status(Optional)      | Status of the transaction. It can be either `active` or `pending`.                         | string       |
| pages(Optional)       | Pagination of the pages data which you wanted to search. It starts with 1.                 | number       |

### **Method**

`GET /v1.0/transactions?app_id=<app_id>&page_id=<page_id>&app_type=<app_type>&status=<status>&pages=<pages>`

#### **Success Response**

- **Code:** 200 <br />
  **Content** `{ status: "success"; message: object; }`

#### **Error Response**

- **Code:** 400 <br />
  **Content** `{ status: "error"; message: "App Id Missing" | "Page Id Missing" | "App Type Missing"; }`

- **Code:** 404 <br />
  **Content** `{ status: "error"; message: "Transactions Not Found"; }`

- **Code:** 500 <br />
  **Content** `{ status: "error"; message: "Internal Server Error"; }`

#### Example Request

```bash
curl --request GET '/v1.0/transactions?app_id=<app_id>&page_id=<page_id>&app_type=<app_type>&status=<status>&pages=<pages>' \
--header 'Authorization: Bearer <access-token>'
```

#### Example Response

```json
{
  "status": "success",
  "message": {
    "current_page": 1,
    "total_pages": 5,
    "transactions": [
      {
        "id": "SJ9WkWcNf",
        "app_type": "messenger",
        "page_id": "112120643877683",
        "app_id": "970540413138028",
        "ref": {},
        "user_id": "123412313",
        "user_ref": "DPJ9TjHWB",
        "status": "pending",
        ...
      }
      ...
    ]
  }
}
```

## **Search User Transaction By Reference Id:**

- Search user transaction by reference id allows to search specifc user by reference id. Reference id generated from checkbox plugin and it use for this query method. The return value of the transaction will guarantee at least one and at most one if you have data in the database.

### **Parameter in Search User Transaction By Reference Id**

| Parameter             | Description                                                                                | Type         |
| --------              | --------                                                                                   | --------     |
| app_id(Required)      | App ID That Represent your Bot. Where you can find the information on system routes.       | string       |
| page_id(Required)     | Page ID That Represent your Bot. Where you can find the information on system routes.      | string       |
| app_type(Required)    | Type of your Bot. It can be either `line` or `messenger`.                                  | string       |
| transaction_ref_id(Required)    | Transaction reference id which was send within the checkbox plugin.              | string       |

### **Method**

`GET /v1.0/transactions/<transaction_ref_id>?app_id=<app_id>&page_id=<page_id>&app_type=<app_type>`

#### **Success Response**

- **Code:** 200 <br />
  **Content** `{ status: "success"; message: object; }`

#### **Error Response**

- **Code:** 400 <br />
  **Content** `{ status: "error"; message: "Transaction Reference Id Missing"; }`

- **Code:** 404 <br />
  **Content** `{ status: "error"; message: "Transaction Reference <transaction_ref_id> Not Found"; }`

- **Code:** 500 <br />
  **Content** `{ status: "error"; message: "Internal Server Error"; }`

#### Example Request

```bash
curl --request GET '/v1.0/transactions/<transaction_ref_id>?app_id=<app_id>&page_id=<page_id>&app_type=<app_type>' \
--header 'Authorization: Bearer <access-token>'
```

#### Example Response

```json
{
  "status": "success",
  "message": {
    "id": "SJ9WkWcNf",
    "app_type": "messenger",
    "page_id": "112120643877683",
    "app_id": "970540413138028",
    "ref": {},
    "user_id": "123412313",
    "user_ref": "DPJ9TjHWB",
    "status": "pending",
    "global_user"?: {
      "app_type": "messenger",
      "app_id": "970540413138028",
      "channel_id": "112120643877683",
      "user_id": "123412313",
      "id": "12312412321",
      "firstName": "Test",
      "lastName": "User",
      "displayName": "Test User",
      ...
    }
  }
}
```

## **Update User Transaction By Reference Id:**

- Update user transaction by reference id route allows you to update reference data ref fields only.

### **Parameter in Update User Transaction By Reference Id**

| Parameter             | Description                                                                                | Type         |
| --------              | --------                                                                                   | --------     |
| app_id(Required)      | App ID That Represent your Bot. Where you can find the information on system routes.       | string       |
| page_id(Required)     | Page ID That Represent your Bot. Where you can find the information on system routes.      | string       |
| app_type(Required)    | Type of your Bot. It can be either `line` or `messenger`.                                  | string       |
| transaction_ref_id(Required)    | Transaction reference id which was send within the checkbox plugin.              | string       |
| ref(Required)         | Reference fields which was original generated in checkbox plugin as a metadata like fields.              | object       |

### **Method**

`PUT /v1.0/transactions/<transaction_ref_id>?app_id=<app_id>&page_id=<page_id>&app_type=<app_type>`

#### **Success Response**

- **Code:** 200 <br />
  **Content** `{ status: "success"; message: "Transaction Reference <transaction_ref_id> Update Success"; }`

#### **Error Response**

- **Code:** 400 <br />
  **Content** `{ status: "error"; message: "Transaction Reference id Parametes Must be String Type" | "Empty Update Not Allowed"; }`

- **Code:** 404 <br />
  **Content** `{ status: "error"; message: "Transaction Reference <transaction_ref_id> Not Found"; }`

- **Code:** 409 <br />
  **Content** `{ status: "error"; message: "Transaction Reference <transaction_ref_id> Update Fail"; }`

- **Code:** 500 <br />
  **Content** `{ status: "error"; message: "Internal Server Error"; }`

#### Example Request

```bash
curl --request PUT '/v1.0/transactions/<transaction_ref_id>?app_id=<app_id>&page_id=<page_id>&app_type=<app_type>' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <access-token>' \
--data-raw '{
    "ref": {
        "phone": "12311231231",
        "email": "test987@test.com"
    }
}'
```

#### Example Response

```json
{
  "status": "success",
  "message": "Transaction Reference E7ndHWUTz Update Success",
}
```
