> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.tangerine365.com/llms.txt.
> For full documentation content, see https://docs.tangerine365.com/llms-full.txt.

# Multiple User Creation

POST https://localhost:8090//api/user/createusers
Content-Type: application/json

Create multiple users in one request.  
Each user is submitted as a nested array field in the `users` array.  
The response contains the creation result for each user.

This is the recommended endpoint when importing or bulk-registering multiple users.

Reference: https://docs.tangerine365.com/tangerine-365-enterprise/multiple-user-creation

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Tangerine365 Enterprise
  version: 1.0.0
paths:
  //api/user/createusers:
    post:
      operationId: multiple-user-creation
      summary: Multiple User Creation
      description: >-
        Create multiple users in one request.  

        Each user is submitted as a nested array field in the `users` array.  

        The response contains the creation result for each user.


        This is the recommended endpoint when importing or bulk-registering
        multiple users.
      tags:
        - ''
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Multiple User Creation_Response_200'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                auth:
                  type: string
                users:
                  type: array
                  items:
                    $ref: >-
                      #/components/schemas/ApiUserCreateusersPostRequestBodyContentApplicationJsonSchemaUsersItems
              required:
                - auth
                - users
servers:
  - url: https://localhost:8090
components:
  schemas:
    ApiUserCreateusersPostRequestBodyContentApplicationJsonSchemaUsersItems:
      type: object
      properties:
        role:
          type: string
        email:
          type: string
          format: email
        orgid:
          type: integer
        valid:
          type: integer
        lastname:
          type: string
        password:
          type: string
        username:
          type: string
        firstname:
          type: string
      required:
        - role
        - email
        - orgid
        - valid
        - lastname
        - password
        - username
        - firstname
      title: ApiUserCreateusersPostRequestBodyContentApplicationJsonSchemaUsersItems
    ApiUserCreateusersPostResponsesContentApplicationJsonSchemaDataItems:
      type: object
      properties:
        idst:
          description: Any type
        success:
          type: boolean
        username:
          type: string
        tenant_userid:
          type: string
      required:
        - success
        - username
        - tenant_userid
      title: ApiUserCreateusersPostResponsesContentApplicationJsonSchemaDataItems
    Multiple User Creation_Response_200:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: >-
              #/components/schemas/ApiUserCreateusersPostResponsesContentApplicationJsonSchemaDataItems
        message:
          type: string
        success:
          type: boolean
      required:
        - data
        - message
        - success
      title: Multiple User Creation_Response_200

```

## SDK Code Examples

```python Multiple User Creation_example
import requests

url = "https://localhost:8090//api/user/createusers"

