# connect

URL: /business/nouns/domain/connect · Id: `verb:Domain.connect` · Call: `await $.Domain.connect({ … })` (SDK) or the `do` tool at `https://api.sb/mcp`. Inputs says what to pass, Outputs what returns, When it waits who approves.

> Connect attaches a hostname a Startup already holds and verifies ownership through DNS.

Connect attaches a hostname a [Startup](/business/nouns/startup) already holds and verifies ownership through DNS.

## Inputs
| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `hostname` | `string` | Yes | The hostname to attach. |
| `startup` | [Startup](/business/nouns/startup) | Yes | The Startup it serves. |
| `tenant` | [Tenant](/business/nouns/tenant) | No | The Tenant it serves, when a Customer connects its own name. |

## Outputs
| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `domain` | [Domain](/business/nouns/domain) | Yes | The connected Domain. |

## Effects
- Emits [`Domain.connected`](/business/events/Domain.connected).
- Performed by the [Integration Engineer](/agents/engineering/integration-engineer).
- Two-way: it runs at once, in the `try`, `send` and `do` modes.
- Issues a certificate once the DNS record verifies.
- Asks for a TXT ownership proof and a CNAME that delegates certificate validation; refuses to reach `live` without the CNAME.
- Refuses a wildcard name for a Tenant, and past the Tenant’s name count follows its Entitlement’s `atBound`.
- Registers the Domain with Stripe as a payment method domain on the Startup’s account.

## Refuses when
| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The input does not match the schema of the operation. | [`invalid-input`](/code/api/errors/invalid-input) | Read the schema of the operation, then send every required field with the right type. | [Domain.connect](/business/nouns/domain/connect) |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | [Domain.connect](/business/nouns/domain/connect) |
| The record changed since it was read, so the write would overwrite a newer version. | [`conflict`](/code/api/errors/conflict) | Read the record again, then retry the write against its current state. | [Domain.connect](/business/nouns/domain/connect) |
| A wildcard name for a Tenant, and past the Tenant’s name count follows its Entitlement’s `atBound` | [`refused`](/code/api/errors/refused) | Clear what the check names, then call it again. | [Domain.connect](/business/nouns/domain/connect) |

## When it waits
| Gate | Default |
| --- | --- |
| Decision class | Medium: two-way, visible |
| [Delay window](/systems/trust-and-governance/controls/one-way-windows) | 1 business hour, in which a watcher can pause, redirect or cancel it; then it runs. |
| Limit | The call [Limit](/business/nouns/limit) of the [Permission](/business/nouns/permission) it runs under. |
| Over the Limit | It waits `pending` for an [Approval](/business/nouns/approval) from the [Founder](/agents/founding/founder). Approved, it runs; refused, it ends `refused` with [`limit-exceeded`](/code/api/errors/limit-exceeded); unanswered by its deadline, it ends `canceled`. |

## Example

**Ask**

```text
Connect the domain “kilnbakery.com” with a startup.
```

**API**

```bash
curl -X POST https://api.sb/kilnbakery.com/domains/connect \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"hostname":"kilnbakery.com","startup":"startup_1"}'
```

```json
{
  "api": "https://api.sb/kilnbakery.com",
  "domain": {
    "$id": "https://api.sb/kilnbakery.com/domains/domain_1",
    "$type": "Domain",
    "hostname": "kilnbakery.com",
    "role": "canonical",
    "state": "verifying"
  },
  "action": {
    "$id": "https://api.sb/kilnbakery.com/actions/action_1",
    "operation": "Domain.connect",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/kilnbakery.com/actions/action_1"
  }
}
```

**SDK**

```ts
import { $ } from 'startup-builder'

const domain = await $.Domain.connect({ hostname: 'kilnbakery.com', startup: 'startup_1' })
```

**CLI**

```bash
npx startup-builder do Domain.connect --json '{"hostname":"kilnbakery.com","startup":"startup_1"}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.Domain.connect({ hostname: 'kilnbakery.com', startup: 'startup_1' })"
  }
}
```

Guides that call it: [Buy a domain](/products/site/domains/buy-a-domain), [Connect my domain](/products/site/domains/connect-my-domain).