To assign proxies by country, Mosaic's country mode gives each selected profile a saved proxy whose IP is in the country you picked. It goes by the country a check measured where one has run, and by the country the proxy was saved with where none has. It hands out proxies no other profile holds first, and only then starts doubling up. The code is in src/main/proxy/assign.ts, and the reasons behind it are what this post is about.

Why there is one assign function

Pointing profiles at saved proxies used to be written three times: once for the window's IPC, once for REST, once for MCP. They had drifted by the time we looked. REST returned the list of assignments and IPC did not, and MCP returned neither reused nor perProxy. So only one of three surfaces could tell a caller that forty profiles had just been put on one IP.

Now there is one assignProxies, and all three doors call it through one reader that refuses unknown fields by name. It has four modes:

ModeWhat it does
oneevery profile on proxyId; null detaches
roundRobinproxyIds dealt out in order, wrapping when profiles outnumber proxies
uniqueone proxy per profile that no other profile holds, or a refusal naming the shortfall
countryproxies that come out in country, unused first, then the least loaded

unique refuses on purpose. Owning forty proxies is supposed to mean forty IPs, and a mode that quietly wrapped would hand you thirty-nine and a shared one. country is the forgiving one, because a market with two proxies and eight profiles is a real situation, and refusing it would push people back to doing it by hand.

Make 500 profiles in one go, then work on all of them at onceIn Mosaic: Bulk actions. 500 profiles per batch; start, edit and type into many. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

How it works: Bulk actions

Assign by country: measured beats declared, one proxy at a time

Every proxy row carries a declared country, the two-letter code it was saved with, usually what the seller said when you bought it. A check replaces that with a measurement: where the proxy's IP actually geolocates. The rule that decides between them is one line:

(p.lastCheck?.ok && p.lastCheck.countryCode) || p.countryCode || ''

A successful check that found a country wins. Otherwise the declared code stands. The decision is made per proxy, not for the whole list, so a freshly pasted batch with no checks yet still sorts by what the seller said, and each proxy moves to its measured country the moment it is checked. We keep the declared code for that window because a list of twenty new proxies with no flags on them is hard to tell apart exactly when you are trying to.

The window uses the same rule. Under Profiles, select the profiles and open Assign proxy. The By country list counts proxies by that same measured-or-declared country, so a proxy sold as German that checks out in the Netherlands is listed under the Netherlands. Why that matters for everything drawn on top of the IP, timezone and language included, is on the IP matching page.

Unused first, and what "unused" means

For each profile the mode builds a pool: the proxies in proxyIds if you named some, otherwise every saved proxy the profile's project can see, filtered to the country. Then it splits the pool. A proxy is fresh if no profile outside this batch holds it.

If any fresh proxy exists, the profile gets the fresh one with the fewest profiles from this batch on it. Only when there is no fresh proxy left at all does it fall back to the whole pool, again least loaded first.

That has a consequence worth knowing. Give country mode six profiles and three unused US proxies, plus a US proxy your other client's profile already uses. You get two profiles on each of the three unused proxies, and the other client's proxy is left alone. Sharing inside the batch you are working on is visible in the answer. Sharing with a profile you were not looking at is the kind that links two accounts nobody meant to connect, which is why forty profiles should mean forty IPs.

Nothing written until everything is chosen

Every choice is made before any profile is written. If the fifth of eight profiles has no proxy in the country visible to its project, the call stops with a sentence that names that profile and the country, ends "Nothing was changed.", and the first four are as they were. A batch that half-applied and then failed would leave you guessing which rows moved.

When it succeeds, the answer is the same on every surface:

POST /api/v1/proxies/assign
{ "profileIds": ["…", "…"], "mode": "country", "country": "DE" }

{ assigned, mode, reused, perProxy,
  assignments: [{ profileId, profileName, proxyId, proxyName }] }

reused is true when two profiles from this call ended up on one proxy, and perProxy is the most any proxy carries. The window turns that into a toast, "8 profiles on DE proxies, sharing", with the detail that up to 2 profiles share each proxy, so some share an IP. MCP's assign_proxy returns the same object. The country must be a two-letter code; anything else is refused with the field named.

If the real need is a fresh IP per profile in one country, a provider is the better tool than a list of saved proxies: each profile gets its own session, and pinning the country, not the address explains why. Country mode is for the proxies you already own, and the bulk bar it lives in is on the bulk actions page.