AI Audio Detection API
Complete documentation for integrating TruthScan's AI audio detection API into your applications.
Try it out without code by visiting our FastAPI endpoint: https://detect-audio.truthscan.com/docs
Authentication
TruthScan uses API keys to allow access to the API. You can get your API key at the top of the page in our developer portal.
TruthScan expects for the API key to be included in all API requests to the server in a request body that looks like the following:
{
  "key": "YOUR API KEY GOES HERE"
}You must replace YOUR API KEY GOES HERE with your personal API key.
AI Audio Detector
Detect (3-Step Process)
The AI Audio Detection workflow consists of the following steps:
- Obtain a Pre-signed Upload URL
 - Upload the Audio
 - Submit the Audio for Detection
 
1. Obtain a Pre-signed Upload URL
Begin by requesting a pre-signed URL from the API. This URL allows you to securely upload your audio file to the storage server.
Supported File Formats
MP3, WAV, M4A, FLAC, OGG
Important Note
It is necessary to remove spaces from the audio filename when requesting a pre-signed URL.
GET https://detect-audio.truthscan.com/get-presigned-url?file_name=example.mp3Example Request
curl -X GET 'https://detect-audio.truthscan.com/get-presigned-url?file_name=example.mp3' \
--header 'apikey: YOUR API KEY GOES HERE'Example Response
{
  "status": "success",
  "presigned_url": "https://nyc3.digitaloceanspaces.com/ai-audio-detector-prod/uploads/581d47c7-3ef4-42af-88d9-6dab6bf69389_20250611-121955_example.mp3...",
  "file_path": "https://ai-audio-detector-prod.nyc3.digitaloceanspaces.com/uploads/581d47c7-3ef4-42af-88d9-6dab6bf69389_20250901-090201_example.mp3"
}2. Upload the Audio
Use the provided 'presigned_url' to upload your audio via a PUT request. Ensure the correct content type is set according to your audio format.
Important Note
It is necessary to remove spaces from the audio filename when uploading the audio.
Example Request
curl -X PUT 'https://nyc3.digitaloceanspaces.com/ai-audio-detector-prod/uploads/581d47c7-3ef4-42af-88d9-6dab6bf69389_20250611-121955_example.mp3...' \
  --header 'Content-Type: audio/<FILE_FORMAT - mp3, wav, m4a, flac, ogg>' \
  --header 'x-amz-acl: private' \
  --data-binary '@example.mp3' # AttachmentFile Size Limits
- Minimum file size: 1KB
 - Maximum file size: 10MB
 
