# Send from your customer's own inbox

Let them connect the Gmail or Outlook account they already work out of. From then on it sends and receives through AI Inbx on the same API as a domain you own.

[Get started](/signup)
[Documentation](https://docs.aiinbx.com/guides/mailboxes)

Your customer approves a Microsoft sign-in consent screen once, letting your app read their mail, send mail as them and keep that access. From then on support@harbourly.com is connected, and your product sends from it with the same aiinbx.emails.send call as any other address.

Connecting

## Connected through your own OAuth app

Register an OAuth app with Google or Microsoft and add it to AI Inbx. The consent screen, the hosted page and the connect link carry your product's name.

Three ways to connect a mailbox. Hosted page (aiinbx.com/connect/yourapp): A link you share. The person sees: A page in your brand, then the consent screen. Connect link (aiinbx.com/connect/yourapp/start): A URL on a button. The person sees: The consent screen, then a page of yours. API (mailboxes.connect({ app\_id, space\_id })): One server-side call. The person sees: The consent screen, then a page of yours. Each ends with mailbox.connected on your webhook.

### Three ways to connect

Share the hosted page, put a connect link on a button or mint a URL from your server. Each ends with the person approving at Google or Microsoft.

Example: the hosted connect page at aiinbx.com/connect/yourapp carries the name Yourapp, its logo, the line “Let Yourapp handle your inbox”, a Connect Gmail button and the support address support@yourapp.com.

### Hosted page

Each OAuth app has a permanent page with your name, logo, accent colour and support address. Send people there or put it in an email.

Example: tom@harbourly.com at Harbourly and jana@rheinbau.de at Rheinbau are connected through Yourapp, your own OAuth app, each in its customer’s space.

### [In the customer's space](/features/spaces)

A connect URL minted with space\_id puts the mailbox in that customer's space, along with everything synced from it.

Example: the Gmail mailbox tom@harbourly.com is connected and lists the aliases sales@harbourly.com and billing@harbourly.com, each usable as a from address.

### Aliases

A Gmail account's verified send-as addresses come with the mailbox. Each works as a from, and a reply goes out as the alias the message was written to.

Example: jana@rheinbau.de reads needs\_reauth. The mailbox.needs\_reauth event carries the mailbox id, the ref user\_8812 and the metadata set when it was connected. Once the person approves again the mailbox is active.

### Re-authorisation

When a grant expires or is revoked, mailbox.needs\_reauth reaches your webhook with the ref and metadata you set, so you know which user to prompt.

API

## From OAuth app to connected mailbox

The app is created once. Each customer gets a connect URL from your server, and mailbox.connected tells you the mailbox is live.

Step 1, oauthApps.create: once, with the client you registered at the provider.

```
const app = await aiinbx.oauthApps.create({
  provider: "google",
  name: "Yourapp",
  slug: "yourapp",
  client_id: process.env.GOOGLE_CLIENT_ID,
  client_secret: process.env.GOOGLE_CLIENT_SECRET,
})

console.log(app.redirect_uri) // add it to the provider's redirect list
```

Step 2, mailboxes.connect: per customer, from your server.

```
const { url } = await aiinbx.mailboxes.connect({
  provider: "google",
  app_id: app.id,
  space_id: space.id,
  return_to: "https://app.yourapp.com/settings/mailboxes",
  ref: user.id,
})

// Redirect the customer to url
```

Step 3, mailbox.connected: the signal that the mailbox is live.

```
if (event.type === "mailbox.connected") {
  const { mailbox_id, address, ref } = event.data

  await markMailboxReady(ref, mailbox_id, address)
}
```

Details

## A connected mailbox works like any other address

-   One approval: Connecting takes one person approving once. Their mail keeps flowing through Google or Microsoft as before, and AI Inbx syncs it.
-   Sync: New mail in a connected mailbox reaches your webhook as it arrives. The first sync covers the last 7 days, or the number you set with backfill\_days.
-   Threads and categories: Replies land on the thread they answer, and what arrives is labelled before your webhook fires, the same way it is on a domain.
-   Pacing: Your rules and sending hours hold a mailbox like any other address. Scope a limit to its from address and it has a budget of its own.
-   Suppressions: Sends from a mailbox are checked against the same suppression lists, so someone who asked you to stop is blocked here too.
-   Webhooks: The same payloads with the same signature. mailbox\_id on an event names the mailbox the mail went through.

Solutions

## Where it comes in

-   [Inbound email APIReceive email in your app over an API. Point an MX record at AI Inbx or connect Gmail and Outlook, and every message arrives as a signed, parsed JSON webhook.ThreadingAttachmentsMailboxesWildcard domains](/solutions/inbound-email-api)
-   [Email reply parserParse every email reply down to what the sender wrote: quoted text and repeated signatures removed, answers typed inside the quote kept where they were.ThreadingMailboxes](/solutions/email-reply-parser)
-   [Auto-reply detectionTell an out-of-office, a ticket acknowledgement or a bounce from a real reply. Every inbound email arrives with a category, even when no header gives it away.MailboxesSuppressions](/solutions/auto-reply-detection)
-   [Send email APISend email from your domain or your users' own Gmail and Outlook with one API call. Opt-outs and pacing are checked first, and replies land on the thread.ThreadingMailboxesPacingSuppressions](/solutions/send-email-api)

## Give your product an inbox. The hard parts are already handled.

[Get started](/signup)
