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

# Sending Bulk Mail

> You can send letter or postcards to thousands of recipients at once.

## Providing Multiple Recipients

To send a print job to many people, provide a recipient object for each of them in the print job.

<CodeGroup>
  ```javascript Node.js SDK theme={null}
  import Intelliprint from 'intelliprint'

  const ip = new Intelliprint('your-api-key-here')

  const printJob = await ip.prints.create({
    type: 'letter',
    content: 'Hello World!\nThis is a letter!',
    recipients: [
      {
        address: {
          name: '1: John Doe',
          line: '123 Main Street, Anytown, Anyplace',
          postcode: 'AB1 2CD',
          country: 'GB'
        }
      },
      {
        address: {
          name: '2: Hopper Doe',
          line: '456 Main Street, Anytown, Anyplace',
          postcode: 'AB1 2CD',
          country: 'GB'
        }
      },
      {
        address: {
          name: '3: Jane Doe',
          line: '789 Main Street, Anytown, Anyplace',
          postcode: 'AB1 2CD',
          country: 'GB'
        }
      }
    ],
    confirmed: false //Set to 'true' when you're ready to start submitting mail for printing.
  })

  console.log('Print job created:', printJob.id)
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.intelliprint.net/v1/prints \
    -H 'Authorization: YOUR_API_KEY' \
    -d 'type=letter' \
    -d 'content=Hello World!\nThis is a letter!' \
    -d 'recipients[0][address][name]=1 John Doe' \
    -d 'recipients[0][address][line]=123 Main Street, Anytown, Anyplace' \
    -d 'recipients[0][address][postcode]=AB1 2CD' \
    -d 'recipients[0][address][country]=GB' \
    -d 'recipients[1][address][name]=2 Hopper Doe' \
    -d 'recipients[1][address][line]=456 Main Street, Anytown, Anyplace' \
    -d 'recipients[1][address][postcode]=AB1 2CD' \
    -d 'recipients[1][address][country]=GB' \
    -d 'recipients[2][address][name]=3 Jane Doe' \
    -d 'recipients[2][address][line]=789 Main Street, Anytown, Anyplace' \
    -d 'recipients[2][address][postcode]=AB1 2CD' \
    -d 'recipients[2][address][country]=GB' \
    -d 'confirmed=false'
  ```
</CodeGroup>

<Note>
  You can design a template with dynamic fields (variables) in the [Intelliprint Dashboard](https://dashboard.intelliprint.net) if you would like to customise your mailings for each recipient.
</Note>

## Using a Mailing List

Sometimes you may want to send the same print job to the same recipients multiple times. In this case, you can use a mailing list to store the recipients and then send the print job to the mailing list.

#### Creating a Mailing List

<CodeGroup>
  ```javascript Node.js SDK theme={null}
  import Intelliprint from 'intelliprint'

  const ip = new Intelliprint('your-api-key-here')

  const mailingList = await ip.mailing_lists.create({
    name: 'My Mailing List',
    recipients: [
      {
        address: {
          name: 'John Doe',
          line: '123 Main Street, Anytown, Anyplace',
          postcode: 'AB1 2CD',
          country: 'GB'
        },
        variables: {
          employee_id: '123456'
        }
      }
    ]
  })

  console.log('Mailing list created:', mailingList.id)
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.intelliprint.net/v1/mailing_lists \
    -H 'Authorization: YOUR_API_KEY' \
    -d 'name=My Mailing List' \
    -d 'recipients[0][address][name]=John Doe' \
    -d 'recipients[0][address][line]=123 Main Street, Anytown, Anyplace' \
    -d 'recipients[0][address][postcode]=AB1 2CD' \
    -d 'recipients[0][address][country]=GB' \
    -d 'recipients[0][variables][employee_id]=123456' \
  ```
</CodeGroup>

#### Adding Recipients to a Mailing List

<CodeGroup>
  ```javascript Node.js SDK theme={null}
  import Intelliprint from 'intelliprint'

  const ip = new Intelliprint('your-api-key-here')

  const mailingList = await ip.mailing_lists.update('my-mailing-list-id', {
    delete_old_recipients: false,
    recipients: [ // The following recipients will be appended to the mailing list.
      {
        address: {
          name: 'John Doe',
          line: '123 Main Street, Anytown, Anyplace',
          postcode: 'AB1 2CD',
          country: 'GB'
        },
        variables: {
          employee_id: '123456'
        }
      }
    ]
  })
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.intelliprint.net/v1/mailing_lists/my-mailing-list-id \
    -H 'Authorization: YOUR_API_KEY' \
    -d 'delete_old_recipients=false' \
    -d 'recipients[0][address][name]=John Doe' \
    -d 'recipients[0][address][line]=123 Main Street, Anytown, Anyplace' \
    -d 'recipients[0][address][postcode]=AB1 2CD' \
    -d 'recipients[0][address][country]=GB' \
    -d 'recipients[0][variables][employee_id]=123456' \
    # The above recipients will be appended to the mailing list.
  ```
</CodeGroup>

#### Sending a Print Job to a Mailing List

<CodeGroup>
  ```javascript Node.js SDK theme={null}
  import Intelliprint from 'intelliprint'

  const ip = new Intelliprint('your-api-key-here') 

  const printJob = await ip.prints.create({
    template: 'tmpl_design',
    mailing_list: 'mal_example',  // [!code ++]
    confirmed: false //Set to 'true' when you're ready to start submitting mail for printing.
  })

  console.log('Print job created:', printJob.id)
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.intelliprint.net/v1/prints \
    -H 'Authorization: YOUR_API_KEY' \
    -d 'template=tmpl_design' \
    -d 'mailing_list=mal_example' \
    -d 'confirmed=false'
  ```
</CodeGroup>

<Info>
  Mailing Lists are limited to 100,000 recipients. Contact [Intelliprint Support](mailto:hello@intelliprint.net) if you want this limit increased for your account.
</Info>
