# Spheron Upload API
> Please contact the team in the Discord if you are facing issues using this endpoint.
> Please keep in mind that Spheron API key can be only used from **Node.js environment**. Please make sure to not use it in Frontend.
## Enpoint Details
The endpoint URL for upload API is
```
https://api-v2.spheron.network/v1/deployment/upload?protocol=${protocol}&organization=${organizationId}&project=${projectName}
```
There are 3 required search param for this endpoint
- **Protocol** - You need to pass on protocol that you want to upload the files or directory to. There are 3 options to choose from - "**ipfs-filecoin**", "**ipfs-pinata**", "**arweave**"
- **Organization** - Pass the organization id from your dashboard
- **Project** - Pass any project name that you want to group the upload. If same name is passed the uploads will be aggregated to the same project name in the organisation.
### Authorization
Spheron Access Tokens are required to authenticate by passing it via Headers.
```
Authorization: Bearer <TOKEN>
```
### Form Data
To send the files to our server, you need to create a form-data request and add all the files you want to upload to the API. You can even send a nested directory by pass filepath in the form data options. Check method `fillFormData` in the example.
## Example
We have create a Javascript example of the use of upload api and how to create the form data for the Upload endpoint POST request.
```js
const fs = require("fs");
const axios = require("axios");
const FormData = require("form-data");
function fillFormData(dir, rootPath, formData) {
const files = fs.readdirSync(dir);
for (const file of files) {
const path = dir + "/" + file;
const filePath = rootPath + file;
if (fs.statSync(path).isDirectory()) {
fillFormData(path, filePath + "/", formData);
} else {
formData.append("files", fs.createReadStream(path), {
filepath: filePath,
});
}
}
}
(async function upload() {
const uploadDirectory = process.argv[2];
const protocol = process.argv[3];
const organizationId = process.argv[4];
const projectName = process.argv[5];
const token = process.argv[6];
const data = new FormData();
fillFormData(uploadDirectory, "./", data);
const response = await axios.post(
"https://api-v2.spheron.network/v1/deployment/upload?protocol=${protocol}&organization=${organizationId}&project=${projectName}",
data,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
console.log(response.data);
})();
```