Register New Company
POST/company/auth/register
Endpoint for registering new companies and their initial administrator user.
Performs the following operations:
- Validates required data (company name, matching passwords)
- Verifies email uniqueness
- Creates fiscal address
- Creates company in the database
- Creates administrator user
- Configures Stripe account (customer + connected account)
- Sends welcome email
- Creates initial free rate for 1 month
- Links to existing provider if taxid matches
Detailed flow:
- Client sends company and user data in JSON format
- Server validates required fields (406 if missing)
- Validates taxid according to Spanish tax regulations (406 if invalid)
- Checks email uniqueness (403 if already exists)
- Creates fiscal address with provided data
- Registers company in the database
- Creates administrator user with hashed password
- Configures Stripe account (customer + connected account) for future payments
- Sends activation email with unique token
- Creates initial free rate for 30 days
- If a company_provider with the same taxid exists, links it
Data requirements:
- Valid Taxid/NIF/CIF according to Spanish regulations (optional but recommended)
- Full company name
- Unregistered corporate email
- Secure password (minimum 8 characters, uppercase, numbers, and special characters)
- Complete fiscal address
Request structure:
\{
user: \{
email: admin@company.com,
password: SecurePassword123!,
password_confirm: SecurePassword123!
\},
invoice_data: \{
taxid: B12345678,
email: admin@company.com,
socialName: Example Transports S.L.,
phone: +34123456789
\},
socialName: Example Transports S.L.,
address: \{
place_id: ChIJgTwKgJcpQg0RaSKMYcHeNs,
formatted_address: Calle Mayor 123, Madrid, 28013, Spain,
geometry: \{
location: \{ lat: 40.4168, lng: -3.7038 \}
\},
phone: +34123456789
<Heading
id={"request"}
as={"h2"}
className={"openapi-tabs__heading"}
children={"Request"}
>
</Heading>
<ParamsDetails
parameters={[]}
>
</ParamsDetails>
<RequestSchema
title={"Body"}
body={{"content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","description":"Administrator user data","properties":{"email":{"type":"string","format":"email","description":"User's Email"},"password":{"type":"string","format":"password","description":"User password"},"password_confirm":{"type":"string","description":"Password Confirmation"}}},"invoice_data":{"type":"object","description":"Billing tax data","properties":{"taxid":{"type":"string","description":"Company's Tax ID/VAT Number"},"email":{"type":"string","format":"email","description":"Billing email"},"socialName":{"type":"string","description":"Company Name"},"phone":{"type":"string","description":"Contact phone number"}}},"socialName":{"type":"string","description":"Company's legal name"},"address":{"type":"object","description":"Company's tax address","properties":{"place_id":{"type":"string","description":"Google Places Location ID"},"formatted_address":{"type":"string","description":"Formatted Address"},"geometry":{"type":"object","description":"GPS Coordinates","properties":{"location":{"type":"object","properties":{"lat":{"type":"number","format":"float"},"lng":{"type":"number","format":"float"}}}}},"address_components":{"type":"array","description":"Steering Components","items":{"type":"object"}},"phone":{"type":"string","description":"Director's phone"}}}},"required":["user","invoice_data","socialName","address"],"title":"RegisterRequest"},"example":{"user":{"email":"admin@transportesejemplo.com","password":"Transportes2024!","password_confirm":"Transportes2024!"},"invoice_data":{"taxid":"B12345678","email":"admin@transportesejemplo.com","socialName":"Transportes Ejemplo S.L.","phone":"+34123456789"},"socialName":"Transportes Ejemplo S.L.","address":{"place_id":"ChIJgTwKgJcpQg0RaSKMYcHeNs","address_components":[{"long_name":"123","types":["street_number"]},{"long_name":"Calle Mayor","types":["route"]},{"long_name":"Madrid","types":["locality","administrative_area_level_2"]},{"long_name":"Madrid","types":["administrative_area_level_1"]},{"long_name":"28013","types":["postal_code"]},{"long_name":"Spain","types":["country"]}],"formatted_address":"Calle Mayor 123, Madrid, 28013, Spain","geometry":{"location":{"lat":40.4168,"lng":-3.7038}},"phone":"+34123456789"}}}},"required":true}}
>
</RequestSchema>
<StatusCodes
id={undefined}
label={undefined}
responses={{"200":{"description":"Successful registration (returns empty object)","content":{"application/json":{"schema":{"type":"object","example":{}}}},"headers":{}},"400":{"description":"Error creating address or invalid UTC","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"integer","example":400},"message":{"type":"string","example":"Error creating address"}}}}},"headers":{}},"403":{"description":"Email already registered","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"integer","example":403},"message":{"type":"string","example":"COMPANY_EXISTS"},"existingCompany":{"type":"object"}}}}},"headers":{}},"406":{"description":"Validation Error","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"integer","example":406},"message":{"type":"string","enum":["NAME_REQUIRED","PASSWORD_NOT_MATCH","USER_ALREADY_EXISTS","USER_DISABLED_RECOVERABLE","CIA_ASIGN_FAILED","TRUCKER_DATA_INCOMPLETE"],"example":"PASSWORD_NOT_MATCH"}}}}},"headers":{}}}}
>
</StatusCodes>