# Go API

A Go API built with `net/http` reports its runtime, answers health checks, and lets you list or add todos. Tokay compiles the source and runs the binary as one Web Service.

The project is intentionally close to what you would write for any Go host. You keep the standard library server and Tokay handles the build and live routing.

## Facts

- Runtime: Go
- Framework: net/http
- Service types: Web Service
- Resources: None
- Required secrets: None

## What it does

The root route tells you which Go runtime compiled the service.

Fetch `/todos` to see three starting tasks. Post a JSON title and the API adds it with the next ID. Malformed JSON, unknown fields, and blank titles receive a helpful `400` response.

Use `/health` when you need a simple check that the process is answering requests.

## 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

Point the commands at your live URL and prove that a write appears in the next read.

```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"
```

The list includes the new title while this process is running. A fresh deployment resets it to the sample data because storage is deliberately outside this starter.

## How it works

You do not need to ship a compiled artifact. Tokay reads `go.mod`, builds `main.go`, supplies the port, and starts the finished program for you.

## Secrets

There are no secrets to configure. The API has no outside dependencies.

## Grow from here

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

## Source files

- [go.mod](https://tokay.io/examples/src/go-api/go.mod)
- [main.go](https://tokay.io/examples/src/go-api/main.go)

## Download and source

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