# Audio conversion API

> Convert WAV, FLAC, M4A and other audio files through an API, or take the sound out of a video. Free API key, 20 files a day.

Send an audio file or a video and get MP3, WAV, FLAC or another audio format back. Set the bitrate or keep only a part in the same request.

```bash
# API key: switchfile.io/dashboard/keys
code=$(curl -sL "https://api.switchfile.io/v1/convert?wait=30" \
  -o reply -D headers -w "%{http_code}" \
  -H "Authorization: Bearer $SWITCHFILE_API_KEY" \
  -H "Accept: application/octet-stream" \
  -F 'options={"audio_bitrate":192}' \
  -F file=@interview.wav -F to=mp3)
if grep -qi '^x-incomplete' headers; then
  grep -i '^x-notes' headers  # partial result, left in reply
elif [ "$code" = 200 ] && grep -qi '^content-disposition' headers; then
  mv reply interview.mp3
else
  # 202: still running, fetch links.self. Several files: result.files.
  cat reply  # otherwise the error
fi
```

```js
// npm i switchfile
import Switchfile from "switchfile";

const switchfile = new Switchfile({ apiKey: process.env.SWITCHFILE_API_KEY });
const conversion = await switchfile.convert("interview.wav", "mp3", {
  options: { audio_bitrate: 192 },
});
await switchfile.download(conversion, "interview.mp3");
```

```python
# pip install switchfile-sdk
import os
import switchfile
switchfile.configure(api_key=os.environ["SWITCHFILE_API_KEY"])
conversion = switchfile.convert("interview.wav", "mp3", {"audio_bitrate": 192})
switchfile.download(conversion, "interview.mp3")
```

```php
<?php // composer require switchfile/switchfile-php
require "vendor/autoload.php";

$switchfile = new Switchfile\Switchfile(["api_key" => getenv("SWITCHFILE_API_KEY")]);
$conversion = $switchfile->convert("interview.wav", "mp3", ["audio_bitrate" => 192]);
$switchfile->download($conversion, "interview.mp3");
```

