Overview
This tutorial walks through the steps of generating a simple API server from scratch using the Sutro API.Before you begin
Roles & credentials
- All calls in this tutorial are made as a Builder. Make sure you’ve completed the steps to set up Builder authentication before starting.
Tools
jqandcurl
Variables and files
- You’ll need access to the
sutro.keyandsutro.crtfiles created in Step 2 of the Builder authentication setup. - Use Step 4 to generate JWTs for your requests and store them in the
BUILDER_JWTenvironment variable. - Download the Sutro Certificate Authority (CA) certificate from
/certs/ca.crtto secure API requests.
Steps
This flow takes you from prompt to deployment so every asset—project, app, and OpenAPI spec—stays under your control the whole time.1
Create a Project
Start by creating a Project to hold the prompt, application, and generated assets.Add a short description so you remember the goal. In this example, use “My To Do Server”.Call Congratulations! You’ve just created a Sutro Project.The project details now live in
POST /projectsproject.json; refer to that file in upcoming steps.2
Create an Application
Next, create an Application. Most Projects contain a single Application.Call Now you have an Application; two more steps and it will be building…
POST /projects/{projectId}/applications3
Add a Prompt to the Application
Provide the Application with a prompt so the LLM knows what to generate.Since this tutorial builds a to-do server, use the following prompt:Call The prompt is now attached; the Application is ready to generate.
Build me an API server that helps users track To Dos. It should include the ability to set deadlines on To Do items, as well as mark them completed
POST /applications/{applicationId}/prompt.4
Generate the Application
Generating an API server takes a little time, so call the Sutro API to start the process. Monitoring happens in the next step.Call This call will return quickly; our API server is being generated.
POST /applications/{applicationId}/generation.5
Monitor for generation to complete
Because Make this call every ~10 seconds until the status shows completion.
curl drives this tutorial, poll the API for the Application’s status.The -s flag limits output to just the Application status, so keep an eye out for unexpected text that might signal local network issues.Call GET /applications/{applicationId}/status.6
Deploy the Application
The application is ready to deploy.Just like generation, deployment takes time, so this API call starts a deployment and creates a new version.Call The
POST /applications/{applicationId}/deploymentdeployment.json file will contain the deploymentId of the deployment (so that we can its status) and the version that was generated.7
Monitor for the deployment to complete
Monitor deployment the same way as generation.Call Once the response says
GET /applications/{applicationId}/versions/{version}/deployment/{deploymentId}/"Successful", the API is ready to use.8
Start using the API
There are many ways to exercise the new API. Start by getting a description so you know the available paths and methods.Call With the OpenAPI document in hand, pick your favorite API client and start exploring.This API doesn’t have any user credentials because security wasn’t configured. That’s fine for exploration, but add proper authentication before going live with real users’ data.
GET /applications/{applicationId}/versions/{version}/openapi.Your backend is generated, deployed, and documented. Grab the OpenAPI file and start wiring clients with confidence.
Reference
POST /projectsPOST /projects/{projectId}/applicationPOST /applications/{applicationId}/promptPOST /applications/{applicationId}/generationGET /applications/{applicationId}/statusPOST /applications/{applicationId}/deploymentGET /applications/{applicationId}/versions/{version}/deployment/{deploymentId}/GET /applications/{applicationId}/versions/{version}/openapi