> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chip-in.asia/llms.txt
> Use this file to discover all available pages before exploring further.

# List all accounts

> Returns list of accounts.


Use this endpoint to know:

* Your available settlement (collection) amount that can be converted to CHIP Send Limit;
* Current balance;
* Send Fee;
* Account Verification Fee;
* No. of approvals required to convert collection balance to CHIP Send Limit

Please note that `convertible_balance_from_statement` will return different data depending on when you hit this endpoint. This adds flexibility and time for you to plan out your CHIP Send Budget Allocation requests, without having to send extra information.

For example:

* Trigger today at 11.59 PM MYT will return convertible balance from today's collection.
* Trigger tomorrow at 12.00 AM MYT will return convertible balance from today's collection.
* Trigger tomorrow at 11.59 AM MYT will return convertible balance from today's collection.
* Trigger tomorrow at 12.00 PM MYT will return convertible balance from tomorrow's collection.


## OpenAPI

````yaml _openapi-chip-send GET /send/accounts
openapi: 3.1.0
info:
  description: >

    This is CHIP Send API which enables you to programatically send funds via
    REST API. It also enables you to register and validate recipient bank
    accounts.


    # Prerequisites


    You will need the credentials to proceeed with this integration, which your
    CHIP Send Account to be created by CHIP Admin before hand. Please contact
    your CHIP Account Manager to get the credentials, by providing the details
    below:

      1. Main email
      1. List of approvers (email). If you need 2 approvals, please provide both emails.

    # Basic integration flow


    4 things to test the whole integration flow:

      1. Call [Accounts API](#/Accounts)
      1. Call [Increase Send Limit API](#/Send%20Limits/send_limits_create)
      1. Call [Add Bank Account API](#/Bank%20Accounts/bank_accounts_create)
      1. Call [Create Send Instruction API](#/Send%20Instructions/send_instructions_create)

     # Endpoints

     Make sure to use the correct endpoint depending on the environment you're on.

     1. Staging: [https://staging-api.chip-in.asia/api/](https://staging-api.chip-in.asia/api/)
     1. Production: [https://api.chip-in.asia/api/](https://api.chip-in.asia/api/)

    # Credentials


    You will need 2 details for integration with CHIP Send:


    1. **API Key** (used to construct a signing string and Authorization Header)

    1. **API Secret** (used to sign the signing string)


    *You will need your **API Key** that you can obtain in the CHIP Send
    Dashboard. Please use this key as a bearer token in the Authorization header
    included in every request:* `Authorization: Bearer <API Key>`.


    *Since this API is meant for performing high risk task such as sending
    payments, extra security measure has to be in place. Hence, you also need
    **API Secret** to sign the request that you made. This keys will never leave
    your server and shall be stored securely. For every request, you will need
    to include **epoch** that contains Unix time and **checksum** that contains
    hash for epoch signed with API Secret in every request header.*


    # Epoch value


    Epoch is a current unix timestamp where it is in seconds and have 10
    character length. Example of epoch value is 1689826456. In PHP, epoch value
    can be retrieved by calling time() function.


    # Checksum Calculation


    To generate a checksum, it requires current unix timestamp (`epoch`),
    `api_key` and `api_secret`.


    *Note: epoch time must be less than 30 seconds from the current request and
    at least greater than current time.*


    Provided an epoch value is `1689826456`, api_key is
    `e0645c9e-fcf2-4f29-a327-202f7ed3d969` and api_secret is
    `a118729e-4243-4145-83b3-0b8cb213fe8e`, both epoch and api_key must be
    concatenated and sign with HMAC SHA512.


    The string that must be prepared is:


    `1689826456e0645c9e-fcf2-4f29-a327-202f7ed3d969`


    The checksum generated is:


    `45bee62dba8087ab1e7e767d92f8d6e26f8bd19ee5fd2fef6386bb9425976498a86ffdbddb7a49919998e993c20626196ea652320f438a9528d2b8c9d19ec266`


    Example Postman Pre-Request Script:


    ```js

    var epoch = (new Date).getTime();

    var epochSecs = Math.floor( epoch / 1000 );

    pm.collectionVariables.set("epoch", epochSecs);

    var data = epochSecs.toString() + environment["api_key"];

    var hmacDigest = CryptoJS.enc.Hex.stringify(CryptoJS.HmacSHA512(data,
    environment["api_secret"]));

    pm.collectionVariables.set("checksum", hmacDigest);

    ```

    *Note: JavaScript getTime() is in miliseconds while the unix timestamp is in
    seconds. Hence, it is required to divide it by 1000.*


    Example Ruby code:


    ```ruby

    epoch = Time.current.to_i

    application = Application.find_by(slug: "aaa")

    OpenSSL::HMAC.hexdigest OpenSSL::Digest.new('sha512'),
    application.api_secret, "#{epoch}#{application.api_key}"

    ```


    Example PHP code:


    ```php

    <?php


    // $epoch = time(); // 1689826456

    // $api_key = 'e0645c9e-fcf2-4f29-a327-202f7ed3d969';

    // $str = $epoch . $api_key;

    $str = '1689826456e0645c9e-fcf2-4f29-a327-202f7ed3d969';

    $hmac = hash_hmac( 'sha512', $str, 'a118729e-4243-4145-83b3-0b8cb213fe8e' );

    ```


    # Approving Chip Send Budget Allocation requests


    Each approver will get an email. To approve, approvers must click the
    Approve button in the email. Once all approvers approve, the balance will be
    reflected in [Accounts API](#/Accounts) response.


    **Token** used in the Authorization is the **API Key** mentioned in the
    Credentials section above.
  version: 1.0.1
  title: CHIP Send API
  termsOfService: https://www.chip-in.asia/terms-of-service
  contact:
    name: CHIP
    url: https://www.chip-in.asia
servers:
  - description: Sandbox
    url: https://staging-api.chip-in.asia/api
  - description: Production
    url: https://api.chip-in.asia/api
security:
  - bearerAuth: []
tags:
  - name: Accounts
    description: >-
      This is an API to get CHIP Send account information. Depending on your
      account agreement, you may only have one account.
  - name: Send Limits
    description: >
      Send Limit records incoming (coverted from collection - transaction_type:
      in) and outgoing (send to recipient - transaction_type: out) transactions
      in CHIP Send.


      To be able to send funds to third parties, you must have balance in your
      CHIP Send Account. Use Increase Chip Send Budget Allocation API to covert
      settlement (collection) amount to Send Limit.


      Please note in Staging / UAT environment, your convertible collection
      amount is set to MYR 1,000.00. In Production, it will reflect your actual
      upcoming settlement amount.
  - name: Bank Accounts
    description: This is an API to manage recipeint bank account details.
  - name: Send Instructions
    description: >-
      This is an API to perform a send instructions. This is the main API that
      you can benefit from CHIP Send.
  - name: Groups
    description: To manage grouping to group company bank account
  - name: Webhooks
    description: To manage webhook events for server-to-server notification
paths:
  /send/accounts:
    get:
      tags:
        - Accounts
      summary: List all accounts
      description: |
        Returns list of accounts.
      operationId: accounts_index
      parameters:
        - name: epoch
          in: header
          description: Unix epoch timestamp
          required: true
          schema:
            allOf:
              - $ref: '#/components/schemas/UnixTimestamp'
        - name: checksum
          in: header
          description: Refer to checksum calculation
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  results:
                    type: array
                    items:
                      $ref: '#/components/schemas/Account'
                  meta:
                    type: object
                    properties:
                      pagination:
                        $ref: '#/components/schemas/MetaPagination'
              example:
                results:
                  - id: 1
                    status: active
                    currency: MYR
                    settlement_convert_approvals_count: 1
                    send_fee: 1
                    send_fee_type: flat
                    account_verification_fee: 1
                    account_verification_fee_type: flat
                    convertible_balance_from_statement: 1000
                    current_balance: 100
                    created_at: '2023-07-20T08:35:25.389Z'
                    updated_at: '2023-07-20T08:35:25.389Z'
                meta:
                  pagination:
                    current_page: 1
                    prev_page: null
                    next_page: null
                    total_pages: 1
                    total_count: 1
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/UnauthorizedAction'
        '404':
          $ref: '#/components/responses/NotFound'
      security:
        - bearerAuth: []
components:
  schemas:
    UnixTimestamp:
      type: integer
      description: Unix timestamp (seconds)
      format: Unix timestamp (seconds)
      example: 1619740800
    Account:
      type: object
      description: This is account schema
      properties:
        id:
          type: integer
          format: int64
          example: 1
        status:
          example: active
          allOf:
            - $ref: '#/components/schemas/SendAccountStatus'
        currency:
          type: string
          example: MYR
          allOf:
            - $ref: '#/components/schemas/SendAccountCurrency'
        settlement_convert_approvals_count:
          type: integer
          example: 1
        send_fee:
          type: number
          example: 1
          description: 1 for RM 1
          pattern: ^[0-9]*\.*[0-9]{0,2}$
        send_fee_type:
          type: string
          example: flat
          allOf:
            - $ref: '#/components/schemas/FeeType'
        account_verification_fee:
          type: number
          example: 1
          description: 1 for RM 1
          pattern: ^[0-9]*\.*[0-9]{0,2}$
        account_verification_fee_type:
          type: string
          example: flat
          allOf:
            - $ref: '#/components/schemas/FeeType'
        convertible_balance_from_statement:
          type: number
          example: 1000
          description: |
            - 1000 for RM 1,000.
            - Reset daily to RM 1,000 for staging environment.
            - Reflect realtime for production environment.
          pattern: ^[0-9]*\.*[0-9]{0,2}$
        current_balance:
          type: number
          example: 100
          description: |
            - 100 for RM 100
            - Available balance to perform Send instructions.
          pattern: ^[0-9]*\.*[0-9]{0,2}$
        created_at:
          readOnly: true
          description: Object creation time in UTC
          type: string
          format: date-time
        updated_at:
          readOnly: true
          description: Object updated time in UTC
          type: string
          format: date-time
    MetaPagination:
      type: object
      description: This is pagination schema
      properties:
        current_page:
          type: integer
          format: int64
          example: 1
          description: Current page value
        prev_page:
          type: integer
          format: int64
          nullable: true
          example: null
          description: Previous page value
        next_page:
          type: integer
          format: int64
          nullable: true
          example: null
          description: Next page value
        total_pages:
          type: integer
          format: int64
          example: 1
          description: Total available pagination
        total_count:
          type: integer
          format: int64
          example: 1
          description: Total avaialable records
    SendAccountStatus:
      type: string
      enum:
        - active
        - pending
    SendAccountCurrency:
      type: string
      enum:
        - MYR
      description: |
        - `MYR`: Ringgit Malaysia (RM)
    FeeType:
      type: string
      enum:
        - flat
        - percentage
    BadRequestResponse:
      type: object
      properties:
        message:
          type: string
          example: Bad request
        code:
          type: number
          example: 400
        data:
          type: object
          example: {}
    UnauthorizedResponse:
      type: object
      properties:
        message:
          type: string
          example: Unauthorized
        code:
          type: number
          example: 401
        data:
          type: object
          example: {}
    UnauthorizedActionResponse:
      type: object
      properties:
        message:
          type: string
          example: You are not authorized to perform this action
        code:
          type: number
          example: 403
        data:
          type: object
          example: {}
    NotFoundResponse:
      type: object
      properties:
        message:
          type: string
          example: Record not found
        code:
          type: number
          example: 404
        data:
          type: object
          example: {}
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BadRequestResponse'
    Unauthorized:
      description: Unauthorized request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/UnauthorizedResponse'
    UnauthorizedAction:
      description: Unauthorized action request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/UnauthorizedActionResponse'
    NotFound:
      description: Record not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NotFoundResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````