> ## 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

> Cette documentation fournit une vue d'ensemble complète de l'endpoint POST /v1/objects de l'API Blob de SquareCloud.

<ParamField header="Authorization" type="string" placeholder="API Key" required>
  La clé d'API de votre compte. Vous pouvez la trouver dans les [paramètres de votre compte](https://squarecloud.app/fr/account/security).
</ParamField>

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

<ParamField query="name" type="string" placeholder="File Name" required>
  Une chaîne représentant le nom du fichier. (sans extension)<br />Doit respecter le motif a à z, A à Z, 0 à 9 et \_. (3 à 32 caractères)
</ParamField>

<ParamField query="prefix" type="string" placeholder="File Prefix">
  Une chaîne représentant le préfixe du fichier.<br />Doit respecter le motif a à z, A à Z, 0 à 9 et \_. (3 à 32 caractères)
</ParamField>

<ParamField query="expire" type="number" placeholder="Expiration (days)">
  Un nombre indiquant la période d'expiration du fichier, comprise entre 1 et 365 jours.
</ParamField>

<ParamField query="security_hash" type="boolean" placeholder="Security Hash">
  Définissez sur true si un hash de sécurité est requis.
</ParamField>

<ParamField query="auto_download" type="boolean" placeholder="Auto Download">
  Définissez sur true si le fichier doit être configuré pour un téléchargement automatique.
</ParamField>

### Limites de débit et concurrence

<Note>
  L'upload nécessite un plan payant.

  * Les plans **Hobby** et **Standard** sont limités à **1 upload par seconde**.
  * Les plans **Pro** et **Enterprise** ne sont **pas** soumis à la limite par seconde — ils peuvent en revanche exécuter jusqu'à **4 uploads simultanés**.

  Sur l'ensemble des plans payants, un compte peut avoir au plus **4 uploads en cours simultanément**. Démarrer un autre upload alors que 4 sont encore en cours renvoie `TOO_MANY_CONCURRENT_UPLOADS` (429).
</Note>

<Info>
  Pour des raisons de sécurité, les fichiers `.html` et `.svg` sont toujours délivrés en tant que téléchargements (servis en `application/octet-stream`) au lieu d'être rendus en ligne.
</Info>

### Réponse

<ResponseField name="status" type="string">
  Indique si l'appel a réussi. "success" en cas de succès, "error" sinon.
</ResponseField>

<ResponseField name="response" type="object">
  <Expandable title="Afficher l'objet">
    <ResponseField name="id" type="string">
      L'ID du fichier uploadé.
    </ResponseField>

    <ResponseField name="name" type="string">
      Le nom du fichier uploadé.
    </ResponseField>

    <ResponseField name="prefix" type="string">
      Le préfixe sous lequel le fichier a été stocké (renvoyé à partir du paramètre `prefix` ; omis lorsqu'aucun n'a été envoyé).
    </ResponseField>

    <ResponseField name="size" type="number">
      La taille du fichier uploadé, en octets.
    </ResponseField>

    <ResponseField name="url" type="string">
      L'URL du fichier uploadé. (Fichier distribué sur le CDN de Square Cloud)
    </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>

### Dépannage

<Tabs>
  <Tab title="Code de statut 400">
    ### Lié à l'objet

    <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>

    ### Lié au fichier

    <Info>La taille maximale actuelle des fichiers est de 100 Mo. À l'avenir, nous prévoyons de l'augmenter à 10 Go. Pour l'instant, la limite est de 100 Mo en raison de contraintes techniques et de répartition de charge.</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="Code de statut 401">
    ### Non autorisé

    <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="Code de statut 403">
    ### Quota de stockage dépassé

    <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="Code de statut 409">
    ### Type de contenu invalide

    <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="Code de statut 413">
    ### Charge utile trop volumineuse

    <Info>La taille maximale actuelle des fichiers est de 100 Mo.</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="Code de statut 429">
    ### Débit limité

    <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="Code de statut 500">
    ### Échec de l'upload

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