> ## 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 Cutter

> Trims an audio file using the specified start and end times.



## OpenAPI

````yaml POST /v1/audio_cutter
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_cutter:
    post:
      summary: Cut an audio file between specified timestamps
      description: Trims an audio file using the specified start and end times.
      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: Audio file to upload and process directly.
                start_time:
                  type: number
                  format: float
                  description: Start time in milliseconds.
                  example: 10500
                end_time:
                  type: number
                  format: float
                  description: End time in milliseconds.
                  example: 45000
                output_extension:
                  type: string
                  enum:
                    - mp3
                    - wav
                    - flac
                    - ogg
                    - aac
                    - webm
                  description: Desired output format.
                  example: mp3
                webhook_url:
                  type: string
                  description: Callback URL for async processing results.
                  example: http://your-webhook-url.com/callback
              required:
                - start_time
                - end_time
              anyOf:
                - required:
                    - audio_url
                - required:
                    - 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: b0ac9d46-64d7-4843-af48-a0b6effe3666
                  conversion_id: fe19945b-d466-4183-b559-5d264bddd492
                  eta: 66
                  credit_estimate: 0.015
                  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 time range 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: 25
                  available_credits:
                    type: number
                    example: 10
        '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 audio trimming
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: Python
          source: >-
            import requests


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

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


            payload = {
                "start_time": 10500,
                "end_time": 45000,
                "output_extension": "mp3"
            }


            # Option 1: audio_url

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

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


            # Option 2: File Upload

            # with open("input_audio.mp3", "rb") as f:

            #     files = {"audio_file": f}

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


            print(response.json())
        - lang: PHP
          source: |-
            <?php
            $url = 'https://api.wav.com/api/public/v1/audio_cutter';
            $headers = ['Authorization: <API_KEY>'];

            $data = [
                'start_time' => 10500,
                'end_time' => 45000,
                'output_extension' => 'mp3'
            ];

            // Option 1: audio_url
            $data['audio_url'] = 'https://example.com/input_audio.mp3';

            // Option 2: File Upload
            // $data['audio_file'] = new CURLFile('input_audio.mp3');

            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $response = curl_exec($ch);
            curl_close($ch);
            echo $response;
        - lang: Go
          source: "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"mime/multipart\"\n\t\"net/http\"\n\t\"os\"\n)\n\nfunc main() {\n\turl := \"https://api.wav.com/api/public/v1/audio_cutter\"\n\tapiKey := \"<API_KEY>\"\n\n\tbody := &bytes.Buffer{}\n\twriter := multipart.NewWriter(body)\n\n\twriter.WriteField(\"start_time\", \"10500\")\n\twriter.WriteField(\"end_time\", \"45000\")\n\twriter.WriteField(\"output_extension\", \"mp3\")\n\n\t// Option 1: audio_url\n\twriter.WriteField(\"audio_url\", \"https://example.com/input_audio.mp3\")\n\n\t// Option 2: File Upload\n\t// file, _ := os.Open(\"input_audio.mp3\")\n\t// defer file.Close()\n\t// part, _ := writer.CreateFormFile(\"audio_file\", \"input_audio.mp3\")\n\t// io.Copy(part, file)\n\n\twriter.Close()\n\n\treq, _ := http.NewRequest(\"POST\", url, body)\n\treq.Header.Add(\"Authorization\", apiKey)\n\treq.Header.Add(\"Content-Type\", writer.FormDataContentType())\n\n\tresp, _ := http.DefaultClient.Do(req)\n\tdefer resp.Body.Close()\n\tresponse, _ := io.ReadAll(resp.Body)\n\tfmt.Println(string(response))\n}"
        - lang: Java
          source: // Java version omitted for brevity; request if needed.
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````