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

# Create Organization Record

> Create organization metadata and business entity

Creates an organization details record in `clerk_organization_details` table and a business entity in the `entities` table. This is called during onboarding after the Clerk organization is created.

## What This Does

1. **Creates organization metadata** in `clerk_organization_details` (links Clerk org to database)
2. **Gets/creates ranking score** in the pre-payment rankings database (32-49 range)
3. **Creates business entity** in `entities` table (needed for visibility tracking)
4. **Updates Clerk metadata** with business info for frontend access

## Request Body

<ParamField body="business_name" type="string" required>
  The name of the business (e.g., "Nike", "Acme Corp")
</ParamField>

<ParamField body="business_url" type="string">
  The main website URL for the business
</ParamField>

<ParamField body="tracking_type" type="string">
  Type of tracking: `"business"` or `"product"`
</ParamField>

<ParamField body="clerk_org_id" type="string">
  The Clerk organization ID (e.g., `org_2abc123`)
</ParamField>

<ParamField body="clerk_user_id" type="string">
  The Clerk user ID who created the business
</ParamField>

<ParamField body="org_slug" type="string">
  The Clerk organization slug (e.g., `nike-123456`). Used to create the entity in the `entities` table.
</ParamField>

## Response

<ResponseField name="id" type="integer">
  Database record ID in `clerk_organization_details`
</ResponseField>

<ResponseField name="business_uuid" type="string">
  Unique identifier (UUID v4)
</ResponseField>

<ResponseField name="business_name" type="string">
  The organization name
</ResponseField>

<ResponseField name="created_at" type="string">
  ISO 8601 timestamp of creation
</ResponseField>

<ResponseField name="ranking_score" type="integer">
  Pre-payment AI visibility ranking score (32-49)
</ResponseField>

<ResponseField name="entity_id" type="string">
  The UUID of the created entity in the `entities` table
</ResponseField>

<Info>
  The `entity_id` is created here so that **[Materialize Score](/api-reference/endpoint/onboarding/materialize-score)** can immediately copy the ranking score to the main database after onboarding completes.
</Info>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://searchcompany-main.up.railway.app/api/business \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -d '{
      "business_name": "Nike",
      "business_url": "https://nike.com",
      "tracking_type": "business",
      "clerk_org_id": "org_2abc123",
      "clerk_user_id": "user_2xyz789",
      "org_slug": "nike-123456"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "id": 42,
    "business_uuid": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
    "business_name": "Nike",
    "created_at": "2024-01-15T10:30:00Z",
    "ranking_score": 38,
    "entity_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  }
  ```
</ResponseExample>
