# Error Handling | Signal House API Docs

> The HTTP status codes and machine-readable error codes the Signal House API returns, and how to handle each one.

Source: https://docs.signalhouse.io/error-handling

---

## Error Handling

## Common HTTP Status Codes

| Status | Meaning | Description |
| --- | --- | --- |
| `200` | OK | Request succeeded. |
| `201` | Created | Resource created successfully. |
| `400` | Bad Request | Invalid parameters or malformed request body. |
| `401` | Unauthorized | Missing, invalid, or expired token. |
| `403` | Forbidden | Valid token but not allowed: insufficient role, a key used from outside its allowed IPs or countries, or a send to a country the key is not allowed to reach (details.code DESTINATION\_COUNTRY\_NOT\_ALLOWED). A session ended by a password reset or a sign-out of other users is also refused with 403 and details.code SESSION\_REVOKED: sign in again for a new token. |
| `404` | Not Found | The requested resource does not exist. |
| `409` | Conflict | Resource already exists or conflicts with current state. |
| `422` | Unprocessable Entity | Request is well-formed but contains semantic errors. |
| `429` | Too Many Requests | Rate limit exceeded. Slow down and retry. A request from an OAuth connector or MCP server that breaches a connector cap carries details.code CONNECTOR\_CAP\_EXCEEDED (see Connector Caps below). |
| `500` | Internal Server Error | Unexpected server-side failure. Retry with backoff. |
| `503` | Service Unavailable | A dependency is unavailable. When an OAuth connector or MCP request's caps cannot be checked (the check fails closed), the response carries a Retry-After header and details.code CONNECTOR\_CAP\_UNAVAILABLE with details.retryAfterSeconds. |

## Connector Caps

OAuth connector tokens, and any request that carries the header `X-SignalHouse-Origin: mcp`, are held to fixed caps for each connection. The header can only restrict a request, never lift a limit. Other callers are not affected.

- **Recipients per call:** at most 10 on `POST /message/sms`, `/message/mms`, `/message/groupMessage`, `/message/rcs` and `/message/rcs/batch` (cap `recipients_per_call`).
- **Messages per hour:** 50 (cap `messages_per_hour`).
- **Spend per day:** $25 (cap `spend_per_day`). This is a worst-case estimate, reserved when the send is queued, not the amount finally charged.
- **New numbers per day:** 1 across `POST /number`, `POST /number/toll-free` and `POST /number/short-code` (cap `numbers_per_day`). Port-ins are not counted.
- **Destinations:** US and Canada only, written as 1 followed by the 10-digit number (e.g. `14175551234` or `+14175551234`). Any other recipient, a bare 10-digit number included, is refused with `403` and `details.code` `DESTINATION_COUNTRY_NOT_ALLOWED`.

Windows are fixed for each connection and start at the first counted request. Sends to a simulated number count toward the recipient and hourly caps but not the spend cap. A request over a cap is refused whole and uses none of the quota.

```
HTTP/1.1 429 Too Many Requests
Retry-After: 1800

{
  "error": "This connection has reached a usage limit. Please try again later.",
  "details": {
    "code": "CONNECTOR_CAP_EXCEEDED",
    "cap": "messages_per_hour",
    "limit": 50,
    "retryAfterSeconds": 1800
  }
}
```

A request over the recipient cap, or one that alone asks for more than a cap's whole limit (for example 2 numbers in one purchase), has`retryAfterSeconds` 0 and no `Retry-After` header, because waiting will not help: send a smaller request. When the caps cannot be checked (for example the cap store cannot be reached), the request is refused with `503`, and nothing is sent. The delay is in both the `Retry-After` header and `details.retryAfterSeconds`:

```
HTTP/1.1 503 Service Unavailable
Retry-After: 60

{
  "error": "This is temporarily unavailable. Please try again shortly.",
  "details": {
    "code": "CONNECTOR_CAP_UNAVAILABLE",
    "retryAfterSeconds": 60
  }
}
```

## Compliance-Rejected Accounts

