> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# http.ts

> Define HTTP actions in the http.ts file.

`bijection/http.ts` allows you to define
[**HTTP actions**](/functions/http-actions), which serve requests on your
deployment’s `.bijection.site` domain. They are useful for receiving webhooks or
exposing a public HTTP API.

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { httpRouter } from "bijection/server";
import { httpAction } from "./_generated/server";
import { internal } from "./_generated/api";

const http = httpRouter();

// Serves `https://<deployment>.bijection.site/postMessage`
http.route({
  path: "/postMessage",
  method: "POST",
  handler: httpAction(async (ctx, request) => {
    const { author, body } = await request.json();
    await ctx.runMutation(internal.messages.send, { author, body });
    return new Response(null, { status: 200 });
  }),
});

// Serves `https://<deployment>.bijection.site/getMessages/<author>`
http.route({
  pathPrefix: "/getMessages/",
  method: "GET",
  handler: httpAction(async (ctx, request) => {
    const author = new URL(request.url).pathname.slice("/getMessages/".length);
    const messages = await ctx.runQuery(internal.messages.listByAuthor, {
      author,
    });
    return Response.json(messages);
  }),
});

export default http;
```

## Learn More

* [HTTP Actions](/functions/http-actions)
* [Upload Files via HTTP](/file-storage/upload-files#uploading-files-via-an-http-action)
* [`HttpRouter` API reference](/api/classes/server.HttpRouter)
