rentfree

API reference

For anything that cannot run rf. The CLI and the TypeScript SDK are thin layers over this, and this page is generated from the same contract they are, so it cannot drift from them.

Base address

https://api.rentfree.dev/api. Every authenticated endpoint lives under /v1; only the health check, this document, and the login flow sit outside it. Bodies and answers are JSON. Timestamps are ISO 8601 in UTC. The OpenAPI 3.1 document is at /api/openapi.json, for generating a client in another language.

Authentication

Authorization: Bearer rf_…

A key is rf_ followed by 43 characters, and is shown once when made. A user-level key acts as the account; an agent key acts as one agent, within its permissions, and cannot manage the account. Every refusal is the same 401 body, so the answer does not say which check failed.

Writes are idempotent

Every POST under /v1 that writes requires an Idempotency-Key header, any string up to 255 printable characters, remembered for 24 hours. A retry with the same key and the same body replays the first answer instead of running again. /search and /context are reads sent as POST because they have a body, and need none. The SDK and rf send the header themselves.

Errors

An error is { error, issues? }, where issues is a list of { path, message } when a request field is at fault. Each endpoint below lists the codes it can answer.

StatuserrorWhen
400invalid_requestA field is missing or wrong; issues names each one.
401unauthorizedNo key, a malformed key, a revoked key, or a deleted account.
403access_deniedThe login was denied in the browser.
403forbiddenThe key may not do this: an agent outside its permissions, or an agent key on an account endpoint.
404not_foundNot the caller's, or does not exist; the two are not told apart.
409collection_archivedA write into an archived collection, or making one the default.
409collection_defaultThe default collection cannot be archived.
409embed_model_in_useThe account has content, so its model is fixed.
409idempotency_key_in_progressThe same Idempotency-Key while its first request is still running.
409ingest_in_progressReading a source again while it is still being read.
409memory_expiredRestoring a memory that expired; it stays expired.
409memory_inactiveChanging a memory that is archived or expired.
409name_takenAnother active collection has that name.
409not_a_text_sourceReplacing the text of a url or file source.
409not_refreshableRefreshing a source that is not a url.
409session_endedAn event for a session that has ended.
409source_kind_mismatchAdding a source under an external id a source of another kind has.
409source_not_readyThe content of a source that is not ready yet.
410device_session_expiredThe login's ten minutes passed, or its key was already handed out.
422idempotency_key_reusedThe same Idempotency-Key with a different request.
429rate_limitedToo many login sessions from one address in an hour.
429slow_downPolled a login faster than its interval.
500internalA fault on our side; it has been reported.

Endpoints

memories

What an agent should remember.

POST /v1/memories

Write a memory. Any key.

Body

collectionIdstringnot empty
typestringnot empty
tier"working" | "long"
contentstringat most 20000 characters
subject?string | null
importance?number0 to 1
expiresAt?timestamp

Answers

  • 201 Created: Memory
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 collection_archived, idempotency_key_in_progress
  • 422 idempotency_key_reused
  • 500 internal

GET /v1/memories

Memories in a collection, newest first. Any key.

Parameters

collectionIdquery, stringnot empty
status?query, "active" | "archived" | "expired"default "active"
limit?query, integer1 to 100; default 20
cursor?query, stringnot empty

Answers

  • 200 OK: MemoryPage
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

GET /v1/memories/{id}

One memory. Any key.

Parameters

idpath, stringnot empty

Answers

  • 200 OK: Memory
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

PATCH /v1/memories/{id}

Correct a memory, or archive or restore it. Any key.

Parameters

idpath, stringnot empty

Body

content?stringat most 20000 characters
subject?string | null
importance?number0 to 1
status?"active" | "archived"

Answers

  • 200 OK: Memory
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 collection_archived, memory_expired, memory_inactive
  • 500 internal

DELETE /v1/memories/{id}

Archive a memory; its history and sources stay. Any key.

Parameters

idpath, stringnot empty

Answers

  • 200 OK: Memory
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 collection_archived
  • 500 internal

GET /v1/memories/{id}/history

Every change to a memory, newest first. Any key.

Parameters

idpath, stringnot empty
limit?query, integer1 to 100; default 50

Answers

  • 200 OK: object
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

