API ReferenceStorage APIPOST /upload

POST /storage/upload

Uploads a file (currently supports images) to the project’s storage. Returns a media ID that can be used to link the file to other resources, such as a user avatar.

⚠️

Authentication required. You must send a valid JWT: Authorization: Bearer <token>

Endpoint

POST /api/v1/public/projects/:projectSlug/storage/upload

Request Parameters

Path Parameters

ParameterTypeRequiredDescription
projectSlugstringYour project’s unique slug

Headers

HeaderRequiredDescription
AuthorizationBearer <jwt-token>
Content-Typemultipart/form-data

Body (Multipart Form Data)

FieldTypeRequiredDescription
fileFileThe file to upload (Max 5MB, Images only)

Response

Success (201 Created)

{
  "id": "725365d7-21fc-45eb-b6ec-8390f0a438d1",
  "url": "/api/v1/public/projects/my-project/storage/725365d7-21fc-45eb-b6ec-8390f0a438d1/file",
  "filename": "avatar.jpg",
  "mime_type": "image/jpeg",
  "size": 177382
}
FieldTypeDescription
idstringImportant: The Media ID. Use this ID to link the file to other resources (e.g., updating user avatar).
urlstringPublic URL to access the file
filenamestringOriginal filename
mime_typestringFile MIME type
sizenumberFile size in bytes

Error Responses

Status CodeError CodeDescription
400BAD_REQUESTNo file uploaded, invalid type, or size limit exceeded
401UNAUTHORIZEDMissing or invalid token
429RATE_LIMIT_EXCEEDEDToo many uploads

Usage Example

Javascript (FormData)

const formData = new FormData();
formData.append('file', fileInput.files[0]);
 
const response = await fetch('https://api.aerostack.dev/api/v1/public/projects/my-project/storage/upload', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`
    // Note: Do NOT set Content-Type header manually when using FormData, 
    // the browser will set it with the correct boundary.
  },
  body: formData
});
 
const data = await response.json();
console.log('Uploaded File ID:', data.id);