Ensure that the file format remains consistent during the upload process. A successful upload will return a status code of 200.
3. Submit Audio for AI Detection
After uploading, submit the audio for AI detection by referencing the 'file_path' from the previous step.
POST https://detect-audio.truthscan.com/detectExample Request
curl -X 'POST' \
  'https://detect-audio.truthscan.com/detect' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "key": "YOUR-API-KEY-GOES-HERE",
  "url": "<FILE_PATH>",
  "document_type": "Audio",
  "analyzeUpToSeconds": 60
}'The 'FILE_PATH' refers to the path obtained from the response in the initial step, 'Obtain a Pre-signed Upload URL'.
Optional Parameters
analyzeUpToSeconds: Analyze up to N seconds from the beginning (default: 60)document_type: Type of document (default: 'Audio')email: Optional email for processing
Example Response
{
    "id": "77565038-9e3d-4e6a-8c80-e20785be5ee9",
    "status": "pending"
}The response includes a unique ID for tracking the detection status.
Query Detection Status and Results
To check the status and retrieve the results, use the /query endpoint with the ID.
POST https://detect-audio.truthscan.com/queryExample Request
curl -X 'POST' \
  'https://detect-audio.truthscan.com/query' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "id": "ID-GOES-HERE"
}'Example Response
{
    "id": "00fee5ff-a55b-42fb-b7c7-d14f05ae0769",
    "status": "done",
    "result": 0.873,
    "result_details": {
        "is_valid": true,
        "message": "processed",
        "original_duration": 123.45,
        "is_truncated": true,
        "truncated_duration": 60.0,
        "mean_ai_prob": 0.873,
        "individual_chunks_ai_prob": [0.81, 0.90, 0.91]
    }
}Result Details
is_valid: Indicates if the audio file is valid (true/false)message: Processing messageoriginal_duration: Duration in seconds of the original audiois_truncated: Whether the audio was truncated for analysistruncated_duration: Duration analyzed if truncatedmean_ai_prob: Overall AI probability scoreindividual_chunks_ai_prob: Per-chunk AI probability scores
The "status" field will be one of: "pending" (processing is queued), "analyzing" (AI detection is in progress), "done" (results are available), or "failed" (processing failed).
Check User Credits
This endpoint accepts the users apikey via the header. And returns users credit details.
GET https://detect-audio.truthscan.com/check-user-creditsExample Request
curl -X 'GET' \
  'https://detect-audio.truthscan.com/check-user-credits' \
  -H 'apikey: YOUR API KEY GOES HERE' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json'Example Response
{
    "baseCredits": 10000,
    "boostCredits": 1000,
    "credits": 11000
}Health Check
Check the health status of the API server.
GET https://detect-audio.truthscan.com/healthExample Request
curl -X 'GET' \
  'https://detect-audio.truthscan.com/health' \
  -H 'accept: application/json'Example Response
{
    "status": "healthy"
}Errors
Most errors will be from incorrect parameters being sent to the API. Double check the parameters of each API call to make sure it's properly formatted, and try running the provided example code.
The generic error codes we use conform to the REST standard:
| Error Code | Meaning | 
|---|---|
| 400 | Bad Request -- Your request is invalid. | 
| 403 | Forbidden -- The API key is invalid, or there aren't sufficient credits for audio processing. | 
| 404 | Not Found -- The specified resource doesn't exist. | 
| 405 | Method Not Allowed -- You tried to access a resource with an invalid method. | 
| 406 | Not Acceptable -- You requested a format that isn't JSON. | 
| 410 | Gone -- The resource at this endpoint has been removed. | 
| 422 | Invalid Request Body -- Your request body is formatted incorrectly or invalid or has missing parameters. | 
| 429 | Too Many Requests -- You're sending too many requests! Slow it down! | 
| 500 | Internal Server Error -- We had a problem with our server. Try again later. | 
| 503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later. | 
Common Issues and Solutions
Authentication Issues
"User verification failed" (403)
Cause: Invalid or expired API key
Solution:
- Verify your API key is correct
 - Check if your API key is active in your account
 - Try regenerating your API key
 
"Not enough credits" (403)
Cause: Insufficient credits for audio processing
Solution:
- Check your remaining credits using /check-user-credits
 - Purchase additional credits if needed
 - Use analyzeUpToSeconds to analyze less audio and consume fewer credits
 
Input Validation Issues
"Unsupported file format" (400)
Cause: Unsupported or invalid audio format submitted
Solution:
- Verify audio format is supported (MP3, WAV, M4A, FLAC, OGG)
 - Ensure the file is not corrupted
 - Check Content-Type header when uploading
 
"File too large" (400)
Cause: File size exceeds 10MB limit
Solution:
- Compress or convert the audio to under 10MB
 - Check file size before uploading
 - Use more efficient formats like MP3 when possible
 
Processing Issues
"Audio processing took too long"
Cause: Audio processing took too long or timeout occurred
Solution:
- Try with a smaller audio file or shorter duration
 - Use analyzeUpToSeconds to analyze only the first seconds
 - Check if the service is experiencing high load
 - Retry the request after a few minutes
 
Status "failed" in /query response
Cause: Processing failed for various reasons
Solution:
- Check if audio meets minimum requirements (1KB - 10MB)
 - Verify audio is in a supported format
 - Verify upload completed successfully before submitting for detection
 - Contact support if issue persists
 
Upload Issues
"Audio upload failed" (403/400)
Cause: Invalid or expired pre-signed URL, or issues with storage server
Solution:
- Ensure you use the pre-signed URL immediately after receiving it (may expire)
 - Verify Content-Type header is correct for audio format
 - Remove spaces from filename before uploading
 - Try generating a new pre-signed URL if the current one expired
 
"Invalid pre-signed URL" (400)
Cause: Filename with spaces or expired/corrupted pre-signed URL
Solution:
- Remove all spaces from filename before requesting pre-signed URL
 - Use only alphanumeric characters, hyphens and underscores in filename
 - Generate a new pre-signed URL if needed
 
Need Help?
For more information about using our API or for technical support, please contact us.
API Frequently Asked Questions
Find answers to the most common questions about our AI audio detection API.