GET /v1/memories/{id}/sources

Where a memory came from. Any key.

Parameters

idpath, stringnot empty

Answers

  • 200 OK: object
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

recall

Search and the context pack.

POST /v1/context

A context pack: what an agent needs for its next turn, within a budget. Any key.

Body

collectionIdstringnot empty
query?stringat most 2000 characters
tokenBudget?integer200 to 16000; default 2000

Answers

  • 200 OK: ContextPack
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 collection_archived
  • 500 internal

GET /v1/collections/{id}/profile

A collection's latest profile. Any key.

Parameters

idpath, stringnot empty

Answers

  • 200 OK: Profile
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 collection_archived
  • 500 internal

GET /v1/index/status

How much content is still waiting to be embedded. Any key.

Answers

sessions

Logging what happens, as it happens.

POST /v1/sessions

Start a session, or find the one with this externalId. Any key.

Body

collectionId?stringnot empty
externalId?stringat most 200 characters
title?stringat most 500 characters

Answers

  • 200 OK: Session
  • 201 Created: Session
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 collection_archived, idempotency_key_in_progress
  • 422 idempotency_key_reused
  • 500 internal

GET /v1/sessions

Sessions in a collection, newest first. Any key.

Parameters

collectionIdquery, stringnot empty
externalId?query, stringat most 200 characters
limit?query, integer1 to 100; default 20
cursor?query, stringnot empty

Answers

  • 200 OK: SessionPage
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

GET /v1/sessions/{id}

One session. Any key.

Parameters

idpath, stringnot empty

Answers

  • 200 OK: Session
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

PATCH /v1/sessions/{id}

Retitle a session, or end it, which starts a recap. Any key.

Parameters

idpath, stringnot empty

Body

title?string | null
ended?true

Answers

  • 200 OK: Session
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 collection_archived
  • 500 internal

POST /v1/sessions/{id}/events

Log one event, or a batch of up to 100, all or none. Any key.

Parameters

idpath, stringnot empty

Body

One of:

eventsobject[]1 to 100 items

or:

type"message.user" | "message.assistant" | "tool.call" | "tool.result" | "note"
contentstringat most 100000 characters
metadata?objectdefault {}

Answers

  • 201 Created: object
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 collection_archived, idempotency_key_in_progress, session_ended
  • 422 idempotency_key_reused
  • 500 internal

GET /v1/sessions/{id}/events

A session's events, oldest first. Any key.

Parameters

idpath, stringnot empty
limit?query, integer1 to 100; default 20
cursor?query, stringnot empty

Answers

  • 200 OK: EventPage
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

sources

Documents, URLs, and files.

POST /v1/sources

Add text, a URL, or an uploaded file; under an external id the collection already has, update that source. Any key.

Body

One of:

kind"text"
contentstring
title?string | null
format?"markdown" | "text"
collectionId?stringnot empty
uri?stringat most 2000 characters
externalId?stringat most 500 characters
metadata?objectdefault {}

or:

kind"url"
urlstringat most 2000 characters
title?string | null
collectionId?stringnot empty
externalId?stringat most 500 characters
metadata?objectdefault {}

or:

kind"file"
blobKeystringat most 1000 characters
title?string | null
collectionId?stringnot empty
externalId?stringat most 500 characters
metadata?objectdefault {}

Answers

  • 200 OK: Source
  • 201 Created: AddedSource
  • 202 Accepted; the work continues in the background: Source
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 collection_archived, idempotency_key_in_progress, ingest_in_progress, source_kind_mismatch
  • 422 idempotency_key_reused
  • 500 internal

GET /v1/sources

Sources in a collection, newest first. Any key.

Parameters

collectionIdquery, stringnot empty
externalId?query, stringat most 500 characters
limit?query, integer1 to 100; default 20
cursor?query, stringnot empty

Answers

  • 200 OK: SourcePage
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

GET /v1/sources/{id}

One source, with its ingest status. Any key.

Parameters

idpath, stringnot empty

Answers

  • 200 OK: Source
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

PUT /v1/sources/{id}

Replace a text source; unchanged content is a no-op. Any key.

Parameters

idpath, stringnot empty

Body

contentstring
title?string | null
format?"markdown" | "text"

