> For the complete documentation index, see [llms.txt](https://developer.perculus.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.perculus.com/services/participant-management/attandee-add.md).

# Creating Participants

{% hint style="danger" %}
**Important Note!**\
\
Constructor Groups’ V1 API has been retired and is no longer available to new customers. Please use the Groups V2 API going forward.\
\
Link to V2 API documentation: <https://developer.perculus.com/v2-en>
{% endhint %}

Using Groups API, there are two ways to create participants for a session:

* [Adding an already existing user to the session](#adding-a-user-to-the-session)
* [Guests](/services/participant-management/attandee-add/guests.md)

### Adding a user to the session

{% hint style="danger" %}
Before you can add a user as a participant in a session, you will need the **USER\_ID** data of that user and the **SESSION\_ID** data of that specific session.
{% endhint %}

Available parameters:

<table><thead><tr><th>Parameter</th><th>Type</th><th width="106">Required</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td>user_id</td><td>string</td><td>Yes</td><td>n/a</td><td>GUID of the user that will be added to the session as a participant</td></tr><tr><td>role</td><td>string</td><td>No</td><td>User's role. <em><mark style="color:green;">See information Hint below</mark></em></td><td>Role of the participant(<a href="/pages/s7xHSgEOsXGduC8JhoWN">see</a>)</td></tr></tbody></table>

{% hint style="info" %}
If the role parameter is not sent, the user will be added to the session with the role she has. <mark style="color:yellow;">Sending the parameter with a non null value will override this.</mark>

For example:

* User with ID: a4cfd141-ea72-42e1-9b9b-d325ca3b255f has role 'e'
* Try add user to session with payload:&#x20;

{% code fullWidth="false" %}

```json
{
    "user_id": "a4cfd141-ea72-42e1-9b9b-d325ca3b255f"
}
```

{% endcode %}

* Attendee will be added with role 'e'
  {% endhint %}

**Example Payload:**

{% tabs %}
{% tab title="CURL" %}

```bash
curl --location --request POST \
'https://<DOMAIN>/xapi/session/<SESSION_ID>/attendees' \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '[{
    "user_id": "<USER_ID>",
    "role": "u"
}]'
```

{% endtab %}

{% tab title="Python" %}

```python
from perculus_sdk.client import APIClient

# API client
client = APIClient()
...

# Add an Attendee
attendee = client.attendees.add_by_user_id("<SESSION_ID>", "<USER_ID>")
print(attendee)

# Add Multiple Attendees
attendees = client.attendees.add_multiple_by_user_id("<SESSION_ID>", [
    { "user_id": "<USER_ID1>" },
    { "user_id": "<USER_ID2>" }
])
print(attendees)
```

{% endtab %}

{% tab title="C#" %}

```
// ASAP :)
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
import APIClient from "perculus-sdk"

// API client
const client = new APIClient()
...

// Add an attendee
const attendee = client.attendees.addAttendee("<SESSION_ID>", "<USER_ID>")
console.log(attendee)

// Add Multiple Attendees
const attendees = client.attendees.addMultipleAttendees("<SESSION_ID>", [
    { user_id: "<USER_ID1>" },
    { user_id: "<USER_ID2>" }
])
console.log(attendees)
```

{% endtab %}

{% tab title="GO" %}

```
// ASAP :)
```

{% endtab %}
{% endtabs %}

***

{% hint style="info" %}
Using the same calls, you can make a batch operation for adding attendees to a session, which will significantly reduce overhead by making a request for each attendee to add.

**Example payload for batch operation:**

```json
[
    {
        "user_id": "<USER_ID1>",
        "role": "u"
    },
    {
        "user_id": "<USER_ID2>"
    }
]
```

{% endhint %}

**Example Response:**

```json
{
    "approved": [
        {
            "session_id": "<SESSION_ID>",
            "user_id": "<USER_ID>",
            "attendee_id": "***",
            "attendance_code": "<ATTENDANCE_CODE>",
            "name": "john",
            "surname": "Doe",
            "email": "john@doe.com",
            "role": "u",
            "mobile": "",
            "avatar": null,
            "creation_date": "2024-08-16T01:55:15.7991084Z",
            "updating_date": null
        }
    ],
    "rejected": []
}
```

{% hint style="danger" %}
You will need to work with the **'ATTENDANCE\_CODE'** data in the example response you see above if you are making an edit to the settings of a participant in that session. You must therefore store this data securely.

To obtain the attendance link for participants to join the session, please see the [relevant section](/services/participant-management/attendance-link.md).
{% endhint %}

:red\_circle: You will see two objects as approved and rejected in the response, you can see their details below:

* approved:
  * Lists the records successfully added from the users.
* rejected:
  * Lists the records that cannot be added from users.&#x20;

**Example Response:**

```json
{
    "approved": [],
    "rejected": [
        {
            "model": null,
            "state": {
                "code": 10,
                "details": "Object reference not set to an instance of an object."
            }
        }
    ]
}
```
