Serving a browser or mobile client
Anything shipped to a device is readable. An API key in a browser bundle, a mobile binary, a mobile app’s config file or a client-side environment variable is a published key. So a front end never calls this API directly — it calls a small backend of yours that holds the key.
Three routes: submit, poll, fetch a result image. Proxy nothing else.
The rule that is easy to miss
This API authenticates your account, not your end users. Within your account it provides no isolation between your users, by design — one key, one environment. Two of your customers sharing that key share every asset and every job.
So the authorization your users need is one only you can implement: your BFF has to record which of your callers submitted which job, and which result assets that job produced, and refuse any id it cannot attribute to the caller asking. A BFF that forwards whatever job or asset id it is given lets one of your customers read another customer’s face analysis.
That check is the difference between a proxy and a BFF.
Submit
The submit route does two upstream calls: it uploads the image as an asset, then submits the job that names it. The asset id never needs to reach your client.
remember_job_for_caller, remember_asset_for_caller and the two is_..._issued_to_caller
checks are yours because only you know what a caller is — a signed-in account, a
session, a device token. Whatever it is, persist the association somewhere every route
below can read it, and somewhere that survives a deploy and is shared across workers.
An in-process dictionary works until the second replica.
Poll
Pass the upstream Retry-After on to your client rather than polling on your own
schedule, and pass ETag / If-None-Match through if you cache —
Asynchronous jobs, Retries and backoff.
Answer 404 and not 403 for a job that is not the caller’s, for the same reason
we do: 403 confirms the job exists.
Fetch a result image
The asset id is a single path segment you have already attributed, so there is no path to validate — only the attribution to check.
The rules, in one table
Whatever your BFF stores on the way through is subject to the same obligations as the rest — Privacy and retention.