Answers

  • 200 OK: Source
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 collection_archived, not_a_text_source
  • 500 internal

DELETE /v1/sources/{id}

Remove a source and its chunks. Any key.

Parameters

idpath, stringnot empty

Answers

  • 204 Done; no body
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 collection_archived
  • 500 internal

GET /v1/sources/{id}/content

A ready source's text. Any key.

Parameters

idpath, stringnot empty

Answers

  • 200 OK: object
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 source_not_ready
  • 500 internal

GET /v1/sources/{id}/chunks

A source's chunks, in document order. Any key.

Parameters

idpath, stringnot empty
level?query, "document" | "section" | "paragraph"
limit?query, integer1 to 200; default 50
cursor?query, stringnot empty

Answers

  • 200 OK: ChunkPage
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

POST /v1/sources/{id}/refresh

Fetch a URL source again. Any key.

Parameters

idpath, stringnot empty

Answers

  • 202 Accepted; the work continues in the background: Source
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 collection_archived, idempotency_key_in_progress, ingest_in_progress, not_refreshable
  • 422 idempotency_key_reused
  • 500 internal

POST /v1/uploads

Get a short-lived URL to PUT a file to, before adding it. Any key.

Body

filenamestringat most 255 characters
contentType"application/pdf" | "text/markdown" | "text/plain"
sizeinteger1 to 20971520

Answers

  • 201 Created: Upload
  • 400 invalid_request
  • 401 unauthorized
  • 409 idempotency_key_in_progress
  • 422 idempotency_key_reused
  • 500 internal

recap

Turning events into memories.

POST /v1/recap/run

Start a recap of the events not yet read. Any key.

Answers

  • 200 OK: RecapRunAnswer
  • 202 Accepted; the work continues in the background: RecapRunAnswer
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 409 idempotency_key_in_progress
  • 422 idempotency_key_reused
  • 500 internal

GET /v1/recap/runs

Recap runs, newest first. Any key.

Parameters

limit?query, integer1 to 100; default 20

Answers

  • 200 OK: object
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 500 internal

GET /v1/recap/runs/{id}

One recap run. Any key.

Parameters

idpath, stringnot empty

Answers

  • 200 OK: RecapRun
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

account

Collections, agents, and keys.

GET /v1/me

The user, the key in use, and what it can see. Any key.

Answers

  • 200 OK: Me
  • 401 unauthorized
  • 404 not_found
  • 500 internal

PATCH /v1/me

Choose the embedding model, while the account has no content. A user-level key.

Body

embedModelstringnot empty
embedDimensions?integer | null

Answers

  • 200 OK: User
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 embed_model_in_use
  • 500 internal

DELETE /v1/me

Delete the account; every key stops at once. A user-level key.

Answers

  • 200 OK: object
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

GET /v1/collections

Collections; an agent sees the active ones it may read. Any key.

Parameters

status?query, "active" | "archived"default "active"

Answers

  • 200 OK: object
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 500 internal

POST /v1/collections

Make a collection. A user-level key.

Body

namestringat most 100 characters

Answers

  • 201 Created: Collection
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 409 idempotency_key_in_progress, name_taken
  • 422 idempotency_key_reused
  • 500 internal

PATCH /v1/collections/{id}

Rename a collection, or make it the default. A user-level key.

Parameters

idpath, stringnot empty

Body

name?stringat most 100 characters
isDefault?boolean

Answers

  • 200 OK: Collection
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 collection_archived, name_taken
  • 500 internal

DELETE /v1/collections/{id}

Archive a collection: still readable, nothing new goes in. A user-level key.

Parameters

idpath, stringnot empty

Answers

  • 200 OK: Collection
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 409 collection_default
  • 500 internal

GET /v1/agents

Agents, live by default. A user-level key.

Parameters

status?query, "active" | "revoked"default "active"

Answers

  • 200 OK: object
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 500 internal

POST /v1/agents

Make an agent with its permissions. A user-level key.

Body

namestringat most 100 characters
canReadMemoriesboolean
canWriteMemoriesboolean
readCollectionIdsstring[]at most 100 items
writeCollectionIdsstring[]at most 100 items

Answers

  • 201 Created: Agent
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 409 idempotency_key_in_progress
  • 422 idempotency_key_reused
  • 500 internal