[Get a free API key](https://switchfile.io/signup) (Free for 20 files a day.) [Try it in the browser](https://switchfile.io/wav-to-mp3).

## What comes back

With Accept: application/octet-stream, as in the curl example, a 200 response is the file itself when the conversion has exactly one result file. With several result files, for example one image per page, or without that header, you get the conversion as JSON, and the files are in result.files:

```json
{
  "id": "0b8a7c1e-5d0f-4a51-9f39-2f7f4c1d9a10",
  "object": "conversion",
  "status": "finished",
  "progress": 100,
  "input": {
    "filename": "interview.wav",
    "format": "wav",
    "size": 48213
  },
  "to": "mp3",
  "options": {
    "audio_bitrate": 192
  },
  "result": {
    "files": [
      {
        "filename": "interview.mp3",
        "size": 61544,
        "url": "https://api.switchfile.io/files/2a6f8e1c-4b3d-4e7a-9c5f-8d1b0e2a4c67/interview.mp3?expires=1794074402&signature=3f9c2a7d41e8b6c05d1f9e2a7b4c8d3e6f0a1b2c3d4e5f60718293a4b5c6d7e8"
      }
    ],
    "incomplete": false
  },
  "download_url": "https://api.switchfile.io/files/2a6f8e1c-4b3d-4e7a-9c5f-8d1b0e2a4c67/interview.mp3?expires=1794074402&signature=3f9c2a7d41e8b6c05d1f9e2a7b4c8d3e6f0a1b2c3d4e5f60718293a4b5c6d7e8",
  "error": null,
  "credits": 1,
  "batch_id": null,
  "created_at": "2026-11-06T18:00:00+00:00",
  "finished_at": "2026-11-06T18:00:02+00:00",
  "expires_at": "2026-11-07T18:00:02+00:00",
  "links": {
    "self": "https://api.switchfile.io/v1/conversions/0b8a7c1e-5d0f-4a51-9f39-2f7f4c1d9a10"
  }
}
```

download_url is a signed link to the result. It works without your API key until expires_at, 24 hours after the conversion finished.

No browser at hand? POST /v1/signup with an email address sends a code, and POST /v1/signup/verify with that code returns the key. [Get an API key without a browser](https://switchfile.io/docs/authentication#get-an-api-key-without-a-browser)

## What you get

- **Audio and video in**: 31 audio formats go in, and the sound of 27 video formats too. 24 audio formats come out.
- **MP3 quality**: By default an MP3 uses a variable bitrate at high quality, around 190 kbit/s for music. audio_bitrate sets a fixed rate.
- **Keep a part**: trim_start and trim_end cut out the part you need, in seconds or as HH:MM:SS.
- **Volume and channels**: volume makes the sound louder or quieter. channels set to 1 gives mono.

Converter pages: [WAV to MP3](https://switchfile.io/wav-to-mp3), [MP4 to MP3](https://switchfile.io/mp4-to-mp3), [FLAC to MP3](https://switchfile.io/flac-to-mp3), [M4A to MP3](https://switchfile.io/m4a-to-mp3), [MP3 to WAV](https://switchfile.io/mp3-to-wav)

## Options

| Option | Meaning |
|---|---|
| `audio_bitrate` | Audio bitrate in kbit/s. Without a value the encoder picks a quality-based rate. |
| `audio_qscale` | Quality of variable bitrate MP3 from 0 (best) to 9. Ignored when audio_bitrate is set. Default: 2. |
| `volume` | Change the volume: 1.0 keeps it, 1.1 is 10% louder, 0.5 is half as loud. At most 10. |
| `channels` | Number of audio channels, for example 1 for mono or 2 for stereo. |
| `sample_rate` | Sample rate in Hz, for example 44100 or 48000 (8000 to 192000). |
| `trim_start` | Start of the part to keep, in seconds or HH:MM:SS. |
| `trim_end` | End of the part to keep, in seconds or HH:MM:SS. |

A 202 response means the conversion is still running: at once without the wait parameter, after 30 seconds with it. Fetch links.self with GET until status is finished, then download download_url. If you set a webhook URL for the request or your account, we also call it when the conversion is done. Up to 50 files go into one batch.

## Where your files go

- **Converted on our server**: Conversions run on our server in the EU. Stored files and results are deleted after 24 hours. [Hosting in the privacy policy](https://switchfile.io/privacy#hosting)
- **Without storage: store=false**: The file and the result are processed in memory while the request runs and are not written to our file storage or database. The service that converts them cannot open connections to the internet. In this mode files can be up to 50 MB. Your usage history keeps the time, formats, sizes and credits, never the file name. [Converting without storage](https://switchfile.io/docs/no-store)
- **Data processing agreement**: We sign a data processing agreement (DPA) under Art. 28 GDPR on request. Write to hello@switchfile.io. [Security](https://switchfile.io/security#dpa)

```bash
code=$(curl -s "https://api.switchfile.io/v1/convert?store=false" \
  -o reply -D headers -w "%{http_code}" \
  -H "Authorization: Bearer $SWITCHFILE_API_KEY" \
  -F file=@interview.wav -F to=mp3)
if grep -qi '^x-incomplete' headers; then
  grep -i '^x-notes' headers  # partial result, left in reply
elif [ "$code" = 200 ] && grep -qi '^content-disposition' headers; then
  mv reply interview.mp3
else
  cat reply  # otherwise the error
fi
```

## Pricing

Free: 20 files/day, free API key
Credit pack: from €7, 500 credits, one-time, no subscription
Monthly: from €4, 500 credits a month, cancel at any time
Audio conversions: 1 credit per started minute of conversion time, at least 1 per file.
A file that is done within a minute uses 1 credit, which costs €0.0043 to €0.014 depending on the plan or pack.
Add ?dry_run=1 to a convert request to see the credits and the price of a file before you convert it. [Cost before converting](https://switchfile.io/docs/simple-api#dry-run)
[Pricing](https://switchfile.io/pricing)

## SDKs

Client libraries and integrations: [SDK overview](https://switchfile.io/developers#sdks).

## Questions

### What are the limits?

Files can be up to 1 GB. A file sent in the request can be up to 100 MB; larger files go through an upload, which the SDKs do on their own. One conversion can run for up to 5 minutes. Without storage (store=false), files can be up to 50 MB.

### What happens to surround sound in an MP3?

MP3 holds at most two channels, so surround audio is mixed down to stereo.

### Which audio track is used from a video?

Only the sound is kept and the picture is dropped. If the video has several audio tracks, you get the one marked as default, or the first one if none is marked.

### How long do you keep my files?

A stored conversion keeps the file and the result for 24 hours, then both are deleted. With store=false no file is stored: the result comes back in the response, and only an entry with time, formats, sizes and credits stays in your usage history for 400 days.
