Skip to main content
Creates a Firebase Authentication user and writes a document to the u_staff Firestore collection. Staff members are platform administrators and operators.

Endpoint

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

Request body

All parameters are nested under a data key.
data.name
string
required
Full name of the staff member.
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.phone
string
Contact phone number.
data.status
string
Account status (for example, active or inactive).
data.account_type
string
Account classification used for access control.
data.id
string
Government-issued identification number.
data.id_type
string
Type of identification document.
data.commercial_name
string
Commercial or display name for the staff member.

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_staff \
  -H "Content-Type: application/json" \
  -d '{
    "data": {
      "name": "Ana Torres",
      "email": "[email protected]",
      "password": "SecurePass123!",
      "phone": "+58-212-555-0300",
      "status": "active",
      "account_type": "admin",
      "id": "V-20123456",
      "id_type": "cedula",
      "commercial_name": "TMT Operations",
      "city": "Caracas",
      "country": "Venezuela",
      "line": "Torre Empresarial, Piso 8",
      "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: ghi789rst .",
  "status": 200,
  "data": {
    "uid": "ghi789rst"
  }
}
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_staff/{uid} with the following structure:
{
  "name": "Ana Torres",
  "email": "[email protected]",
  "phone": "+58-212-555-0300",
  "status": "active",
  "account_type": "admin",
  "id": "V-20123456",
  "id_type": "cedula",
  "commercial_name": "TMT Operations",
  "address": {
    "city": "Caracas",
    "country": "Venezuela",
    "line": "Torre Empresarial, Piso 8",
    "zipcode": "1060"
  },
  "security_2fa": {
    "status": false,
    "type": "email"
  },
  "timezone": "",
  "date": {
    "create": "<Firestore Timestamp>",
    "last_access": "",
    "last_update": ""
  }
}
All staff accounts are created with security_2fa.status set to false and security_2fa.type set to "email". The timezone field is initialized as an empty string. The password field is never written to Firestore.

Build docs developers (and LLMs) love