{
  "info": {
    "name": "MiCash Individual and GMT Onboarding",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Run each step manually for the current customer state. Each app uses its own backend secret. Company UUIDs, cookies and provider JWTs are not needed. Never run this collection as an automatic batch."
  },
  "variable": [
    {
      "key": "urlHost",
      "value": "",
      "type": "string"
    },
    {
      "key": "apiKey",
      "value": "",
      "type": "string"
    },
    {
      "key": "onboardingId",
      "value": "",
      "type": "string"
    },
    {
      "key": "externalReference",
      "value": "",
      "type": "string"
    },
    {
      "key": "mobileNumber",
      "value": "",
      "type": "string"
    },
    {
      "key": "email",
      "value": "",
      "type": "string"
    },
    {
      "key": "displayName",
      "value": "",
      "type": "string"
    },
    {
      "key": "firstNames",
      "value": "",
      "type": "string"
    },
    {
      "key": "surname",
      "value": "",
      "type": "string"
    },
    {
      "key": "identityNumber",
      "value": "",
      "type": "string"
    },
    {
      "key": "selfieDataUrl",
      "value": "",
      "type": "string"
    },
    {
      "key": "identityDataUrl",
      "value": "",
      "type": "string"
    },
    {
      "key": "dateOfBirth",
      "value": "",
      "type": "string"
    },
    {
      "key": "registrationOtp",
      "value": "",
      "type": "string"
    },
    {
      "key": "pinOtp",
      "value": "",
      "type": "string"
    },
    {
      "key": "walletPin",
      "value": "",
      "type": "string"
    },
    {
      "key": "genderType",
      "value": "MALE"
    },
    {
      "key": "countryOfBirth",
      "value": "ZA"
    }
  ],
  "item": [
    {
      "name": "Register a new customer",
      "item": [
        {
          "name": "01 Begin or recover by reference",
          "request": {
            "method": "POST",
            "url": "{{urlHost}}/api/v1/individual/onboardings",
            "header": [
              {
                "key": "X-Integrator-Key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "description": "OTP_REQUIRED: verify registration OTP. EXISTING_PROFILE_REQUIRES_LINKING: use the existing-customer topic; do not recreate the profile.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"mobileNumber\": \"{{mobileNumber}}\",\n  \"email\": \"{{email}}\",\n  \"termsAccepted\": true\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "02 Verify registration OTP",
          "request": {
            "method": "POST",
            "url": "{{urlHost}}/api/v1/individual/onboardings/{{onboardingId}}/otp-verification",
            "header": [
              {
                "key": "X-Integrator-Key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "description": "Use the registration OTP sent to this mobile number. This is different from the later PIN OTP.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"otp\": \"{{registrationOtp}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "03 Validate profile details",
          "request": {
            "method": "POST",
            "url": "{{urlHost}}/api/v1/individual/onboardings/{{onboardingId}}/profile-validation",
            "header": [
              {
                "key": "X-Integrator-Key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "description": "No provider profile is written. Correct invalidField before continuing. For passports, replace identity with the passport fields in the guide.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"displayName\": \"{{displayName}}\",\n  \"email\": \"{{email}}\",\n  \"photo\": \"{{selfieDataUrl}}\",\n  \"identity\": {\n    \"identityNumber\": \"{{identityNumber}}\",\n    \"firstNames\": \"{{firstNames}}\",\n    \"surname\": \"{{surname}}\",\n    \"genderType\": \"{{genderType}}\",\n    \"countryOfBirth\": \"{{countryOfBirth}}\",\n    \"dateOfBirth\": \"{{dateOfBirth}}\",\n    \"photo\": \"{{identityDataUrl}}\"\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "04 Create profile and save documents",
          "request": {
            "method": "POST",
            "url": "{{urlHost}}/api/v1/individual/onboardings/{{onboardingId}}/profile",
            "header": [
              {
                "key": "X-Integrator-Key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "description": "Writes the provider profile after private document persistence. If completion requires review, recover ownership; do not resend creation blindly.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"displayName\": \"{{displayName}}\",\n  \"email\": \"{{email}}\",\n  \"photo\": \"{{selfieDataUrl}}\",\n  \"identity\": {\n    \"identityNumber\": \"{{identityNumber}}\",\n    \"firstNames\": \"{{firstNames}}\",\n    \"surname\": \"{{surname}}\",\n    \"genderType\": \"{{genderType}}\",\n    \"countryOfBirth\": \"{{countryOfBirth}}\",\n    \"dateOfBirth\": \"{{dateOfBirth}}\",\n    \"photo\": \"{{identityDataUrl}}\"\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "05 Request wallet PIN OTP",
          "request": {
            "method": "POST",
            "url": "{{urlHost}}/api/v1/individual/onboardings/{{onboardingId}}/wallet-pin/otp",
            "header": [
              {
                "key": "X-Integrator-Key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "description": "Request a separate PIN verification code."
          }
        },
        {
          "name": "06 Set wallet PIN",
          "request": {
            "method": "POST",
            "url": "{{urlHost}}/api/v1/individual/onboardings/{{onboardingId}}/wallet-pin",
            "header": [
              {
                "key": "X-Integrator-Key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "description": "Use the separate PIN OTP. Keep PIN/OTP strings to preserve leading zeros.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"otp\": \"{{pinOtp}}\",\n  \"pin\": \"{{walletPin}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "07 Complete and associate this app",
          "request": {
            "method": "POST",
            "url": "{{urlHost}}/api/v1/individual/onboardings/{{onboardingId}}/completion",
            "header": [
              {
                "key": "X-Integrator-Key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "description": "Requires live customer PIN proof. Returns canonical E_ID/account UUID and this application wallet. MiCash activation is limited to proven beneficiary-only records.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"pin\": \"{{walletPin}}\",\n  \"termsAccepted\": true\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Import an existing customer",
      "item": [
        {
          "name": "08 Link existing provider profile",
          "request": {
            "method": "POST",
            "url": "{{urlHost}}/api/v1/individual/onboardings/{{onboardingId}}/profile-link",
            "header": [
              {
                "key": "X-Integrator-Key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "description": "After begin reports an existing profile, authenticate the customer PIN and reuse the same account. Then run 07 Complete.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"mobileNumber\": \"{{mobileNumber}}\",\n  \"pin\": \"{{walletPin}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Wallet balance",
      "item": [
        {
          "name": "09 Read this external app wallet",
          "request": {
            "method": "GET",
            "url": "{{urlHost}}/api/v1/individual/onboardings/{{onboardingId}}/wallet",
            "header": [
              {
                "key": "X-Integrator-Key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "description": "Backend secret only. Returns the saved allocation belonging to this external app; no provider login or customer PIN required. MiCash overall balance requires request 10."
          }
        },
        {
          "name": "10 Verify live account and read app view",
          "request": {
            "method": "POST",
            "url": "{{urlHost}}/api/v1/individual/onboardings/{{onboardingId}}/wallet",
            "header": [
              {
                "key": "X-Integrator-Key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "description": "Customer PIN proof and private provider refresh. External apps still receive only their own allocation; MiCash receives overall/main/associated wallets.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"pin\": \"{{walletPin}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Status and recovery",
      "item": [
        {
          "name": "11 Check onboarding status",
          "request": {
            "method": "GET",
            "url": "{{urlHost}}/api/v1/individual/onboardings/{{onboardingId}}",
            "header": [
              {
                "key": "X-Integrator-Key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "description": "Read durable status before choosing a next step."
          }
        },
        {
          "name": "12 Resume or resend registration OTP",
          "request": {
            "method": "POST",
            "url": "{{urlHost}}/api/v1/individual/onboardings/{{onboardingId}}/resume",
            "header": [
              {
                "key": "X-Integrator-Key",
                "value": "{{apiKey}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "description": "Recover expiring OTP proof using the original mobile number and reference. Existing/ambiguous created profiles require ownership linking instead of another creation.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"mobileNumber\": \"{{mobileNumber}}\",\n  \"resendOtp\": true\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        }
      ]
    }
  ],
  "event": [
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          "const result = pm.response.json(); pm.test(\"Controlled API response\", () => pm.expect(result.success).to.be.a(\"boolean\")); if (result.onboarding) { pm.collectionVariables.set(\"onboardingId\", result.onboarding.id); pm.collectionVariables.set(\"onboardingStatus\", result.onboarding.status); }"
        ]
      }
    }
  ]
}
