---
title: "HTTP routes"
description: "Plain HTTP for webhooks and other services."
url: "https://arkapi.emincanozcan.com/docs/http"
---

# HTTP routes

Plain HTTP for webhooks and other services.

Some callers are not your app: a payment provider, a form, a script. Export `routes` from any api file to accept plain HTTP requests.

```ts
import { ApiError, type Routes } from 'arkapi/server'

export const routes: Routes = {
  'POST /announce': async (req) => {
    const token = process.env.ANNOUNCE_TOKEN
    if (!token || req.headers.get('Authorization') !== `Bearer ${token}`) {
      throw new ApiError('UNAUTHORIZED', 'Invalid token')
    }
    const text = await req.text()
    return Response.json({ accepted: text })
  },
  'PUT /items/:id': async (req, params) => Response.json({ id: params.id }),
}
```

Keys are `METHOD /path`; `:name` segments arrive in `params`. Handlers get the standard `Request` and return a `Response`.

The URLs are `<base>/http/announce` and `<base>/http/items/123`, where `<base>` is your app's URL (`BASE` in the generated client). A route refreshes live data like a mutation.

```sh
curl -X POST https://arkapi.emincanozcan.com/apps/<app>/http/announce \
  -H 'Authorization: Bearer your-token' -d 'Hello from outside'
```

Set secrets with `bunx arkapi env set ANNOUNCE_TOKEN=...`. Browser cookies are not forwarded; use the `Authorization` header.
