# Groups

Source: https://swapcard.dev/content-api/examples/groups


List and create the groups of an event. Groups split the people and exhibitors of an event so you can give them different rights, allow or block features, manage meeting rules, send them different emails or target different advertisements.

Reference: [`EventGroup` object](../graphql-event-api-schema/objects/event-group.mdx)

## Default groups

Every event has three groups by default:

| Group | Who is in it |
| --- | --- |
| Attendees | People who attend the event (guests, visitors, etc.). |
| Exhibitors | Exhibitor companies and their members, usually company representatives who attend the event with a booth. |
| Speakers | People who speak at a session (`planning` in the API). |

Some groups are assigned automatically:

- When you add a person to an exhibitor as a member, they are added to the Exhibitors group.
- When you add a person to a session as a speaker, they are added to the Speakers group.

You can create other groups in [Swapcard Studio](https://studio.swapcard.com) or with the Content API.

## Group priority
A person can be in several groups. An exhibitor can be in a single group, by default the Exhibitors group.

If a person is in several groups, directly or through an exhibitor they are a member of, only the group with the highest `priority` applies.

## Before you begin

- An API key, sent in the `Authorization` header. The key acts with the roles and permissions of the user who created it. See [Authentication](/organizer/authentication).
- The ID of your event (`eventId`). See [Events](./graphql-event-api-examples-event.md).

## List the groups of an event
Use this query to fetch all the groups created on an event, with their priority and number of people.

| Argument | Type | Description |
| --- | --- | --- |
| [`eventId`](../graphql-event-api-schema/queries/event.mdx#id-id) | `ID!` | The ID of the event. |

```graphql title="Query"
query EventGroupsByEventId($eventId: ID!) {
  event(id: $eventId) {
    groups {
      id
      name
      peopleCount
      priority
      isDefault
    }
  }
}
```

```json title="Variables"
{
  "eventId": "RXZlbnDY1Nc4"
}
```

## Create a group
Use this mutation to create a group on an event, for example before you assign people to it with [`importEventPeople`](./graphql-event-api-examples-people.md#perform-different-actions-on-a-people).

| Argument | Type | Description |
| --- | --- | --- |
| `eventId` | `ID!` | The ID of the event on which to create the group. |
| `data.name` | `String!` | The name of the group. |

```graphql title="Mutation"
mutation CreateEventGroup($eventId: ID!, $data: CreateEventGroupInput!) {
  createEventGroup(eventId: $eventId, data: $data) {
    id
    name
    priority
  }
}
```

```json title="Variables"
{
  "eventId": "RXZlbnDY1Nc4",
  "data": {
    "name": "NEWTESTGROUP1"
  }
}
```
