# ICP Builder API Reference

> Platform documentation snapshot. Access, charging and provider requirements remain operation-specific; examples do not execute requests.

### What it does

Describe your best customers in natural language or point at existing wins and the ICP Builder derives a structured, machine-readable ideal customer profile: industries, size bands, geographies, titles and buying signals, ready to feed directly into the search endpoints.

### Use cases

- Onboard a new customer or a new sales motion without a manual discovery workshop.
- Translate closed-won data into concrete search filters that RevOps can run on a schedule.
- Compare two candidate ICPs side by side to decide which segment to fund next quarter.

### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `description` | string | Plain-text description of your ideal customer profile (required) |
| `count` | integer | Number of matching companies to return (default: 50, max: 200) |
| `webhook_url` | string | URL to receive results when the job completes (optional — alternative to polling) |

### Response Schema

_Complete documented fields for this section, with nested notation preserved. Endpoint-specific envelopes, availability and additional fields are described under each endpoint below._

| Field | Notes |
|-------|-------|
| job_id | |
| status (pending → processing → completed → failed) | |
| results[] → company_id, name, website, industry, employee_count, city, state, country, match_score | |

**Illustrative Example Response (synthetic, not a complete endpoint schema):**

```json
{
  "job_id": "job_abc123",
  "status": "completed",
  "created_at": "2025-06-01T12:00:00Z",
  "completed_at": "2025-06-01T12:00:42Z",
  "results": [
    {
      "job_id": "abc123",
      "status": "string",
      "results": [
        {
          "company_id": "abc123",
          "name": "string",
          "website": "https://example.com",
          "industry": "string",
          "employee_count": 0,
          "city": "string",
          "state": "CA",
          "country": 0,
          "match_score": 0
        }
      ]
    }
  ]
}
```

### POST /v1/icp-builder — Build ICP

Describe your ideal customer profile in plain text. Returns a job_id immediately — results are delivered asynchronously via webhook or polling. Costs 50 credits per run. Provide a webhook_url to receive results when complete.

**Example Request Body:**

```json
{
  "description": "SaaS companies with 50-500 employees in the cybersecurity space that sell to enterprise customers",
  "count": 50,
  "webhook_url": "https://your-app.com/webhooks/icp-complete"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/v1/icp-builder",
  "method": "POST",
  "body": {
    "description": "SaaS companies with 50-500 employees in the cybersecurity space that sell to enterprise customers",
    "count": 50,
    "webhook_url": "https://your-app.com/webhooks/icp-complete"
  }
}'
```

### GET /v1/jobs/{job_id}?type=icp — Get ICP Job Status

Poll the status of an ICP build job. Returns the current status and results when complete. Status values: pending, processing, completed, failed. Free — does not consume credits.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/v1/jobs/{job_id}?type=icp",
  "method": "GET"
}'
```

