# Using SilverBullet APIs to update/add to a page

**URL:** https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397
**Category:** General
**Created:** [April 23, 2024, 8:29am UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397 "2024-04-23T08:29:45Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![daveb](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/d/b5a626/32.png) [@daveb](https://community.silverbullet.md/u/daveb)
#### Post date: [April 23, 2024, 8:29am UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/1 "2024-04-23T08:29:45Z")

</div>

I’ve looked at the API page in SilverBullet and, although I’m comfortable with APIs, I’m confused on how to use the SilverBullet API. I would assume a PUT to to add content to [index.md](http://index.md) would look something like

```auto
curl --location --request PUT 'http://192.168.86.43:3000/index.md' \
--header 'Content-Type: text/plain' \
--data ' **TEST**'

```

Is this correct? How would I authorize this? Thanks for any help! Dave

---

<div class="post-metadata">

### Author: ![stephen](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@stephen](https://community.silverbullet.md/u/stephen)
#### Post date: [April 23, 2024, 9:17pm UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/2 "2024-04-23T21:17:26Z")

</div>

I am also interested. Maybe especially how to **append** to a file.  
It would be nice, to build a small quick-capture app in android which can be a share target for other apps as well

---

<div class="post-metadata">

### Author: ![daveb](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/d/b5a626/32.png) [@daveb](https://community.silverbullet.md/u/daveb)
#### Post date: [April 23, 2024, 10:55pm UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/3 "2024-04-23T22:55:23Z")

</div>

A quick capture app would be great. I was thinking of a web clipper extension for browsers.

---

<div class="post-metadata">

### Author: ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)
#### Post date: [April 24, 2024, 4:46am UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/4 "2024-04-24T04:46:59Z")

</div>

> **[API](https://silverbullet.md/API)**
>
> The server API is relatively small. The client primarily communicates with the server for file “CRUD” (Create, Read, Update, Delete) style operations.All API requests from the client will always set the X-Sync-Mode request header set to true. The...

So what you’re trying is more or less correct, but the content type for markdown is `text/markdown`. Authentication headers may be required depending on your setup.

I don’t have access to my laptop right now, but if you look at your browser’s network traffic page, after you edit a file you’ll see a PUT request happen. Look at the headers there or copy it as a curl and you should see what’s going on.

There’s no append operation at the moment.

---

<div class="post-metadata">

### Author: ![daveb](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/d/b5a626/32.png) [@daveb](https://community.silverbullet.md/u/daveb)
#### Post date: [April 24, 2024, 6:09am UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/5 "2024-04-24T06:09:20Z")

</div>

Thanks for the reply Zef, I’ll look at the network traffic. Thanks for the effort you put into SilverBullet, it’s a great app!

---

<div class="post-metadata">

### Author: ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)
#### Post date: [April 24, 2024, 6:54am UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/6 "2024-04-24T06:54:45Z")

</div>

Regarding authentication, another convenient option is using the SB\_AUTH\_TOKEN environment variable: [Install/Configuration](https://silverbullet.md/Install/Configuration#Authentication)

When you configure that, you can authenticate using a simple `Authorization: Bearer <token>` header.

---

<div class="post-metadata">

### Author: ![daveb](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/d/b5a626/32.png) [@daveb](https://community.silverbullet.md/u/daveb)
#### Post date: [April 24, 2024, 7:25am UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/7 "2024-04-24T07:25:32Z")

</div>

Thanks to the your look at the network traffic advice I got a PUT working. It works using the cookie for auth eg:

```auto
curl 'https://sb.burke.chat/Projects.md' \
  -X 'PUT' \
  -H 'content-type: text/markdown' \
  -H 'cookie: auth_sb_burke_chat=eyJh.........' \
  --data-raw $'[[Klipper & Mainsail on VM]]\n[[NHS Couch to 5k]]\n[[Note Taking Apps]]\n[[Sailing Holiday 2025]]\n[[VPS For Critical Services]]\n[[Silverbullet Backup]]\n[[Winter Break 2024]]\n[[Update Homebox]]\n[[Yuri]]\n[[Weather Station]]\n[[TEST15]]\n'   

```

But when I use the token I created in the environment variable it doesn’t work. Docker compose file:

```yaml
services:
  silverbullet:
    image: zefhemel/silverbullet
    restart: unless-stopped
    environment:
    - SB_USER=admin:xxxxxxxx
    - SB_AUTH_TOKEN:j3e....
    volumes:
      - ./space:/space
    ports:
      - 3000:3000
  watchtower:
    image: containrrr/watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

```

and curl using the bearer token:

```auto
curl 'https://sb.burke.chat/Projects.md' \
  -X 'PUT' \
  -H 'content-type: text/markdown' \
  -H 'Authorization: Bearer j3e...' \
  --data-raw $'[[Klipper & Mainsail on VM]]\n[[NHS Couch to 5k]]\n[[Note Taking Apps]]\n[[Sailing Holiday 2025]]\n[[VPS For Critical Services]]\n[[Silverbullet Backup]]\n[[Winter Break 2024]]\n[[Update Homebox]]\n[[Yuri]]\n[[Weather Station]]\n[[TEST16]]\n'

```

Does the token in the environment variable need to be encrypted or a certain length? I just typed in some randon string. Thanks

---

<div class="post-metadata">

### Author: ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)
#### Post date: [April 24, 2024, 11:50am UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/8 "2024-04-24T11:50:32Z")

</div>

Strange, have you properly recreated the containers to make sure the new environment variables propagated? Here’s what I just tried and it works:

I run my server via:

```auto
SB_USER=zef:zef SB_AUTH_TOKEN=1234 silverbullet ~/tmp

```

But this is equivalent to what you do with docker compose.

Then I curl:

```auto
curl -X PUT -H 'Authorization: Bearer 1234' http://localhost:3000/testzef.md -v --data "Sup"

```

And it accepts the request and writes the file (when I change 1234 to something else it fails, as it should).

---

<div class="post-metadata">

### Author: ![daveb](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/d/b5a626/32.png) [@daveb](https://community.silverbullet.md/u/daveb)
#### Post date: [April 24, 2024, 12:08pm UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/9 "2024-04-24T12:08:25Z")

</div>

Thanks for confirming I’m on the right track. When I updated the docker env variable I did a compose down and then a compose up assuming that would be enough. I’ll keep playing around with it tomorrow, thanks for the help so far.

---

<div class="post-metadata">

### Author: ![daveb](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/d/b5a626/32.png) [@daveb](https://community.silverbullet.md/u/daveb)
#### Post date: [April 25, 2024, 2:45am UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/10 "2024-04-25T02:45:36Z")

</div>

I’ve narrowed down the issue. I installed silverbullet via deno and ran the command that you successfully tested

```auto
SB_USER=zef:zef SB_AUTH_TOKEN=1234 silverbullet ~/tmp

```

and I could PUT without an issue. I then tried a https PUT via ngix proxy manager and it also worked

I noticed that when I run docker compose

```auto
services:
  silverbullet:
    image: zefhemel/silverbullet
    restart: unless-stopped
    environment:
    - SB_AUTH_TOKEN:1234
    - SB_USER=zef:zef
    volumes:
      - ./space:/space
    ports:
      - 3000:3000
  watchtower:
    image: containrrr/watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

```

the SB\_AUTH\_TOKEN wasn’t included in the env variables when I inspected docker

```auto
"Env": [
    "SB_USER=zef:zef",
    "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
    "DENO_DIR=/deno-dir/",
    "DENO_INSTALL_ROOT=/usr/local",
    "DENO_VERSION=1.41.2",
    "TINI_VERSION=v0.19.0",
    "SB_HOSTNAME=0.0.0.0",
    "SB_FOLDER=/space"
],

```

Great I thought! I’ve cracked it! I then ran docker from the command line

```auto
docker run --restart unless-stopped -e SB_USER=zef:zef -e SB_AUTH_TOKEN:1234 -v ./space:/space -p 3000:3000 zefhemel/silverbullet

```

and the SB\_AUTH\_TOKEN is now included

```auto
"Env": [
    "SB_USER=admin:zef:zef",
    "SB_AUTH_TOKEN:1234",
    "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
    "DENO_DIR=/deno-dir/",
    "DENO_INSTALL_ROOT=/usr/local",
    "DENO_VERSION=1.41.2",
    "TINI_VERSION=v0.19.0",
    "SB_HOSTNAME=0.0.0.0",
    "SB_FOLDER=/space"
],

```

**But** it still doesn’t work ☹ I don’t know how docker works but could the SB\_AUTH\_TOKEN not be passed into silverbullet somehow? Thanks

---

<div class="post-metadata">

### Author: ![justyns](https://community.silverbullet.md/user_avatar/community.silverbullet.md/justyns/32/132_2.png) [@justyns](https://community.silverbullet.md/u/justyns)
#### Post date: [May 2, 2024, 3:33am UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/11 "2024-05-02T03:33:09Z")

</div>

I’m not positive, but the issue might be because you’re using : instead of =. If you switch SB\_AUTH\_TOKEN:1234 to SB\_AUTH\_TOKEN=1234, does it work?

---

<div class="post-metadata">

### Author: ![daveb](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/d/b5a626/32.png) [@daveb](https://community.silverbullet.md/u/daveb)
#### Post date: [May 2, 2024, 11:14pm UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/12 "2024-05-02T23:14:00Z")

</div>

Thanks Justyns, you nailed it!

---

<div class="post-metadata">

### Author: ![Johnl](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/j/dec6dc/32.png) [@Johnl](https://community.silverbullet.md/u/Johnl)
#### Post date: [April 18, 2025, 2:27pm UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/13 "2025-04-18T14:27:18Z")

</div>

@daveb or @stephen or anyone else, did you figure out a good Android quick-capture workflow?

---

<div class="post-metadata">

### Author: ![fiddler](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/f/e8c25b/32.png) [@fiddler](https://community.silverbullet.md/u/fiddler)
#### Post date: [August 26, 2025, 6:29pm UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/14 "2025-08-26T18:29:17Z")

</div>

> [@Android share target - alternative implementation](https://community.silverbullet.md/t/android-share-target-alternative-implementation/2994):
>
> I want to add SilverBullet as a “share” target on Android. This would allow me to send it pages I’m looking at, notes from chats, and others. I’ve requested a native PWA implementation in [#1090](https://github.com/silverbulletmd/silverbullet/issues/1090), but in the meantime I found an alternative. [https://http-shortcuts.rmy.ch/](https://http-shortcuts.rmy.ch/) is an Android app that lets you set up a custom share target which sends an HTTP request. My config: Basic request is PUT to https://my.sb.instance/Inbox/{dateSlashTime}.md dateSlashTime is a global variable (you can define it…

---

<div class="post-metadata">

### Author: ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)
#### Post date: [August 27, 2025, 8:02am UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/15 "2025-08-27T08:02:41Z")

</div>

Breaking change: as of the latest v2 build the FS API has moved under `/.fs`: [V2 Changelog - #7 by zef](https://community.silverbullet.md/t/v2-changelog/2067/7)

---

<div class="post-metadata">

### Author: ![Mrton0121](https://community.silverbullet.md/user_avatar/community.silverbullet.md/mrton0121/32/980_2.png) [@Mrton0121](https://community.silverbullet.md/u/Mrton0121)
#### Post date: [August 27, 2025, 8:18am UTC](https://community.silverbullet.md/t/using-silverbullet-apis-to-update-add-to-a-page/397/16 "2025-08-27T08:18:56Z")

</div>

Hey!  
I created a wrapper for the API in go. It makes it easier to use the API. I developed some additional functions than just the CRUD ones, also included an append. You can check it out here: [GitHub - Mrton0121/silverbullet-go-api: Silverbullet API wrapper written in Go](https://github.com/Mrton0121/silverbullet-go-api)
