***

title: serve
slug: /reference/python/agents/swml-service/serve
description: Start the FastAPI/Uvicorn web server for the SWML service.
max-toc-depth: 3
---------------------

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

[as-router]: /docs/server-sdks/reference/python/agents/swml-service/as-router

Start a FastAPI/Uvicorn web server that serves the SWML document over HTTP. This is a
blocking call that runs the server until it is stopped. The server responds to both GET
and POST requests at the configured route, returning the current SWML document as JSON.

On startup, the server prints the service URL and authentication credentials to the
console. If routing callbacks are registered, their endpoint URLs are also displayed.

<Warning>
  `serve()` blocks the current thread. For production deployments, consider using
  [`as_router()`][as-router] to integrate into an existing ASGI application instead.
</Warning>

## **Parameters**

<ParamField path="host" type="Optional[str]" default="None" toc={true}>
  Host to bind to. Overrides the value set in the constructor. When `None`, uses
  the constructor's `host` value.
</ParamField>

<ParamField path="port" type="Optional[int]" default="None" toc={true}>
  Port to bind to. Overrides the value set in the constructor. When `None`, uses
  the constructor's `port` value.
</ParamField>

<ParamField path="ssl_cert" type="Optional[str]" default="None" toc={true}>
  Path to an SSL certificate file. Overrides the `SWML_SSL_CERT_PATH` environment
  variable.
</ParamField>

<ParamField path="ssl_key" type="Optional[str]" default="None" toc={true}>
  Path to an SSL private key file. Overrides the `SWML_SSL_KEY_PATH` environment
  variable.
</ParamField>

<ParamField path="ssl_enabled" type="Optional[bool]" default="None" toc={true}>
  Explicitly enable or disable SSL. Overrides the `SWML_SSL_ENABLED` environment
  variable.
</ParamField>

<ParamField path="domain" type="Optional[str]" default="None" toc={true}>
  Domain name for the SSL certificate. Used for URL generation when SSL is enabled.
</ParamField>

## **Returns**

`None` — This method blocks until the server is stopped.

## **Example**

```python {8}
from signalwire import SWMLService

service = SWMLService(name="my-service", route="/swml")
service.add_verb("answer", {})
service.add_verb("play", {"url": "https://example.com/welcome.mp3"})

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

# Or override host and port
# service.serve(host="127.0.0.1", port=8080)
```