Create a voiceprint

POST https://api.fourhz.ai/v1/speaker-enrollments

Header: Authorization: <API Key>; use the raw API key without Bearer.

Submit one 5–10 second clip by default. The browser trims longer uploads to the first continuous 10 seconds; the service validates it and uses the first continuous 5 seconds. Normalize enrollment audio to 16 kHz mono 16-bit PCM WAV with a WAV header. Direct API clients should convert before upload and must not send the headerless raw PCM16LE used by the realtime WebSocket API. Legacy three-clip uploads remain supported at 1–8 seconds per clip.

Request parameters

ParameterTypeRequiredDescription
audiofile × 1Yes · MultipartUse 16 kHz mono 16-bit PCM WAV with a WAV header. One 5–10 second clip; for the legacy format repeat audio three times, 1–8 seconds each.
audio_formatstringNo · MultipartUsually omitted; provide one hint per clip for the legacy three-clip format.
namestringNo · MultipartDisplay name, at most 64 characters.
scopestringNo · MultipartDefaults to user; api_key restricts use to the current key.

Response fields

FieldTypeDescription
enrollment_idstringComplete voiceprint ID; reuse unchanged for lookups, deletion and transcription.
statusstringSuccessful creation returns ready. A failed registration returns an error, never a usable voiceprint.
member_countintegerNumber of reference clips.
namestring?Optional display name, not an identity match.
scopestring?user shares within the account; api_key restricts use to the creating key.
created_atstring?Creation time in RFC3339. Legacy voiceprints may omit metadata.

Request examples

curl -X POST 'https://api.fourhz.ai/v1/speaker-enrollments' \
  -H "Authorization: $FOURHZ_API_KEY" \
  -F 'audio=@speaker.wav' \
  -F 'name=Alice' \
  -F 'scope=user'

Response example

HTTP 200

{
  "enrollment_id": "enr_example",
  "status": "ready",
  "member_count": 3,
  "name": "Alice",
  "scope": "user",
  "created_at": "2026-10-16T00:00:00Z"
}

Enrollment quality checks and error codes

Single-clip enrollment checks audio level, active speech, and clipping; legacy three-clip enrollment also checks speaker consistency. A failed quality check rejects registration without returning a usable voiceprint. Do not treat an error as success. Record again according to the error; repeatedly submitting the same unsuitable audio will not improve it.

Quality-check errors return HTTP 422; empty audio, duration, and decoding errors return HTTP 400 (see the table). Branch on error_code; message explains the problem and should not be parsed for program logic.

HTTPerror_codeCause and recommended action
422low_qualityUsable speech does not meet the recording quality requirements, for example because it is too faint or distorted. Record again in a quiet environment at a clear, moderate level without clipping.
422audio_too_quietThe recording is too quiet. Move closer to the microphone, raise the input level, and record again.
422insufficient_speechToo little active speech or too many pauses. Record clear, continuous speech with less silence.
422audio_clippedThe recording is clipped. Lower the input gain or increase microphone distance, then record again.
422speaker_samples_inconsistentSpeaker characteristics differ across the three clips. Record the same speaker alone, avoiding cross-talk and overlapping voices.
400too_shortThe clip or its usable speech is too short. Record again within the duration limits with enough clear speech.
400emptyThe audio is empty. Record again or select a file that contains audio.
400unsupported_formatThe audio format is unsupported. Use a supported format and check audio_format.
400decode_failedThe audio cannot be decoded. Check that the file is complete and its format hint is correct, or export it again.

A temporary service failure returns 503 and does not mean the recording failed a quality check. Retry later; do not substitute an existing voiceprint for the failed registration.

When the problem can be attributed to one clip, audio_index is its zero-based upload index: 0, 1, and 2 identify the first, second, and third clips. If attribution is unreliable, such as an inconsistent group, the field is omitted. Review or record all three clips again instead of guessing which clip failed.

{
  "error_code": "audio_too_quiet",
  "message": "The reference audio is too quiet. Record it again at a clear speaking volume.",
  "audio_index": 0
}

Errors

HTTPDescription
401Missing or invalid API key in the header.
503Service temporarily unavailable; retry later.

