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

# createTappifyHandler

> Builds the one fetch handler that answers every route Tappify calls on your server.

```ts theme={null}
function createTappifyHandler(options): TappifyFetchHandler;
```

Builds the one `fetch` handler that answers every route Tappify calls on your
server.

## Parameters

### options

[`TappifyHandlerOptions`](/extensions/reference/server-api/Interface.TappifyHandlerOptions)

## Returns

[`TappifyFetchHandler`](/extensions/reference/server-api/TypeAlias.TappifyFetchHandler)

## Remarks

It routes the paths under `/tappify`, minus `basePath` when your framework mounts
it under a prefix, and hands each matched handler a `TappifyRequest`. Every
route but `GET /tappify/health` needs a bearer install token, which it verifies
with `verifyTappifyToken`, and an `X-Tappify-Event-Id` header; a missing token is
401 `TAP_TOKEN_MISSING`, a missing id 400 `TAP_EVENT_ID_MISSING`, an unknown path
404 `TAP_ROUTE_UNKNOWN` and a declared name with no handler 404
`TAP_HANDLER_MISSING`. A body that is not JSON is 400 `TAP_BODY_INVALID` and one
over 1 MB is 413 `TAP_BODY_TOO_LARGE`. A `TapServerError` a handler throws is
answered with its own code and status, and a `TapError` other than the two token
failures with its own code and 400; anything else becomes 500
`TAP_INTERNAL_ERROR` with a fixed message, so an internal failure never reaches
the owner. An events route answers 204 with no body, and every other route
answers the handler's return value as JSON. Export the options object as well as
the handler: `createTestClient` takes the options.

## Example

```ts theme={null}
import {
  createTappifyHandler,
  type TappifyHandlerOptions,
} from '@tappify/extension-sdk/server';

const handlerOptions: TappifyHandlerOptions = {
  extensionId: 'starter',
  health: () => ({ ok: true, version: '0.1.0' }),
  procedures: {
    getSummary: () => ({ installs: 1260, delta: 0.087, topKeyword: 'photo editor' }),
  },
};

const handler = createTappifyHandler(handlerOptions);
```
