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

# Detect AI-generated music

POST https://app.resemble.ai/api/v2/detect/music
Content-Type: multipart/form-data

Analyze a song or music track and classify it as AI-generated or human-produced.

Supply audio via one of three intake methods:

* **Direct file upload**: `multipart/form-data` with the file attached as `file`. Files must be 150 MB or smaller.
* **Public URL**: `application/json` with a `url` field. Resemble downloads and stores the file before analysis.
* **Secure upload token**: `application/json` with a `media_token` field obtained from `POST /secure_uploads`.

Exactly one of `file`, `url`, or `media_token` must be provided per request. Only audio files are
accepted.

Processing is asynchronous by default: the response returns immediately with `status: processing`.
Music detections are standard detections, so you can poll
[`GET /detect/{uuid}`](/api-reference/deepfake-detection/get-detection) or supply a `callback_url` to
be notified. Send the `Prefer: wait` header to block until the verdict is available and receive the
completed item in the same response. Allow a generous client timeout when waiting, since the first
request after a period of inactivity can take several minutes while the model warms up.

Each successful analysis is billed as audio Deepfake Detection usage. Failed analyses are not billed.

Reference: https://docs.resemble.ai/api-reference/music-detection/create-music-detection

## Authentication

- `Authorization` header (bearer token, required) — API key from https://app.resemble.ai/hub/api

## Request

### Headers

- `Prefer` (enum, optional) — When set to "wait", the API processes synchronously and returns the completed result.
  - Allowed values: `wait`

### Body (multipart/form-data)

This endpoint expects a multipart form containing a file.

- `file` (file, required) — The audio file to analyze. Must be 150 MB or smaller.
- `name` (string, optional) — Display name for the detection. Defaults to the source filename.
- `callback_url` (string, optional) — POST destination for the result once processing finishes. The body matches the response of `GET /detect/{uuid}`.
- `visualize` (boolean, optional) — Return a base64-encoded heatmap image in `metrics.image`.
- `start_region` (double, optional) — Start of the segment to analyze, in seconds.
- `end_region` (double, optional) — End of the segment to analyze, in seconds.

## Response

### 200

Music detection created (or completed when `Prefer: wait` was sent)

- `success` (boolean, required)
- `item` (MusicDetectItem, required)

## Errors

### 400 Bad Request Error

Invalid request: no `file`, `url`, or `media_token`; a non-audio file; a file over 150 MB; an invalid or expired `media_token`; a URL that resolves to a private address; or a malformed `callback_url`.

- `success` (boolean, optional)
- `error` (string, optional)
- `errors` (map from string to list of string, optional)
- `message` (string, optional)

### 401 Unauthorized Error

Unauthorized

- `success` (boolean, optional)
- `error` (string, optional)
- `errors` (map from string to list of string, optional)
- `message` (string, optional)

### 402 Payment Required Error

Insufficient balance for the detection.

- `success` (boolean, optional)
- `error` (string, optional)
- `errors` (map from string to list of string, optional)
- `message` (string, optional)

### 403 Forbidden Error

Audio Deepfake Detection is not included in your subscription.

- `success` (boolean, optional)
- `error` (string, optional)
- `errors` (map from string to list of string, optional)
- `message` (string, optional)

### 422 Unprocessable Entity Error

Invalid `start_region`/`end_region`, or (with `Prefer: wait`) the audio could not be decoded. The failed item is returned in `item` with `status: failed`.

- `success` (boolean, required)
- `item` (MusicDetectItem, required)

### 502 Bad Gateway Error

With `Prefer: wait`, the detection model returned an error. The failed item is returned in `item`.

- `success` (boolean, required)
- `item` (MusicDetectItem, required)

### 504 Gateway Timeout Error

With `Prefer: wait`, the detection model timed out. The failed item is returned in `item`.

- `success` (boolean, required)
- `item` (MusicDetectItem, required)

## Types

### MusicDetectItem

- `uuid` (string, required)
- `status` (enum, required) — `processing` until inference returns, `completed` once `metrics` is populated, or `failed` if the analysis errored. Failed analyses are not billed.
  - Allowed values: `processing`, `completed`, `failed`
- `media_type` (enum, required)
  - Allowed values: `audio`
