FlowPrime guides
A worked example of a two-sided marketplace on FlowPrime: companies post jobs and pay for the product, their staff work in the company's space, and independent workers (cleaners, drivers, tutors) sign in on their own and apply to jobs from any company. It uses only what is live today. Read platform_guide topic=auth first for the sign-in code and the token checks this guide relies on.
| Part | Who holds it | How |
|---|---|---|
| Who the person is, and which company they act for | FlowPrime Auth | the token: sub, account, account_role |
| A company's team (owner and staff), invitations, removing a seat | FlowPrime Auth | hosted Team page, or POST /v1/orgs/{org}/accounts/mine/invites |
| The company's subscription and plan | FlowPrime Payments and Licensing | checkout, then license_customer_entitlements |
| Jobs, applications, assignments, reviews, who may see what | YOUR database | your tables, keyed by account and sub |
| Photos, documents, contracts | FlowPrime Storage | a space per company, file ids kept in your database |
| Splitting a payment between the company and the worker (payouts) | FlowPrime Payments, on your own Stripe account with Stripe Connect turned on | reseller_payee_create, reseller_payee_signup_link for the worker to finish sign-up, then reseller_booking_checkout per job; see platform_guide topic=payments, "Pay your providers" |
FlowPrime has no database. Your jobs and applications need one, with backups: see "Your database" below.
Sparkle Ltd = account A owner Ana, member Bruno -> app "company"
Fresh Homes = account B owner Carla -> app "company"
Dina = consumer sub dina-123 -> app "worker"
jobs: id, account_id (A or B), title, when, status
applications: id, job_id, worker_sub (dina-123), status
Dina applies to a job of Sparkle and a job of Fresh Homes with one login. She is never a member of either company: the link between her and a company is an application row in your database.
customerauth_create_oidc_app, surface: "customer"): the companies. Checkout-first (checkoutUrl = your pricing page, allowSelfRegistration: false) so a company exists only once it paid, or a free tier (allowSelfRegistration: true, signupGrantsAccount: true, freeTier) to let them try first. The first sign-in after the purchase creates the company's account and seats the buyer as owner.surface: "customer", allowSelfRegistration: true, consumerAccountId = an account you own): the independent workers. Each one gets account_role consumer on your account and is told apart by sub. It must be an account you own: auth_list_customer_accounts lists every customer account with its id and owner.Use signupProfile on each app for the fields each side must give at sign-up (a company number for companies, a phone for workers).
The company owner invites staff from the hosted Team page or through your app (POST /v1/orgs/{org}/accounts/mine/invites with the owner's own token). An invited person is seated as member of that company once they accept. Removing the seat cuts their access at the next refresh.
Validate every token as platform_guide topic=auth says (signature, issuer, your workspace, azp), then route by who is calling:
COMPANY_APP = os.environ["COMPANY_CLIENT_ID"]
WORKER_APP = os.environ["WORKER_CLIENT_ID"]
def company_user(c: dict = Depends(claims)) -> dict:
if c.get("azp") != COMPANY_APP or c.get("account_role") not in ("owner", "member"):
raise HTTPException(403, "company route")
return c # scope every query to c["account"]
def worker(c: dict = Depends(claims)) -> dict:
if c.get("azp") != WORKER_APP or c.get("account_role") != "consumer":
raise HTTPException(403, "worker route")
return c # scope every query to c["sub"]
@app.get("/company/jobs")
def company_jobs(c=Depends(company_user)):
return db.jobs.where(account_id=c["account"])
@app.get("/company/jobs/{job_id}/applications")
def applicants(job_id: str, c=Depends(company_user)):
job = db.jobs.get(job_id)
if not job or job.account_id != c["account"]:
raise HTTPException(404) # another company's job: say nothing
return db.applications.where(job_id=job_id)
@app.get("/jobs") # open jobs from every company
def open_jobs(c=Depends(worker)):
return db.jobs.where(status="open")
@app.post("/jobs/{job_id}/apply")
def apply(job_id: str, c=Depends(worker)):
return db.applications.insert(job_id=job_id, worker_sub=c["sub"], status="applied")
@app.get("/me/applications")
def my_applications(c=Depends(worker)):
return db.applications.where(worker_sub=c["sub"])
Rules that keep the sides apart:
account_id is its own account, and a worker's details only through an application to one of its jobs.sub, plus open jobs.account_role, kept in your code.license_customer_entitlements for that account, never from the fact that a token exists.If a worker is also on a company's staff, seat them in that company too (an invitation). They then sign in on the company app as a member of that company, and on the worker app as themselves. Someone seated in several companies is asked which one at sign-in (the hosted account chooser), and their token names only that one.
Give each company a space in Storage (storage_create_space), upload with a space key from your backend, and keep the file id in your database next to the job or application it belongs to (platform_guide topic=storage).
FlowPrime has no database. Jobs, applications and permissions need a durable relational database with backups, which you run next to FlowPrime:
customer apps sign in the same people: check azp on every route, or a worker's token opens company routes.account is the key of everything it owns. Never take a company id from the request body or the URL without checking it equals the token's account.reseller_payee_create, then reseller_payee_signup_link), and reseller_booking_checkout charges the company for one job and pays that worker minus your fee. The fee can be a percentage, a fixed amount, or both with a minimum and a maximum, set for the whole workspace, for one worker or for one job ("Your fee" in the payments guide). A worker must be can_be_paid or payouts_on before a checkout can pay them. One payment pays one worker; splitting it across several is not supported yet. See platform_guide topic=payments, "Pay your providers".platform_guide)platform_guide topic=ai)platform_guide topic=analytics)platform_guide topic=auth)platform_guide topic=feedback)platform_guide topic=mail)platform_guide topic=marketing)platform_guide topic=newsletter)platform_guide topic=observability)platform_guide topic=payments)platform_guide topic=pilot)platform_guide topic=reporting)platform_guide topic=storage)platform_guide topic=webhooks)