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 authentication

Manage Companies

Create a new company

post

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 id field

Inheritance:

  • If parent is specified, child company automatically inherits all services from the parent

Authorizations
X-AuthorizationstringRequired

Auth header token that doesn't expire

Body
namestringRequired

Company name (required)

Example: Acme Corporation
vatstring | nullableOptional

VAT/Tax identification number

Example: VAT123456789
addressstring | nullableOptional

Company address

Example: 123 Business Street
zipstring | nullableOptional

Postal/ZIP code

Example: 12345
phonestring | nullableOptional

Phone number

Example: +1-555-0123
emailstring · email | nullableOptional

Contact email

Example: [email protected]
logostring | nullableOptional

URL to company logo

Example: https://example.com/logo.png
Responses
200

Company created successfully. Returns the created company object with assigned ID.

application/json
post
/company/add
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": {}
}

Get all companies

get

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 c parameter 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 ipp and pn are provided, response includes total count

  • Response always includes Companies array and optional Total field

Authorizations
X-AuthorizationstringRequired

Auth header token that doesn't expire

Query parameters
dstring · enumOptional

Include domains (y/n)

Default: yExample: yPossible values:
sstring · enumOptional

Include services (y/n)

Default: yExample: yPossible values:
ustring · enumOptional

Include users (y/n)

Default: yExample: yPossible values:
cintegerRequired

Company ID - you can only access companies you belong to

Example: 1
ippintegerOptional

Items per page

Default: 0Example: 20
pnintegerOptional

Page number

Default: 0Example: 1
hstring | nullableOptional

Company name filter (partial match)

Example: Acme
rstring · enum | nullableOptional

Sort order (asc/desc)

Example: ascPossible values:
mstring · enum | nullableOptional

Column to sort by (id, created, name, vat, zip)

Example: namePossible values:
Responses
200

Successfully retrieved companies

application/json
get
/company/all
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 an existing company

post

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

Authorizations
X-AuthorizationstringRequired

Auth header token that doesn't expire

Body
idintegerRequired

Company ID (required, cannot be 0)

Example: 42
namestring | nullableOptional

Company name

Example: Updated Corporation
vatstring | nullableOptional

VAT/Tax identification number

Example: VAT987654321
addressstring | nullableOptional

Company address

Example: 456 New Street
zipstring | nullableOptional

Postal/ZIP code

Example: 54321
phonestring | nullableOptional

Phone number

Example: +1-555-9999
emailstring · email | nullableOptional

Contact email

Example: [email protected]
logostring | nullableOptional

URL to company logo

Example: https://example.com/new-logo.png
Responses
200

Company updated successfully

application/json
post
/company/update
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
}

Delete a company

post

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)

Authorizations
X-AuthorizationstringRequired

Auth header token that doesn't expire

Body
idintegerRequired

Company ID to delete

Example: 42
Responses
200

Company deleted successfully

application/json
post
/company/delete
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 company admin user

post

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:

  1. Creates user if needed (requires all user fields)

  2. Authorizes user with "company-admin" role

  3. Joins user to company

  4. Generates API key v2

  5. Generates JWT token (valid 7 days)

Query Parameters:

  • c: Company ID (required)

  • k: API key name (optional, defaults to "company admin api key")

Authorizations
X-AuthorizationstringRequired

Auth header token that doesn't expire

Query parameters
cintegerRequired

Company ID

Example: 1
kstringOptional

API key name

Default: company admin api keyExample: Production API Key
Body
usernamestringRequired

Username (required)

Example: john.doe
firstnamestring | nullableOptional

First name (required if user doesn't exist)

Example: John
lastnamestring | nullableOptional

Last name (required if user doesn't exist)

Example: Doe
emailstring · email | nullableOptional

Email (required if user doesn't exist)

Example: [email protected]
passwordstring | nullableOptional

Password (required if user doesn't exist)

Example: SecurePass123!
Responses
200

Company admin added successfully

application/json
post
/user/add_company_admin
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?