Skip to main content

Overview

This guide walks through the full workflow, from authentication to deployment, using the Sutro API to build a full-stack application from a prompt.

Before you begin

Roles & credentials

Tools

  • jq and curl

Variables and files

  • You’ll need the sutro.key and sutro.crt files created in Step 2 of the Builder authentication setup.
  • Use Step 4 to generate JWTs for your requests and store them in the BUILDER_JWT environment variable.
  • Download the Sutro Certificate Authority (CA) certificate from /certs/ca.crt so API requests remain secure.

Steps

Sutro takes you through every stage, from prompts to production, so you retain end-to-end visibility while Sutro does the heavy lifting.
1

Create a new project

The first step is to create a new project. A project is like the container for your application, and it can have multiple components:
  • backend: A backend API hosted by Sutro
  • frontend: An optional frontend web application, hosted by Sutro, or exported as static bundle
It’s currently not possible to create a standalone frontend project.Call POST /projects
curl -H "Content-Type: application/json" \
     -H "Authorization: Bearer ${BUILDER_JWT}" \
     -cacert ca.crt \
     --key sutro.key \
     --cert sutro.crt \
     -X POST \
     -o project.json \
     -d '{
       "name": "My New Project",
       "components": ["backend", "frontend"]
     }' \
     https://sapi.withsutro.com/projects
Congratulations! You’ve just created your first Sutro Project.The project details are stored in project.json; refer to that file in upcoming steps.
2

Create an app

Next, create an empty application within your project. This application will serve as the container for your generated code.Call POST /projects/{projectId}/applications
curl -H "Content-Type: application/json" \
     -H "Authorization: Bearer ${BUILDER_JWT}" \
     -cacert ca.crt \
     --key sutro.key \
     --cert sutro.crt \
     -X POST \
     -o application.json \
     -d '{
       "scode": {}
     }' \
     https://sapi.withsutro.com/projects/$(jq -r '.id' < project.json)/applications
Now you have an Application; next attach a prompt to it.
3

Attach a prompt

Attach a prompt to the application that describes what you want to build. This prompt will be used during the generation process.Call POST /applications/{applicationId}/prompt.
curl -H "Content-Type: application/json" \
     -H "Authorization: Bearer ${BUILDER_JWT}" \
     -cacert ca.crt \
     --key sutro.key \
     --cert sutro.crt \
     -X POST \
     -d '{
       "prompt": "A todo app where users can create, edit, and delete tasks. Users should be able to mark tasks as complete and filter by status."
     }' \
     https://sapi.withsutro.com/applications/$(jq -r '.id' < application.json)/prompt
The prompt is attached and the Application is ready to generate.
4

Generate the app

Generating an application takes a little time, so call the Sutro API to start the process and monitor it in the next step.This will automatically use the prompt that was attached to this specific application. Because you selected the backend and frontend components when creating the project, this will first generate a backend API, and then a frontend web application based on the prompt you attached.Call POST /applications/{applicationId}/generate.
curl -H "Content-Type: application/json" \
     -H "Authorization: Bearer ${BUILDER_JWT}" \
     -cacert ca.crt \
     --key sutro.key \
     --cert sutro.crt \
     -X POST \
     https://sapi.withsutro.com/applications/$(jq -r '.id' < application.json)/generate
This call returns quickly; your application is being generated.
5

Monitor for generation to complete

Because curl drives this guide, poll the API for the application’s status.The -s flag limits output to the Application status, so unexpected text may signal local network issues.Call GET /applications/{applicationId}/status.
curl -H "Content-Type: application/json" \
     -H "Authorization: Bearer ${BUILDER_JWT}" \
     -cacert ca.crt \
     --key sutro.key \
     --cert sutro.crt \
     -s \
     -X GET \
     https://sapi.withsutro.com/applications/$(jq -r '.id' < application.json)/status | jq
Make this call every ~10 seconds until the status shows completion.Once the status shows "Active", your application has been successfully generated and is ready to be published.
6

Publish the application

Now that your application has been generated, you need to publish it to make it accessible. Publishing creates a new version of your application and deploys it.Just like Application generation, Application deployment takes a little time, so this API call will start a deployment.It will also create a new Version of your Application.Call POST /applications/{applicationId}/deployment
curl -H "Content-Type: application/json" \
     -H "Authorization: Bearer ${BUILDER_JWT}" \
     -cacert ca.crt \
     --key sutro.key \
     --cert sutro.crt \
     -o deployment.json \
     -X POST \
     https://sapi.withsutro.com/applications/$(jq -r '.id' < application.json)/deployment
The deployment.json file contains the deploymentId of the deployment (so that we can check its status) and the versionId that was generated.
7

Monitor for the deployment to complete

Monitor deployment the same way you monitored generation.Call GET /applications/{applicationId}/versions/{version}/deployment/{deploymentId}
curl -H "Content-Type: application/json" \
     -H "Authorization: Bearer ${BUILDER_JWT}" \
     -cacert ca.crt \
     --key sutro.key \
     --cert sutro.crt \
     -s \
     -X GET \
     https://sapi.withsutro.com/applications/$(jq -r '.id' < application.json)/versions/$(jq -r '.versionId' < deployment.json)/deployment/$(jq -r '.deploymentId' < deployment.json) | jq
Once the response says that the status is "Successful", your application has been deployed and is ready to use.
8

Access your deployed application

Now that your application has been deployed, you can get the URL where it’s accessible.Call GET /applications/{applicationId} to retrieve the application details, including the public URL.
curl -H "Content-Type: application/json" \
     -H "Authorization: Bearer ${BUILDER_JWT}" \
     -cacert ca.crt \
     --key sutro.key \
     --cert sutro.crt \
     -s \
     -X GET \
     https://sapi.withsutro.com/applications/$(jq -r '.id' < application.json) | jq
The response includes the application details, including the URL where your frontend application is accessible. You can now open this URL in your browser to view and interact with your deployed full-stack application.
Your application is deployed, versioned, and ready for teammates or customers to explore. Share the URL with confidence!

Reference