While a group's compliance status is `rejected`, most mutating requests (sending messages, creating or modifying campaigns, purchasing or managing phone numbers, managing API keys) return `403` with a machine-readable code in the response body's `details` field:

```json
{
  "error": "This action is unavailable while your account is under compliance review. Contact support to resolve it.",
  "details": { "code": "GROUP_REJECTED" }
}
```

Billing and account-management routes are not affected — they remain reachable so the account can be resolved. Check `details.code === "GROUP_REJECTED"` to distinguish this from a generic `403` (e.g. insufficient role) rather than parsing the message text, which may change.

## Unverified Accounts

Submitting an RCS agent (`POST /rcs/agent/:agentId/submit`) and requesting its launch (`POST /registration/:registrationId/launch`) wait on account verification, as a 10DLC campaign's filing does. While the group's compliance status is `unverified`, they return `403` with this code; a `rejected`group gets `GROUP_REJECTED`, and a `pending` verification passes:

```json
{
  "error": "Finish account verification before you submit or launch an agent.",
  "details": { "code": "GROUP_UNVERIFIED" }
}
```

## Destination Country Restrictions

An API key created or updated with `allowedDestinationCountries` can only send to those countries. If any recipient of an SMS, MMS, group message or P2P request is in another country, the whole request is rejected with `403` and nothing is queued or charged:

```json
{
  "error": "This API key can't send to GB. Update the key's destination countries in the portal.",
  "details": {
    "code": "DESTINATION_COUNTRY_NOT_ALLOWED",
    "countries": ["GB"],
    "recipients": ["447400123456"]
  }
}
```

