***

title: SignalWireRestError
slug: /reference/python/rest/rest-error
description: Error raised when the REST API returns a non-success response.
max-toc-depth: 3
---------------------

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

Custom exception class for REST API errors. Extends Python's built-in `Exception`
class. Raised when an HTTP request to the SignalWire REST API returns a non-success
status code.

```python {1}
from signalwire.rest import SignalWireRestError
```

## **Properties**

<ParamField path="status_code" type="int" toc={true}>
  HTTP status code returned by the API (e.g., `404`, `422`, `500`).
</ParamField>

<ParamField path="body" type="str | dict" toc={true}>
  Response body from the API (JSON dict if parseable, otherwise raw string).
</ParamField>

<ParamField path="url" type="str" toc={true}>
  The URL path that was requested.
</ParamField>

<ParamField path="method" type="str" toc={true}>
  The HTTP method used (`"GET"`, `"POST"`, `"PUT"`, `"PATCH"`, `"DELETE"`).
</ParamField>

## **Example**

```python {9}
from signalwire.rest import RestClient, SignalWireRestError

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

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