# Common Frontend Flows

### Recommended Deployment Shape

KYC should always follow a **backend-first** pattern. The frontend never communicates directly with the KYC provider.

1. The frontend requests the backend to start a KYC session.
2. The backend calls `createApplicant` to create or fetch the applicant record.
3. The backend calls `createAccessToken` to mint a short-lived SDK token.
4. The backend returns the token to the frontend, which launches the provider's hosted verification flow.
5. The backend polls `getApplicantStatus` or processes provider webhooks to determine the verification outcome before unlocking downstream access (e.g. vault deposits, fiat on-ramps).

***

### Status Polling vs. Webhooks

For prototyping and low-traffic environments, polling `getApplicantStatus` on a short interval after the user completes the hosted flow is the simplest path. For production deployments, configure the provider's webhook endpoint to push status updates to your backend — this eliminates polling overhead and gives you real-time state transitions.

***

### Gating Access After Verification

Once `reviewResult.reviewAnswer` returns `GREEN`, your backend should persist the verification state against the user record. Use this persisted flag — not a live provider call — to gate access to protected features. If the answer is `RED`, surface the `rejectLabels` to your support tooling so the user can be guided through remediation. If the answer is `RETRY`, prompt the user to re-enter the hosted flow with a fresh access token.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://city-protocol.gitbook.io/docs/software-development-kit/kyc/common-frontend-flows.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