PATCH /v1/agents/{id}

Change an agent's name or permissions. A user-level key.

Parameters

idpath, stringnot empty

Body

name?stringat most 100 characters
canReadMemories?boolean
canWriteMemories?boolean
readCollectionIds?string[]at most 100 items
writeCollectionIds?string[]at most 100 items

Answers

  • 200 OK: Agent
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

DELETE /v1/agents/{id}

Revoke an agent and every key it holds. A user-level key.

Parameters

idpath, stringnot empty

Answers

  • 200 OK: object
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

GET /v1/keys

Keys, live by default; never the secret. A user-level key.

Parameters

status?query, "active" | "revoked"default "active"

Answers

  • 200 OK: object
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 500 internal

POST /v1/keys

Mint a key; the secret is in this answer only. A user-level key.

Body

namestringat most 100 characters
agentId?stringnot empty

Answers

  • 201 Created: CreatedKey
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 409 idempotency_key_in_progress
  • 422 idempotency_key_reused
  • 500 internal

DELETE /v1/keys/{id}

Revoke a key. A user-level key.

Parameters

idpath, stringnot empty

Answers

  • 200 OK: Key
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

login

The browser login the CLI runs.

POST /auth/device

Start a login; the CLI shows the code and opens the page. No key.

Body

namestringat most 100 characters

Answers

  • 201 Created: LoginStarted
  • 400 invalid_request
  • 429 rate_limited
  • 500 internal

POST /auth/device/poll

Ask whether the browser has approved; the key comes back once. No key.

Body

deviceCodestringnot empty

Answers

  • 200 OK: LoginPoll
  • 400 invalid_request
  • 403 access_denied
  • 404 not_found
  • 410 device_session_expired
  • 429 slow_down
  • 500 internal

GET /auth/device/{userCode}

What the approval page shows about a login. A browser session.

Parameters

userCodepath, stringnot empty

Answers

  • 200 OK: DeviceSession
  • 400 invalid_request
  • 401 unauthorized
  • 404 not_found
  • 500 internal

POST /auth/device/approve

Approve or deny a login; a first approval creates the account. A browser session.

Body

userCodestringat most 20 characters
decision"approve" | "deny"

Answers

  • 200 OK: object
  • 400 invalid_request
  • 401 unauthorized
  • 403 forbidden
  • 404 not_found
  • 500 internal

meta

Liveness.

GET /health

Whether the api and its database are up. No key.

Answers

  • 200 OK: Health
  • 500 internal
  • 503 The database is unreachable

GET /openapi.json

This document. No key.

Answers

Schemas

AddedSource

idstring
collectionIdstring
kind"text" | "url" | "file"
status"pending" | "processing" | "ready" | "failed"
titlestring | null
uristring | null
externalIdstring | null
format"markdown" | "text"
metadataobject
errorstring | null
versioninteger-9007199254740991 to 9007199254740991
createdAttimestamp
updatedAttimestamp
duplicateOf?object

Agent

idstring
namestring
canReadMemoriesboolean
canWriteMemoriesboolean
readCollectionIdsstring[]
writeCollectionIdsstring[]
createdAttimestamp
revokedAttimestamp | null

Chunk

idstring
parentIdstring | null
level"document" | "section" | "paragraph"
ordinalinteger-9007199254740991 to 9007199254740991
headingPathstring | null
contextHeaderstring | null
textstring
tokenCountinteger-9007199254740991 to 9007199254740991
charStartinteger-9007199254740991 to 9007199254740991
charEndinteger-9007199254740991 to 9007199254740991

ChunkHit

idstring
textstring
headingPathstring | null
sourceobject
scorenumber
vectorRankinteger | null
textRankinteger | null

ChunkPage

itemsChunk[]
nextCursorstring | null

Collection

idstring
namestring
isDefaultboolean
createdAttimestamp
archivedAttimestamp | null

ContextPack

textstring
tokenCountinteger-9007199254740991 to 9007199254740991
tokenBudgetinteger-9007199254740991 to 9007199254740991
mode"hybrid" | "text" | "importance"
profileobject | null
memoriesobject[]
chunksChunkHit[]

CreatedKey

