Notify a device about a conversion
The device gets a notification when the conversion finishes or fails. With activity_token, the Live Activity gets the progress; without one, the server can start a Live Activity after about 15 seconds when the device has a push-to-start token.
PUT
https://api.switchfile.io/v1/conversions/{id}/pushExample
Request
curl -X PUT "https://api.switchfile.io/v1/conversions/0b8a7c1e-5d0f-4a51-9f39-2f7f4c1d9a10/push" \
-H "Authorization: Bearer $SWITCHFILE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"device_id": "b3e1f2a4-5c6d-4e7f-8a9b-0c1d2e3f4a5b"
}'const res = await fetch("https://api.switchfile.io/v1/conversions/0b8a7c1e-5d0f-4a51-9f39-2f7f4c1d9a10/push", {
method: "PUT",
headers: {
Authorization: `Bearer ${process.env.SWITCHFILE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
device_id: "b3e1f2a4-5c6d-4e7f-8a9b-0c1d2e3f4a5b"
}),
});
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/push');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode([
'device_id' => 'b3e1f2a4-5c6d-4e7f-8a9b-0c1d2e3f4a5b',
]),
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.put(
"https://api.switchfile.io/v1/conversions/0b8a7c1e-5d0f-4a51-9f39-2f7f4c1d9a10/push",
headers={"Authorization": f"Bearer {os.environ['SWITCHFILE_API_KEY']}"},
json={
"device_id": "b3e1f2a4-5c6d-4e7f-8a9b-0c1d2e3f4a5b",
},
)
res.raise_for_status()
print(res.json())Parameters
Path parameters
idstring (uuid)requiredID of the conversion
Request body
activity_tokenstring | nullAPNs token as hex
matches ^[0-9a-fA-F]{32,200}$
device_idstring (uuid)required
Responses
200OK
conversion_idstring (uuid)requireddevice_idstring (uuid)requiredlive_activitybooleanrequiredprogressstring (integer) | integerrequiredstatusstringrequiredone of "queued", "processing", "finished", "failed"
200 application/json{ "conversion_id": "0b8a7c1e-5d0f-4a51-9f39-2f7f4c1d9a10", "device_id": "b3e1f2a4-5c6d-4e7f-8a9b-0c1d2e3f4a5b", "status": "processing", "progress": 50, "live_activity": false }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 with a service key or a connected app
NOT_AVAILABLE403 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-not-available", "title": "Not available", "status": 403, "code": "NOT_AVAILABLE", "detail": "This endpoint is only available with your own API key or the switchfile app." }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": "Not found." }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." }