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

# Introduction

![Internal tools. Just code. An io.display.table call next to the Users page of the demo backoffice, where it shows the All users table](https://mintcdn.com/awaitio/csnpRo_garxWT8fI/images/intro-hero.png?fit=max\&auto=format\&n=csnpRo_garxWT8fI\&q=85\&s=e60cc7d98566808f62c5653ff9bf23e6)

AwaitIO is a backoffice written just like regular API routes. Each action is an async TypeScript function, like a route handler. Instead of reading a request, every `await` on `io` asks a person in the browser and waits for the answer.

There is no frontend to build. The same Node process serves the UI, so there is nothing else to host.

## What you write

```ts actions/accounts/createAccountAction.ts theme={null}
import { app } from '../../app';
import { constants } from '../../constants';
import { db } from '../../db/db';

export const createAccountAction = app.defineAction({
  name: 'Create account',
  description: 'Opens a 14-day trial for a new store and invites its owner.',
  handler: async ({ io }) => {
    const { name, domain, ownerName, ownerEmail, plan } = await io.group({
      store: io.display.heading('Store', { description: 'How the store is called and where it runs.' }),
      name: io.input.text('Store name', { placeholder: 'Acme Coffee' }),
      domain: io.input.text('Domain', { placeholder: 'acme-coffee.example' }),
      owner: io.display.heading('Owner', { description: 'Gets the invitation and full access.' }),
      ownerName: io.input.text('Owner name'),
      ownerEmail: io.input.email('Owner email'),
      plan: io.select.single('Plan after the trial', { options: constants.PLANS, defaultValue: 'growth' }),
    });

    const trialEndsAt = new Date(Date.now() + 14 * 24 * 60 * 60 * 1000);

    const account = await db.account.create({
      data: { name, domain, plan: plan.value, status: 'trial', monthlyRevenue: 0, ownerEmail, trialEndsAt, createdAt: new Date() },
    });

    await db.user.create({
      data: { name: ownerName, email: ownerEmail, role: 'owner', accountId: account.id, lastLoginAt: null, createdAt: new Date() },
    });

    return { account: account.name, id: account.id, plan: plan.label, trialEndsAt, invitationSentTo: ownerEmail };
  },
});
```

## What people see

The form shows what `io.group` asked for. It is the same action in the [demo](https://demo.awaitio.com), whose `db` stands in for your Prisma client:

![The Create account action: store and owner fields filled in for Juniper Tea, with a Continue button](https://mintcdn.com/awaitio/csnpRo_garxWT8fI/images/intro-form.png?fit=max\&auto=format\&n=csnpRo_garxWT8fI\&q=85\&s=894ff9ab363626fdfeb9a54e26ac2c2f)

**Continue** sends the answers to the server, which validates them and resumes the handler. Its return value is the result:

![The result of Create account: the new account, its plan, the end of its trial and who got the invitation](https://mintcdn.com/awaitio/csnpRo_garxWT8fI/images/intro-result.png?fit=max\&auto=format\&n=csnpRo_garxWT8fI\&q=85\&s=7f19568d7bd0b96c8c1d93bcaf113086)

## Bring your codebase

A handler is a plain async function that runs in your own Node process, so everything your app already has works inside it. Bring along:

* **your database**: the Prisma client, the ORM or the queries you already use;
* **your business logic**: the services and rules your product runs on, without copying them;
* **logic shared with your API or GraphQL**: the same functions your resolvers and endpoints call;
* **your internal tools**: scripts, utilities, environment variables and any npm package.

AwaitIO only adds `io` to ask a person and `ctx` to know who it is.

```ts actions/refundOrderAction.ts theme={null}
import { app } from '../app';
import { prisma } from '../prisma';
import { formatMoney } from '../utils/formatMoney';

export const refundOrderAction = app.defineAction({
  name: 'Refund order',
  handler: async ({ io, ctx }) => {
    const orderId = await io.input.text('Order ID');
    const order = await prisma.order.findUniqueOrThrow({ where: { id: orderId } });
    const reason = await io.input.textarea(`Why refund ${formatMoney(order.total)}?`);

    await prisma.refund.create({ data: { orderId, reason, approvedBy: ctx.user.email } });

    return { refunded: formatMoney(order.total) };
  },
});
```

Nothing has to be wrapped, exported to another service or rewritten: between two `await io` calls it is just your code.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.