***

title: REST Client
sidebar-title: Overview
subtitle: Python API reference for RestClient and resource namespaces
slug: /reference/python/rest
description: HTTP client for SignalWire REST API resource management.
max-toc-depth: 3
position: 0
---------------------

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

[client]: /docs/server-sdks/reference/python/rest/client

[phone-numbers]: /docs/server-sdks/reference/python/rest/phone-numbers

[fabric]: /docs/server-sdks/reference/python/rest/fabric

[calling]: /docs/server-sdks/reference/python/rest/calling

[video]: /docs/server-sdks/reference/python/rest/video

[datasphere]: /docs/server-sdks/reference/python/rest/datasphere

[logs]: /docs/server-sdks/reference/python/rest/logs

[registry]: /docs/server-sdks/reference/python/rest/registry

[compat]: /docs/server-sdks/reference/python/rest/compat

[mfa]: /docs/server-sdks/reference/python/rest/mfa

The REST namespace provides a synchronous HTTP client for the SignalWire platform
APIs. It organizes every HTTP endpoint into namespaced resource objects with
standard CRUD operations, letting you manage phone numbers, fabric resources,
call logs, video rooms, datasphere documents, and more from Python.

## Example

Search for available phone numbers, purchase one, and assign it to a fabric
AI agent resource:

```python
from signalwire.rest import RestClient, SignalWireRestError

client = RestClient(
    project="your-project-id",
    token="your-api-token",
    host="your-space.signalwire.com",
)

# Search for available numbers in area code 512
available = client.phone_numbers.search(area_code="512", quantity=3)
for number in available.get("data", []):
    print(f"{number['number']} - {number.get('region')}")

# Purchase the first available number
purchased = client.phone_numbers.create(number=available["data"][0]["number"])
print(f"Purchased: {purchased['number']}")

# List your AI agent resources
response = client.fabric.ai_agents.list()
for agent in response.get("data", []):
    print(f"Agent: {agent['name']} ({agent['id']})")

# Query recent voice call logs
logs = client.logs.voice.list(page_size=5)
for log in logs.get("data", []):
    print(f"Call from {log.get('from')} to {log.get('to')}")
```

<Note>
  All three constructor arguments can also be provided via environment variables:
  `SIGNALWIRE_PROJECT_ID`, `SIGNALWIRE_API_TOKEN`, and `SIGNALWIRE_SPACE`.
  When those are set, you can instantiate with `RestClient()` and no arguments.
</Note>

## Error Handling

REST errors raise `SignalWireRestError`:

```python
from signalwire.rest import RestClient, SignalWireRestError

client = RestClient()

try:
    client.phone_numbers.get("nonexistent-id")
except SignalWireRestError as e:
    print(f"HTTP {e.status_code}: {e.body}")
    print(f"URL: {e.method} {e.url}")
```

## Resources

<CardGroup cols={2}>
  <Card title="RestClient" href="/docs/server-sdks/reference/python/rest/client">
    Constructor, authentication, and all namespace properties.
  </Card>

  <Card title="Phone Numbers" href="/docs/server-sdks/reference/python/rest/phone-numbers">
    Search, purchase, and manage phone numbers.
  </Card>

  <Card title="Fabric" href="/docs/server-sdks/reference/python/rest/fabric">
    AI agents, SWML scripts, [subscribers](/docs/platform/subscribers), call flows, and tokens.
  </Card>

  <Card title="Calling" href="/docs/server-sdks/reference/python/rest/calling">
    REST-based call control with 37+ commands.
  </Card>

  <Card title="Video" href="/docs/server-sdks/reference/python/rest/video">
    Rooms, conferences, sessions, recordings, and streams.
  </Card>

  <Card title="Datasphere" href="/docs/server-sdks/reference/python/rest/datasphere">
    Document management and semantic search.
  </Card>

  <Card title="Logs" href="/docs/server-sdks/reference/python/rest/logs">
    Message, voice, fax, and conference log queries.
  </Card>

  <Card title="Registry" href="/docs/server-sdks/reference/python/rest/registry">
    10DLC brand and campaign registration.
  </Card>

  <Card title="Compatibility" href="/docs/server-sdks/reference/python/rest/compat">
    Twilio-compatible LAML API for migration.
  </Card>

  <Card title="MFA" href="/docs/server-sdks/reference/python/rest/mfa">
    Multi-factor authentication via SMS and voice.
  </Card>
</CardGroup>