Reference
API reference
Every endpoint, its fields and what comes back, with the rules every request follows.
Conventions
- Base URL.
https://app.ragnar.build/api. Every path starts with/v1. - Authentication. Send
Authorization: Bearer <your API key>with every request. See API keys. - JSON. Send JSON bodies with
Content-Type: application/json, up to 512 KiB.POST /v1/projectswith every default still sends{}. - Names. Fields and query parameters are in snake_case. Times are ISO 8601 strings in UTC.
- Optional fields. Leave out a field you do not set.
nullgets400 INVALID_REQUEST. - New fields. Ragnar ignores fields and query parameters it does not know, so it can add new ones without a new version. Ignore response fields and values you do not know too. A known query parameter sent twice gets
400 INVALID_REQUEST. - Ids. Treat ids as opaque strings. An id that names nothing you can open, or the id of another kind of resource, gets
404 NOT_FOUND. - Your projects and chats. The API does not list them. Keep the ids it returns, or take a project's id from the app's address,
?project=<id>. The address shows?chat=<id>after you pick a chat in the chat list. The API takes only the chats of a project's main design. - Errors. A refused request gets an HTTP status and
{"error": {"code", "message"}}. A method a path does not take gets405with an empty body. See Errors and limits. - Browsers. The API sends no CORS headers. Call it from servers and scripts.
Lists
A list takes limit and cursor, and returns one page:
{ "data": [], "next_cursor": "<cursor>" }Send next_cursor back as cursor for the next page. It is null on the last page. A page can hold fewer items than limit, even none, while next_cursor is not null, so read until it is null. A cursor works only with the list it came from.
Projects
POST /v1/projects
Creates an empty project with one empty chat. Needs a Read and build key.
nameoptional string, 1 to 100 characters- The project's name, without outer spaces. Defaults to
Untitled Project. workspace_idoptional string- Creates the project in this workspace. Settings → Developers lists your workspaces with their ids. A workspace you are not a member of gets
404 NOT_FOUND. Leave it out for a personal project.
Returns 201 with the project:
idstring- The project's id. Pass it as
project_idto open a chat or to use its folder. namestring- The project's name.
workspace_idstring or null- The project's workspace, or null for a personal project.
created_atstring- When the project was created, as an ISO 8601 time in UTC.
Chats
POST /v1/chats
Opens a chat on the project's main design. While its newest chat has never been used, Ragnar returns that chat, so the app shows the same one. Otherwise it creates a new chat. A chat an earlier call returned counts as used, so each call gets its own chat. Needs a Read and build key and edit access to the project.
project_idstring- The project to work on. You need edit access to it.
Returns 201 with the chat:
idstring- The chat's id. Write and read its messages with it.
project_idstring- The project the chat works on. The project's folder holds the chat's files.
created_atstring- When the chat was created.
The message endpoints also take the chats people made in the app, on the project's main design.
Messages
POST /v1/chats/{chat_id}/messages
Writes a message in the chat. Needs a Read and build key and edit access to the project.
textstring, 1 to 100,000 characters- What you want, in plain words, without outer spaces. Include sizes and units. With one short reference for each file, the message must still fit in 100,000 characters (
400 PROMPT_TOO_LARGE). filesoptional array of `{id}`- Up to 64 different files that are in the folder of the chat's project now. A message can name a file name only once, whatever its case.
reply_tooptional array with one id- The question this message answers. Leave it out and Ragnar still takes your message as the answer while its question waits for you in this chat, unless the message is
/export. effortoptional stringlow(Quick),medium(Balanced, the default),high(Thorough) orxhigh(Deep). In a personal project,highandxhighneed Pro on your own account; a workspace project allows every effort. An answer keeps its build's effort.ask_clarifying_questionsoptional boolean- Defaults to
false: Ragnar never stops to ask. Withtrue, Ragnar can ask one set of up to three questions before it starts the CAD work. Your question setting in the app does not apply to the API.
Returns 201 with the message. Follow its task_id. See Messages and tasks.
GET /v1/chats/{chat_id}/messages
The chat's messages in the order they were written, oldest first.
afteroptional message id- Returns only the messages listed after this message. To wait for a reply, pass the message you sent.
limitoptional integer, 1 to 100- The most messages a page holds. Defaults to 20. A page of messages never holds more than 30.
cursoroptional string- The
next_cursorof the page before. Send it with the sameafter.
Returns a page of messages:
idstring- The message's id. Use it in
reply_toandafter. authorobject{type, id, name}. A person is{"type": "user", …}with their Ragnar user id; Ragnar is{"type": "agent", "id": "ragnar", "name": "Ragnar"}.textstring- The message's text, written for people. A question lists each question with its options, then what Ragnar will assume.
filesarray of `{id, name, size}`- On your message, the files it names. On Ragnar's message, the files its work wrote, one for each name. They fill in as the work delivers them.
reply_toarray of ids- The messages this one answers. Empty when it answers nothing. It only links messages: it never ends a task.
task_idstring or null- Set on every message a person writes, and on each question a build asked, answered or not. Otherwise null.
created_atstring- When the message was written.
Tasks
GET /v1/tasks/{task_id}
How the work on one message is going. Read it about every 5 seconds.
Returns 200 with the task. See task statuses.
Files
POST /v1/files
Uploads one file to a project's folder. The request body is the file. Needs a Read and build key and edit access to the project. See Files and exports.
Returns 201 with the file.
GET /v1/files
A project's folder, newest first. Returns a page of files.
GET /v1/files/{file_id}/content
The file's bytes as a download. HEAD returns the same headers without the bytes.
Retries and idempotency
Every POST takes an optional Idempotency-Key header: 16 to 128 characters of letters, digits, ., _, : and -. A UUID works.
- The same key with the same body is a replay. Ragnar answers with the same status and resource, the resource's current state as the body, and the header
Idempotent-Replayed: true. Nothing is created twice. - The same key with a different body gets
409 IDEMPOTENCY_CONFLICT. - Keys belong to your account, so all your API keys share them, and each kind of resource keeps its own. A key you used for a project, chat or message stays tied to it.
- Without a key, a retry creates again: a second project, chat, message or file.
After a timeout, a 500 or a 503, send the same request again with the same key.