Managing Agents
Agents are the people in your sales team who use the Soryk app to place orders for B2B customers and earn commissions. Everything about them — name, email, assigned companies, role, territory, language — lives in one place: Admin → Agents.
Create an agent manually
- Go to Admin → Agents and click Create agent.
- Fill the modal:
- Email — unique. Used for login and as the commission attribution key.
- Name — display name in the app and on payouts.
- Companies — assign one or more B2B companies (multi-select). Can be edited later.
- Locale — UI language: EN, IT, ES (the agent app supports more languages, this picks the default).
- Click Create. The agent is saved as a
soryk_agentmetaobject. They cannot log in until you send the magic link.
Bulk import via CSV
For teams of 5 or more, use Admin → Agents → Bulk import.
Template columns
| Column | Required | Format | Notes |
|---|---|---|---|
email | Yes | Valid email | Validated against a regex. Invalid rows are reported. |
name | Yes | String | Free text. |
company_ids | No | Comma-separated GIDs | Must match gid://shopify/Company/<numericId>. |
locale | No | en | it | es | Default en. |
role | No | agent | manager | Default agent. |
Example CSV
email,name,company_ids,locale,role
marco.bianchi@example.com,Marco Bianchi,"gid://shopify/Company/123,gid://shopify/Company/456",it,agent
laura.conti@example.com,Laura Conti,gid://shopify/Company/789,it,manager
sara.romano@example.com,Sara Romano,,en,agent
How errors are reported. Rows with invalid emails or wrong-format Company GIDs come back in unresolvedCompanies in the import response. Nothing is half-imported — fix the CSV and re-run. The endpoint is idempotent on email: re-importing the same agent updates fields rather than creating a duplicate.
Invite an agent — magic link
- Open the agent's profile (Agents → click row).
- Click Send magic link.
- Soryk sends an email via Resend with a one-time link. The agent opens it on their phone, gets logged in, and is prompted to install the app from the App Store / Play Store (or use the app in their browser).
The send response includes emailDelivered: true|false. If false, the UI surfaces a warning toast — usually a typo'd email or a Resend rate-limit. Re-send after fixing.
Edit a profile
From the agent detail page /agents/[id]:
- Name & email — editable. Changing email re-keys commission attribution from that point forward (past earnings keep their original tag).
- Active toggle — set to inactive to immediately revoke session access without deleting the agent. Useful for suspensions or vacations.
- Locale — switch UI language.
- Companies — add or remove assigned companies.
- Role — agent or manager (see Roles).
- Zone — territory editor (see Territories).
Assign companies to an agent
An agent can be assigned to many companies. A company can have many assigned agents — that's where commission overrides matter (more on the conflict resolution in Commissions → multi-agent fallback).
- Open the agent profile.
- In the Companies section, click Add.
- Search by name. Select one or many. Save.
From the company side: Companies → [Company] → Agents — the same multi-select editor.
Roles & manager hierarchy
Two roles:
- Agent — places orders, builds quotes, sees own commissions and own assigned companies. Cannot see other agents' data.
- Manager — same as agent, plus: sees the team they manage, can place orders on behalf of them, can view team commissions (read-only).
Set up a manager:
- Toggle the agent's role to Manager.
- In the Managed agents selector, pick the team members reporting to them.
- Optionally set a Manager override percent — applied on top of the regular commission for orders the manager personally places.
The setting managerOrderAttribution controls how a manager's order on behalf of a team member is tagged: team_agent (commission goes to the team member) or manager_only (commission goes to the manager).
Territories
Each agent can have a territory definition with five layers:
- Countries — ISO codes (e.g.
IT,FR,DE). - Regions — free-text region names (e.g.
Lombardia,Île-de-France). - ZIP prefixes — e.g.
20matches all 20xxx postal codes. - Circles — center lat/lng + radius km (Haversine matching).
- Polygons — array of vertices (ray-casting matching).
Country, region and ZIP work out of the box. Circles + polygons require lat/lng on company locations — see the known caveat.
Full walkthrough: Territories & Geo.
Remove an agent
- Open the agent profile.
- Click Delete agent at the bottom.
- Confirm.
What happens:
- The
soryk_agentmetaobject is deleted. - Existing commission earnings are preserved — they stay in the historical record under the deleted agent's email.
- Future orders tagged with that email no longer attribute (the engine logs the unmatched tag).
- Active sessions are revoked on next request.
Prefer "Inactive" over delete. Setting active=false revokes login but keeps everything else intact. Delete only when an agent is permanently gone and you don't expect any orders to ever reference their email again.
Best practices
One email per human. Don't share an email between two reps — commissions can't be split automatically. If two people work the same territory, give each their own agent and use a manager hierarchy or commission overrides.
Use the agent's real personal/work email. Not sales1@yourcompany.com. The magic link goes there, push notifications go there, and audit logs read better. If they leave, you delete or deactivate the account — not the email.
Assign companies before sending the invite. An agent who logs in to an empty company list will think the app is broken. Assign at least one before they get the magic link.