Skip to main content

Create Company API

Overview​

Onboards a new corporate client / company and simultaneously creates the company's primary Company Admin user (with role COMPANY_ADMIN) in a single atomic database transaction.

  • Endpoint: /api/companies/create
  • Method: POST
  • Auth Required: Yes (Bearer <token>)
  • Access Role: Super Admin / Platform RM

Request Body Schema​

FieldTypeRequiredDefaultDescription
nameStringYes—Display name of the company
legalNameStringNonullRegistered legal entity name
gstinStringNonull15-character GST identification number
gstTypeEnumNonullREGISTERED, UNREGISTERED, COMPOSITION, or SEZ
panNumberStringNonull10-character Permanent Account Number
addressStringNonullOffice street address
stateIdNumber (Integer)NonullForeign key ID referencing the State master record
pincodeStringNonullArea postal pincode
phoneStringNonullCorporate contact phone number
emailIdStringNonullOfficial corporate contact email
websiteString (URL)NonullCorporate website URL
creditLimitNumberNo500000Total credit limit granted (>= 0)
creditDaysNumber (Integer)No15Credit payment window in days (>= 0)
priceToleranceTypeEnumNo"PERCENTAGE"Price tolerance strategy: PERCENTAGE or FLAT
priceTolerancePercentNumberNo5Allowed booking price escalation percentage (0 to 100)
priceToleranceAmountNumberNonullAllowed booking price escalation flat amount (>= 0)
adminUserObjectNonullPrimary Company Admin user creation payload

adminUser Object Schema​

FieldTypeRequiredDefaultDescription
firstNameStringYes—Admin user's first name
lastNameStringNonullAdmin user's last name
emailStringYes—Unique corporate email address for login
passwordStringNo"Password123!"Admin login password (minimum 6 characters)
phoneStringNonullUnique contact phone number for admin user

Request Body Example​

{
"name": "Abbott Healthcare",
"legalName": "Abbott Healthcare India Private Limited",
"gstin": "27AAACA0000A1Z5",
"gstType": "REGISTERED",
"panNumber": "AAACA0000A",
"address": "123 Business Park, BKC",
"stateId": 21,
"pincode": "400051",
"phone": "+912212345678",
"emailId": "info@abbott.com",
"website": "https://www.abbott.com",
"creditLimit": 1000000,
"creditDays": 30,
"priceToleranceType": "PERCENTAGE",
"priceTolerancePercent": 5,
"adminUser": {
"firstName": "Anita",
"lastName": "Iyer",
"email": "admin@abbott.com",
"password": "Password123!",
"phone": "+919876543210"
}
}

Success Response (201 Created)​

{
"success": true,
"message": "Company onboarded successfully",
"data": {
"company": {
"id": "c478a846-993d-4c8d-bf8d-d77cb3370e01",
"name": "Abbott Healthcare",
"legalName": "Abbott Healthcare India Private Limited",
"gstin": "27AAACA0000A1Z5",
"gstType": "REGISTERED",
"panNumber": "AAACA0000A",
"address": "123 Business Park, BKC",
"stateId": 21,
"pincode": "400051",
"phone": "+912212345678",
"emailId": "info@abbott.com",
"website": "https://www.abbott.com",
"creditLimit": "1000000.00",
"creditDays": 30,
"priceToleranceType": "PERCENTAGE",
"priceTolerancePercent": 5,
"priceToleranceAmount": null,
"active": true,
"delete": false,
"createdAt": "2026-09-02T07:30:00.000Z",
"updatedAt": "2026-09-02T07:30:00.000Z",
"employeeBands": [],
"departments": [],
"users": [
{
"id": "u555-admin-uuid",
"email": "admin@abbott.com",
"firstName": "Anita",
"lastName": "Iyer",
"employeeBand": null
}
],
"_count": {
"users": 1,
"bookings": 0
}
},
"adminUser": {
"id": "u555-admin-uuid",
"email": "admin@abbott.com",
"firstName": "Anita",
"lastName": "Iyer",
"phone": "+919876543210",
"companyId": "c478a846-993d-4c8d-bf8d-d77cb3370e01",
"bandId": null,
"employeeBand": null,
"clientType": "B2B",
"active": true,
"delete": false,
"createdAt": "2026-09-02T07:30:00.000Z",
"updatedAt": "2026-09-02T07:30:00.000Z"
}
}
}

Error Responses​

400 Bad Request — Validation Error​

{
"success": false,
"data": {
"name": {
"_errors": ["Company display name is required"]
}
},
"message": "Validation failed"
}

400 Bad Request — Duplicate Company Name​

{
"success": false,
"data": null,
"message": "Active company with name 'Abbott Healthcare' already exists"
}

400 Bad Request — Duplicate Admin Email​

{
"success": false,
"data": null,
"message": "User with email 'admin@abbott.com' already exists"
}

Database Impact​

  • Tables Affected: Company, User, UserSystemRoleMap, CompanyUserRole
  • Transaction: Performed inside an atomic Prisma transaction (prisma.$transaction).