- `name` (string, optional, nullable) — Display name for the detection.
- `metrics` (MusicDetectMetrics, optional) — Music detection verdict. Empty while the detection is processing or when it failed.
- `duration` (double, optional, nullable) — Duration of the submitted audio in seconds.
- `url` (string, optional, nullable) — URL to the stored audio file.
- `filename` (string, optional, nullable) — Original filename.
- `error_message` (string, optional, nullable) — Reason the analysis failed. Null unless `status` is `failed`.
- `extra_params` (MusicDetectItemExtraParams, optional) — Request metadata. Music detections always include `detector` set to `music`.
- `created_at` (datetime, optional)
- `updated_at` (datetime, optional)

### MusicDetectMetrics

Music detection verdict. Empty while the detection is processing or when it failed.

- `label` (enum, optional) — `fake` when the track is classified as AI-generated music, `real` when it is classified as human-produced.
  - Allowed values: `fake`, `real`
- `aggregated_score` (double, optional) — Overall likelihood that the track is AI-generated, from 0 to 1.
- `score` (list of double, optional) — Per-window likelihood that the audio is AI-generated, from 0 to 1. A window that could not be scored (for example, silence) is `null`.
- `duration` (double, optional) — Duration of the analyzed audio in seconds.
- `consistency` (double, optional) — How consistent the per-window scores are across the track, from 0 to 100.
- `image` (string, optional) — Base64-encoded heatmap image. Present only when `visualize` was `true`.

### MusicDetectItemExtraParams

Request metadata. Music detections always include `detector` set to `music`.

- `detector` (enum, optional)
  - Allowed values: `music`

## Examples

**Request**

```json
{
  "file": "<file: string>"
}
```

**Response**

```json
{
  "success": true,
  "item": {
    "uuid": "5b2e4d1c-8a7f-4e3b-9c6d-1f0a2b3c4d5e",
    "status": "processing",
    "media_type": "audio",
    "name": "string",
    "metrics": {
      "label": "fake",
      "aggregated_score": 0.9935,
      "score": [
        0.9975,
        0.9979,
        null,
        0.9943
      ],
      "duration": 4,
      "consistency": 97.1,
      "image": "string"
    },
    "duration": 1.1,
    "url": "string",
    "filename": "string",
    "error_message": "string",
    "extra_params": {
      "detector": "music"
    },
    "created_at": "2024-01-15T09:30:00Z",
    "updated_at": "2024-01-15T09:30:00Z"
  }
}
```

**SDK Code**

```python
import requests

url = "https://app.resemble.ai/api/v2/detect/music"

files = { "file": "open('string', 'rb')" }
payload = {
    "name": ,
    "callback_url": ,
    "visualize": ,
    "start_region": ,
    "end_region": 
}
headers = {"Authorization": "Bearer <token>"}

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

print(response.json())
```

```javascript
const url = 'https://app.resemble.ai/api/v2/detect/music';
const form = new FormData();
form.append('file', 'string');
form.append('name', '');
form.append('callback_url', '');
form.append('visualize', '');
form.append('start_region', '');
form.append('end_region', '');

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://app.resemble.ai/api/v2/detect/music"

	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=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"callback_url\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"visualize\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"start_region\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"end_region\"\r\n\r\n\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://app.resemble.ai/api/v2/detect/music")

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=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"callback_url\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"visualize\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"start_region\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"end_region\"\r\n\r\n\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://app.resemble.ai/api/v2/detect/music")
  .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=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"callback_url\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"visualize\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"start_region\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"end_region\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.resemble.ai/api/v2/detect/music', [
  'multipart' => [
    [
        'name' => 'file',
        'filename' => 'string',
        'contents' => null
    ]
  ]
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.resemble.ai/api/v2/detect/music");
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=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"callback_url\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"visualize\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"start_region\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"end_region\"\r\n\r\n\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": "name",
    "value": 
  ],
  [
    "name": "callback_url",
    "value": 
  ],
  [
    "name": "visualize",
    "value": 
  ],
  [
    "name": "start_region",
    "value": 
  ],
  [
    "name": "end_region",
    "value": 
  ]
]

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://app.resemble.ai/api/v2/detect/music")! 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()
```