---
title: "nuxt-backend/http"
description: "Every export of nuxt-backend/http, with its signature and where it is defined."
canonical_url: "https://nuxt-backend.dev/docs/reference/api/http"
---
# nuxt-backend/http

Version: nuxt-backend 0.6.x · Tab: Reference · Kind: reference · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

## Interfaces

### RegisterBackendRoutesOptions

Defined in: [src/convex/integrations/http.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts)

One call to mount every inbound route the backend handles on your Convex
HTTP router: the auth routes, the guarded
billing events endpoint (entitlement refresh + gift fulfilment), the
guarded email delivery-events endpoint (status tracking), the metered
AI stream endpoint, and the backend's health at `/backend/health` (a fixed
path: the app's `/api/backend/health` asks it there). Each part is
required: a route left unmounted fails only when a provider or a client
first calls it.

The webhook endpoints share one fail-closed policy (see `webhook-guard.ts`):
missing secret → 503, invalid signature → 403 (±5 min replay tolerance),
oversized → 413, authentic-but-unknown type → 202, handler throw → 500 so
the provider retries, redelivery of a processed id → 200. Every request's
outcome lands in the component's delivery log.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="auth">
        
      </a>
      
       <code>
        auth
      </code>
    </td>
    
    <td>
      { <code>
        authComponent
      </code>
      
      : { <code>
        registerRoutes
      </code>
      
      : (...<code>
        args
      </code>
      
      ) => <code>
        void
      </code>
      
      ; <code>
        safeGetAuthUser?
      </code>
      
      : (<code>
        ctx
      </code>
      
      ) => <code>
        Promise
      </code>
      
      < | { <code>
        role?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        banned?
      </code>
      
      : <code>
        boolean
      </code>
      
       | <code>
        null
      </code>
      
      ; } | <code>
        null
      </code>
      
       | <code>
        undefined
      </code>
      
      >; }; <code>
        createAuth
      </code>
      
      : <code>
        unknown
      </code>
      
      ; }
    </td>
    
    <td>
      From <code>
        setupAuth
      </code>
      
      : mounts the auth HTTP routes.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        auth.authComponent
      </code>
    </td>
    
    <td>
      { <code>
        registerRoutes
      </code>
      
      : (...<code>
        args
      </code>
      
      ) => <code>
        void
      </code>
      
      ; <code>
        safeGetAuthUser?
      </code>
      
      : (<code>
        ctx
      </code>
      
      ) => <code>
        Promise
      </code>
      
      < | { <code>
        role?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        banned?
      </code>
      
      : <code>
        boolean
      </code>
      
       | <code>
        null
      </code>
      
      ; } | <code>
        null
      </code>
      
       | <code>
        undefined
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        auth.authComponent.registerRoutes
      </code>
    </td>
    
    <td>
      (...<code>
        args
      </code>
      
      ) => <code>
        void
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        auth.authComponent.safeGetAuthUser?
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      ) => <code>
        Promise
      </code>
      
      < | { <code>
        role?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        banned?
      </code>
      
      : <code>
        boolean
      </code>
      
       | <code>
        null
      </code>
      
      ; } | <code>
        null
      </code>
      
       | <code>
        undefined
      </code>
      
      >
    </td>
    
    <td>
      The account behind a request's session: the health route serves its detail to an admin.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        auth.createAuth
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="billing">
        
      </a>
      
       <code>
        billing
      </code>
    </td>
    
    <td>
      { <code>
        webhookHandler
      </code>
      
      : (<code>
        ctx
      </code>
      
      , <code>
        request
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Response
      </code>
      
      >; }
    </td>
    
    <td>
      From <code>
        setupBilling
      </code>
      
      : mounts the guarded billing events webhook at <a href="#billingpath">
        RegisterBackendRoutesOptions.billingPath
      </a>
      
       (fail-closed statuses, redelivery dedupe, delivery logging — pass the whole <code>
        billing
      </code>
      
       instance). Every workspace (or account, with <code>
        billTo: 'user'
      </code>
      
      ) the auth routes make is handed to it too, which starts the catalog's free plan for it, and a workspace the auth routes delete is refused while it holds a paid subscription.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        billing.webhookHandler
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        request
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Response
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="email">
        
      </a>
      
       <code>
        email
      </code>
    </td>
    
    <td>
      { <code>
        webhookHandler
      </code>
      
      : (<code>
        ctx
      </code>
      
      , <code>
        request
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Response
      </code>
      
      >; }
    </td>
    
    <td>
      From <code>
        setupEmail
      </code>
      
      : mounts the email events webhook at <a href="#emailpath">
        RegisterBackendRoutesOptions.emailPath
      </a>
      
      , and the RFC 8058 one-click unsubscribe at <code>
        /email/unsubscribe
      </code>
      
       (<code>
        GET
      </code>
      
       sends the reader to the unsubscribe page, <code>
        POST
      </code>
      
       unsubscribes at once).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        email.webhookHandler
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        request
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Response
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="ai">
        
      </a>
      
       <code>
        ai
      </code>
    </td>
    
    <td>
      { <code>
        httpHandler
      </code>
      
      : <code>
        unknown
      </code>
      
      ; <code>
        corsOrigin
      </code>
      
      : <code>
        string
      </code>
      
      ; }
    </td>
    
    <td>
      From <code>
        setupAi
      </code>
      
      : mounts the metered stream endpoint at <a href="#aipath">
        RegisterBackendRoutesOptions.aiPath
      </a>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ai.httpHandler
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ai.corsOrigin
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="storage">
        
      </a>
      
       <code>
        storage?
      </code>
    </td>
    
    <td>
      { }
    </td>
    
    <td>
      From <code>
        setupStorage
      </code>
      
      , when the app keeps files: mounts the route that serves <code>
        storage.signedUrl
      </code>
      
      's expiring URLs (<code>
        GET /storage/<id>
      </code>
      
      ). Without it, a signed URL answers 404.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="billingpath">
        
      </a>
      
       <code>
        billingPath?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Route for the billing events webhook. Default <code>
        /billing/events
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="emailpath">
        
      </a>
      
       <code>
        emailPath?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Route for the email events webhook. Default <code>
        /email/events
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="aipath">
        
      </a>
      
       <code>
        aiPath?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Route for the AI stream endpoint. Default <code>
        /ai/stream
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="adminroles">
        
      </a>
      
       <code>
        adminRoles?
      </code>
    </td>
    
    <td>
      readonly <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      The roles that count as admin for the backend's health: a session whose account holds one reads the detail (each layer's reason, the env it lacks). Default <code>
        ['admin']
      </code>
      
      , as <code>
        createFunctions
      </code>
      
       takes them.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts" rel="nofollow">
        src/convex/integrations/http.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Functions

### registerBackendRoutes()

```ts
function registerBackendRoutes(http, options): void;
```

Defined in: [src/convex/integrations/http.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/http.ts)

Mount every route the backend serves on the app's HTTP router: the auth
routes, the billing and email webhooks, the
metered AI stream, and the health. Every part is required; a missing one throws,
naming it. `storage` is the one optional part: pass it when the app keeps
files, and `storage.signedUrl`'s expiring URLs are served.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        http
      </code>
    </td>
    
    <td>
      <code>
        HttpRouter
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options
      </code>
    </td>
    
    <td>
      <a href="#registerbackendroutesoptions">
        <code>
          RegisterBackendRoutesOptions
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

`void`

#### Example

```ts
// convex/http.ts
import { registerBackendRoutes } from 'nuxt-backend/http'
import { httpRouter } from 'convex/server'
import { components } from './_generated/api'
import { ai } from './ai'
import { authComponent, createAuth } from './auth'
import { billing } from './billing'
import { email } from './email'

const http = httpRouter()
registerBackendRoutes(http, { auth: { authComponent, createAuth }, billing, email, ai })
export default http
```


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
