Developer API documentation
Submit text or documents from your server, retrieve the result, and reconcile each charge in website credits.
Quick start
Create a key in the developer center. The secret appears once. Store it in the TURNIN_API_KEY environment variable on your server. These examples use Bash, curl and jq.
BASE="${TURNIN_BASE:-https://www.turnitins.org/api/v1/developer}"
AUTH="Authorization: Bearer ${TURNIN_API_KEY:?Set TURNIN_API_KEY on your server}"
curl --fail-with-body -sS "$BASE/catalog"
curl --fail-with-body -sS -H "$AUTH" "$BASE/whoami"Get a free quote. The reserved_credits field gives the maximum reservation for the job.
BODY='{"task":"ai_detect","text":"We recorded the soil temperature every morning. The second plot stayed cooler for most of the week."}'
QUOTE=$(curl --fail-with-body -sS -H "$AUTH" -H 'Content-Type: application/json' \
--data "$BODY" "$BASE/quote") || exit 1
LIMIT=$(jq -er '.quote.reserved_credits' <<<"$QUOTE") || exit 1
echo "$LIMIT"Generate and save one UUID per logical operation and set RUN_KEY to it. Send the quote as max_credits to reject a reservation above the amount you accepted.
# RUN_KEY is the ID your application stores for this operation.
: "${RUN_KEY:?Set RUN_KEY to a saved UUID for this job}"
REQUEST=$(curl --fail-with-body -sS -H "$AUTH" -H 'Content-Type: application/json' \
-H "Idempotency-Key: $RUN_KEY" \
--data "$(jq -c --argjson n "$LIMIT" '. + {max_credits:$n}' <<<"$BODY")" \
"$BASE/execute") || exit 1
ID=$(jq -er '.request.id' <<<"$REQUEST") || exit 1Poll the returned id. A pending job is in progress. Read result and charged_credits on success, or error_code on failure. Successful AI detection jobs also have a downloadable PDF.
while true; do
RECEIPT=$(curl --fail-with-body -sS -H "$AUTH" "$BASE/requests/$ID") || exit 1
case "$(jq -r '.request.status' <<<"$RECEIPT")" in
succeeded) jq '.request | {charged_credits, result}' <<<"$RECEIPT"; break ;;
failed) jq '.request | {error_code, charged_credits}' <<<"$RECEIPT"; exit 1 ;;
pending) sleep 3 ;;
*) exit 1 ;;
esac
done
curl --fail-with-body -sS -H "$AUTH" "$BASE/requests/$ID/report.pdf" -o ai-report.pdfAvailable tasks
- English AI text detection with sentence predictions and a summary
ai_detect- Grammar correction, paraphrasing and chat
grammarparaphrasechat- Problem solving, tutoring and text evaluation
solvertutorpaper_evaluation- Standard, advanced and expert AI reduction
reduce_standardreduce_advancedreduce_expert
Each text job accepts up to 32 KiB of UTF-8 text. AI detection needs at least 30 characters and a readable English sentence. Similarity checking is currently unavailable. The PDF contains TurnDetect AI predictions.
Pricing and settlement
The API uses the website credit balance of the account that owns the key. Multiply cost by one plus the markup, divide by the CNY value of one credit, and round up. A successful paid job costs at least one credit. The default markup is 20%. See catalog for current settings.
Model jobs use separate input and output token rates and the configured USD/CNY conversion. Execution reserves credits, then refunds the difference after settlement. Missing upstream usage is estimated from text. The charge is capped at the accepted reservation.
AI detection uses an estimated local compute cost per thousand billing words. Each reduction mode uses a configured all-in cost, excluding references from the editable body. A missing tariff prevents a new reservation.
Failed jobs release the entire reservation. Quotes, status checks, extraction and report downloads are free. See your balance, reservations and settled charges in the developer center.
Documents and reports
Send raw file bytes to extract. A file can be up to 4 MiB. TXT, DOCX and text-based PDFs are supported. PDF extraction reads up to 80 pages. Extraction returns up to about 120,000 characters. Review the text and quote longer documents in sections.
Use application/vnd.openxmlformats-officedocument.wordprocessingml.document for DOCX or text/plain for TXT. Read text and truncated from the response.
curl --fail-with-body -sS -H "$AUTH" -H 'Content-Type: application/pdf' \
--data-binary @paper.pdf "$BASE/extract" > extracted.json
jq '{task:"ai_detect", text:.text}' extracted.jsonEndpoints
All paths start with /api/v1/developer. The catalog is public. The other endpoints require the Authorization: Bearer header. The OpenAPI file includes request and response schemas.
GET /catalog- List tasks and effective pricing settings
GET /whoami- Verify a key and retrieve its owner
POST /extract- Extract text from a TXT, DOCX or PDF file
POST /quote- Quote a job in website credits
POST /execute- Reserve credits and submit or replay a job
GET /requests/{id}- Read job status, result and settled credits
GET /requests/{id}/report.pdf- Download a completed AI detection report
Errors and retries
After a disconnect, timeout or unknown response, retry with the same Idempotency-Key, task and original text to retrieve the same job. Use a new key for a new logical operation or different text.
- 400
- Check the task, text length and idempotency key (16–128 letters, digits, underscores or hyphens).
- 401
- Check whether the key is valid or revoked.
- 402
- Insufficient website credits. Top up and retry with the same key.
- 403
- The feature is disabled or the request origin was rejected.
- 404
- Unknown request or different owner.
- 409
- The key belongs to another payload, the quote exceeds your cap, or the report is unavailable.
- 413 / 415 / 422
- Check file size, media type and readable text.
- 429
- Concurrency or rate limit reached. Back off and preserve the key.
- 503
- Pricing or service unavailable. Inspect the code and request a fresh quote.