Skip to main content
The create_client function creates a Firebase Authentication user and writes a corresponding document to the u_clients Firestore collection. Clients represent organizations or individuals that own events on the platform.

Endpoint

POST https://<region>-<project>.cloudfunctions.net/create_client

Request body

All fields are nested under a top-level data key.

Identity fields

data.name
string
required
Full legal name of the client.
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.id
string
Government-issued identification number.
data.id_type
string
Type of identification document (for example, passport, national_id).
data.account_type
string
Account classification used for access control and billing.

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.

Commercial and fiscal fields

data.name_commercial
string
Trading or commercial name of the organization.
data.commercial_registry
string
Company registration number.
data.commercial_license
string
Commercial operating license identifier.
data.last_assembly_minutes
string
Reference to the most recent shareholders’ meeting minutes document.
data.fiscal_info
string
Tax identification or fiscal registry information.
data.taxpayer_type
string
Taxpayer classification (for example, ordinary, special).
Name or identifier of the legal representative.
data.contact_person
string
Primary contact person for the account.
data.bank_accounts
array
List of bank account objects associated with the client.

Example request

{
  "data": {
    "name": "Acme Events S.A.",
    "email": "[email protected]",
    "password": "SecurePass123!",
    "phone": "+58-212-555-0100",
    "status": "active",
    "id": "J-12345678-9",
    "id_type": "rif",
    "account_type": "business",
    "city": "Caracas",
    "country": "Venezuela",
    "line": "Av. Principal, Edificio Centro, Piso 3",
    "zip_code": "1060",
    "name_commercial": "Acme Events",
    "commercial_registry": "RM-2024-00123",
    "commercial_license": "LIC-2024-456",
    "fiscal_info": "J-12345678-9",
    "taxpayer_type": "ordinary",
    "legal_representative": "María González",
    "contact_person": "Carlos Pérez",
    "bank_accounts": []
  }
}

What is written to Firestore

The function writes a document to u_clients/{uid} with the following structure:
{
  "name": "Acme Events S.A.",
  "email": "[email protected]",
  "name_commercial": "Acme Events",
  "phone": "+58-212-555-0100",
  "status": "active",
  "id": "J-12345678-9",
  "id_type": "rif",
  "address": {
    "city": "Caracas",
    "country": "Venezuela",
    "line": "Av. Principal, Edificio Centro, Piso 3",
    "zipcode": "1060"
  },
  "account_type": "business",
  "commercial_registry": "RM-2024-00123",
  "commercial_license": "LIC-2024-456",
  "last_assembly_minutes": null,
  "fiscal_info": "J-12345678-9",
  "taxpayer_type": "ordinary",
  "legal_representative": "María González",
  "contact_person": "Carlos Pérez",
  "bank_accounts": [],
  "date": {
    "create": "<Firestore Timestamp>",
    "last_access": "",
    "last_update": ""
  },
  "data": {
    "collaborators": 0,
    "contracts": 0,
    "events": 0
  }
}
The document ID in Firestore is the Firebase Authentication UID returned by auth.createUser(). The password field is never written to Firestore.

Response

Success

message
string
Confirmation message including the new UID.
status
number
200 on success.
data
object
{
  "message": " Ingresado con el ID: abc123xyz .",
  "status": 200,
  "data": {
    "uid": "abc123xyz"
  }
}

Error

message
string
Error description.
status
number
400 when Firebase Authentication fails (for example, duplicate email).
data
object
{
  "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 a 400 response and stops. Check for duplicate email addresses before calling this endpoint.

The data counters

Each client document is initialized with a data object that tracks aggregate counts:
FieldInitial valueDescription
data.collaborators0Number of collaborator accounts linked to this client.
data.contracts0Number of contracts associated with this client.
data.events0Number of events created by this client.

Build docs developers (and LLMs) love