---
title: Compress Audio to Target File Size API
slug: compress-audio-to-target-file-size-api
url: https://apyhub.com/freedailypro/service/compress-audio-to-target-file-size-api
provider: FreeDailyPro
tags: [audio, compress audio, audio compression, reduce file size, mp3, target file size, audio processing]
auth: api_key
version: 1.0.0
service_type: sync
endpoints: 1
atoms: 10
mcp: true
---

# Compress Audio to Target File Size API

Compress an audio file to a size you choose, such as 2MB or 500KB. Upload up to 30 MB and get a smaller MP3 back as a binary file.

## Endpoints

| Method | URL | Description | Atoms |
| --- | --- | --- | --- |
| POST | `https://api.eu.apyhub.com/freedailypro/compress-audio-to-target-file-size-api/audio-compress` | What it does Compresses an uploaded audio file to a smaller size and returns it as an MP3. The size… | 10 |

## Endpoint reference

### Compress audio

`POST https://api.eu.apyhub.com/freedailypro/compress-audio-to-target-file-size-api/audio-compress` · 10 atoms · accepts `multipart/form-data` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `file` | body | string (binary) | yes | The audio file. Up to 30 MB. |
| `targetFileSize` | body | string | no | Optional. The size you want the file to end up at, for example 2MB, 500KB or a number of bytes. Default: half the original size. |

#### Quickstart

Compress an audio file by uploading it. `targetFileSize` is optional; leave it out for about half the original size.

```bash
curl -X POST "https://api.eu.apyhub.com/freedailypro/compress-audio-to-target-file-size-api/audio-compress" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/audio.mp3" \
  -F "targetFileSize=500KB"
```

#### What you'll get back

Returns binary data as the compressed MP3 file.

## About

## What it does
Compress Audio is a simple file-processing endpoint that takes an audio file and returns a compressed binary MP3 file. Send a file up to 30 MB, optionally set a `targetFileSize`, and get back the processed audio as the response body.

Use `targetFileSize` when you need a specific output size, such as `2MB`, `500KB`, or a byte count. If you omit it, the service defaults to about half the original file size. That makes it useful when you need to reduce upload costs, fit content into storage limits, or prepare audio for faster delivery in an app or pipeline.

Because the response is binary, you can write it straight to disk, pass it to another media workflow, or store it wherever your application keeps generated files. The API does one job: reduce audio file size and return the result as a downloadable MP3 file.

## Usage

Base URL: `https://api.eu.apyhub.com` (default region — see
`GET https://apyhub.com/api/public/regions` for the rest).

Authenticate with an ApyHub API key in the `apy-token` header.
Full docs and a live playground: https://apyhub.com/freedailypro/service/compress-audio-to-target-file-size-api
