Create an emergency address through REST, look up the phone number, and attach that address to it.
e911numberscompliance
The claim
POST /api/relay/rest/addresses creates the address. The vendored REST spec requires label, country, first_name, last_name, street_number, street_name, city, state and postal_code. It takes emergency_enabled, auto_correct_address, address_type and address_number as options. POST /api/relay/rest/phone_numbers/{id}/e911_address with e911_address_id attaches the address to a number.
Why it holds
The SDK wraps the first call as client.addresses.create. Its addresses namespace, signalwire/rest/namespaces/addresses.py, has no method for the attach path in 3.0.1. The recipe sends that request through the HttpClient that RestClient builds once and hands to every namespace (signalwire/rest/client.py:74-85).
How it works
def number_id(e164):
for item in client.phone_numbers.list().get("data", []):
if item.get("number") == e164:
return item["id"]
def attach(phone_number_id, address_id):
return client.addresses._http.post(
f"/api/relay/rest/phone_numbers/{phone_number_id}/e911_address",
body={"e911_address_id": address_id})
def register(e164, **address):
created = create_address(**address) # the nine required fields, emergency_enabled on
return attach(number_id(e164), created["id"])
The spec lists address_type as an enum: Apartment, Basement, Building, Department, Floor, Office, Penthouse, Suite, Trailer or Unit. The number id is the id of the phone number resource, not the number itself. number_id reads it from GET /api/relay/rest/phone_numbers with the spec’s filter_number query, so a project with hundreds of numbers still answers on the first page.
Limitations
The verifier proves the requests. Address validation, and whether the platform accepts the address as an emergency location, happen on the live call to the API.
There is no SDK method for the attach call in 3.0.1, so the recipe reaches for the shared HTTP client. A later SDK may add a wrapper.
This recipe was written for US addresses and US numbers and enforces neither. country defaults to US, the only value it was verified with; check the spec’s emergency_enabled behaviour before trying another.
What to change first
Drop postal_code from the create body and run the verifier. The required-list assertion fails, which is the point: the spec, not this recipe, decides what an emergency address must carry.