payload = {
    "auth": "{{token}}",
    "users": [
        {
            "role": "user",
            "email": "testuser1@email.com",
            "orgid": 15,
            "valid": 1,
            "lastname": "mylastname",
            "password": "tester123",
            "username": "testuser1",
            "firstname": "username"
        },
        {
            "role": "user",
            "email": "testuser2@email.com",
            "orgid": 15,
            "valid": 1,
            "lastname": "doe",
            "password": "secret456",
            "username": "testuser2",
            "firstname": "jane"
        }
    ]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Multiple User Creation_example
const url = 'https://localhost:8090//api/user/createusers';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"auth":"{{token}}","users":[{"role":"user","email":"testuser1@email.com","orgid":15,"valid":1,"lastname":"mylastname","password":"tester123","username":"testuser1","firstname":"username"},{"role":"user","email":"testuser2@email.com","orgid":15,"valid":1,"lastname":"doe","password":"secret456","username":"testuser2","firstname":"jane"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Multiple User Creation_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://localhost:8090//api/user/createusers"

	payload := strings.NewReader("{\n  \"auth\": \"{{token}}\",\n  \"users\": [\n    {\n      \"role\": \"user\",\n      \"email\": \"testuser1@email.com\",\n      \"orgid\": 15,\n      \"valid\": 1,\n      \"lastname\": \"mylastname\",\n      \"password\": \"tester123\",\n      \"username\": \"testuser1\",\n      \"firstname\": \"username\"\n    },\n    {\n      \"role\": \"user\",\n      \"email\": \"testuser2@email.com\",\n      \"orgid\": 15,\n      \"valid\": 1,\n      \"lastname\": \"doe\",\n      \"password\": \"secret456\",\n      \"username\": \"testuser2\",\n      \"firstname\": \"jane\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Multiple User Creation_example
require 'uri'
require 'net/http'

url = URI("https://localhost:8090//api/user/createusers")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"auth\": \"{{token}}\",\n  \"users\": [\n    {\n      \"role\": \"user\",\n      \"email\": \"testuser1@email.com\",\n      \"orgid\": 15,\n      \"valid\": 1,\n      \"lastname\": \"mylastname\",\n      \"password\": \"tester123\",\n      \"username\": \"testuser1\",\n      \"firstname\": \"username\"\n    },\n    {\n      \"role\": \"user\",\n      \"email\": \"testuser2@email.com\",\n      \"orgid\": 15,\n      \"valid\": 1,\n      \"lastname\": \"doe\",\n      \"password\": \"secret456\",\n      \"username\": \"testuser2\",\n      \"firstname\": \"jane\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Multiple User Creation_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://localhost:8090//api/user/createusers")
  .header("Content-Type", "application/json")
  .body("{\n  \"auth\": \"{{token}}\",\n  \"users\": [\n    {\n      \"role\": \"user\",\n      \"email\": \"testuser1@email.com\",\n      \"orgid\": 15,\n      \"valid\": 1,\n      \"lastname\": \"mylastname\",\n      \"password\": \"tester123\",\n      \"username\": \"testuser1\",\n      \"firstname\": \"username\"\n    },\n    {\n      \"role\": \"user\",\n      \"email\": \"testuser2@email.com\",\n      \"orgid\": 15,\n      \"valid\": 1,\n      \"lastname\": \"doe\",\n      \"password\": \"secret456\",\n      \"username\": \"testuser2\",\n      \"firstname\": \"jane\"\n    }\n  ]\n}")
  .asString();
```

```php Multiple User Creation_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://localhost:8090//api/user/createusers', [
  'body' => '{
  "auth": "{{token}}",
  "users": [
    {
      "role": "user",
      "email": "testuser1@email.com",
      "orgid": 15,
      "valid": 1,
      "lastname": "mylastname",
      "password": "tester123",
      "username": "testuser1",
      "firstname": "username"
    },
    {
      "role": "user",
      "email": "testuser2@email.com",
      "orgid": 15,
      "valid": 1,
      "lastname": "doe",
      "password": "secret456",
      "username": "testuser2",
      "firstname": "jane"
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Multiple User Creation_example
using RestSharp;

var client = new RestClient("https://localhost:8090//api/user/createusers");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"auth\": \"{{token}}\",\n  \"users\": [\n    {\n      \"role\": \"user\",\n      \"email\": \"testuser1@email.com\",\n      \"orgid\": 15,\n      \"valid\": 1,\n      \"lastname\": \"mylastname\",\n      \"password\": \"tester123\",\n      \"username\": \"testuser1\",\n      \"firstname\": \"username\"\n    },\n    {\n      \"role\": \"user\",\n      \"email\": \"testuser2@email.com\",\n      \"orgid\": 15,\n      \"valid\": 1,\n      \"lastname\": \"doe\",\n      \"password\": \"secret456\",\n      \"username\": \"testuser2\",\n      \"firstname\": \"jane\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Multiple User Creation_example
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "auth": "{{token}}",
  "users": [
    [
      "role": "user",
      "email": "testuser1@email.com",
      "orgid": 15,
      "valid": 1,
      "lastname": "mylastname",
      "password": "tester123",
      "username": "testuser1",
      "firstname": "username"
    ],
    [
      "role": "user",
      "email": "testuser2@email.com",
      "orgid": 15,
      "valid": 1,
      "lastname": "doe",
      "password": "secret456",
      "username": "testuser2",
      "firstname": "jane"
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://localhost:8090//api/user/createusers")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```