> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bbrands.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Company

export const ParamField = ({default: defaultValue, deprecated = false, children, name, required = false, rules, type, unique = false, visibility = 'public'}) => <div className="pt-2.5 pb-5 my-2.5 border-gray-50 dark:border-gray-800/50 border-b">
    <div className="flex font-mono text-sm group/param-head param-head">
      <div className="flex-1 flex content-start py-0.5 mr-5">
        <div className="flex items-center flex-wrap gap-2">
          <div className="absolute h-0 w-0">
            <a href="#param-commercial-activity" className="-ml-10 flex items-center opacity-0 border-0 group-hover/param-head:opacity-100 py-2 [.expandable-content_&]:-ml-[2.1rem]" aria-label="Navigate to header">
              <div className="w-6 h-6 text-gray-400 rounded-md flex items-center justify-center zinc-box bg-white ring-1 ring-gray-400/30 dark:ring-gray-700/25 hover:ring-gray-400/60 dark:hover:ring-white/20">
                <svg xmlns="http://www.w3.org/2000/svg" fill="gray" height="12px" viewBox="0 0 576 512">
                  <path d="M0 256C0 167.6 71.6 96 160 96h72c13.3 0 24 10.7 24 24s-10.7 24-24 24H160C98.1 144 48 194.1 48 256s50.1 112 112 112h72c13.3 0 24 10.7 24 24s-10.7 24-24 24H160C71.6 416 0 344.4 0 256zm576 0c0 88.4-71.6 160-160 160H344c-13.3 0-24-10.7-24-24s10.7-24 24-24h72c61.9 0 112-50.1 112-112s-50.1-112-112-112H344c-13.3 0-24-10.7-24-24s10.7-24 24-24h72c88.4 0 160 71.6 160 160zM184 232H392c13.3 0 24 10.7 24 24s-10.7 24-24 24H184c-13.3 0-24-10.7-24-24s10.7-24 24-24z"></path>
                </svg>
              </div>
            </a>
          </div>
          <div className="font-semibold text-primary dark:text-primary-light cursor-pointer">{name}</div>
          <div className="flex items-center space-x-2 text-xs font-medium">
            {type && <span className="px-2 py-0.5 rounded-md bg-gray-100/50 dark:bg-white/5 text-gray-600 dark:text-gray-200 font-medium">
                {type}
              </span>}
            {defaultValue && <span className="px-2 py-0.5 rounded-md bg-gray-100/50 dark:bg-white/5 text-gray-600 dark:text-gray-200 font-medium">
                <span className="text-gray-400 dark:text-gray-500">default:</span>"{defaultValue}"
              </span>}
            {visibility && <span className="px-2 py-0.5 rounded-md bg-gray-100/50 dark:bg-white/5 text-blue-600 dark:text-blue-300 font-medium">
                {visibility === 'private' ? 'private' : 'public'}
              </span>}
            {unique && <span className="px-2 py-0.5 rounded-md bg-gray-100/50 dark:bg-white/5 text-blue-600 dark:text-blue-300 font-medium">
                unique
              </span>}
            {required && <span className="px-2 py-0.5 rounded-md bg-red-100/50 dark:bg-red-400/10 text-red-600 dark:text-red-300 font-medium">
                required
              </span>}
            {deprecated && <span className="px-2 py-0.5 rounded-md bg-amber-100/50 dark:bg-amber-400/10 text-amber-600 dark:text-amber-300 font-medium">
                deprecated
              </span>}
          </div>
        </div>
      </div>
    </div>
    {children && <div className="mt-4 prose-sm prose-gray dark:prose-invert [&_.prose>p:first-child]:mt-0 [&_.prose>p:last-child]:mb-0">
        {children}
      </div>}
    {rules && <div className="mt-2 prose-sm prose-gray dark:prose-invert [&_.prose>p:first-child]:mt-0 [&_.prose>p:last-child]:mb-0">
        <b>Rules</b>: <span>{rules}</span>
      </div>}
  </div>;

Creates a new company record in the database. Validates request body parameters using Zod schemas and ensures data integrity.

## Endpoint

```
POST /api/v3/product/company
```

## Authentication

This endpoint requires authentication. Include a valid bearer token in the Authorization header.

**Permission Required**: `company:create`

## Request Body

<ParamField name={'name'} required={true} type={'string'} rules={'Max length: 100 characters'} visibility={'public'}>
  The name of the company.
</ParamField>

<ParamField name={'internal'} required={true} type={'string'} rules={'Max length: 50 characters, must be unique'} visibility={'public'}>
  The internal identifier for the company. Must be unique across all non-deleted companies.
</ParamField>

<ParamField name={'description'} type={'string'} rules={'Max length: 255 characters'} visibility={'public'}>
  A description of the company. Optional.
</ParamField>

<ParamField name={'image'} type={'string'} rules={'Max length: 500 characters'} visibility={'public'}>
  The image URL associated with the company. Optional.
</ParamField>

**Note**: Tracking fields (`created_at`, `updated_at`, `deleted_at`, `is_actived`, `is_deleted`, `document_id`) are managed automatically by the system and cannot be set during creation.

## Response

### Success Response (201 CREATED)

Returns the newly created company record.

```json theme={null}
{
  "message": "Company record created successfully",
  "data": {
    "document_id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Acme Corporation",
    "internal": "ACME",
    "description": "A leading technology company",
    "image": "https://example.com/logo.png",
    "is_actived": true,
    "is_deleted": false,
    "created_at": "2024-01-01T00:00:00.000Z",
    "updated_at": "2024-01-01T00:00:00.000Z",
    "deleted_at": null
  },
  "meta": {
    "correlation": "29146752-ef3a-4569-b397-ff2144412c4a",
    "status": 201,
    "timestamp": "2024-01-01T00:00:00.000Z"
  }
}
```

### Error Responses

**400 Bad Request** - Invalid request body or validation failed

```json theme={null}
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Validation failed",
    "errors": [
      {
        "field": "name",
        "message": "Name is required"
      }
    ]
  },
  "meta": {
    "correlation": "...",
    "status": 400,
    "timestamp": "..."
  }
}
```

**401 Unauthorized** - Missing or invalid authentication token

**403 Forbidden** - Insufficient permissions

**409 Conflict** - Internal identifier already exists

## Examples

### Basic Request

```bash theme={null}
curl -X POST 'https://api.bbrands.io/api/v3/product/company' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Acme Corporation",
    "internal": "ACME",
    "description": "A leading technology company",
    "image": "https://example.com/logo.png"
  }'
```

### Minimal Request (Required Fields Only)

```bash theme={null}
curl -X POST 'https://api.bbrands.io/api/v3/product/company' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Acme Corporation",
    "internal": "ACME"
  }'
```