`countries` lists each blocked country (`unknown` when a number's country cannot be determined), and `recipients` shows up to 20 of the numbers that were blocked. Requests made from a portal login are not restricted.

## Signal House Message Error Codes

Carrier failures carry a numeric code inside `successOrFailureReason` (see the table below). Failures Signal House decides itself are stamped on the message's `errorCode` field, are included on the FAILED status callback, are filterable with `GET /message?errorCode=`, and appear in the error-code breakdown under the category shown here.

A message sent from a toll-free number on some carriers, whether the carrier refused it or failed to deliver it, carries that carrier's own code instead, as `Carrier error <code>: <reason>`, or `Carrier error <code>` when the code has no description. Those codes are not in the table below.

| errorCode | Name | Description | Billed |
| --- | --- | --- | --- |
| `OUT` | `RECIPIENT_OPTED_OUT` | Recipient has opted out of messages from this campaign. They must reply START to opt back in. The send returns 2xx; the record is FAILED with no provider submit. See [Opt-Out Enforcement](https://docs.signalhouse.io/opt-out). | No |

## Simulated Delivery Errors

Signal House provides a set of reserved test phone numbers that simulate specific delivery error responses. Send a message to any phone number listed below to receive the corresponding error in the delivery status webhook. These numbers never reach a real handset.

### RCS

The numbers above work on `POST /message/rcs` as they do on SMS. If any recipient is one, the API answers the whole request at once with `{ simulated: true, webhooks }`: one `MESSAGE_FAILED` body for each such recipient, with the agent as the sender. Nothing is stored, sent or charged, and the agent does not need to be launched.

To simulate an outcome on a real handset, send `POST /message/rcs` to an approved tester of the agent with `simulate` set to a value below. The RCS leg never reaches a carrier, and the message is marked `isTest`. To simulate a reply or a tap, use `POST /message/rcs/simulate-inbound`.

| simulate | Outcome | Events |
| --- | --- | --- |
| `delivered` | The message is delivered over RCS. | MESSAGE\_DELIVERED |
| `read` | The message is delivered over RCS and read. | MESSAGE\_READ |
| `not_capable` | The handset cannot take RCS. The fallback runs with reason NOT\_CAPABLE. The fallback leg is a real, billed SMS or MMS; with no fallback the message fails. | MESSAGE\_FALLBACK\_TRIGGERED, MESSAGE\_FALLBACK\_SENT |
| `ttl_expired` | The message expires undelivered. The fallback runs with reason TTL\_EXPIRED. The fallback leg is a real, billed SMS or MMS; with no fallback the message expires. | MESSAGE\_FALLBACK\_TRIGGERED, MESSAGE\_FALLBACK\_SENT |

## SDK Error Behavior

The SDK intercepts all HTTP responses and wraps them in the standardized format. It **never throws exceptions on HTTP errors**. The **only exception** is validation errors, thrown before any HTTP request is made.

JavaScript

```
const response = await signalHouse.messages.sendSMS({
  senderPhoneNumber: "15551230000",
  recipientPhoneNumbers: ["15559990000"],
  messageBody: "Hello",
});
if (!response.success) {
  console.error(`Error ${response.status}: ${response.error}`);
}
```

Python

```
response = sdk.messages.send_sms(
    sender_phone_number="15551230000",
    recipient_phone_numbers=["15559990000"],
    message_body="Hello",
)
if not response["success"]:
    print(f"Error {response['status']}: {response['error']}")
```

GoLang

```
response, err := client.Messages.SendSMS(ctx, signalhouse.SendSMSParams{
    SenderPhoneNumber:     "15551230000",
    RecipientPhoneNumbers: []string{"15559990000"},
    MessageBody:           "Hello",
}, nil)
if err != nil { log.Fatal(err) }
if !response.Success {
    log.Printf("Error %d: %s", response.Status, response.Error)
}
```

PHP

```
$response = $sdk->messages->sendSMS('15551230000', ['15559990000'], 'Hello');
if (!$response['success']) {
    echo "Error {$response['status']}: {$response['error']}";
}
```

.NET

```
var response = await client.Messages.SendSmsAsync(
    "15551230000",
    new[] { "15559990000" },
    "Hello",
    null,
    false,
    false
);
if (!response.Success)
    Console.Error.WriteLine($"Error {response.Status}: {response.Error}");
```

Ruby

```
response = client.messages.send_sms(
  sender_phone_number: "15551230000",
  recipient_phone_numbers: ["15559990000"],
  message_body: "Hello"
)
unless response["success"]
  puts "Error #{response['status']}: #{response['error']}"
end
```

Rust

```
let response = client.messages.send_sms("15551230000", &json!(["15559990000"]), "Hello", None, false, None).await?;
if !response.success {
    eprintln!("Error {}: {}", response.status, response.error.as_deref().unwrap_or("unknown"));
}
```

## Validation Errors

The SDK validates required parameters before sending a request. If a required parameter is missing, it throws a validation error immediately. This is the **only case** where you need a try/catch block.

JavaScript

```
try {
  const response = await signalHouse.messages.sendSMS({});
} catch (err) {
  if (err.name === "SignalHouseValidationError") {
    console.error("Validation error:", err.message);
  }
}
```

Python

```
from signalhouse_sms import SignalHouseValidationError

try:
    response = sdk.messages.send_sms(
        sender_phone_number="",
        recipient_phone_numbers=[],
        message_body="",
    )
except SignalHouseValidationError as err:
    print(f"Validation error: {err}")
```

GoLang

```
resp, err := client.Messages.SendSMS(ctx, signalhouse.SendSMSParams{}, nil)
if err != nil {
    if vErr, ok := err.(*signalhouse.ValidationError); ok {
        log.Printf("Validation error: %s", vErr.Error())
    }
}
```

PHP

```
use SignalHouse\SDK\Exceptions\ValidationException;

try {
    $response = $sdk->messages->sendSMS('', [], '');
} catch (ValidationException $e) {
    echo "Validation error: " . $e->getMessage();
}
```

.NET

```
using SignalHouse.SDK.Exceptions;

try {
    var response = await client.Messages.SendSmsAsync(null, new string[0], "", null, false, false);
} catch (ValidationException ex) {
    Console.Error.WriteLine($"Validation error: {ex.Message}");
}
```

Ruby

```
begin
  response = client.messages.send_sms(
    sender_phone_number: nil,
    recipient_phone_numbers: nil,
    message_body: nil
  )
rescue SignalHouseSms::ValidationError => e
  puts "Validation error: #{e.message}"
end
```

Rust

```
use signalhouse_sms::SignalHouseError;

match client.messages.send_sms("", &json!([]), "", None, false, None).await {
    Err(SignalHouseError::Validation(msg)) => {
        eprintln!("Validation error: {}", msg);
    }
    _ => {}
}
```

## Retry on 429 and 500

Transient errors (rate limits and server errors) can often be resolved by retrying with exponential backoff.

JavaScript

```
async function withRetry(fn, { maxRetries = 3, baseDelay = 1000 } = {}) {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    const response = await fn();
    if (response.success) return response;
    const isRetryable = response.status === 429 || response.status >= 500;
    if (!isRetryable || attempt === maxRetries) return response;
    const delay = baseDelay * Math.pow(2, attempt);
    await new Promise(r => setTimeout(r, delay * (0.5 + Math.random() * 0.5)));
  }
}
```

Python

```
import time, random

def with_retry(fn, max_retries=3, base_delay=1.0):
    for attempt in range(max_retries + 1):
        response = fn()
        if response["success"]: return response
        if response["status"] not in (429, 500, 502, 503): return response
        if attempt == max_retries: return response
        delay = base_delay * (2 ** attempt) * (0.5 + random.random() * 0.5)
        time.sleep(delay)
```

GoLang

```
func withRetry(fn func() (*Response, error), maxRetries int) (*Response, error) {
    for attempt := 0; attempt <= maxRetries; attempt++ {
        resp, err := fn()
        if err != nil { return nil, err }
        if resp.Success { return resp, nil }
        if resp.Status != 429 && resp.Status < 500 { return resp, nil }
        if attempt == maxRetries { return resp, nil }
        time.Sleep(time.Duration(math.Pow(2, float64(attempt))) * time.Second)
    }
    return nil, nil
}
```

PHP

```
function withRetry(callable $fn, int $maxRetries = 3, float $baseDelay = 1.0) {
    for ($attempt = 0; $attempt <= $maxRetries; $attempt++) {
        $response = $fn();
        if ($response['success']) return $response;
        if (!in_array($response['status'], [429, 500, 502, 503])) return $response;
        if ($attempt === $maxRetries) return $response;
        usleep((int)($baseDelay * pow(2, $attempt) * 1_000_000));
    }
}
```

.NET

```
async Task<Response> WithRetry(Func<Task<Response>> fn, int maxRetries = 3) {
    for (int attempt = 0; attempt <= maxRetries; attempt++) {
        var response = await fn();
        if (response.Success) return response;
        if (response.Status != 429 && response.Status < 500) return response;
        if (attempt == maxRetries) return response;
        await Task.Delay((int)(Math.Pow(2, attempt) * 1000));
    }
    return null;
}
```

Ruby

```
def with_retry(max_retries: 3, base_delay: 1.0, &block)
  (0..max_retries).each do |attempt|
    response = block.call
    return response if response["success"]
    return response unless [429, 500, 502, 503].include?(response["status"])
    return response if attempt == max_retries
    sleep(base_delay * (2 ** attempt))
  end
end
```

Rust

```
async fn with_retry<F, Fut>(f: F, max_retries: u32) -> Result<Response>
where F: Fn() -> Fut, Fut: Future<Output = Result<Response>> {
    for attempt in 0..=max_retries {
        let resp = f().await?;
        if resp.success { return Ok(resp); }
        if resp.status != 429 && resp.status < 500 { return Ok(resp); }
        if attempt == max_retries { return Ok(resp); }
        tokio::time::sleep(Duration::from_secs(2u64.pow(attempt))).await;
    }
    unreachable!()
}
```

## Standardized Response Format

Every response from the Signal House API SDKs follow a consistent envelope format, regardless of whether the request succeeded or failed.

**Success (2xx):**

Success

```json
{
  "success": true,
  "data": { "id": "msg_abc123", "status": "queued" },
  "status": 200
}
```

**Error (4xx/5xx):**

Failure

```json
{
  "success": false,
  "error": "Invalid phone number format",
  "status": 400
}
```
