> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# serve

> Start the HTTP server (Python-compat alias for run).

[ref-run]: /docs/server-sdks/reference/typescript/agents/swml-service/run

[ref-asrouter]: /docs/server-sdks/reference/typescript/agents/swml-service/as-router

Start the HTTP server that serves the SWML document. This is a Python-compat
alias for [`run()`][ref-run] and forwards all
arguments unchanged. Use either name interchangeably -- pick `serve()` when
porting code from the Python SDK.

<Note>
  Returns immediately when `SWAIG_CLI_MODE=true` is set, so the CLI testing
  tool can load the service without opening a port.
</Note>

<Warning>
  `serve()` (and `run()`) start a `@hono/node-server` instance that runs until
  explicitly stopped. For embedding into an existing application, use
  [`asRouter()`][ref-asrouter] to get a mountable Hono sub-app instead.
</Warning>

## **Parameters**

<ParamField path="host" type="string" toc={true}>
  Hostname to bind to. Defaults to the `host` passed to the constructor, or
  `"0.0.0.0"`.
</ParamField>

<ParamField path="port" type="number" toc={true}>
  Port number to listen on. Defaults to the `port` passed to the constructor,
  which itself falls back to the `PORT` environment variable or `3000`.
</ParamField>

<ParamField path="opts" type="object" toc={true}>
  Optional SSL/TLS overrides. Each field falls back to the matching value on
  the service instance.
</ParamField>

<Indent>
  <ParamField path="opts.sslCert" type="string" toc={true}>
    Path to the SSL certificate file.
  </ParamField>

  <ParamField path="opts.sslKey" type="string" toc={true}>
    Path to the SSL private key file.
  </ParamField>

  <ParamField path="opts.sslEnabled" type="boolean" toc={true}>
    Override whether SSL/HTTPS is enabled for this run.
  </ParamField>

  <ParamField path="opts.domain" type="string" toc={true}>
    Domain name associated with the SSL certificate.
  </ParamField>
</Indent>

## **Returns**

`Promise<void>` -- resolves once the listener is bound.

## **Example**

```typescript {8}
import { SWMLService } from '@signalwire/sdk';

const service = new SWMLService({ name: 'my-service', route: '/swml' });
service.addVerb('answer', {});
service.addVerb('play', { url: 'https://example.com/welcome.mp3' });

// Start on default host/port (0.0.0.0:3000)
await service.serve();

// Or override host and port
// await service.serve('127.0.0.1', 8080);
```