Skip to content

Generic Requests

This endpoint manages generic requests, which are custom requests that are not part of the regular API collection.

Some generic requests have custom handlers defined. Others must be passed on to the back end.

Request

PUT /requests/

Submit a new generic request. There are two required properties:

Name Type Description
typeId string the type of the request
intTag number unique number to identify this request and avoid duplicates

The rest of the Request body depends on the type.

The API looks for a handler for this type. If found, the request is processed by the handler. Otherwise the request is sent to the backoffice for processing.

Request body example:

This generic request opens a new account for an existing user.

  {
    "typeId": "newExpenseAccount", //generic request type id
    "intTag": 35,  // Unique tag for dedup. Typically an integer, epoch.
    "AFiUserId": "qweaurlatw083dyy", // a field required for this particular type of generic requests. 
    "name": "my new expense account", // a field required for this particular type of generic requests.  
  }

Response body example:

  {
    "success": true,
    "requestId": "qweamplifigrl6cfadukqweaurl4mwdiq8gppbjmfhwoixrlauldzbgs",
    "isDuplicate": false //true if it's a duplicate request
  }

List Requests

GET /requests/

List all the generic requests ever submitted by this user, as found in the database.

Response body example:

  {
    "success": true,
    "payload": [
        {
            "intTag": 35,
            "typeId": "newExpenseAccount",
            "payload": {
                "AFiUserId": "qweaurlatw083dyy",
                "name": "my new expense account"
            },
            "AFiUserId": "qweaurlatw083dyy",
            "requestId": "qweamplifigrlbcnm7ubqweaurlatw083dyyyshjianqnogqtahyxgif",
            "dtsAccepted": "2022-06-20T15:49:27.018Z",
            "requestStatus": "success",
            "logs": [
                {
                    "requestId": "qweamplifigrlbcnm7ubqweaurlatw083dyyyshjianqnogqtahyxgif",
                    "dts": "2022-06-20T15:49:32.567Z",
                    "utc": 1655740172567,
                    "requestStatus": "success",
                    "requestStatusDetails": null
                },
                {
                    "requestId": "qweamplifigrlbcnm7ubqweaurlatw083dyyyshjianqnogqtahyxgif",
                    "dts": "2022-06-20T15:49:27.115Z",
                    "utc": 1655740167115,
                    "requestStatus": "processing now",
                    "requestStatusDetails": null
                }
            ]
        }
    ]
  }

List with Status

GET /requests/:status

List all the generic requests ever submitted by this user that have a particular status. The status is given as a path parameter.

Response body example:

  {
    "success": true,
    "payload": [
        {
            "_id": "62b09707af509816e07c878b",
            "intTag": "l4mwy1bvz905vfixglbh18i290ckmhmve7jq0odg",
            "typeId": "randomCredit",
            "payload": {
                "amount": 50,
                "currency": "USD",
                "narrativeCredit": "Bonus from AWSM 🎁"
            },
            "userId": "qweaurl4mwdiq8gp",
            "AFiUserId": "qweaurl4mwdiq8gp",
            "requestId": "qweamplifigrl4mwy1d6qweaurl4mwdiq8gpqtgvjvvpubhkbgiyzgak",
            "dtsAccepted": "2022-06-20T15:49:27.018Z",
            "requestStatus": "processing", //certain status
            "logs": []
        }
    ]
  }