# Ruby Sinatra API

A Sinatra API serves a small todo list with routes for health, runtime details, reads, and writes. Tokay runs the Ruby app with Puma as one Web Service.

Choose this example when you want the shortest route from a Ruby file and Gemfile to a public API. Your app stays ordinary Sinatra code while Tokay handles its service setup.

## Facts

- Runtime: Ruby
- Framework: Sinatra
- Service types: Web Service
- Resources: None
- Required secrets: None

## What it does

Visit the root route to see the Ruby version behind your live service.

The `/todos` route lists three starting items. Post a JSON title to add another. Bad JSON or an empty title returns a `400` response instead of changing the list.

The `/health` route confirms that Puma and the app are responding.

## Deploy it

Bring this folder to Tokay any way you like. Paste or upload it in the dashboard, push it with git, or hand it to your AI agent along with [our agent instructions](https://app.tokay.io/llms.txt). Tokay figures out the rest.

Working in Claude, ChatGPT, VS Code, or another MCP client? Connect the [Tokay MCP server](https://tokay.io/docs/platform-mcp) and ask your agent to deploy this example. It signs in through your browser, so there is no token to paste.

New to Tokay? The [getting started guide](https://tokay.io/getting-started) walks you through your first deploy.

## Try it

Use your live URL to add a todo and read it back.

```sh
export APP_URL="https://your-app.tokay.app"
curl -X POST "$APP_URL/todos" \
  -H 'Content-Type: application/json' \
  -d '{"title":"ship the next thing"}'
curl "$APP_URL/todos"
```

You will find the new item in the second response. Deploy once more and the original three return because the example keeps its list in memory.

## How it works

You can keep Sinatra's small route based structure. Tokay installs the gems, provides `PORT`, and starts Puma with the same `app.rb` you run locally.

## Secrets

No private values are needed. The full API works as soon as the service is live.

## Grow from here

Browse the [Tokay examples catalog](/examples) when you want saved data or scheduled work.

## Source files

- [Gemfile](https://tokay.io/examples/src/ruby-sinatra-api/Gemfile)
- [app.rb](https://tokay.io/examples/src/ruby-sinatra-api/app.rb)

## Download and source

- [Download the complete project](https://tokay.io/examples/downloads/ruby-sinatra-api.zip)
- Last updated: 2026-07-31
- Example revision: `52c7b7f`
- [View this revision on GitHub](https://github.com/tokayio/tokay-examples/tree/52c7b7ffd52e157375b08f1f11ff4fbe6c498642/ruby-sinatra-api)
- [Deploy a web app](https://tokay.io/use-cases/deploy-webapp)
