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

# Receiving client

> Full reference for the Paubox Node.js SDK receiving API: managing domains, mailboxes, and retrieving inbound email.

The receiving methods are on the same `emailService` you use to send email.

```javascript theme={null}
const pbMail  = require('paubox-node');
const service = pbMail.emailService({ apiKey: 'YOUR_API_KEY' });
```

## Domains

### List domains

```javascript theme={null}
const domains = await service.listReceivingDomains();
domains.data.forEach(d => console.log(d.domain));
```

### Create a domain

```javascript theme={null}
const domain = await service.createReceivingDomain('support');
console.log(domain.data.domain); // support.inbound.paubox.email
```

Pass `null` or omit the argument to auto-generate a slug.

### Get a domain

```javascript theme={null}
const domain = await service.getReceivingDomain(1);
```

### Delete a domain

```javascript theme={null}
await service.deleteReceivingDomain(1);
```

## Mailboxes

### List mailboxes

```javascript theme={null}
const mailboxes = await service.listReceivingMailboxes(domainId);
```

### Create a mailbox

```javascript theme={null}
const mailbox = await service.createReceivingMailbox(
  domainId, 'intake', 'SecurePass123!'
);
console.log(mailbox.data.email_address);
```

Pass a fourth argument for `quotaBytes`.

### Get a mailbox

```javascript theme={null}
const mailbox = await service.getReceivingMailbox(domainId, mailboxId);
```

### Delete a mailbox

```javascript theme={null}
await service.deleteReceivingMailbox(domainId, mailboxId);
```

## Emails

### List received emails

```javascript theme={null}
const emails = await service.listReceivedEmails({ limit: 10 });
emails.data.forEach(e => console.log(`${e.email_id}: ${e.subject}`));

// Cursor pagination
const next = await service.listReceivedEmails({
  after: emails.data[emails.data.length - 1].email_id
});
```

### Get a received email

```javascript theme={null}
const email = await service.getReceivedEmail('eaaaaab');
console.log(email.data.body.text);
```

### Download an attachment

```javascript theme={null}
const attachment = await service.getReceivedEmailAttachment('eaaaaab', 'blob123');
```
