Skip to main content
This guide shows how to use the Judt API from a terminal. You create an API key, and then you use the key to create an App, change its code, preview it in the sandbox, and publish it to production. At the end of the guide, you get an agent prompt that tells a coding agent how to do the same work for you.

Before you begin

You need the following:
  • A Judt account. To sign in, go to judt.ai.
  • A terminal that has curl.
Each request in this guide goes to the base URL https://api.judt.ai.

Create an API key

An API key gives access to the Judt API. The key acts as you in one organization.
1

Open the API keys page

In the Judt dashboard, go to API keys.
2

Start a new key

Click Create key. If the organization has no keys yet, click Create your first key.
3

Set the key properties

Set the following fields:
  • Name: a name for where you use the key, such as Laptop CLI.
  • Expires: select when the key stops working.
Click Create key.
4

Copy the key

Click Copy, and then click Done.
The dashboard shows the key one time only. If you lose the key, revoke it and create a new key.
An API key starts with judt_. For more information about API keys and OAuth tokens, see Authentication.

Store the key

Keep the key out of your shell history and out of your source files. Put the key in an environment variable:
The command waits for input. Paste the key, and then press Enter. Using read lets you avoid the key entering your terminal history.

Send your first request

List the Apps in your organization:
The response is similar to the following:

Create an App

Create an App from the default Hello template. The Hello template contains a Worker that returns a greeting for each request.
The response is similar to the following:
The API generates a unique slug for the App and sets its url. Nothing is published yet (production.status is "unpublished"), so the URL does not serve the App until you deploy. Put the App ID in an environment variable:

Change the code

Each App has a development sandbox that holds its source files and runs a dev server. The sandbox starts automatically when a request needs it, so the first request to a stopped sandbox takes a few extra seconds.
1

Read the entry file

Get index.js from the sandbox:
2

Write the new code

Replace index.js with code that returns a new greeting:
3

Preview the change in the sandbox

Create a preview URL for the dev server:
Open the URL from the url field in a browser. The page shows Hello from my first App. The preview link expires after 5 minutes, at the time in the expires_at field.

Commit the change

A commit records a snapshot of the App’s source in Git and creates a durable backup. If you deploy without a commit, the deployment commits any changes first.
The commit_sha field in the response is the 40-character Git SHA of the new commit.

Publish the App

Publish the sandbox to production:
The request builds the App, publishes the bundle, verifies that the runtime is serving, and returns the completed deployment:
Send a request to the published App:
The response is:
If a write request returns status 503 or 504, the operation may still finish on the server. Each response to a write request has an Idempotency-Key header. To get the result, retry with that key. See Sandboxes, retries, and time limits.

Give the work to an agent

A coding agent can run these same API calls for you when it has a shell and the JUDT_API_KEY environment variable. To restrict the agent to a single App, create an App token with POST /api/tokens. See Give an agent access to an App. Copy the following prompt to your agent. Replace TASK with what you want the agent to build, such as Add an endpoint at /time that returns the current UTC time as JSON, and publish the App.
Agent prompt

Next steps