> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nyra-labs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nyra-labs.com/_mcp/server.

# Create alignment

POST https://api.nyra-labs.com/v1/audio/alignments
Content-Type: multipart/form-data

Aligns a transcript to its recording: answers with the start and end of every word and of every sound in it, and how well each word fits the audio. Fillers, vocal sounds and cut-off words are aligned too when the transcript marks them. English only. The [forced alignment guide](/forced-alignment) covers the transcript conventions and every field of the response.

Reference: https://docs.nyra-labs.com/api-reference/audio/align

## Authentication

- `Authorization` header (bearer token, required) — Your API key, e.g. `Authorization: Bearer nl_live_...`.

## Servers

- `https://api.nyra-labs.com` (Production, default)
- `http://localhost:3001` (Local)

## Request

### Body (multipart/form-data)

This endpoint expects a multipart form containing a file.

- `file` (file, required) — The recording to align, up to 25 MB and one hour. Same formats as transcription: wav, mp3, m4a, flac, ogg and webm. Send an hour as compressed audio (MP3 or Opus).
- `language` (enum, optional) — The language of the recording. Only `en` is supported; it is the default.
- `model` (enum, required) — The model to align with. Required; `nyra-forced-aligner-en` is the only one.
- `text` (string, required) — What is said in the recording, word for word. Write fillers as `[UH]` and `[UM]`, vocal sounds as `[laughter]`, `[cough]`, `[breath]` and the like, and cut-off words with a trailing hyphen (`th-`). Casing and punctuation are ignored. CrisperWhisper's verbatim transcript is in exactly this form.

## Response

### 200

The alignment. A key that starts with `nl_test_` gets the transcript's words spread evenly over the recording: no alignment runs and nothing is charged.

- `duration` (double, required) — Duration of the decoded audio, in seconds.
- `language` (enum, required)
  - Allowed values: `en`
- `skipped` (list of string, required) — Transcript tokens that could not be aligned: unknown tags such as `[music]` and tokens without a pronunciation. Every other token is in `words`, in order.
- `usage` (Usage, required)
- `words` (list of AlignedWord, required)

## Errors

### 400 Bad Request Error

A parameter is missing or invalid, the language is not English (`unsupported_language`), the file is not audio (`invalid_audio`) or longer than an hour (`audio_too_long`), or the transcript does not fit the recording (`alignment_failed`, `alignment_too_complex`). Nothing is charged.

- `error` (ErrorResponseError, required)

### 401 Unauthorized Error

The API key is missing, malformed or invalid.

- `error` (ErrorResponseError, required)

### 403 Forbidden Error

The API key is missing the `transcriptions:write` scope, or its organization or creator is suspended.

- `error` (ErrorResponseError, required)

### 413 Content Too Large Error

The upload exceeds the 25 MB limit.

- `error` (ErrorResponseError, required)

### 429 Too Many Requests Error

Rate limit exceeded, insufficient balance (`insufficient_quota`), or a spend cap is reached.

- `error` (ErrorResponseError, required)

### 503 Service Unavailable Error

The aligner is at capacity (`capacity_exceeded`, retry after `retry-after`), or not deployed in this environment (`model_backend_unavailable`).

- `error` (ErrorResponseError, required)

## Types

### Usage

- `seconds` (double, required) — Billed audio seconds: the audio's duration rounded up to a whole second.
- `type` (enum, required)
  - Allowed values: `duration`

### AlignedWord

- `confidence` (double, required) — How well the audio under the word fits it, from 0 to 1. Correct words score about 0.87 in the median; below 0.5 usually means the transcript is wrong here (misheard, or missing speech next to it). Several low words in a row point at untranscribed or mistranscribed speech. Cut-offs and very short words score lower by nature. A ranking for review, not a probability.
- `end` (double, required) — End of the word, in seconds.
- `phones` (list of AlignedPhone, required) — The word's sounds, in order, covering exactly the word's span.
- `start` (double, required) — Start of the word, in seconds.
- `type` (enum, required) — `word`, `filler` (`[UH]`, `[UM]`), `sound` (a vocal sound tag) or `cutoff` (a fragment ending in `-`).
  - Allowed values: `word`, `filler`, `sound`, `cutoff`
- `word` (string, required) — The transcript token as you sent it, punctuation included.

### ErrorResponseError

