AI Voice Address Capture: Resolve Recorded Addresses with Swiftcomplete
Updated
On this page
1Step 1: Overview#
Use Swiftcomplete’s recorded address API to resolve a spoken postal address from a voicemail, recorded call or voice message.
Send a recording containing one spoken address in a single HTTPS POST. If the API identifies an address, the response field contains the validated postal address in single-line and multiline formats. The API returns postcode-level coordinates by default, or property-level coordinates if you request them and they’re available. If the API can’t identify the address confidently, it returns a result with type set to not_resolved.
For live calls, use the streaming API to send audio and receive transcripts as the caller speaks. Both APIs use the same format for the final result.
2Step 2: How it works#
- Your server sends one recording, holding one spoken address, in a single HTTPS
POST. - We transcribe the recording and identify the address.
- The response holds exactly one result: the validated address,
not_resolvedor an error.
There’s no job to poll and no callback: the result is in the response. The response holds only the result, with no transcripts. To resolve another address, send another request.
3Step 3: Authentication#
All requests require an API key passed in the x-api-key header.
Keep your key on your server. Always send recordings from your backend, never from a web page or mobile app, where your key could be read. If you record the caller in a browser or app, upload the recording through your server.
4Step 4: Prepare your recording#
Send a WAV file, or raw audio with its format in the query string (step 5). Send the audio at its original sample rate. There’s no need to resample it.
| Audio | encoding | sampleRateHz | Typical source |
|---|---|---|---|
| 16-bit PCM | pcm_s16le | 48000 | Browser and app microphones |
| 16-bit PCM | pcm_s16le | 16000 | Wideband (HD) voice and many voice AI platforms |
| 16-bit PCM | pcm_s16le | 8000 | Telephone audio decoded to 16-bit PCM |
| G.711 μ-law | mulaw | 8000 | Telephone recordings, common in North America and Japan |
| G.711 A-law | alaw | 8000 | Telephone recordings, common in Europe |
The audio must be mono. pcm_s16le is signed 16-bit little-endian PCM. mulaw and alaw are G.711, one byte per sample.
- WAV files declare their own format, so there’s nothing else to send. Standard and extensible WAV files both work.
- Raw audio has no header, so you must tell us its format with
encodingandsampleRateHz(step 5). Without them, the request ends withprotocol_error. - Compressed formats, such as MP3, M4A, Ogg or Opus, aren’t accepted. Convert them first.
Each recording can hold up to 60 seconds of audio. It works best when it holds just the caller saying their address.
To convert a recording, you can use FFmpeg:
ffmpeg -i input.m4a -ac 1 -ar 16000 -c:a pcm_s16le address.wavIf your call recordings are stereo, with the caller on one channel, send only the caller’s channel. For example, -af "pan=mono|c0=c1" in place of -ac 1 keeps the right-hand channel.
5Step 5: Send the recording#
Send the recording as the body of a POST to:
https://voice.swiftcomplete.com/v1/address/recording| Header | Required | Description |
|---|---|---|
| x-api-key | Yes | Your Swiftcomplete API key. |
| Content-Type | No | audio/wav for a WAV file. A body that starts with a WAV header is read as a WAV file whatever its Content-Type. |
| Idempotency-Key | No | Identifies this address across retries, for example a UUID: 1 to 128 printable ASCII characters, without spaces. See Retries in step 7. |
For example, with curl:
curl https://voice.swiftcomplete.com/v1/address/recording \
-H "x-api-key: $SWIFTCOMPLETE_API_KEY" \
-H "Content-Type: audio/wav" \
-H "Idempotency-Key: $(uuidgen)" \
--data-binary @address.wavFor raw audio, add its format to the query string:
curl "https://voice.swiftcomplete.com/v1/address/recording?encoding=mulaw&sampleRateHz=8000" \
-H "x-api-key: $SWIFTCOMPLETE_API_KEY" \
-H "Content-Type: application/octet-stream" \
--data-binary @address.ulaw| Query parameter | Required | Description |
|---|---|---|
| encoding | For raw audio | pcm_s16le, mulaw or alaw, as in step 4. |
| sampleRateHz | For raw audio | 8000, 16000 or 48000, as in step 4. |
| channels | No | 1, the default. |
| coordinateResolution | No | postcode, the default, or premise for coordinates at the property, for any recording. Any other value is refused with 400 and protocol_error. See Coordinates in step 6. |
| clipToCountry | No | Return only addresses in these countries: comma-separated codes, GB, GG, IM or JE. See Limit the area below. |
| clipToCircle | No | Return only addresses within a circle: lat,lng,km, for example 51.520847,-0.195521,1. |
| clipToBoundingBox | No | Return only addresses within a box: south_lat,west_lng,north_lat,east_lng. |
| clipToPolygon | No | Return only addresses within a polygon: 4 to 25 lat,lng pairs, the last the same as the first. |
| language | No | The language the caller speaks: en-GB, the default, or en for the same. |
| mode | No | The level of confidence required to return an address: strict, flexible (the default) or top_rank. See Choose a mode below. |
For a WAV file, we ignore the query string’s format and read the file’s own. We ignore parameters we don’t recognise, so a client that sends extra ones keeps working.
The whole recording must arrive within 30 seconds. We recommend a client timeout of 60 seconds after your upload completes.
Limit the area
If you know where the address should be, for example within your delivery area, you can limit the addresses we return with the same clip options as the what3words AutoSuggest API, in the query string. Commas may be sent as they are or as %2C:
curl "https://voice.swiftcomplete.com/v1/address/recording?clipToCountry=GB&clipToCircle=51.520847,-0.195521,20" \
-H "x-api-key: $SWIFTCOMPLETE_API_KEY" \
-H "Content-Type: audio/wav" \
--data-binary @address.wavInside means the postcode. An address is inside an area when its postcode’s location is, so an address near the edge may fall on either side of it.
Countries are alternatives, options must all hold.
GB,JEreturns addresses in either country. WithclipToCountryandclipToCircle, an address must be in one of the countries and inside the circle.GB is the United Kingdom without the Crown Dependencies. For Jersey, Guernsey or the Isle of Man, add JE, GG or IM. Use GB, not UK, and GG, not GY. Without
clipToCountry, all four are included.We return only addresses inside the area, in every mode. We choose the best match among the addresses inside it. If none of them can be returned under your mode and the address we identify is outside it, you receive
not_resolvedwith the reasonoutside_clip(step 6).Each option can be given once. An option that can’t be read, a country we don’t cover, or an option given twice is refused with 400 and
invalid_parameterbefore any work is done (step 6).
language is the language the caller speaks. We currently support English as spoken in the UK, en-GB, which is the default; en means the same. It doesn’t change the address returned or its format.
Choose a mode
mode determines the level of confidence required to return an address. The result looks the same in every mode, and every address returned is charged once.
| mode | An address is returned when it is |
|---|---|
| strict (most strict) | identified with confidence and the speaker included a locality or postcode that is confidently matched to the rest of the address. |
| flexible (default - medium strictness) | identified with confidence, without requiring the strong confidence level for the locality or postcode that is required in strict mode. |
| top_rank (least strict) | the top ranked address that matches what was heard. The best match is returned even when confidence isn’t high; it is still possible to have no result returned (although in almost all cases a result is expected to be returned). |
Any other value, or
modegiven twice, is refused with 400 andinvalid_parameterbefore any work is done (step 6).Note:
top_rankmay be helpful when using a narrow clipping area and it is desirable to return results based on partial addresses. For example, in the use case of a local taxi service in a village (which doesn’t contain duplicate street names), a speaker may omit locality and postcode from the address in the belief that they are not required. For any cases for which clipping is not applied or is only applied at country level, flexible or strict modes are strongly recommended.
6Step 6: Handle the response#
Refused before processing
If we can’t accept the request, you receive an HTTP status without a result:
| Status | Meaning | What to do |
|---|---|---|
| 401 | The key is missing or malformed, or Swiftcomplete doesn't recognise it. | Check that the key is copied exactly and sent in x-api-key. |
| 403 | Swiftcomplete recognises the key but won't accept it, for example because its free trial has ended or it is restricted to URLs or IP addresses. | Read the description, then check your account or use an unrestricted key. |
| 429 | The key already has four requests or streaming connections open, or the service has too many requests waiting to start. | Retry after the number of seconds in Retry-After. |
| 503 | The service is temporarily unavailable. | Retry with backoff. |
A 401 or 403 for a key in the right format comes with a JSON body from Swiftcomplete that explains why, the same as the Validate API’s:
{
"parameter": "key",
"description": "Your credits have expired. Please sign in to your account and purchase credits to continue using the service.",
"resolutionExamples": []
}Show or log the description. Its wording comes from Swiftcomplete and may change, so don’t match on it. A missing or malformed key gets a 401 with no body.
Otherwise, the response body is one of the three results below, as JSON. Read its type, and use the HTTP status only to tell success from failure.
validation_completed: an address was found
HTTP 200:
{
"type": "validation_completed",
"turnId": "9fb7c1e2-4d0a-4c55-a0f3-2b8e6d1f7a90",
"appliedOptions": { "clipToCountry": "GB,GG,IM,JE", "language": "en-GB", "mode": "flexible" },
"response": {
"validation": { "result": "match", "resolution": "premise" },
"address": {
"singleLine": "65 Alfred Road, London, W2 5EU, United Kingdom",
"multiLine": {
"line1": "65 Alfred Road",
"primaryLocality": "London",
"postalCode": "W2 5EU"
}
},
"associatedRecords": null
}
}response is exactly what the Swiftcomplete Validate API returns for this address, so you can handle it with the same code.
validation.resultismatch,suggestionornone.validation.resolutionis the level the address was matched to, for examplepremiseorstreet.addressholds the formatted address, both on a single line and split into lines.
turnId identifies this request. Include it if you contact support.
appliedOptions lists the clip, language and mode options the request used, including the defaults, so you can confirm they were applied.
Coordinates
By default, coordinates are returned at postcode level. To request property-level coordinates, set the coordinateResolution query parameter to premise. If property-level coordinates are unavailable, postcode coordinates are returned instead. See the Validate API documentation for the response format.
Each address is charged once, based on the coordinates returned. Premise coordinates are charged at the premise price; postcode coordinates, including when premise coordinates were requested but unavailable, are charged at the standard price.
what3words addresses
A caller can end their address with a what3words address, for example “65 Alfred Road, London, filled count soap”. When they do, it’s returned with the address, exactly as the Validate API returns one: in address.multiLine.what3words and at the end of address.singleLine.
{
"type": "validation_completed",
"turnId": "9fb7c1e2-4d0a-4c55-a0f3-2b8e6d1f7a90",
"appliedOptions": { "clipToCountry": "GB,GG,IM,JE", "language": "en-GB", "mode": "flexible" },
"response": {
"validation": { "result": "match", "resolution": "premise" },
"address": {
"singleLine": "65 Alfred Road, London, W2 5EU, United Kingdom, ///filled.count.soap",
"multiLine": {
"line1": "65 Alfred Road",
"primaryLocality": "London",
"postalCode": "W2 5EU",
"what3words": "///filled.count.soap"
}
},
"associatedRecords": null
}
}If the caller doesn’t give one, address.multiLine.what3words is null.
not_resolved: no address could be identified
HTTP 200:
{"type":"not_resolved","turnId":"9fb7c1e2-4d0a-4c55-a0f3-2b8e6d1f7a90"}We couldn’t identify an address that your mode returns (see Choose a mode in step 5), so we don’t return a guess. With top_rank, this means we found no address at all. Ask the caller again if you can, for example asking them to say the postcode clearly.
If you limited the area and we could only identify an address outside it, the result says so, with HTTP 200, and isn’t charged:
{"type":"not_resolved","turnId":"9fb7c1e2-4d0a-4c55-a0f3-2b8e6d1f7a90","reason":"outside_clip","appliedOptions":{"clipToCountry":"GB,GG,IM,JE","clipToCircle":"51.520847,-0.195521,20","language":"en-GB","mode":"flexible"}}error: the request failed
{"type":"error","turnId":"9fb7c1e2-4d0a-4c55-a0f3-2b8e6d1f7a90","code":"service_busy","retryAfterMs":1000}| HTTP | code | Meaning | What to do |
|---|---|---|---|
| 400 | invalid_audio | The recording isn't in a supported format (step 4) or holds no audio, or the Content-Type says WAV but the body isn't a WAV file. | Check your recording against step 4. |
| 400 | protocol_error | The request couldn't be read, for example raw audio without encoding and sampleRateHz, an invalid Idempotency-Key or query parameter, or an upload that took more than 30 seconds. | Fix your request. |
| 400 | invalid_parameter | A clip, language or mode option couldn't be read or isn't supported, or was given twice. parameter names it and message says why. No work was done. | Fix the option. |
| 403 | api_key_rejected | Swiftcomplete stopped accepting your key during the request, for example because your credits ran out or your free trial ended. The address isn't returned. | Read the description and check your account. Retrying won't help until it's fixed. |
| 413 | utterance_limit_exceeded | The recording holds more than 60 seconds of audio, or the request is too large. | Send only the address. |
| 422 | no_speech | We heard no speech. | Ask the caller to say their address again. |
| 429 | service_busy | The service is at capacity, or a request with the same Idempotency-Key is still in progress. This request was not processed. | Retry after retryAfterMs milliseconds. The Retry-After header gives the same wait in seconds. |
| 503 or 500 | service_unavailable | A temporary failure on our side. | Retry once (see below). If it keeps happening, contact us with the turnId and errorRef. |
An api_key_rejected error also has a description from Swiftcomplete, for example:
{"type":"error","turnId":"9fb7c1e2-4d0a-4c55-a0f3-2b8e6d1f7a90","code":"api_key_rejected","description":"Your free trial has expired. Please sign in to your account and purchase credits to continue using the service."}An invalid_parameter error names the option and says what’s wrong, for example:
{"type":"error","turnId":"9fb7c1e2-4d0a-4c55-a0f3-2b8e6d1f7a90","code":"invalid_parameter","parameter":"clipToPolygon","message":"clipToPolygon must be closed: repeat the first lat,lng pair as the last"}A service_unavailable error also has an errorRef, such as "errorRef":"E954", which helps our support team find the cause. New values may be added, so don’t write code that depends on particular ones.
7Step 7: Retries#
If a network failure or timeout prevents you from receiving a result, retry with the same recording and Idempotency-Key.
For 120 seconds after a result, the same key returns the original result and turnId without reprocessing the audio. Keys for requests that end in an error aren’t retained, so retries are processed again. Retries while the original request is still processing return service_busy.
Use a new key for each recording. Within the 120-second window, reusing a key returns the original result, even if the audio or valid query parameters have changed.
8Step 8: Limits#
| Limit | Value |
|---|---|
| Addresses per request | 1 |
| Audio per recording | 60 seconds |
| Request size | 5.8 MB, enough for 60 seconds of 48 kHz audio |
| Time to upload the recording | 30 seconds |
| Simultaneous requests per key | 4, shared with streaming connections. Contact us if you need more. |
9Step 9: Coverage#
The API resolves postal addresses in the United Kingdom (GB), Guernsey (GG), the Isle of Man (IM) and Jersey (JE), spoken in English, one address per recording. To check what's supported from your code, send a GET with your key in the x-api-key header to:
https://voice.swiftcomplete.com/v1/address/available-countrieshttps://voice.swiftcomplete.com/v1/address/available-languages
{"countries":[{"code":"GB","languages":["en-GB"],"name":"United Kingdom"},{"code":"GG","languages":["en-GB"],"name":"Guernsey"},{"code":"IM","languages":["en-GB"],"name":"Isle of Man"},{"code":"JE","languages":["en-GB"],"name":"Jersey"}]}
{"languages":[{"code":"en-GB","name":"English (UK)","nativeName":"English (UK)"}]}These requests aren't charged.
10Step 10: Example code#
Both examples send a WAV file, retry with the same Idempotency-Key after a network failure or a 429, and print the result.
Python
"""Resolve a recorded UK address with Swiftcomplete.
Usage:
pip install requests
export SWIFTCOMPLETE_API_KEY=your-key
python resolve_recording.py address.wav
"""
import os
import sys
import time
import uuid
import requests
URL = "https://voice.swiftcomplete.com/v1/address/recording"
ATTEMPTS = 3
TIMEOUT_S = (10, 90) # To connect, then for the upload and the result.
def post(audio, idempotency_key):
return requests.post(
URL,
data=audio,
headers={
"x-api-key": os.environ["SWIFTCOMPLETE_API_KEY"],
"Content-Type": "audio/wav",
"Idempotency-Key": idempotency_key,
},
timeout=TIMEOUT_S,
)
def describe(response):
try:
body = response.json()
except ValueError:
body = {}
if body.get("type") == "validation_completed":
result = body["response"]
address = (result.get("address") or {}).get("singleLine")
return f"{result['validation']['result']}: {address}"
if body.get("type") == "not_resolved":
return "No address identified; ask the caller again"
if body.get("type") == "error":
detail = ""
if "retryAfterMs" in body:
detail += f", retry after {body['retryAfterMs']} ms"
if "errorRef" in body:
detail += f", ref {body['errorRef']}"
if "description" in body:
detail += f": {body['description']}"
return f"Error: {body['code']}{detail} (turn {body['turnId']})"
# Refused before processing, with Swiftcomplete's description when it gave one.
description = body.get("description")
return f"Refused: HTTP {response.status_code}" + (f": {description}" if description else "")
def main():
with open(sys.argv[1], "rb") as file:
audio = file.read()
idempotency_key = str(uuid.uuid4()) # One key for this address, reused if we retry.
for attempt in range(1, ATTEMPTS + 1):
try:
response = post(audio, idempotency_key)
except requests.RequestException as error:
print(f"Request failed ({error})")
continue
if response.status_code == 429 and attempt < ATTEMPTS:
time.sleep(float(response.headers.get("Retry-After", 1)))
continue
print(describe(response))
return
sys.exit("No result")
if __name__ == "__main__":
main()Node.js
// Resolve a recorded UK address with Swiftcomplete.
//
// Usage (Node.js 18 or later):
// SWIFTCOMPLETE_API_KEY=your-key node resolve-recording.mjs address.wav
import { randomUUID } from "node:crypto";
import { readFileSync } from "node:fs";
import { setTimeout as sleep } from "node:timers/promises";
const URL = "https://voice.swiftcomplete.com/v1/address/recording";
const ATTEMPTS = 3;
const TIMEOUT_MS = 90000; // For the upload and the result.
function post(audio, idempotencyKey) {
return fetch(URL, {
method: "POST",
headers: {
"x-api-key": process.env.SWIFTCOMPLETE_API_KEY,
"Content-Type": "audio/wav",
"Idempotency-Key": idempotencyKey,
},
body: audio,
signal: AbortSignal.timeout(TIMEOUT_MS),
});
}
function describe(status, body) {
if (body.type === "validation_completed") {
const { validation, address } = body.response;
return `${validation.result}: ${address?.singleLine}`;
}
if (body.type === "not_resolved") return "No address identified; ask the caller again";
if (body.type === "error") {
const retry = body.retryAfterMs ? `, retry after ${body.retryAfterMs} ms` : "";
const ref = body.errorRef ? `, ref ${body.errorRef}` : "";
const why = body.description ? `: ${body.description}` : "";
return `Error: ${body.code}${retry}${ref}${why} (turn ${body.turnId})`;
}
// Refused before processing, with Swiftcomplete's description when it gave one.
return `Refused: HTTP ${status}${body.description ? `: ${body.description}` : ""}`;
}
async function resolve(audio) {
const idempotencyKey = randomUUID(); // One key for this address, reused if we retry.
for (let attempt = 1; attempt <= ATTEMPTS; attempt++) {
let response;
try {
response = await post(audio, idempotencyKey);
} catch (error) {
console.error(`Request failed (${error.message})`);
continue;
}
const text = await response.text();
if (response.status === 429 && attempt < ATTEMPTS) {
await sleep(Number(response.headers.get("retry-after") ?? 1) * 1000);
continue;
}
let body = {};
try { body = JSON.parse(text); } catch { /* no JSON body */ }
return describe(response.status, body);
}
return null;
}
const result = await resolve(readFileSync(process.argv[2]));
if (result) {
console.log(result);
} else {
console.error("No result");
process.exitCode = 1;
}11Step 11: Best practices#
- Ask for the whole address at once, including the postcode, for example: “Please tell me your full address, including the postcode.”
- Record only the caller’s answer, on the caller’s channel alone if your recordings have one channel per speaker.
- Send the original audio. Don’t resample telephone audio up to a higher rate, and don’t compress it on the way.
- Read the address back to the caller to confirm it when you can.
- If the address isn’t resolved, ask again if you can, for example asking for the postcode first.
- Keep your API key on your server.
12Step 12: Troubleshooting#
401: check that the key is copied exactly and is sent in thex-api-keyheader.403without atype: read thedescription. Check that your account has credits and that the key has no URL or IP address restrictions.api_key_rejected: your key stopped being accepted during the request. Read thedescriptionand check your account.protocol_errorfor raw audio: check that the query string hasencodingandsampleRateHz, or send a WAV file instead.invalid_parameter: read themessage. Check the option’s format against step 5, and use GB, GG, IM or JE as country codes.invalid_audio: check that the recording is mono, in a format and sample rate from step 4, and not compressed. For raw audio, check that the query string matches the audio.utterance_limit_exceeded: trim the recording to the caller saying their address.- Frequent
not_resolvedorno_speech: check that the recording is the caller’s voice at its original sample rate, isn’t clipped or very quiet, and contains the full address. - Timeouts: allow 60 seconds after your upload completes.
If you need help, contact us at
support@swiftcomplete.com and include the turnId, and
the errorRef if you received one.
How your business might benefit from Swiftcomplete
- Voicemail: turn an address left in a voicemail into a validated address.
- Recorded calls: pick up a caller’s address after the call, without listening back.
- Voice messages: take addresses that customers send as voice notes in your app or messaging channel.
- Deliveries and bookings: collect a delivery or appointment address recorded over the phone.
- Insurance and claims: record the address of a property or incident accurately.
- Utilities and telecoms: check addresses recorded during sign-up, moves and engineer bookings.