Rate a conversion
Good or bad, with optional reasons. Rating again replaces the earlier rating. The file itself is not kept for the rating.
POST
https://api.switchfile.io/v1/conversions/{id}/ratingExample
Request
curl "https://api.switchfile.io/v1/conversions/0b8a7c1e-5d0f-4a51-9f39-2f7f4c1d9a10/rating" \
-H "Authorization: Bearer $SWITCHFILE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"good": false,
"reasons": [
"layout"
]
}'const res = await fetch("https://api.switchfile.io/v1/conversions/0b8a7c1e-5d0f-4a51-9f39-2f7f4c1d9a10/rating", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.SWITCHFILE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
good: false,
reasons: [
"layout"
]
}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
console.log(await res.json());<?php
$ch = curl_init('https://api.switchfile.io/v1/conversions/0b8a7c1e-5d0f-4a51-9f39-2f7f4c1d9a10/rating');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode([
'good' => false,
'reasons' => [
'layout',
],
]),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SWITCHFILE_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
if ($status >= 400) {
throw new RuntimeException("HTTP $status: $response");
}
print_r(json_decode($response, true));import os
import requests
res = requests.post(
"https://api.switchfile.io/v1/conversions/0b8a7c1e-5d0f-4a51-9f39-2f7f4c1d9a10/rating",
headers={"Authorization": f"Bearer {os.environ['SWITCHFILE_API_KEY']}"},
json={
"good": False,
"reasons": [
"layout",
],
},
)
res.raise_for_status()
print(res.json())Parameters
Path parameters
idstring (uuid)requiredID of the conversion
Request body
goodbooleanrequiredreasonsstring[]Short keys like layout or text, or failed:<error code>
at most 10 items
Responses
200OK
conversion_idstring (uuid)requiredgoodbooleanrequiredidstring (uuid)requiredreasonsstring[]required
200 application/json{ "id": "4d2c9a7e-1f3b-4e8a-9c6d-5b0a7f2e1c3d", "conversion_id": "0b8a7c1e-5d0f-4a51-9f39-2f7f4c1d9a10", "good": false, "reasons": [ "layout" ] }401The API key is missing or not valid
UNAUTHENTICATED401 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-unauthenticated", "title": "Unauthenticated", "status": 401, "code": "UNAUTHENTICATED", "detail": "Missing or invalid API key." }403Not available without an account, or with a connected app
SIGN_IN_REQUIRED403 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-sign-in-required", "title": "Sign in required", "status": 403, "code": "SIGN_IN_REQUIRED", "detail": "Sign in to use this." }404Does not exist for this account
NOT_FOUND404 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-not-found", "title": "Not found", "status": 404, "code": "NOT_FOUND", "detail": "Conversion not found." }409The conversion is still running
CONVERSION_NOT_FINISHED409 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-conversion-not-finished", "title": "Conversion not finished", "status": 409, "code": "CONVERSION_NOT_FINISHED", "detail": "Rate the conversion once it has finished." }422Invalid data. errors names the fields
INVALID_DATA422 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-invalid-data", "title": "Invalid data", "status": 422, "code": "INVALID_DATA", "detail": "The request contains invalid data.", "errors": { "to": [ "Expected string" ] } }429Too many requests or a daily quota is used up. See Retry-After
RATE_LIMIT_EXCEEDED429 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-rate-limit-exceeded", "title": "Rate limit exceeded", "status": 429, "code": "RATE_LIMIT_EXCEEDED", "detail": "Too many requests. Try again in 12 seconds." }