List voiceprints

GET https://api.fourhz.ai/v1/speaker-enrollments

Header: Authorization: <API Key>; use the raw API key without Bearer.

Request parameters

ParameterTypeRequiredDescription
querystringNo · QuerySearch for a substring in name or enrollment_id.
scopestringNo · Queryuser or api_key; omit to list all voiceprints accessible to this credential.
limitintegerNo · QueryDefault 20, maximum 100.
offsetintegerNo · QueryNumber of records to skip, default 0.

Response fields

FieldTypeDescription
enrollmentsarrayAccessible voiceprints, newest first.
enrollments[].statusstringEmpty in list responses. Query details to determine availability.
enrollments[].enrollment_idstringComplete voiceprint ID; reuse unchanged for lookups, deletion and transcription.
enrollments[].member_countintegerNumber of reference clips.
enrollments[].namestring?Optional display name, not an identity match.
enrollments[].scopestring?user shares within the account; api_key restricts use to the creating key.
enrollments[].created_atstring?Creation time in RFC3339. Legacy voiceprints may omit metadata.
totalintegerTotal matching record count.
limit / offsetintegerEffective page size and offset.

Request examples

curl -X GET 'https://api.fourhz.ai/v1/speaker-enrollments?limit=20&offset=0' \
  -H "Authorization: $FOURHZ_API_KEY"

Response example

HTTP 200

{
  "enrollments": [
    {
      "enrollment_id": "enr_example",
      "status": "",
      "member_count": 3,
      "name": "Alice",
      "scope": "user",
      "created_at": "2026-10-16T00:00:00Z"
    }
  ],
  "total": 1,
  "limit": 20,
  "offset": 0
}

Errors

HTTPDescription
401Missing or invalid API key in the header.
503Service temporarily unavailable; retry later.

Get voiceprint details

GET https://api.fourhz.ai/v1/speaker-enrollments/{enrollment_id}

Header: Authorization: <API Key>; use the raw API key without Bearer.

Request parameters

ParameterTypeRequiredDescription
enrollment_idstringYes · PathComplete ID returned at creation. Unknown, deleted and inaccessible IDs all return HTTP 404.

Response fields

FieldTypeDescription
enrollment_idstringComplete voiceprint ID; reuse unchanged for lookups, deletion and transcription.
statusstringDetails return ready or unknown; only ready means available.
member_countintegerNumber of reference clips.
namestring?Optional display name, not an identity match.
scopestring?user shares within the account; api_key restricts use to the creating key.
created_atstring?Creation time in RFC3339. Legacy voiceprints may omit metadata.

Request examples

curl -X GET 'https://api.fourhz.ai/v1/speaker-enrollments/enr_example' \
  -H "Authorization: $FOURHZ_API_KEY"

Response example

HTTP 200

{
  "enrollment_id": "enr_example",
  "status": "ready",
  "member_count": 3,
  "name": "Alice",
  "scope": "user",
  "created_at": "2026-10-16T00:00:00Z"
}

Errors

HTTPDescription
401Missing or invalid API key in the header.
404Voiceprint does not exist, was deleted, or is outside the credential scope.
503Service temporarily unavailable; retry later.

Delete a voiceprint

DELETE https://api.fourhz.ai/v1/speaker-enrollments/{enrollment_id}

Header: Authorization: <API Key>; use the raw API key without Bearer.

Request parameters

ParameterTypeRequiredDescription
enrollment_idstringYes · PathComplete ID returned at creation. Unknown, deleted and inaccessible IDs all return HTTP 404.

Response fields

HTTP 204 with no body. The voiceprint and reference audio are removed; subsequent lookup or deletion returns HTTP 404.

Request examples

curl -X DELETE 'https://api.fourhz.ai/v1/speaker-enrollments/enr_example' \
  -H "Authorization: $FOURHZ_API_KEY"

Response example

HTTP 204

A successful response has no body; do not parse JSON.

Errors

HTTPDescription
401Missing or invalid API key in the header.
404Voiceprint does not exist, was deleted, or is outside the credential scope.
503Service temporarily unavailable; retry later.