# Invite many users

- Operation ID: `bulkInviteUsersUsingPOST`
- HTTP method: `POST`
- Path: `/uauth/users/invitations/invite-bulk`
- [Human-readable API reference](https://hub.synerise.com/api-reference/identity-and-access-management#tag/User-management/operation/bulkInviteUsersUsingPOST)

## Self-contained OpenAPI method

The fenced document below contains this method's documentation and all of its local references. It is self-contained; no category or master specification fetch is required.

```yaml
openapi: 3.0.0
info:
  title: Synerise Public API
  version: 1.9.1
paths:
  /uauth/users/invitations/invite-bulk:
    post:
      tags:
        - User management
      summary: Invite many users
      description: |
        Invite a number of users to the workspace at once. The users receive emails with invitation tokens.

        ---

        **API consumer:** <a href="/api-reference/authorization?tag=Authorization&amp;operationId=userLogin" target="_blank" rel="noopener">Synerise User</a>

        **User role permission required:** `settings_users: create`
      operationId: bulkInviteUsersUsingPOST
      requestBody:
        description: All the data sent in this request refers to the users being invited.
        content:
          application/json:
            schema:
              type: object
              properties:
                invitations:
                  type: array
                  description: An array of users to invite
                  items:
                    type: object
                    properties:
                      email:
                        type: string
                        description: User's email address
                      firstName:
                        type: string
                        description: First name of the user
                      lastName:
                        type: string
                        description: Last name of the user
                      roles:
                        type: array
                        description: An array of roles (IDs) assigned to the user in the currently selected workspace
                        items:
                          type: integer
                          format: int64
                      expirationDate:
                        type: string
                        format: date-time
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: array
                    items:
                      type: string
                    description: List of successfully invited email addresses
                  fail:
                    type: array
                    items:
                      type: object
                      properties:
                        email:
                          type: string
                        cause:
                          type: string
                    description: List of failed invitations
        "401":
          description: Unauthorized
          content: {}
        "403":
          description: Forbidden
          content: {}
        "404":
          description: Not Found
          content: {}
      security:
        - JWT: []
      x-snr-doc-urls:
        - /api-reference/identity-and-access-management#tag/User-management/operation/bulkInviteUsersUsingPOST
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.synerise.com/uauth/users/invitations/invite-bulk \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
              --header 'content-type: application/json' \
              --data '{"invitations":[{"email":"string","firstName":"string","lastName":"string","roles":[0],"expirationDate":"2019-08-24T14:15:22Z"}]}'
        - lang: Python
          label: Python
          source: |-
            import http.client

            conn = http.client.HTTPSConnection("api.synerise.com")

            payload = "{\"invitations\":[{\"email\":\"string\",\"firstName\":\"string\",\"lastName\":\"string\",\"roles\":[0],\"expirationDate\":\"2019-08-24T14:15:22Z\"}]}"

            headers = {
                'Authorization': "Bearer REPLACE_BEARER_TOKEN",
                'content-type': "application/json"
                }

            conn.request("POST", "/uauth/users/invitations/invite-bulk", payload, headers)

            res = conn.getresponse()
            data = res.read()

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = JSON.stringify({
              "invitations": [
                {
                  "email": "string",
                  "firstName": "string",
                  "lastName": "string",
                  "roles": [
                    0
                  ],
                  "expirationDate": "2019-08-24T14:15:22Z"
                }
              ]
            });

            const xhr = new XMLHttpRequest();
            xhr.withCredentials = true;

            xhr.addEventListener("readystatechange", function () {
              if (this.readyState === this.DONE) {
                console.log(this.responseText);
              }
            });

            xhr.open("POST", "https://api.synerise.com/uauth/users/invitations/invite-bulk");
            xhr.setRequestHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");
            xhr.setRequestHeader("content-type", "application/json");

            xhr.send(data);
        - lang: Node.js
          label: Node.js
          source: |-
            const http = require("https");

            const options = {
              "method": "POST",
              "hostname": "api.synerise.com",
              "port": null,
              "path": "/uauth/users/invitations/invite-bulk",
              "headers": {
                "Authorization": "Bearer REPLACE_BEARER_TOKEN",
                "content-type": "application/json"
              }
            };

            const req = http.request(options, function (res) {
              const chunks = [];

              res.on("data", function (chunk) {
                chunks.push(chunk);
              });

              res.on("end", function () {
                const body = Buffer.concat(chunks);
                console.log(body.toString());
              });
            });

            req.write(JSON.stringify({
              invitations: [
                {
                  email: 'string',
                  firstName: 'string',
                  lastName: 'string',
                  roles: [0],
                  expirationDate: '2019-08-24T14:15:22Z'
                }
              ]
            }));
            req.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/uauth/users/invitations/invite-bulk');
            $request->setMethod(HTTP_METH_POST);

            $request->setHeaders([
              'Authorization' => 'Bearer REPLACE_BEARER_TOKEN',
              'content-type' => 'application/json'
            ]);

            $request->setBody('{"invitations":[{"email":"string","firstName":"string","lastName":"string","roles":[0],"expirationDate":"2019-08-24T14:15:22Z"}]}');

            try {
              $response = $request->send();

              echo $response->getBody();
            } catch (HttpException $ex) {
              echo $ex;
            }
        - lang: Java
          label: Java
          source: |-
            HttpResponse<String> response = Unirest.post("https://api.synerise.com/uauth/users/invitations/invite-bulk")
              .header("Authorization", "Bearer REPLACE_BEARER_TOKEN")
              .header("content-type", "application/json")
              .body("{\"invitations\":[{\"email\":\"string\",\"firstName\":\"string\",\"lastName\":\"string\",\"roles\":[0],\"expirationDate\":\"2019-08-24T14:15:22Z\"}]}")
              .asString();
servers:
  - description: Microsoft Azure EU
    url: https://api.synerise.com
  - description: Microsoft Azure USA
    url: https://api.azu.synerise.com
  - description: Google Cloud Platform
    url: https://api.geb.synerise.com
tags:
  - name: User management
components:
  securitySchemes:
    JWT:
      type: http
      scheme: bearer
      description: |-
        JWT Bearer token. The header looks like this: `Bearer {JWT}`

        Remember to include the space between 'Bearer' and the token.

        Generate a token via the **Authorization** endpoints.
```