idstring
namestring | null
keyPrefixstring
agentIdstring | null
createdAttimestamp
lastUsedAttimestamp | null
revokedAttimestamp | null
apiKeystring

DeviceSession

userCodestring
namestring
status"pending" | "approved" | "denied" | "claimed" | "expired"
createdAttimestamp
expiresAttimestamp

Error

errorstring
issues?object[]

Event

idinteger-9007199254740991 to 9007199254740991
sessionIdstring
agentIdstring | null
type"message.user" | "message.assistant" | "tool.call" | "tool.result" | "note"
contentstring
metadataobject
createdAttimestamp

EventPage

itemsEvent[]
nextCursorstring | null

Health

okboolean
db"up" | "down"

IndexStatus

waitinginteger-9007199254740991 to 9007199254740991
failedinteger-9007199254740991 to 9007199254740991
oldestWaitingAttimestamp | null

Key

idstring
namestring | null
keyPrefixstring
agentIdstring | null
createdAttimestamp
lastUsedAttimestamp | null
revokedAttimestamp | null

LoginPoll

One of:

status"pending"

or:

status"approved"
apiKeystring
keyPrefixstring
userobject
defaultCollectionIdstring | null

LoginStarted

deviceCodestring
userCodestring
verifyUrlstring
expiresIninteger-9007199254740991 to 9007199254740991
intervalinteger-9007199254740991 to 9007199254740991

Memory

idstring
collectionIdstring
typestring
tierstring
originstring
status"active" | "archived" | "expired"
subjectstring | null
contentstring
confidencenumber
importancenumber
importanceNownumber
versioninteger-9007199254740991 to 9007199254740991
validFromtimestamp
validTotimestamp | null
supersedesIdstring | null
accessCountinteger-9007199254740991 to 9007199254740991
lastAccessedAttimestamp | null
createdAttimestamp
updatedAttimestamp
expiresAttimestamp | null

MemoryChange

idinteger-9007199254740991 to 9007199254740991
opstring
actorstring
reasonstring | null
beforeobject | null
afterobject | null
recapRunIdstring | null
createdAttimestamp

MemoryHit

idstring
collectionIdstring
typestring
tierstring
subjectstring | null
contentstring
importancenumber
validFromtimestamp
createdAttimestamp
scorenumber
vectorRankinteger | null
textRankinteger | null

MemoryPage

itemsMemory[]
nextCursorstring | null

MemorySource

sourceIdstring | null
chunkIdstring | null
eventIdinteger | null
sessionIdstring | null
quotestring | null
createdAttimestamp

OpenApiDocument

openapi"3.1.0"
infoobject
pathsobject

Profile

collectionIdstring
versioninteger-9007199254740991 to 9007199254740991
contentstring
tokenCountinteger-9007199254740991 to 9007199254740991
generatedAttimestamp

RecapRun

idstring
triggerstring
statusstring
eventsFromIdinteger-9007199254740991 to 9007199254740991
eventsToIdinteger-9007199254740991 to 9007199254740991
extractModelstring | null
reconcileModelstring | null
inputTokensinteger | null
outputTokensinteger | null
costUsdnumber | null
statsobject
errorstring | null
startedAttimestamp
finishedAttimestamp | null

RecapRunAnswer

One of:

status"running"
runRecapRun

or:

status"idle"

or:

status"started"
unreadinteger-9007199254740991 to 9007199254740991

Session

idstring
collectionIdstring | null
agentIdstring | null
externalIdstring | null
titlestring | null
startedAttimestamp
endedAttimestamp | null

SessionPage

itemsSession[]
nextCursorstring | null

Source

idstring
collectionIdstring
kind"text" | "url" | "file"
status"pending" | "processing" | "ready" | "failed"
titlestring | null
uristring | null
externalIdstring | null
format"markdown" | "text"
metadataobject
errorstring | null
versioninteger-9007199254740991 to 9007199254740991
createdAttimestamp
updatedAttimestamp

SourcePage

itemsSource[]
nextCursorstring | null

Upload

blobKeystring
uploadUrlstring
method"PUT"
headersobject
expiresAttimestamp

User

idstring
emailstring | null
embedModelstring
embedDimensionsinteger | null
createdAttimestamp