Get started
Ragnar API
Build and change CAD models from your own code: write to a chat, share a folder of files, and follow each message's task.
Ragnar's REST API lets your scripts do what you do in the Ragnar chat: describe a part, follow the build, change it in plain words and download the result. It works on your own Ragnar account, with the same projects, workspaces and credits you see in the app.
https://app.ragnar.build/apiEvery path starts with /v1. Send an API key with every request. You create keys in Ragnar under Settings → Developers. See API keys.
Three parts
- A chat. A list of messages in order. You and Ragnar write messages of the same shape. Ragnar's replies and questions are ordinary messages.
- A folder. The files of one project. You upload files to it, and Ragnar writes the files of its work to it. Both of you list and download the same files.
- Tasks. A task follows one message until the message has its answer. Your program reads the task to see how the work goes, so it never has to read text.
The app shows the same chats and files. A message you send through the API appears in Ragnar, and you can go on in either place. To work on a project you made in the app, take its id from the app's address, ?project=<id>, and open a chat on it with POST /v1/chats.
Eight endpoints
POST /v1/projectsbuild · 201- Creates an empty project with one empty chat.
POST /v1/chatsbuild · 201- Opens a chat on a project's main design: its newest chat while nobody has used it, or a new one.
POST /v1/chats/{chat_id}/messagesbuild · 201- Writes a message in the chat. Returns the message with the
task_idto follow. GET /v1/chats/{chat_id}/messagesread · 200 · list- The chat's messages, oldest first.
?after=returns only the messages after one message. GET /v1/tasks/{task_id}read · 200- How the work on a message is going.
POST /v1/filesbuild · 201- Uploads one file to a project's folder. The request body is the file.
GET /v1/filesread · 200 · list- A project's folder, newest first.
GET · HEAD /v1/files/{file_id}/contentread · 200- A file's bytes as a download.
HEADreturns only the headers.
read works with every key. build needs a key with the Read and build permission.
How a build works
- Create a project, or use one you have, and open a chat on it.
- Upload the files the work needs to the project's folder.
- Send a message. Ragnar accepts it at once and returns it with a
task_id. The work runs on its own. - Read the task about every 5 seconds while it is
pendingorworking. - When the task is
answered, read the messages after yours. Ragnar's reply holds the files its work wrote. Download them by id.
Builds use credits as they do in the app. Reading, uploading and downloading use no credits. The API is for servers and scripts: it sends no CORS headers, so a web page cannot call it from a browser.