Manages rows in user_companies (which companies a GOAL user can access).
Base path: /v1/auth/user-companies
Required headers (all endpoints):
| Header | Description |
|---|---|
Authorization |
Bearer <access_token> |
x-app-stage |
Application stage |
x-app-uid |
Application UID |
companyId (query) |
Active company context for permission checks |
Standard envelope: App\Values\Core\ActionResult — { "success": true, "message": "...", "data": ... }.
| Permission | Model action | Effect |
|---|---|---|
G2_ADMIN_USERS_ADD_COMPANY_TO_A_USER (legacy hash) |
Route middleware | Required to create assignments and list assignable companies |
GOAL_V2_AUTH_COMPANY_COMPANY_COMPANY_AUTHORIZER |
Company::COMPANY_AUTHORIZER |
In the current company context, actor may assign users to any active transactional company |
Without Company authorizer, the actor may only assign companies they are actively assigned to.
The same Company authorizer permission (in the active companyId context) also expands data scope on company maintenance list endpoints (GET /v1/base/master/companies/grid-list and GET …/with-children) when the actor already has Company LIST — see Companies Master API.
Company authorizer may also list, assign, and remove company roles for users via auth/user-roles/* when the actor lacks USER_COMPANY_ROLE_* but holds COMPANY_AUTHORIZER in the request companyId context (same scope rules as creating user_companies).
Companies the current user may pick when assigning a company to another user.
GET /v1/auth/user-companies/assignable-companiesgadmin-permission:G2_ADMIN_USERS_ADD_COMPANY_TO_A_USER200 OK{
"success": true,
"message": "Ejecutado correctamente",
"data": [
{
"id": 8,
"name": "DISTRIBUCIONES Y SERVICIOS ROMA SAC",
"short_name": "DS ROMA",
"ruc": "20537004381"
}
]
}
With Company authorizer, data includes all active companies of type transactional (T). Otherwise data is limited to the actor’s active assignments.
| HTTP | When |
|---|---|
401 |
Missing or invalid token |
403 |
Missing G2_ADMIN_USERS_ADD_COMPANY_TO_A_USER |
POST /v1/auth/user-companiesgadmin-permission:G2_ADMIN_USERS_ADD_COMPANY_TO_A_USERCOMPANY_AUTHORIZER or target company_id must be in the actor’s active assignments; otherwise 403.user_id, company_id, etc.).(user_id, company_id); if a soft-deleted row exists, it is restored and updated instead of inserting a duplicate.type = T and base_company_id is set, the user is also assigned to the parent (base) company automatically (minimal row: ERP off, same priority/status as the child assignment when provided).{
"user_id": 42,
"company_id": 8,
"erp_access": false,
"priority": 1,
"status": "A"
}
200 OK{
"success": true,
"message": "Ejecutado correctamente",
"data": {
"id": 1001,
"user_id": 42,
"company_id": 8
}
}
| HTTP | When |
|---|---|
400 |
Validation error or duplicate active assignment |
401 |
Not authenticated |
403 |
Scope check failed (company not assignable) |
404 |
User not found |
422 |
Validation failed |
PUT /v1/auth/user-companies/{id}company_id changes, the same scope check as create runs before validation.