Files
dashback/docs/api/routes/companyuser/create.md
2026-11-02 00:51:15 +01:00

1.3 KiB

POST /companyuser

Protected. Requires a valid session cookie (credentials: 'include').

Add an existing user to the company

Adds an existing (registered) user, identified by email, to the selected company. Admin only. The added user can then switch to this company via PUT /auth/selected-company. For emails that are not registered yet use POST /autoinvite.

Body (JSON)

Field Required Type Description
email yes string
role no string
{
  "email": "colleague@example.com",
  "role": "user"
}

Signals

On success, emits SSE signal: companyuser (see GET /events).

Response 201

Created company user

{
  "companyuser": {
    "id": 1,
    "googleAuthId": 1,
    "email": "…",
    "picture": "…",
    "role": "admin"
  }
}

Errors

Status Description
400 No company selected, invalid email or invalid role — {"error":"…"}
401 Unauthorized — {"error":"…"}
403 Not authorized (admin of the selected company required) — {"error":"…"}
404 No registered user with this email — {"error":"…"}
409 User already in company — {"error":"…"}

Generated from @openapi JSDoc. Do not edit by hand — run npm run docs:api.