> ## Documentation Index
> Fetch the complete documentation index at: https://docs.squarecloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Blob Object Post

> Diese Dokumentation bietet einen umfassenden Überblick über den Endpoint POST /v1/objects der SquareCloud Blob API.

<ParamField header="Authorization" type="string" placeholder="API Key" required>
  Der API-Schlüssel für Ihr Konto. Sie finden ihn in Ihren [Kontoeinstellungen](https://squarecloud.app/de/account/security).
</ParamField>

<ParamField body="file" type="file" placeholder="myphone.png" required>
  Verwende FormData. (multipart/form-data)
</ParamField>

<ParamField query="name" type="string" placeholder="File Name" required>
  Eine Zeichenkette, die den Namen der Datei darstellt. (ohne Erweiterung)<br />Muss dem Muster a bis z, A bis Z, 0 bis 9 und \_ entsprechen. (3 bis 32 Zeichen)
</ParamField>

<ParamField query="prefix" type="string" placeholder="File Prefix">
  Eine Zeichenkette, die das Präfix der Datei darstellt.<br />Muss dem Muster a bis z, A bis Z, 0 bis 9 und \_ entsprechen. (3 bis 32 Zeichen)
</ParamField>

<ParamField query="expire" type="number" placeholder="Expiration (days)">
  Eine Zahl, die die Ablaufdauer der Datei angibt, im Bereich von 1 bis 365 Tagen.
</ParamField>

<ParamField query="security_hash" type="boolean" placeholder="Security Hash">
  Auf true setzen, wenn ein Sicherheits-Hash erforderlich ist.
</ParamField>

<ParamField query="auto_download" type="boolean" placeholder="Auto Download">
  Auf true setzen, wenn die Datei für automatischen Download vorgesehen werden soll.
</ParamField>

### Rate Limits & Nebenläufigkeit

<Note>
  Das Hochladen erfordert einen kostenpflichtigen Plan.

  * **Hobby**- und **Standard**-Pläne sind auf **1 Upload pro Sekunde** beschränkt.
  * **Pro**- und **Enterprise**-Pläne unterliegen **nicht** dem Limit pro Sekunde — sie können stattdessen bis zu **4 Uploads gleichzeitig** ausführen.

  Über alle kostenpflichtigen Pläne hinweg darf ein Konto höchstens **4 Uploads gleichzeitig in Bearbeitung** haben. Das Starten eines weiteren Uploads, während noch 4 laufen, liefert `TOO_MANY_CONCURRENT_UPLOADS` (429) zurück.
</Note>

<Info>
  Aus Sicherheitsgründen werden `.html`- und `.svg`-Dateien immer als Download ausgeliefert (als `application/octet-stream` bereitgestellt), anstatt inline gerendert zu werden.
</Info>

### Response

<ResponseField name="status" type="string">
  Gibt an, ob der Aufruf erfolgreich war. "success" bei Erfolg, "error" andernfalls.
</ResponseField>

<ResponseField name="response" type="object">
  <Expandable title="Objekt ein-/ausblenden">
    <ResponseField name="id" type="string">
      Die ID der hochgeladenen Datei.
    </ResponseField>

    <ResponseField name="name" type="string">
      Der Name der hochgeladenen Datei.
    </ResponseField>

    <ResponseField name="prefix" type="string">
      Das Präfix, unter dem die Datei gespeichert wurde (aus dem `prefix`-Query gespiegelt; entfällt, wenn keines gesendet wurde).
    </ResponseField>

    <ResponseField name="size" type="number">
      Die Größe der hochgeladenen Datei, in Bytes.
    </ResponseField>

    <ResponseField name="url" type="string">
      Die URL der hochgeladenen Datei. (Datei über das Square Cloud CDN verteilt)
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://blob.squarecloud.app/v1/objects?name=myfile&prefix=images&expire=30' \
    --header 'Authorization: YOUR_API_KEY' \
    --form 'file=@./myphone.png'
  ```

  ```javascript JavaScript theme={null}
  import fs from 'node:fs';

  const form = new FormData();
  form.append('file', new Blob([fs.readFileSync('./myphone.png')]), 'myphone.png');

  const params = new URLSearchParams({
    name: 'myfile',
    prefix: 'images',
    expire: '30',
  });

  const response = await fetch(`https://blob.squarecloud.app/v1/objects?${params}`, {
    method: 'POST',
    headers: { Authorization: 'YOUR_API_KEY' },
    body: form,
  });
  ```

  ```python Python theme={null}
  import requests

  with open('myphone.png', 'rb') as f:
      response = requests.post(
          'https://blob.squarecloud.app/v1/objects',
          headers={'Authorization': 'YOUR_API_KEY'},
          params={'name': 'myfile', 'prefix': 'images', 'expire': 30},
          files={'file': ('myphone.png', f, 'image/png')},
      )
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
      "status": "success",
      "response": {
          "id": "3155597145698959364/images/test_lxch4k7y-07ee.png",
          "name": "test",
          "prefix": "images",
          "size": 416230,
          "url": "https://public-blob.squarecloud.dev/3155597145698959364/images/test_lxch4k7y-07ee.png"
      }
  }
  ```
</ResponseExample>

### Fehlerbehebung

<Tabs>
  <Tab title="400 Status Code">
    ### Objektbezogen

    <CodeGroup>
      ```json NAME theme={null}
      // The provided object name is invalid.
      // Must adhere to the a to z, A to Z, 0 to 9, and _ pattern.
      {
          "status": "error",
          "code": "INVALID_OBJECT_NAME"
      }
      ```

      ```json PREFIX theme={null}
      // The provided object prefix is invalid.
      // Must adhere to the a to z, A to Z, 0 to 9, and _ pattern.
      {
          "status": "error",
          "code": "INVALID_OBJECT_PREFIX"
      }
      ```

      ```json EXPIRE theme={null}
      // The provided expiration value for the object is invalid.
      // Must be a number ranging from 1 to 365. (value in days).
      {
          "status": "error",
          "code": "INVALID_OBJECT_EXPIRE"
      }
      ```

      ```json SECURITY_HASH theme={null}
      // The provided security hash boolean is invalid.
      // Just set to true or false. 😅
      {
          "status": "error",
          "code": "INVALID_OBJECT_SECURITY_HASH"
      }
      ```

      ```json AUTO_DOWNLOAD theme={null}
      // The provided auto-download boolean is invalid.
      // Just set to true or false. 😅
      {
          "status": "error",
          "code": "INVALID_STORAGE_AUTO_DOWNLOAD"
      }
      ```
    </CodeGroup>

    ### Dateibezogen

    <Info>Die aktuelle maximale Dateigröße beträgt 100MB. Zukünftig planen wir, sie auf 10GB zu erhöhen. Vorerst liegt das Limit aufgrund technischer und lastverteilungsbedingter Beschränkungen bei 100MB.</Info>

    <CodeGroup>
      ```json INVALID_FILE theme={null}
      // The provided file is invalid.
      {
          "status": "error",
          "code": "INVALID_FILE"
      }
      ```

      ```json FILETYPE theme={null}
      // The provided file type is invalid.
      {
          "status": "error",
          "code": "INVALID_FILETYPE"
      }
      ```

      ```json FILE_TOO_SMALL theme={null}
      // The file size is too small (< 1kb).
      {
          "status": "error",
          "code": "FILE_TOO_SMALL"
      }
      ```
    </CodeGroup>
  </Tab>

  <Tab title="401 Status Code">
    ### Nicht autorisiert

    <CodeGroup>
      ```json ACCESS_DENIED theme={null}
      // The API key is missing or invalid. Set a valid key in the Authorization header.
      // Also returned when the account is on the free plan — uploading requires a paid plan.
      {
          "status": "error",
          "code": "ACCESS_DENIED"
      }
      ```
    </CodeGroup>
  </Tab>

  <Tab title="403 Status Code">
    ### Speicherkontingent überschritten

    <CodeGroup>
      ```json STORAGE_QUOTA_EXCEEDED theme={null}
      // You have exceeded your storage quota. Delete some files or upgrade your plan.
      {
          "status": "error",
          "code": "STORAGE_QUOTA_EXCEEDED"
      }
      ```
    </CodeGroup>
  </Tab>

  <Tab title="409 Status Code">
    ### Ungültiger Content-Type

    <CodeGroup>
      ```json INVALID_CONTENT_TYPE theme={null}
      // This route only accepts multipart/form-data requests.
      {
          "status": "error",
          "code": "INVALID_CONTENT_TYPE"
      }
      ```
    </CodeGroup>
  </Tab>

  <Tab title="413 Status Code">
    ### Payload zu groß

    <Info>Die aktuelle maximale Dateigröße beträgt 100MB.</Info>

    <CodeGroup>
      ```json PAYLOAD_TOO_LARGE theme={null}
      // The uploaded file exceeds the maximum allowed size of 100 MB.
      {
          "status": "error",
          "code": "PAYLOAD_TOO_LARGE"
      }
      ```
    </CodeGroup>
  </Tab>

  <Tab title="429 Status Code">
    ### Rate-limitiert

    <CodeGroup>
      ```json RATELIMIT theme={null}
      // Per-second upload limit reached (Hobby/Standard: max 1 upload per second).
      {
          "status": "error",
          "code": "RATELIMIT"
      }
      ```

      ```json TOO_MANY_CONCURRENT_UPLOADS theme={null}
      // Too many simultaneous uploads (max 4 in progress at a time per account).
      {
          "status": "error",
          "code": "TOO_MANY_CONCURRENT_UPLOADS"
      }
      ```
    </CodeGroup>
  </Tab>

  <Tab title="500 Status Code">
    ### Upload fehlgeschlagen

    <CodeGroup>
      ```json UPLOAD_FAILED theme={null}
      // Failed to upload object to storage. Please try again later.
      {
          "status": "error",
          "code": "UPLOAD_FAILED"
      }
      ```
    </CodeGroup>
  </Tab>
</Tabs>
