Skip to main content
Creates a Firebase Authentication user and writes a document to the u_collaborators Firestore collection. Collaborators are users who operate under a parent client account.

Endpoint

POST https://{region}-{project}.cloudfunctions.net/create_collaborator

Request body

All parameters are nested under a data key.
data.name
string
required
Full name of the collaborator.
data.email
string
required
Email address. Used as the Firebase Authentication login credential.
data.password
string
required
Initial password for the Firebase Authentication account. Not stored in Firestore.
data.client
string
required
UID of the parent client (u_clients document ID) this collaborator belongs to.
data.phone
string
Contact phone number.
data.status
string
Account status. Typically set to false or inactive on creation and activated via validate_user_email.
data.account_type
string
Account classification used for role-based access checks by validate_user_type.
data.id
string
Government-issued identification number.
data.id_type
string
Type of identification document (for example, cedula, passport).

Address fields

data.city
string
City. Stored under address.city in Firestore.
data.country
string
Country. Stored under address.country in Firestore.
data.line
string
Street address line. Stored under address.line in Firestore.
data.zip_code
string
Postal code. Stored under address.zipcode in Firestore.

Example

curl -X POST https://{region}-{project}.cloudfunctions.net/create_collaborator \
  -H "Content-Type: application/json" \
  -d '{
    "data": {
      "name": "Luis Ramírez",
      "email": "[email protected]",
      "password": "SecurePass123!",
      "client": "abc123xyz",
      "phone": "+58-414-555-0200",
      "status": "inactive",
      "account_type": "collaborator",
      "id": "V-18765432",
      "id_type": "cedula",
      "city": "Caracas",
      "country": "Venezuela",
      "line": "Calle 5, Residencia Las Palmas",
      "zip_code": "1060"
    }
  }'

Response

message
string
Confirmation message including the new UID.
status
number
200 on success, 400 on error.
data
object
Success (200):
{
  "message": " Ingresado con el ID: def456uvw .",
  "status": 200,
  "data": {
    "uid": "def456uvw"
  }
}
Error (400):
{
  "message": "Error creando nuevo usuario:",
  "status": 400,
  "data": {
    "error": {
      "code": "auth/email-already-exists",
      "message": "The email address is already in use by another account."
    }
  }
}
If auth.createUser() fails, no Firestore document is written. The function returns 400 and stops processing.

Firestore document

On success, a document is written to u_collaborators/{uid} with the following structure:
{
  "name": "Luis Ramírez",
  "email": "[email protected]",
  "phone": "+58-414-555-0200",
  "status": "inactive",
  "account_type": "collaborator",
  "client": "abc123xyz",
  "id": "V-18765432",
  "id_type": "cedula",
  "address": {
    "city": "Caracas",
    "country": "Venezuela",
    "line": "Calle 5, Residencia Las Palmas",
    "zipcode": "1060"
  },
  "date": {
    "create": "<Firestore Timestamp>",
    "last_access": "",
    "last_update": ""
  }
}
The client field stores the UID of the parent document in u_clients. The password field is never written to Firestore. To activate the account after creation, call validate_user_email with the collaborator’s uid and email.

Build docs developers (and LLMs) love