# Uploading File To Model Using Write API

**URL:** <https://forum.builder.io/t/uploading-file-to-model-using-write-api/4579>\
**Category:** Technical Questions\
**Tags:** api\
**Created:** [November 30, 2023, 5:17pm UTC](https://forum.builder.io/t/uploading-file-to-model-using-write-api/4579 "2023-11-30T17:17:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![doom\_slayer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/doom_slayer/32/4664_2.png) [@doom\_slayer](https://forum.builder.io/u/doom_slayer)\
**Post date:** [November 30, 2023, 5:17pm UTC](https://forum.builder.io/t/uploading-file-to-model-using-write-api/4579/1 "2023-11-30T17:17:57Z")

</div>

**What are you trying to accomplish**  
I want to upload images when creating new model using the Write API

**Code stack you are integrating Builder with**  
API

Is it possible to upload an image directly to model using the Write API? I am not seeing any documentation to see if this is possible.

Thank you.

---

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [November 30, 2023, 6:08pm UTC](https://forum.builder.io/t/uploading-file-to-model-using-write-api/4579/2 "2023-11-30T18:08:15Z")

</div>

Hello @doom_slayer,

You can certainly use **Write API** to upload images

Here is an example

```auto
const fetch = require("node-fetch");
var myHeaders = new fetch.Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer bpk-Your-private-key");

var raw = JSON.stringify({
  "ownerId": "space-id",
  "@version": 3,
  "name": "Facebook Inc",
  "modelId": "model-id",
  "published": "draft",
  "query": [],
  "data": {
    "name": "Facebook",
    "displayName": "fa",
    "logo": "https://cdn.builder.io/api/v1/image/assets%2Fc782aff3c66f48acb425981b997feb10%2F9f2120fe81ff444084dc2819d73f07fb"
  }
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://builder.io/api/v1/write/companies", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

```

If you are looking to upload default images for file fields while creating a model then you might need to use [Admin API](https://www.builder.io/c/docs/admin-graphql-api).

You may also check [Upload API - Builder.io](https://www.builder.io/c/docs/upload-api)

Hope this helps!

---

<div class="post-metadata">

**Author:** ![doom\_slayer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/doom_slayer/32/4664_2.png) [@doom\_slayer](https://forum.builder.io/u/doom_slayer)\
**Post date:** [November 30, 2023, 6:22pm UTC](https://forum.builder.io/t/uploading-file-to-model-using-write-api/4579/3 "2023-11-30T18:22:01Z")

</div>

Ohh okay. So I would upload the file first using the Upload API, then assign the file url to the model?

---

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [November 30, 2023, 6:24pm UTC](https://forum.builder.io/t/uploading-file-to-model-using-write-api/4579/4 "2023-11-30T18:24:19Z")

</div>

Hello @doom_slayer,

That’s right, you can also use an external image URL to upload the images.

> [@Using Upload API](https://forum.builder.io/t/using-upload-api/3482):
>
> The upload API lets you upload files, such as images and videos, to be used within Builder. A sample node js fetch code: const fetch = require("node-fetch"); const fs = require('fs'); function upload\_image(file) { // read binary data var bitmap = fs.readFileSync(file); fetch("https://builder.io/api/v1/upload", { method: "POST", body: bitmap, headers: { "Authorization": "Bearer builder-private-key", "Content-Type": "image/jpeg" }, }).then(res =\> { return …
