Expense Report Ingestion API

This set of APIs are meant to ingest the expense report to the AppZen environment. Below are the steps to be followed in order to ingest a report:

 

Generate the URL to upload attachment: 

This would generate a pre-signed PUT URL to upload the attachment to AppZen environment. Also, as a part of its response, you will get the 'file_id'. This 'file_id' is the name/key by which your attachment would be referred by the AppZen system. You will be required to mention the value of this field while uploading a report.

Example Curl
curl --location --request GET "https://api.appzen.com/expense-ingestion/reports/12AB34CD/images/upload-url" \
--header "x-api-key: EBRxxxxxxxxxxxxxxxxxlij58v" \
--header "customer_id: 9xxx9" \
--header "customer-key: 620bxxxxxxxxxxxxxa355b9dff7"
Sample Response
{
 "Status": "Success",
   "msg": "Successfully generated URL for uploading image",
   "image_upload_url_details": {
       "url": "https://appzen-images.s3.amxxxxws.com/9xxx9/797f3316-xxx-xxxx-xxxx-72e33d789729?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20200921T132222Z&X-Amz-SignedHeaders=host&X-Amz-Expires=300&X-Amz-Credential=AKxxxxxxZ4TKKxxxP3A%2F20200921%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=882xxx83835xxxxxxxxxxxxxx091fbfa5bxxxxxxxxa2f2dxx3fd3",
       "file_id": "797f3316-xxx-xxxx-xxxx-72e33d789729"
   },
   "external_report_id": "12AB34CD"
}

Upload the attachment file using the the URl generated above:

Example Curl
curl --location --request PUT "https://appzen-images.s3.amxxxxws.com/9xxx9/e2d48031-000e-4bd4-9080-75565cff8b75?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20200921T132600Z&X-Amz-SignedHeaders=host&X-Amz-Expires=300&X-Amz-Credential=AKIAIxxxxxKKWxxxP3A%2F20200921%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=91ae27af24a85xxxxxxx1c3fd630d0xxxxxxxx2616cdxxxx6bd" \

--header "customer_id: 9xxx9" \

--header "Content-Type: application/x-www-form-urlencoded" \

--header "x-api-key: XLD9TXxxxxxxxGaGhHxxxxxxxxVUKegx" \

--data-binary "{path_of_the_image}”
Sample Response
Status Code: 200 [with empty response]

Upload the report details using API to ingest the report: 

In the request body, populate the value of image id

Note: This is just a sample request body for reference. For exact fields to be included, please go through the Expense Report Ingestion API Field Details.

Example Curl

curl --location --request PUT "https://api.appzen.com/expense-ingestion/reports/12AB34CD" \

--header "x-api-key: EBRxxxxxxxxxxxxxxxxxlij58v" \

--header "customer_id: 9xxx9" \

--header "customer-key: 620bxxxxxxxxxxxxxa355b9dff7" \

--header "Content-Type: application/json" \

--data "{

  \"expense_report\": {

    \"date\": \"2020-09-01T14:23:57.014Z\",

    \"country\": \"US\",

    \"amount\": \"1100.00\",

    \"report_name\": \"AZAuto891 1335077649\",

    \"last_updated_at\": \"2020-09-01T14:23:57.014Z\",

    \"elines\": [

      {

        \"el_type\": \"Hotel Room Charges\",

        \"el_curr\": \"USD\",

        \"missing_receipt\": \"N\",

        \"expense_line_iId\": 1,

        \"elItemizedFlag\": \"false\",

        \"eldetails\": [],

        \"elamount\": \"787.27\",

        \"elpaidamount\": \"787.27\",

        \"elpurpose\": \"Expense Link Description\",

        \"eldate\": \"2020-08-01T14:23:57.014Z\",

        \"eline_id\": \"1\",

        \"elpaidcurr\": \"USD\",

        \"elconvrate\": \"0.145507246376813\",

        \"elinetype\": \"CREDIT\",

        \"elpersonalflag\": \"N\",

        \"elcostcenter\": \"605\",

        \"elvatflag\": \"false\",

        \"el_image_id\": [

          \"d3f4e3bc-9ec6-xxxx-xxxx-xxx445762b05\"

        ]

      },

      {

        \"eltype\": \"Hotel Room Charges\",

        \"elcurr\": \"USD\",

        \"missingReceipt\": \"N\",

        \"expenseLineId\": 2,

        \"elItemizedFlag\": \"false\",

        \"eldetails\": [],

        \"elamount\": \"787.27\",

        \"elpaidamount\": \"787.27\",

        \"elpurpose\": \"Expense Link Description\",

        \"eldate\": \"2020-09-01T14:23:57.014Z\",

        \"elineid\": \"2\",

        \"elpaidcurr\": \"USD\",

        \"elconvrate\": \"0.145507246376813\",

        \"elinetype\": \"CREDIT\",

        \"elpersonalflag\": \"N\",

        \"elcostcenter\": \"605\",

        \"elvatflag\": \"false\",

        \"elimageid\": [

          \"e2d48031-000e-xxxx-xxxx-75565cff8b75\"

        ]

      }

    ],

    \"external_template_name\": \"external_template_name_trial_2\",

    \"external_template_id\": \"external_template_id_trial_2\",

    \"userName\": \"john smith\",

    \"userid\": \"pkuid000001\",

    \"createdAt\": \"2020-09-01T14:23:57.014Z\",

  \"emailAddress\": \"john.smith@domain.com\",

    \"countryCode\": \"USA\",

    \"customerId\": 9xxx9,

    \"curr\": \"USD\",

    \"desc\": \"Report Description 2\",

    \"status\": \"SUBMITTED TO APPZEN\"

  }

}"
Sample Response

{
    "Status": "Success",

    "msg": "Successfully processed submitted report"

}
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.