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

# Audio Mastering

> Processes an input audio file to match the mastering characteristics of a reference track.

Master your audio files professionally using a reference track.

**Audio Mastering** uses intelligent processing to match the sonic quality of your track to a reference file, perfect for music production, podcasts, and post-production work.

* Match tone, loudness, and clarity
* Quick, accurate mastering with webhook support

***

## Endpoint

```http theme={null}
POST /v1/audio_mastering
```

Use this endpoint to master an audio file based on a reference track.

***

## Sample Output

Listen to the mastered audio:

<audio controls="1" controlslist="nodownload nofullscreen noremoteplayback" src="https://cdn1.wav.com/conversions/sample-mastered.mp3">Your browser does not support audio playback.</audio>

***

## Try it Yourself

Visit the [Audio Mastering Endpoint Explorer](/api-documentation/endpoint/audio_mastering) to upload an audio and reference track for instant mastering.

> Tip: Use a professionally mastered song as your reference for best results!

***

## Request Parameters

| Parameter              | Type     | Required | Description                                                              |
| ---------------------- | -------- | -------- | ------------------------------------------------------------------------ |
| `audio_file`           | `File`   | Optional | Upload the audio file directly. Required if `audio_url` is not provided. |
| `reference_audio_file` | `File`   | Optional | rReference audio file.                                                   |
| `audio_url`            | `String` | Optional | URL to the audio file.                                                   |
| `reference_audio_url`  | String   | Optional | URL path of the reference audio file to match.                           |
| `output_extension`     | String   | Optional | Desired output format (`mp3`, `wav`, `flac`, `ogg`, `aac`, `webm`)       |
| `webhook_url`          | String   | Optional | URL to receive callback notification when processing completes           |

> **Note:** Either audio\_file or audio\_url must be provided.

> **content-type:** multipart/form-data

***

## Sample Request

### Python

```python theme={null}
import requests

url = "https://api.wav.com/api/public/v1/audio_mastering"

headers = {
    "Authorization": "<API_KEY>"
}

data = {
    "output_extension": "wav",
    "webhook_url": "https://example.com/my-webhook"
}

# Option 1: audio URLs
data["audio_url"] = "<YOUR_AUDIO_URL>"
data["reference_audio_url"] = "<YOUR_REFERENCE_AUDIO_URL>"
response = requests.post(url, headers=headers, data=data)

# Option 2: File Upload
# with open("song.mp3", "rb") as audio, open("reference.mp3", "rb") as reference:
#     files = {
#         "audio_file": audio,
#         "reference_audio_file": reference
#     }
#     response = requests.post(url, headers=headers, data=data, files=files)

print(response.json())
```

***

## Sample Response

### Success (200 OK)

```json theme={null}
{
  "success": true,
  "task_id": "0d12ef34-5678-4abc-9123-456def7890ab",
  "conversion_id": "user_master_12345",
  "credit_estimate": 0.02,
  "eta": 120,
  "message": "Mastering request accepted",
  "status": "IN_QUEUE"
}
```

***

## Webhook Response

```json theme={null}
{
  "success": true,
  "conversion_type": "Audio Mastering",
  "task_id": "0d12ef34-5678-4abc-9123-456def7890ab",
  "conversion_id": "de7b2225-9a75-4315-b761-6dcc4357a8de",
  "output_file": "https://cdn1.wav.com/conversions/sample-mastered.mp3",
  "message": "Audio Mastering Completed"

}
```

***

## Payload and Request Formation


## OpenAPI

````yaml POST /v1/audio_mastering
openapi: 3.1.0
info:
  title: WAV API
  version: 1.0.0
  description: API for retrieving conversion details by ID.
servers:
  - url: https://api.wav.com/api/public
    description: Production server
security: []
paths:
  /v1/audio_mastering:
    post:
      summary: Master an audio file using a reference track
      description: >-
        Processes an input audio file to match the mastering characteristics of
        a reference track.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                audio_url:
                  type: string
                  description: 'Input audio URL (supported format: YouTube URL).'
                  example: https://example.com/input_audio.mp3
                audio_file:
                  type: string
                  format: binary
                  description: Input audio file to upload directly.
                reference_audio_url:
                  type: string
                  description: URL of the reference audio file to match.
                  example: https://example.com/reference_track.wav
                reference_audio_file:
                  type: string
                  format: binary
                  description: Reference audio file to upload directly.
                output_extension:
                  type: string
                  enum:
                    - mp3
                    - wav
                    - flac
                    - ogg
                    - aac
                    - webm
                  description: Desired output file format.
                  example: wav
                webhook_url:
                  type: string
                  description: Callback URL to receive async result.
                  example: http://your-webhook-url.com/callback
              anyOf:
                - required:
                    - audio_url
                    - reference_audio_url
                - required:
                    - audio_file
                    - reference_audio_file
      responses:
        '200':
          description: Successfully initiated task
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  task_id:
                    type: string
                  conversion_id:
                    type: string
                  eta:
                    type: integer
                  credit_estimate:
                    type: number
                  message:
                    type: string
                  status:
                    type: string
                example:
                  success: true
                  task_id: e99d00bb-2ddf-4279-a15e-6e22801ee575
                  conversion_id: fbcf0c40-a33d-40aa-8c1d-7bb6f9df0b0f
                  eta: 40
                  credit_estimate: 0.48
                  message: Message published to queue
                  status: IN_QUEUE
        '400':
          description: Invalid parameters
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: Invalid output format specified
        '401':
          description: Invalid authentication
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: Authentication failed
        '402':
          description: Insufficient credits
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: Insufficient credits for this operation
                  required_credits:
                    type: number
                    example: 150.75
                  available_credits:
                    type: number
                    example: 100
        '404':
          description: User or plan not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: User subscription plan not found
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: Internal server error during mastering
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: Python
          source: >-
            import requests


            url = "https://api.wav.com/api/public/v1/audio_mastering"


            headers = {
                "Authorization": "<API_KEY>"
            }


            data = {
                "output_extension": "wav",
                "webhook_url": "https://example.com/my-webhook"
            }


            # Option 1: audio URLs

            data["audio_url"] = "<YOUR_AUDIO_URL>"

            data["reference_audio_url"] = "<YOUR_REFERENCE_AUDIO_URL>"

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


            # Option 2: File Upload

            # with open("song.mp3", "rb") as audio, open("reference.mp3", "rb")
            as reference:

            #     files = {

            #         "audio_file": audio,

            #         "reference_audio_file": reference

            #     }

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


            print(response.json())
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````