# Create multiple invites

`POST /invites/create-multiple.json`

Authentication: no security requirement declared for this operation.

Parameters:

- `Api-Key` (header, string, required)
  Type: string

- `Api-Username` (header, string, required)
  Type: string

Request body: application/json

Type: object

- `email` (optional)
  Type: string
  
  pass 1 email per invite to be generated. other properties
  will be shared by each invite.
  
  Example:
  
  ```json
  [
    "not-a-user-yet-1@example.com",
    "not-a-user-yet-2@example.com"
  ]
  ```

- `skip_email` (optional)
  Type: boolean
  
  default: false

- `custom_message` (optional)
  Type: string
  
  optional, for email invites

- `max_redemptions_allowed` (optional)
  Type: integer
  
  optional, for link invites
  
  default: 1
  
  Example:
  
  ```json
  5
  ```

- `topic_id` (optional)
  Type: integer

- `group_ids` (optional)
  Type: string
  
  Optional, either this or `group_names`. Comma separated
  list for multiple ids.
  
  Example:
  
  ```json
  "42,43"
  ```

- `group_names` (optional)
  Type: string
  
  Optional, either this or `group_ids`. Comma separated
  list for multiple names.
  
  Example:
  
  ```json
  "foo,bar"
  ```

- `expires_at` (optional)
  Type: string
  
  optional, if not supplied, the invite_expiry_days site
  setting is used

Responses:

- 200: success response

Content type: application/json

Type: object

- `num_successfully_created_invitations` (optional)
  Type: integer
  
  Example:
  
  ```json
  42
  ```

- `num_failed_invitations` (optional)
  Type: integer
  
  Example:
  
  ```json
  42
  ```

- `failed_invitations` (optional)
  Type: Array<any>
  
  Example:
  
  ```json
  []
  ```
  
  Items:
    Type: any

- `successful_invitations` (optional)
  Type: array
  
  Example:
  
  ```json
  [
    {
      "id": 42,
      "link": "http://example.com/invites/9045fd767efe201ca60c6658bcf14158",
      "email": "not-a-user-yet-1@example.com",
      "emailed": true,
      "custom_message": "Hello world!",
      "topics": [],
      "groups": [],
      "created_at": "2021-01-01T12:00:00.000Z",
      "updated_at": "2021-01-01T12:00:00.000Z",
      "expires_at": "2021-02-01T12:00:00.000Z",
      "expired": false
    },
    {
      "id": 42,
      "link": "http://example.com/invites/c6658bcf141589045fd767efe201ca60",
      "email": "not-a-user-yet-2@example.com",
      "emailed": true,
      "custom_message": "Hello world!",
      "topics": [],
      "groups": [],
      "created_at": "2021-01-01T12:00:00.000Z",
      "updated_at": "2021-01-01T12:00:00.000Z",
      "expires_at": "2021-02-01T12:00:00.000Z",
      "expired": false
    }
  ]
  ```

## Examples

### cURL

```bash
curl -X POST 'https://discourse.example.com/invites/create-multiple.json' \
  -H 'Api-Key: string' \
  -H 'Api-Username: string' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "email": [
    "not-a-user-yet-1@example.com",
    "not-a-user-yet-2@example.com"
  ],
  "skip_email": false,
  "custom_message": "string",
  "max_redemptions_allowed": 5,
  "topic_id": 0,
  "group_ids": "42,43",
  "group_names": "foo,bar",
  "expires_at": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "email": [
    "not-a-user-yet-1@example.com",
    "not-a-user-yet-2@example.com"
  ],
  "skip_email": false,
  "custom_message": "string",
  "max_redemptions_allowed": 5,
  "topic_id": 0,
  "group_ids": "42,43",
  "group_names": "foo,bar",
  "expires_at": "string"
}`;

const response = await fetch('https://discourse.example.com/invites/create-multiple.json', {
  method: 'POST',
  headers: {
    'Api-Key': 'string',
    'Api-Username': 'string',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "email": [
    "not-a-user-yet-1@example.com",
    "not-a-user-yet-2@example.com"
  ],
  "skip_email": false,
  "custom_message": "string",
  "max_redemptions_allowed": 5,
  "topic_id": 0,
  "group_ids": "42,43",
  "group_names": "foo,bar",
  "expires_at": "string"
}'''

response = requests.post(
    'https://discourse.example.com/invites/create-multiple.json',
    data=body.encode('utf-8'),
    headers={
        'Api-Key': 'string',
        'Api-Username': 'string',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
