Skip to main content
Read a Vault photo and create a local HTML page that displays it. The API returns the image URL. Keep your access token on your server, where the Node.js script runs.

Read a media URL

Use Node.js 22 or later. You need an access token with vault:read, which lets your app read Vault media. Choose a photo’s numeric media ID from a linked account shared with that token. Clone the Vault image example on GitHub and copy its settings template:
Set OFAUTH_ACCESS_TOKEN, OFAUTH_LINKED_ACCOUNT_ID, and OFAUTH_MEDIA_ID in .env, then run the example:
The example reads the item with GET /v3/access/vault/media/{mediaId}. A successful photo response contains these fields. Other fields are omitted. The image URL below is an example:
The example checks that the photo is ready and you can view it. The SDK call and checks look like this:
Expect Saved media.html for media 123456, with your actual media ID. Open media.html in a browser to see the full-size photo scaled to the window. The page contains the returned display URL, not your access token. Keep the generated file out of version control. Use files.preview for a preview or files.thumb for a thumbnail when those fields are present. Posts, messages, and videos can return different fields. Check their API reference before using this example for them.

Refresh expired URLs

If the image stops loading, rerun npm start with the same OFAUTH_MEDIA_ID and linked account, then reload media.html. The script reads the same Vault item and replaces the saved display URL. Save the media ID and the linked account ID so you can request a new URL later. If the request fails, follow its recovery action. If isReady is false, wait before reading the item again. If access is denied or the item is unavailable, retrying the old URL will not fix it. Read an item and display its returned media URL. If the URL expires, read the post, message, or Vault item again for a current URL.

Save media for later

Vault+ is an optional convenience for galleries and content pickers. It loads saved media faster and lets you find files and thumbnails by media ID, even when they are not attached to a post, message, or story. Add or sync the media you need, then use its ID to read the stored file or thumbnail. Your platform does not need to keep track of expiring OnlyFans URLs for these saved copies. To attach media to new content, follow Media references. To add a new file, follow Upload media.