Prepare an App Store purchase
The products and the token to pass as appAccountToken.
GET
https://api.switchfile.io/v1/account/app-storeExample
Request
curl "https://api.switchfile.io/v1/account/app-store" \
-H "Authorization: Bearer $SWITCHFILE_API_KEY"const res = await fetch("https://api.switchfile.io/v1/account/app-store", {
headers: {
Authorization: `Bearer ${process.env.SWITCHFILE_API_KEY}`,
},
});
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/account/app-store');
curl_setopt_array($ch, [
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SWITCHFILE_API_KEY'),
],
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.get(
"https://api.switchfile.io/v1/account/app-store",
headers={"Authorization": f"Bearer {os.environ['SWITCHFILE_API_KEY']}"},
)
res.raise_for_status()
print(res.json())Responses
200OK
app_account_tokenstring (uuid)requiredPass as appAccountToken with every purchase; only then the purchase can be added to this account
productsobject[]requiredproducts[].creditsstring (integer) | integerrequiredproducts[].product_idstringrequired
200 application/json{ "app_account_token": "6f1c2a9e-3b4d-4e8f-9a0b-1c2d3e4f5a6b", "products": [ { "product_id": "io.switchfile.app.credits250", "credits": 250 }, { "product_id": "io.switchfile.app.credits1000", "credits": 1000 } ] }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." }