My EMI Pay

    My EMI Pay · QA / Dev

    Customer happy flow

    Replay the customer path with sample request and response bodies. Scratch phone 9876543210, product prod_personal, mock OTP 123456. After OTP verify, every customer URL needs Authorization: Bearer <accessToken>. Skip a step → 409 step_not_ready with requiredStep.

    Browse the APIs GET /health Changelog
    Ground rules
    • Money is integer paise. ₹15,000 = 1500000. Never send rupees as a decimal.
    • No create-application API. OTP verify starts the case when isNewUser is true.
    • Customer URLs have no application id. The session picks the open application. Staff still uses /applications/{id}.
    • Revision. Writes need a fresh revision from the last screen. Stale → 409 revision_conflict.
    • Ids look like cust_1735…, app_1735…. Failures look like { "code": "snake_case", "message": "…" }.

    QA dummy phones

    Mock OTP is 123456 for every number. Use published product prod_personal. Tokens in the samples below are placeholders — copy live values from the last response.

    Phone When to use After OTP
    9000000001 Onboarding already finished Customer auto-login, journey under_verification, PAN ACUPA7085R
    9000000002 Draft user — jump to begin-verification User auto-login, next POST /applications/begin-verification
    9000000003 Family picker (two PANs) No accessToken. POST /auth/accounts/select with cust_1700000000001 (Arjun / BQGPA1111A) or cust_1700000000002 (Sita / FWXPA2222B)
    9876543210 Scratch — full happy path from zero New User, follow the steps below

    Happy flow — what to use, when, sample I/O

    Call these in order. After step 4, send the Bearer on every customer request.

    1. GET /health Usage: first request after pointing at a host. Description: proves the Node process is listening — not Postgres, Redis, or vendors. Response 200
      {
        "ok": true
      }
    2. GET /products Usage: before OTP, on the product-picker screen. Description: OTP product_id must be a published catalogue id. Response 200 — send prod_personal
      {
        "products": [
          {
            "id": "prod_personal",
            "name": "Personal loans",
            "version": 1,
            "minAmountPaise": 1000000,
            "maxAmountPaise": 20000000,
            "rateBps": 1400,
            "tenorMonths": 12
          }
        ]
      }
    3. POST /auth/otp/request Usage: customer picked a product and typed a phone. Description: stores a one-time code. The code is never in JSON. Mock = 123456. Request
      {
        "phone": "9876543210",
        "product_id": "prod_personal"
      }
      Response 200
      {
        "ok": true
      }
    4. POST /auth/otp/verify Usage: immediately after the OTP. Same phone + same product_id. Description: proves the phone and starts the application. Save accessToken, customerId, application.id. Request
      {
        "phone": "9876543210",
        "code": "123456",
        "product_id": "prod_personal"
      }
      Response 200
      {
        "phoneSessionToken": "phone_session_…",
        "accounts": [],
        "canAddAccount": true,
        "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…",
        "refreshToken": "refresh_…",
        "tokenType": "Bearer",
        "expiresIn": 86400,
        "identityKind": "user",
        "userId": "user_1735123456789",
        "customerId": "user_1735123456789",
        "productId": "prod_personal",
        "isNewUser": true,
        "application": {
          "application": { "id": "app_1735123456789", "reference": "PME-A1B2C3D4" },
          "status": "started",
          "youCanNow": [
            { "action": "begin_verification", "submitTo": "/applications/begin-verification" }
          ],
          "revision": "1"
        }
      }
    5. GET /application/journey Usage: after OTP and after every successful write. Description: do not guess the next URL — use current.method + current.path. Response 200
      {
        "applicationStatus": "started",
        "isOnboardingFinished": false,
        "revision": "1",
        "current": {
          "step": "begin_verification",
          "method": "POST",
          "path": "/applications/begin-verification"
        },
        "upcoming": {
          "step": "update_profile",
          "method": "POST",
          "path": "/application/profile"
        }
      }
    6. Email verify (optional to log in) Usage: after login, when the app collected an email. Description: email cannot be saved on the profile POST. The start response does not include the token — copy it from the mail / server log. POST /auth/email/verify/start
      { "email": "qa.scratch@example.com" }
      POST /auth/email/verify/confirm → then GET /auth/email/verify/status
      { "token": "email_token_…" }
      
      { "verified": true, "email": "qa.scratch@example.com" }
    7. GET /application/profile then POST /applications/begin-verification Usage: GET as soon as you have a token. POST when status is started. Description: GET binds the form (null = unknown). Begin-verification unlocks KYC (started → verifying). GET /application/profile → 200
      {
        "customerId": "user_1735123456789",
        "phone": "9876543210",
        "email": "qa.scratch@example.com",
        "emailVerified": true,
        "pan": null,
        "fullName": null,
        "dob": null,
        "monthlyIncomePaise": null
      }
      POST /applications/begin-verification → 200
      {
        "status": "verifying",
        "revision": "2",
        "youCanNow": [
          { "action": "update_profile", "submitTo": "/application/profile" }
        ]
      }
    8. POST /application/profile Usage: journey update_profile (after begin-verification, before PAN). Description: PAN/Aadhaar match and later bank-name check need name, DOB, work, income. dob is dd-mm-yyyy. ₹1,45,000 = 14500000. Request
      {
        "fullName": "SCRATCH USER",
        "dob": "01-01-1995",
        "employmentType": "salaried",
        "employerName": "QA Desk",
        "monthlyIncomePaise": 14500000
      }
    9. PAN DigiLocker Usage: journey kyc_pan. Open url, finish consent, poll status. Description: tokens may rotate User → Customer — save the new Bearer. POST /application/kyc/pan
      {
        "pan": "ABCDE1234F",
        "redirectUrl": "https://myemipay.com/application/kyc/return"
      }
      GET /application/kyc/pan/status after DigiLocker → 200
      {
        "status": "resolved",
        "verified": true,
        "data": { "maskedPan": "XXXXXX234F", "documentType": "PAN" },
        "identityKind": "customer",
        "customerId": "cust_1735123456789",
        "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…"
      }
    10. Bureau + acknowledge Usage: after PAN is verified. Acknowledge only when score is present. Description: the customer saw the score. This is not an offer. GET /application/bureau → 200
      {
        "status": "ready",
        "score": 719,
        "activeAccounts": 10,
        "overdueAccounts": 0,
        "worstDpdDays": 0
      }
      POST /applications/acknowledge-credit-score → 200
      {
        "status": "verifying",
        "revision": "3",
        "summary": { "creditScore": "719" },
        "youCanNow": []
      }
    11. Aadhaar DigiLocker — onboarding ends Usage: after credit-score acknowledge. Do not jump to bank. Description: matched to last-4, profile DOB, and name. Then isOnboardingFinished: true and current is under_verification. POST /application/kyc/aadhaar/start
      {
        "aadhaar": "999999999999",
        "redirectUrl": "https://myemipay.com/application/kyc/return"
      }
      GET /application/kyc/aadhaar/status after DigiLocker, then GET /application/journey
      {
        "status": "resolved",
        "verified": true,
        "data": { "maskedAadhaar": "XXXXXXXX9999", "documentType": "AADHAAR" }
      }
      
      {
        "isOnboardingFinished": true,
        "current": { "step": "under_verification", "path": "/application/eligibility" }
      }

    After onboarding

    Staff creates the offer. Bank and eSign are after accept — not during onboarding. 202 on payout is “request accepted”, not “money sent”.

    1. POST /applications/{id}/evaluate (staff — local hatch X-Actor-Kind: staff) Usage: journey under_verification. Path id = applicationId. A customer token here is 403.
      {
        "bureauClaimId": "claim_…",
        "productVersion": 1,
        "ruleSetId": "rules_personal",
        "ruleSetVersion": 1,
        "sanctionDecisionId": "sanction_…",
        "amountPaise": 5000000
      }
    2. GET /application/eligibility then POST /applications/accept-offer Usage: after staff sanction. Show amountPaise only when eligible: true (₹50,000 = 5000000).
      { "eligible": true, "amountPaise": 5000000 }
    3. Bank → eSign → create-loan → request-payout → ops dispatch Usage: status accepted. Then ops must drain the queue.
      POST /application/kyc/bank
      { "accountNumber": "123456789012", "ifsc": "HDFC0000001" }
      
      POST /application/esign/start   → poll GET /application/esign/status
      POST /applications/create-loan  → 201 { "loan": { "id": "loan_…" } }
      POST /applications/request-payout → 202
      POST /ops/dispatch-due          (header X-Internal-Secret)

    How to pick the next API

    Prefer GET /application/journey → use current.method + current.path. Or GET /applications → youCanNow.

    Now Use this Description
    no tokenproducts → OTP request → verifyLogin + auto-start
    startedPOST /applications/begin-verificationUnlock KYC
    update_profilePOST /application/profileName / DOB / income before PAN
    kyc_panPAN start + status pollDigiLocker PAN
    bureauGET /application/bureauScore for the next screen
    acknowledge_credit_scorePOST /applications/acknowledge-credit-scoreCustomer saw the score
    kyc_aadhaarAadhaar start + status pollLast-4 + DOB + name vs XML
    under_verificationwait; staff evaluateUnderwriting
    offer_readyeligibility GET, then accept-offerShow amount, take consent
    acceptedbank → esign → create-loanAfter the offer
    loan existsrequest-payout, then ops dispatchDisbursal