Zum Hauptinhalt springen
POST
/
v2
/
apps
/
{app_id}
/
snapshots
Snapshot erstellen
curl --request POST \
  --url https://api.squarecloud.app/v2/apps/{app_id}/snapshots \
  --header 'Authorization: <authorization>'
import requests

url = "https://api.squarecloud.app/v2/apps/{app_id}/snapshots"

headers = {"Authorization": "<authorization>"}

response = requests.post(url, headers=headers)

print(response.text)
const options = {method: 'POST', headers: {Authorization: '<authorization>'}};

fetch('https://api.squarecloud.app/v2/apps/{app_id}/snapshots', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.squarecloud.app/v2/apps/{app_id}/snapshots",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://api.squarecloud.app/v2/apps/{app_id}/snapshots"

req, _ := http.NewRequest("POST", url, nil)

req.Header.Add("Authorization", "<authorization>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.squarecloud.app/v2/apps/{app_id}/snapshots")
.header("Authorization", "<authorization>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.squarecloud.app/v2/apps/{app_id}/snapshots")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'

response = http.request(request)
puts response.read_body
{
    "status": "success",
    "response": {
        "url": "https://snapshots.squarecloud.app/applications/23457145698959364/a23d130fcc9ddaf2d288ae9599a4292c32.zip?AWSAccessKeyId=i06Xdad2dRD74Pm8Xly&Expires=1753081182&Signature=riWPedawcsouRAPGU5n3kGHnWoOuw%3D",
        "key": "AWSAccessKeyId=i06Xdad2dRD74Pm8Xly&Expires=1753081182&Signature=riWPedawcsouRAPGU5n3kGHnWoOuw%3D"
    }
}
{
  "status": "error",
  "code": "SNAPSHOT_PROCESSING"
}
{
  "status": "error",
  "code": "KEEP_CALM",
  "message": "You already requested a snapshot recently. Please wait a minute before trying again. 1r/5s"
}
{
  "status": "error",
  "code": "DAILY_SNAPSHOTS_LIMIT_REACHED",
  "message": "You are being rate limited for daily snapshots. 8r/24h"
}
Jedes Konto kann bis zu (RAM / 256) * 2 Snapshots alle 24 Stunden erstellen.
Authorization
string
erforderlich
Der API-Schlüssel für Ihr Konto. Sie finden ihn in Ihren Kontoeinstellungen.

Parameter

app_id
string
erforderlich
Die ID der Anwendung. Du findest sie in der URL des Dashboards deiner Anwendung.

Verhalten bei Soft-Deadline

Diese Route folgt einem Soft-Deadline-Modell — sie antwortet nicht mehr immer synchron.
  • Wird der Snapshot innerhalb von ~90 Sekunden fertiggestellt, antwortet die Route mit 200 success und einer signierten Download-URL (30 Tage gültig), genau wie zuvor.
  • Dauert die Erstellung des Snapshots länger als ~90 Sekunden, antwortet die Route sofort mit 202 und dem Code SNAPSHOT_PROCESSING. Das ist kein Fehler. Der Snapshot wird im Hintergrund weiter erstellt und erscheint von selbst in der Snapshot-Auflistung, typischerweise innerhalb von ~2 Minuten. Dies ist erwartetes Verhalten für große Anwendungen.
Verwende diesen POST-Endpoint nicht als Polling-Mechanismus. Um zu prüfen, ob ein Snapshot mit SNAPSHOT_PROCESSING abgeschlossen ist, verwende den Endpoint Snapshots auflisten (GET) — nicht einen weiteren POST. Ein erneuter POST nach Abschluss des Snapshots startet einen komplett neuen Snapshot von Grund auf.
Der Client sollte anhand der Antwort wie folgt verzweigen:
AntwortBedeutungWas zu tun ist
status === "success"Snapshot ist bereit.Verwende die url, um ihn herunterzuladen.
status === "error" und code === "SNAPSHOT_PROCESSING"Snapshot wird noch erstellt.Warte ~2 Minuten und bestätige dann über Snapshots auflisten (GET). Führe keinen erneuten POST aus.
status === "error" mit einem anderen codeTatsächlicher Fehler.Behandle den Fehler (siehe unten).

Antwort

status
string
Gibt an, ob der Aufruf erfolgreich war. success bei Erfolg, error andernfalls.
response
object
Der Inhalt der Antwort. Nur vorhanden, wenn status gleich success ist.
SNAPSHOT_PROCESSING
202
Wird zurückgegeben, wenn der Snapshot die Soft-Deadline von ~90 Sekunden überschreitet. Der Snapshot wird weiterhin im Hintergrund erstellt und erscheint von selbst in der Snapshot-Auflistung, typischerweise innerhalb von ~2 Minuten. Kein Fehler — warte und bestätige über den GET-Auflistungsendpoint.

Fehler

Eine Snapshot-Anfrage kann mit 429 Too Many Requests abgelehnt werden. Verwende das Feld code, um die beiden Fälle zu unterscheiden:
KEEP_CALM
429
Kurzfristige Abkühlphase — du hast das Limit pro Nutzer (1 Anfrage / 5 s) oder pro Anwendung (1 Anfrage / 180 s) erreicht. Warte kurz und versuche es erneut.
DAILY_SNAPSHOTS_LIMIT_REACHED
429
Tageskontingent erreicht — das Konto hat das tägliche Snapshot-Kontingent seines Tarifs aufgebraucht ((RAM / 256) × 2 pro 24 h). Das Kontingent wird wieder frei, während das gleitende 24-Stunden-Fenster fortschreitet; für ein höheres Tageskontingent upgrade den Tarif.
{
    "status": "success",
    "response": {
        "url": "https://snapshots.squarecloud.app/applications/23457145698959364/a23d130fcc9ddaf2d288ae9599a4292c32.zip?AWSAccessKeyId=i06Xdad2dRD74Pm8Xly&Expires=1753081182&Signature=riWPedawcsouRAPGU5n3kGHnWoOuw%3D",
        "key": "AWSAccessKeyId=i06Xdad2dRD74Pm8Xly&Expires=1753081182&Signature=riWPedawcsouRAPGU5n3kGHnWoOuw%3D"
    }
}
{
  "status": "error",
  "code": "SNAPSHOT_PROCESSING"
}
{
  "status": "error",
  "code": "KEEP_CALM",
  "message": "You already requested a snapshot recently. Please wait a minute before trying again. 1r/5s"
}
{
  "status": "error",
  "code": "DAILY_SNAPSHOTS_LIMIT_REACHED",
  "message": "You are being rate limited for daily snapshots. 8r/24h"
}