Companies Management API
The Companies Management API provides endpoints for programmatically managing companies, and hierarchies within the PreCrime Brand platform. This API enables you to create and maintain organizational structures, including parent-child company relationships, and provision administrative users with API credentials to access and manage those companies.
Current Features:
Create companies: Establish new company entities with optional parent-child relationships
Manage hierarchies: Build multi-tenant company structures
Update company information: Modify company details, relationships, and configurations
Remove companies: Safely remove companies and their child companies
Retrieve company data: Access company information
Provision users: Create company administrators with automatic API key generation
Authentication
Check the authentication page to see the available options.
Access and authenticationManage Companies
Create a new company with optional parent company relationship.
Authorization:
If you provide a parent company, you must have access to it
You are automatically joined to the new company with "company-admin" role
Parent Company:
Parent company is optional
If provided, you must have access to the parent company
Include a parent object with the
idfield
Inheritance:
If parent is specified, child company automatically inherits all services from the parent
Auth header token that doesn't expire
Company name (required)
Acme CorporationVAT/Tax identification number
VAT123456789Company address
123 Business StreetPostal/ZIP code
12345Phone number
+1-555-0123URL to company logo
https://example.com/logo.pngCompany created successfully. Returns the created company object with assigned ID.
Bad request - invalid company data
Access denied - you do not have access to the specified parent company
Internal server error
POST /company/add HTTP/1.1
Host: api.bfore.ai
X-Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 200
{
"name": "Subsidiary Corp",
"vat": "VAT123456789",
"address": "123 Business St",
"zip": "12345",
"phone": "+1-555-0123",
"email": "[email protected]",
"parent": {
"id": 1
},
"logo": "https://example.com/logo.png"
}{
"id": 42,
"name": "Subsidiary Corp",
"vat": "VAT123456789",
"address": "123 Business St",
"zip": "12345",
"phone": "+1-555-0123",
"email": "[email protected]",
"parent": {
"id": 1,
"name": "Parent Corp",
"vat": "VAT999999999",
"address": "789 Corporate Blvd",
"zip": "67890",
"phone": "+1-555-9999",
"email": "[email protected]",
"created": "2025-01-15T08:00:00Z"
},
"logo": "https://example.com/logo.png",
"created": "2025-10-20T10:30:00Z",
"users": [],
"domains": [],
"services": [],
"properties": {}
}Retrieve companies you have access to with optional filtering, pagination, and related data inclusion.
Authorization:
You can only access companies you belong to (must provide
cparameter with your company ID)
Data Inclusion:
d: Include domains (y/n, default: y)s: Include services (y/n, default: y)u: Include users (y/n, default: y)
Pagination:
When
ippandpnare provided, response includes total countResponse always includes
Companiesarray and optionalTotalfield
Auth header token that doesn't expire
Include domains (y/n)
yExample: yPossible values: Include services (y/n)
yExample: yPossible values: Include users (y/n)
yExample: yPossible values: Company ID - you can only access companies you belong to
1Items per page
0Example: 20Page number
0Example: 1Company name filter (partial match)
AcmeSort order (asc/desc)
ascPossible values: Column to sort by (id, created, name, vat, zip)
namePossible values: Successfully retrieved companies
Access denied - you do not have access to the specified company
Internal server error
GET /company/all?c=1 HTTP/1.1
Host: api.bfore.ai
X-Authorization: YOUR_API_KEY
Accept: */*
{
"companies": [
{
"id": 1,
"name": "Parent Corp",
"vat": "VAT123456789",
"created": "2025-01-15T08:00:00Z"
},
{
"id": 2,
"name": "Subsidiary Corp",
"vat": "VAT987654321",
"created": "2025-02-10T10:30:00Z"
}
],
"total": 2
}Update company information including basic details, parent relationship, and area.
Authorization:
User must have access to the company being updated
Required Fields:
Company object must include
id(cannot be 0)
Notes:
Parent can be updated by including parent object with id
All updatable fields from the Company entity can be modified
Auth header token that doesn't expire
Company ID (required, cannot be 0)
42Company name
Updated CorporationVAT/Tax identification number
VAT987654321Company address
456 New StreetPostal/ZIP code
54321Phone number
+1-555-9999URL to company logo
https://example.com/new-logo.pngCompany updated successfully
Bad request - invalid company data or missing id
Access denied - user not authorized for this company
Internal server error
POST /company/update HTTP/1.1
Host: api.bfore.ai
X-Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 215
{
"id": 42,
"name": "Updated Corp Name",
"vat": "VAT987654321",
"address": "456 New Address St",
"zip": "54321",
"phone": "+1-555-9999",
"email": "[email protected]",
"parent": {
"id": 1
},
"logo": "https://example.com/new-logo.png"
}{
"success": true
}Soft delete a company and all its child companies recursively.
Authorization:
User must have access to the company being deleted
Side Effects:
Recursively deletes all child companies
This is a soft delete (sets deleted timestamp)
Required Fields:
Company object must include
id(cannot be 0)
Auth header token that doesn't expire
Company ID to delete
42Company deleted successfully
Bad request - invalid company data or missing id
Access denied - user not authorized for this company
Internal server error
POST /company/delete HTTP/1.1
Host: api.bfore.ai
X-Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 9
{
"id": 42
}{
"success": true
}Add a user as company admin and generate API credentials. Creates the user if they don't exist.
Authorization:
You must be company-admin for the specified company
User Creation:
If user exists: Authorizes and joins them to the company
If user doesn't exist: Creates new user with provided details (requires firstname, lastname, email, password)
Automatic Actions:
Creates user if needed (requires all user fields)
Authorizes user with "company-admin" role
Joins user to company
Generates API key v2
Generates JWT token (valid 7 days)
Query Parameters:
c: Company ID (required)k: API key name (optional, defaults to "company admin api key")
Auth header token that doesn't expire
Company ID
1API key name
company admin api keyExample: Production API KeyUsername (required)
john.doeFirst name (required if user doesn't exist)
JohnLast name (required if user doesn't exist)
DoeEmail (required if user doesn't exist)
[email protected]Password (required if user doesn't exist)
SecurePass123!Company admin added successfully
Bad request - missing required fields, company not found, or missing user creation fields for new user
Access denied - you are not authorized as company-admin for this company
Internal server error
POST /user/add_company_admin?c=1 HTTP/1.1
Host: api.bfore.ai
X-Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 23
{
"username": "john.doe"
}{
"user": {
"id": 100,
"username": "john.doe",
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
},
"apiKeyV2": "sk_live_abc123def456..."
}Last updated
Was this helpful?