> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dreamto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Suno Generate validation phrase

> Step 1 of a custom voice: submit a vocal recording and its segment to get a validation phrase the speaker has to read aloud.

`ai-music-api/validation-phrase` is the first step of the Suno custom voice flow. Submit an original recording with vocals as `voice_url` and pick the vocal segment to learn the voice from with `vocal_start_s` / `vocal_end_s`; the voice is analysed and a **validation phrase** is generated, which confirms that the speaker agrees to the use of their voice.

The full flow:

1. Call this endpoint to get the validation phrase `verify_phrase_text`;
2. have the speaker read the phrase aloud, upload the recording and call [Create voice](https://docs.dreamto.ai/en/music/suno/voice-create.md) (`task_id` is this task's ID);
3. to get a different phrase, call [Regenerate validation phrase](https://docs.dreamto.ai/en/music/suno/voice-regenerate.md);
4. confirm the voice with [Check voice](https://docs.dreamto.ai/en/music/suno/voice-check.md), then use it in music generation with `persona_id` (this task's ID) and `persona_model: "voice_persona"`.

This task's ID is the **Voice ID**.

## Setup

The Suno endpoints use an asynchronous task protocol: every endpoint creates its task with `POST /api/v1/jobs/createTask` (`model` selects the endpoint and the parameters go in `input`) and is queried with `GET /api/v1/jobs/recordInfo?taskId=`; with `callBackUrl` the result is pushed to that URL when the task finishes. See the [Suno introduction](https://docs.dreamto.ai/en/music/suno.md) for the flow, chaining tasks and how long files are kept. The base URL is `https://api.dreamto.ai`; send the API Key in the `Authorization: Bearer` header.

Every response has HTTP status 200; the `code` in the body tells the outcome: `200` is success, anything else an error (see the response examples of each endpoint).

| Endpoint | Purpose |
| - | - |
| [`POST /api/v1/jobs/createTask`](https://docs.dreamto.ai/en/api-reference/suno-voice-validate/create-task) | Create task |
| [`GET /api/v1/jobs/recordInfo?taskId=...`](https://docs.dreamto.ai/en/api-reference/suno-voice-validate/query-task) | Get task |
| [`POST callBackUrl`](https://docs.dreamto.ai/en/api-reference/suno-voice-validate/task-callback) | Task callback |

## Parameters

`model` is `ai-music-api/validation-phrase`; the parameters go in `input`. Requests that break a rule return `code: 422`; no task is created or charged.

| Field | Values |
| - | - |
| `voice_url` | Required `http` / `https` URL of the original recording with vocals |
| `vocal_start_s` | Required start of the vocal segment (seconds, integer, ≥ 0) |
| `vocal_end_s` | Required end of the vocal segment (seconds, integer), greater than `vocal_start_s` |
| `language` | Optional language of the validation phrase: `en`, `zh`, `es`, `fr`, `pt`, `de`, `ja`, `ko`, `hi` or `ru` |

## Pricing

Billed per request: each succeeded task is charged once at the model price shown in the console. The balance is checked for that price when the task is created (`code: 402` when insufficient); invalid requests and failed tasks are not charged.

This endpoint is free.

## Quick start

Create a task to get `data.taskId`, poll about every 10 seconds and read `response` once `state` is `success`; or pass `callBackUrl` to be called back when the task finishes. `$DREAMTO_API_KEY` is your API Key.

```bash cURL theme={null}
# 1. Create the task
curl -X POST "https://api.dreamto.ai/api/v1/jobs/createTask" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ai-music-api/validation-phrase",
    "callBackUrl": "https://your-domain.com/api/callback",
    "input": {
      "voice_url": "https://example.com/audio/user_voice.mp3",
      "vocal_start_s": 0,
      "vocal_end_s": 10,
      "language": "en"
    }
  }'

# 2. Query the task
curl "https://api.dreamto.ai/api/v1/jobs/recordInfo?taskId=7d3f0a9c41e85b2f6a1c9e04b8d27f53" \
  -H "Authorization: Bearer $DREAMTO_API_KEY"
```

```python Python theme={null}
import os
import time

import requests

BASE_URL = "https://api.dreamto.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['DREAMTO_API_KEY']}"}

payload = {
    "model": "ai-music-api/validation-phrase",
    "callBackUrl": "https://your-domain.com/api/callback",
    "input": {
        "voice_url": "https://example.com/audio/user_voice.mp3",
        "vocal_start_s": 0,
        "vocal_end_s": 10,
        "language": "en"
    }
}

created = requests.post(f"{BASE_URL}/api/v1/jobs/createTask", headers=HEADERS, json=payload, timeout=60).json()
if created["code"] != 200:
    raise SystemExit(f"{created['code']}: {created['msg']}")
task_id = created["data"]["taskId"]
while True:
    record = requests.get(f"{BASE_URL}/api/v1/jobs/recordInfo", headers=HEADERS, params={"taskId": task_id}, timeout=60).json()["data"]
    if record["state"] == "fail" or record.get("response"):
        break
    time.sleep(10)
if record.get("response"):
    data = record["response"]["data"]
    print(data["verify_phrase_text"])
else:
    print(record["failCode"], record["failMsg"])
```

## Callback

Pass `callBackUrl` (a public `http` / `https` URL) when creating the task; when the task succeeds or fails DreamTo `POST`s the result there once ([callback format](https://docs.dreamto.ai/en/api-reference/suno-voice-validate/task-callback.md)): on success the body is `{"code": 200, "msg": "success", "data": {"taskId", "validateInfo", "status": "wait_validating"}}`, sent when the validation phrase is ready, with `data.taskId` the task ID (the Voice ID) and `validateInfo` the phrase to record before submitting Create voice; on failure `code` is the failure code (not `200`), `msg` the reason and `data` is `{"taskId", "status": "processing_validate_fail", "errorCode", "errorMessage"}`.

The request carries `X-DreamTo-Event: task.completed`, `X-DreamTo-Timestamp` (UTC, RFC 3339) and `X-DreamTo-Signature`:

```
X-DreamTo-Signature = hex( HMAC-SHA256( secret, X-DreamTo-Timestamp + "." + data.taskId + "." + status ) )
```

`status` is `success` when the task succeeded and `failed` when it failed. The secret is generated in the DreamTo console; without one no signature header is sent. Answer with any `2xx` to acknowledge; otherwise the callback is retried.

## Notes

* Once the phrase is generated the task **stays `generating`** while it waits for the speaker's verification: query the task and read the phrase from `response.data.verify_phrase_text`; stop polling as soon as it appears instead of waiting for `success`.
* After [Create voice](https://docs.dreamto.ai/en/music/suno/voice-create.md) is submitted, this task changes to `success` when the voice is ready, or `fail` when verification fails; the callback is sent once: when the validation phrase is ready (`data.status` is `wait_validating`; record it and submit Create voice), or when the phrase could not be generated; the final voice outcome is reported by the Create voice callback or by querying this task.
* Pick a clear segment with a single voice (ideally no accompaniment or reverb) for a better voice; a very short segment or one without vocals can make the task fail.
* `taskId` is issued by DreamTo (32 hex digits) and can only be queried with an API Key of the same account; an unknown or expired task returns `code: 422` with `msg: recordInfo is null`.
* The body accepts only `model`, `callBackUrl` and `input`; undeclared `input` fields, wrong types and values that break a rule return `code: 422` with an English reason in `msg`; no task is created or charged.
* Every file link in a result (audio, cover image, video and so on) is a DreamTo download link (`/v1/tasks/{task_id}/artifacts/...`) that works without an API Key and supports `Range`; files are kept for 14 days after the task is created, so download them promptly.
* `param` echoes the create request, with `input` as a JSON string that needs a second parse; the credits used are not returned, and the charge is shown in the DreamTo console bills.
* `failCode` / `failMsg` of a failed task come from the model service (content moderation, a source audio that cannot be downloaded and so on); internal errors are reported as `failCode: "500"` with `failMsg: "Internal Error, Please try again later."`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.