- `code` (string, required, nullable)
- `message` (string, required)
- `param` (string, required, nullable)
- `type` (enum, required)
  - Allowed values: `invalid_request_error`, `authentication_error`, `permission_error`, `rate_limit_error`, `insufficient_quota`, `server_error`

### AlignedPhone

- `end` (double, required)
- `phone` (string, required) — An ARPAbet phone (`TH`, `ER`, ...) or, for fillers and vocal sounds, the model's unit for them (`FUH`, `FUM`, `LAU`, `COF`, `BRE`, ...).
- `start` (double, required)

## Examples

**Request**

```json
{
  "file": "<file: string>",
  "model": "nyra-forced-aligner-en",
  "text": "so we [UH] we need to reschedule the th- Thursday meeting [laughter]"
}
```

**Response**

```json
{
  "duration": 2.84,
  "language": "en",
  "skipped": [],
  "usage": {
    "seconds": 3,
    "type": "duration"
  },
  "words": [
    {
      "confidence": 0.91,
      "end": 1.53,
      "phones": [
        {
          "end": 1.26,
          "phone": "TH",
          "start": 1.2
        }
      ],
      "start": 1.2,
      "type": "word",
      "word": "Thursday"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.nyra-labs.com/v1/audio/alignments"

files = { "file": "open('string', 'rb')" }
payload = {
    "language": ,
    "model": "nyra-forced-aligner-en",
    "text": "so we [UH] we need to reschedule the th- Thursday meeting [laughter]"
}
headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.nyra-labs.com/v1/audio/alignments';
const form = new FormData();
form.append('file', 'string');
form.append('language', '');
form.append('model', 'nyra-forced-aligner-en');
form.append('text', 'so we [UH] we need to reschedule the th- Thursday meeting [laughter]');

const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

options.body = form;

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.nyra-labs.com/v1/audio/alignments"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nnyra-forced-aligner-en\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"text\"\r\n\r\nso we [UH] we need to reschedule the th- Thursday meeting [laughter]\r\n-----011000010111000001101001--\r\n")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.nyra-labs.com/v1/audio/alignments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nnyra-forced-aligner-en\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"text\"\r\n\r\nso we [UH] we need to reschedule the th- Thursday meeting [laughter]\r\n-----011000010111000001101001--\r\n"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.nyra-labs.com/v1/audio/alignments")
  .header("Authorization", "Bearer <token>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nnyra-forced-aligner-en\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"text\"\r\n\r\nso we [UH] we need to reschedule the th- Thursday meeting [laughter]\r\n-----011000010111000001101001--\r\n")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.nyra-labs.com/v1/audio/alignments', [
  'multipart' => [
    [
        'name' => 'file',
        'filename' => 'string',
        'contents' => null
    ],
    [
        'name' => 'model',
        'contents' => 'nyra-forced-aligner-en'
    ],
    [
        'name' => 'text',
        'contents' => 'so we [UH] we need to reschedule the th- Thursday meeting [laughter]'
    ]
  ]
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.nyra-labs.com/v1/audio/alignments");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nnyra-forced-aligner-en\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"text\"\r\n\r\nso we [UH] we need to reschedule the th- Thursday meeting [laughter]\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]
let parameters = [
  [
    "name": "file",
    "fileName": "string"
  ],
  [
    "name": "language",
    "value": 
  ],
  [
    "name": "model",
    "value": "nyra-forced-aligner-en"
  ],
  [
    "name": "text",
    "value": "so we [UH] we need to reschedule the th- Thursday meeting [laughter]"
  ]
]

let boundary = "---011000010111000001101001"

var body = ""
var error: NSError? = nil
for param in parameters {
  let paramName = param["name"]!
  body += "--\(boundary)\r\n"
  body += "Content-Disposition:form-data; name=\"\(paramName)\""
  if let filename = param["fileName"] {
    let contentType = param["content-type"]!
    let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
    if (error != nil) {
      print(error as Any)
    }
    body += "; filename=\"\(filename)\"\r\n"
    body += "Content-Type: \(contentType)\r\n\r\n"
    body += fileContent
  } else if let paramValue = param["value"] {
    body += "\r\n\r\n\(paramValue)"
  }
}

let request = NSMutableURLRequest(url: NSURL(string: "https://api.nyra-labs.com/v1/audio/alignments")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```