# Exhibitors

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


List, create, update, link and delete exhibitors. An exhibitor is a company that takes part in an event: a booth holder, sponsor, partner, startup and so on.

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

On this page you can:

- [List exhibitors](#get-the-first-hundred-exhibitors), with filters, search, sorting and pagination.
- [Create exhibitors](#create-exhibitors), with or without members and custom fields.
- [Update exhibitors](#update-exhibitors).
- [Link two exhibitors](#link-two-exhibitors-mutation).
- [Delete exhibitors](#delete-exhibitor).

## Exhibitor fields

| Field | Notes |
| --- | --- |
| `name` | Required to create an exhibitor. |
| `logoUrl`, `websiteUrl`, `description` | Recommended. |
| `categories` | One or more keywords displayed on the exhibitor profile. Users can filter exhibitors by category. |
| `type` | A single value, such as Platinum, Gold or Silver, that lets users sort exhibitors by type. Within a type, exhibitors are listed alphabetically. |

:::danger[Phone numbers format]
Specify phone numbers in the [E.164](http://en.wikipedia.org/wiki/E.164) format, prefixed with `+`. For example, the US phone number 415 555 0101 becomes `+14155550101`: the `+` prefix, then the US country code `1`, then the local subscriber number.
:::

## 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 the community, for the `exhibitorsV2` list queries (`communityId`).
- The ID of the event (`eventId`). See [Events](./graphql-event-api-examples-event.md).

## List exhibitors
Use the `exhibitorsV2` query to list the exhibitors of a community. Every example below uses the same query: only the variables change. Combine `filter`, `search`, `sort` and `cursor` as needed. The examples fetch the first 100 exhibitors (`cursor.first`).

### Filter by event
Fetch the exhibitors of one or more events.

| Argument | Description |
| --- | --- |
| [`communityId`](../graphql-event-api-schema/queries/community.mdx#id-id) | The ID of the community. |
| `eventIds` | Array of event IDs (`ID`). |

```graphql title="Query"
query ExhibitorsV2(
  $communityId: ID!
  $search: String
  $cursor: CursorPaginationInput
  $filter: CommunityExhibitorsFilterInput
  $sort: EventExhibitorsSortInput
) {
  exhibitorsV2(
    communityId: $communityId
    search: $search
    filter: $filter
    sort: $sort
    cursor: $cursor
  ) {
    pageInfo {
      endCursor
      hasNextPage
    }
    totalCount
    nodes {
      ...Exhibitor
    }
  }
}
fragment Exhibitor on Exhibitor {
  id
  name
  logoUrl
  websiteUrl
  description
}
```

```json title="Variables"
{
  "communityId": "Q29tbXVuaXR5XzE=",
  "filter": {
    "eventIds": ["INSERT_EVENT_IDS_HERE"]
  },
  "cursor": {
    "first": 100
  }
}
```

### Filter by client ID
Fetch exhibitors by the `clientId` values you set when you created them.

| Argument | Description |
| --- | --- |
| [`communityId`](../graphql-event-api-schema/queries/community.mdx#id-id) | The ID of the community. |
| `clientIds` | Array of client IDs (`ID`). |

```graphql title="Query"
query ExhibitorsV2(
  $communityId: ID!
  $search: String
  $cursor: CursorPaginationInput
  $filter: CommunityExhibitorsFilterInput
  $sort: EventExhibitorsSortInput
) {
  exhibitorsV2(
    communityId: $communityId
    search: $search
    filter: $filter
    sort: $sort
    cursor: $cursor
  ) {
    pageInfo {
      endCursor
      hasNextPage
    }
    totalCount
    nodes {
      ...Exhibitor
    }
  }
}
fragment Exhibitor on Exhibitor {
  id
  name
  logoUrl
  websiteUrl
  description
}
```

```json title="Variables"
{
  "communityId": "Q29tbXVuaXR5XzE=",
  "filter": {
    "clientIds": ["INSERT_CLIENT_IDS_HERE"]
  },
  "cursor": {
    "first": 100
  }
}
```

### Filter by community group
Fetch the exhibitors of one or more community groups.

| Argument | Description |
| --- | --- |
| [`communityId`](../graphql-event-api-schema/queries/community.mdx#id-id) | The ID of the community. |
| `communityGroupIds` | Array of community group IDs. |

```graphql title="Query"
query ExhibitorsV2(
  $communityId: ID!
  $search: String
  $cursor: CursorPaginationInput
  $filter: CommunityExhibitorsFilterInput
  $sort: EventExhibitorsSortInput
) {
  exhibitorsV2(
    communityId: $communityId
    search: $search
    filter: $filter
    sort: $sort
    cursor: $cursor
  ) {
    pageInfo {
      endCursor
      hasNextPage
    }
    totalCount
    nodes {
      ...Exhibitor
    }
  }
}
fragment Exhibitor on Exhibitor {
  id
  name
  logoUrl
  websiteUrl
  description
}
```

```json title="Variables"
{
  "communityId": "Q29tbXVuaXR5XzE=",
  "filter": {
    "communityGroupIds": ["INSERT_COMMUNITY_GROUP_IDS_HERE"]
  },
  "cursor": {
    "first": 100
  }
}
```

### Filter by last update
Fetch the exhibitors updated since a given date and time, for example to sync only what changed.

| Argument | Description |
| --- | --- |
| [`communityId`](../graphql-event-api-schema/queries/community.mdx#id-id) | The ID of the community. |
| `lastUpdatedSince` | A `DateTime`. Only exhibitors updated after it are returned. |

```graphql title="Query"
query ExhibitorsV2(
  $communityId: ID!
  $search: String
  $cursor: CursorPaginationInput
  $filter: CommunityExhibitorsFilterInput
  $sort: EventExhibitorsSortInput
) {
  exhibitorsV2(
    communityId: $communityId
    search: $search
    filter: $filter
    sort: $sort
    cursor: $cursor
  ) {
    pageInfo {
      endCursor
      hasNextPage
    }
    totalCount
    nodes {
      ...Exhibitor
    }
  }
}
fragment Exhibitor on Exhibitor {
  id
  name
  logoUrl
  websiteUrl
  description
}
```

```json title="Variables"
{
  "communityId": "Q29tbXVuaXR5XzE=",
  "filter": {
    "lastUpdatedSince": "2022-08-01 12:00:00"
  },
  "cursor": {
    "first": 100
  }
}
```

### Search by name or email
Find exhibitors whose name or email matches a search string.

| Argument | Description |
| --- | --- |
| [`communityId`](../graphql-event-api-schema/queries/community.mdx#id-id) | The ID of the community. |
| `search` | A `String` matched against exhibitor names and emails. |

```graphql title="Query"
query ExhibitorsV2(
  $communityId: ID!
  $search: String
  $cursor: CursorPaginationInput
  $filter: CommunityExhibitorsFilterInput
  $sort: EventExhibitorsSortInput
) {
  exhibitorsV2(
    communityId: $communityId
    search: $search
    filter: $filter
    sort: $sort
    cursor: $cursor
  ) {
    pageInfo {
      endCursor
      hasNextPage
    }
    totalCount
    nodes {
      ...Exhibitor
    }
  }
}
fragment Exhibitor on Exhibitor {
  id
  name
  logoUrl
  websiteUrl
  description
}
```

```json title="Variables"
{
  "communityId": "Q29tbXVuaXR5XzE=",
  "search": "Exhibitor Name or Email",
  "cursor": {
    "first": 100
  }
}
```

### Sort exhibitors
Sort the results by a field.

| Argument | Description |
| --- | --- |
| [`communityId`](../graphql-event-api-schema/queries/community.mdx#id-id) | The ID of the community. |
| `field` | The field to sort by: `NAME`, `DESCRIPTION`, `TOTAL_BOOKMARKS`, `CREATED_AT` or `UPDATED_AT`. |
| `order` | The sort order: `ASC` or `DESC`. |

```graphql title="Query"
query ExhibitorsV2(
  $communityId: ID!
  $search: String
  $cursor: CursorPaginationInput
  $filter: CommunityExhibitorsFilterInput
  $sort: EventExhibitorsSortInput
) {
  exhibitorsV2(
    communityId: $communityId
    search: $search
    filter: $filter
    sort: $sort
    cursor: $cursor
  ) {
    pageInfo {
      endCursor
      hasNextPage
    }
    totalCount
    nodes {
      ...Exhibitor
    }
  }
}
fragment Exhibitor on Exhibitor {
  id
  name
  logoUrl
  websiteUrl
  description
}
```

```json title="Variables"
{
  "communityId": "Q29tbXVuaXR5XzE=",
  "sort": {
    "field": "NAME",
    "order": "ASC"
  },
  "cursor": {
    "first": 100
  }
}
```

### Get the next page
To fetch the next exhibitors, send the same query and set `cursor.after` to the `pageInfo.endCursor` value of the previous response. Repeat while `pageInfo.hasNextPage` is `true`.

```graphql title="Query"
query ExhibitorsV2(
  $communityId: ID!
  $search: String
  $cursor: CursorPaginationInput
  $filter: CommunityExhibitorsFilterInput
  $sort: EventExhibitorsSortInput
) {
  exhibitorsV2(
    communityId: $communityId
    search: $search
    filter: $filter
    sort: $sort
    cursor: $cursor
  ) {
    pageInfo {
      endCursor
      hasNextPage
    }
    totalCount
    nodes {
      ...Exhibitor
    }
  }
}
fragment Exhibitor on Exhibitor {
  id
  name
  logoUrl
  websiteUrl
  description
}
```

```json title="Variables"
{
  "filter": {
    "eventIds": ["RXZlbnRfMQ=="]
  },
  "communityId": "Q29tbXVuaXR5XzY2NjQ=",
  "cursor": {
		"after": "WzExMDYxOF0="
	} 
}
```

### Get exhibitors by ID
Fetch specific exhibitors of an event.

| Argument | Description |
| --- | --- |
| `communityId` | The ID of the community. |
| `eventIds` | The IDs of the events to search in. |
| `ids` | Array of the IDs of the exhibitors to fetch. |

```graphql title="Query"
query ExhibitorsV2(
  $communityId: ID!
  $search: String
  $cursor: CursorPaginationInput
  $filter: CommunityExhibitorsFilterInput
  $sort: EventExhibitorsSortInput
) {
  exhibitorsV2(
    communityId: $communityId
    search: $search
    filter: $filter
    sort: $sort
    cursor: $cursor
  ) {
    pageInfo {
      endCursor
      hasNextPage
    }
    totalCount
    nodes {
      ...Exhibitor
    }
  }
}
fragment Exhibitor on Exhibitor {
  id
  name
  logoUrl
  websiteUrl
  description
}
```

```json title="Variables"
{
  "filter": {
    "eventIds": ["RXZlbnRfMQ=="],
    "ids": [
      "RXhoaWJzc5MDE3Mg==",
      "RXhoaWXzg4MTkyMA=="
    ]
  },
  "communityId": "Q29tbXVuaXR5XzY2NjQ="
}
```

## Create exhibitors

Use the `upsertEventExhibitors` mutation to create one or more exhibitors in an event.

| Argument | Description |
| --- | --- |
| `eventId` | The ID of the event where you create the exhibitors. |
| `exhibitors` | The data of the exhibitors to create. Each exhibitor needs at least a `name`. |

:::tip
Set a `clientId` on each exhibitor. Use a unique external ID that never changes: you can then use it to identify and update the exhibitor later.
:::

```graphql title="Mutation"
mutation upsertMyExhibitors($eventId: String!, $exhibitors: [ExhibitorInput!]!) {
  upsertEventExhibitors(eventId: $eventId, exhibitors: $exhibitors) {
    id
    name
    logoUrl
    websiteUrl
    description
  }
}
```

```json title="Variables"
{
  "eventId": "RXZlbnRfMQ==",
  "exhibitors": [
    {
      "name": "Test",
      "description": "This is a test Exhibitor.",
      "clientId": "Exhibitor12345"
    }
  ]
}
```

### Create exhibitors with members and custom fields
Create a complete exhibitor in one call, with its address, email, custom fields (`createFields`), documents (`documentsV2`) and members.

| Argument | Description |
| --- | --- |
| `eventId` | The ID of the event where you create the exhibitors. |
| `exhibitors` | The data of the exhibitors to create. Each exhibitor needs at least a `name`. We recommend a unique, stable `clientId` for each exhibitor. |
| `membersIds` | The IDs of the users who become members of the exhibitor. |

```graphql title="Mutation"
mutation upsertMyExhibitors($eventId: String!, $exhibitors: [ExhibitorInput!]!) {
  upsertEventExhibitors(eventId: $eventId, exhibitors: $exhibitors) {
    id
    name
    address {
			state
			street
			city
			country
			zipCode
		}
    description
		documents {
			description
			id
			name
		}
		customFields {
			__typename
			...on ListCustomField {
				fields {
					name
					id
					value
					position
				}
				group {
					name
					id
					type
				}
			}
			...on UniqueCustomField {
				field {
					name
					id
				}
				group {
					name
					type
				}
			}
		}
		email
  }
}
```

```json title="Variables"
{
	"eventId": "RXZlbnRfMTcyMjY0",
	"exhibitors": [
		{
			"name": "Test",
			"description": "This is a test Exhibitor.",
			"clientId": "Exhibitor12345",
			"address": {
				"city": "city test",
				"country": "country test",
				"place": "place test",
				"state": "state test",
				"street": "street test",
				"zipCode": "12939492"
			},
			"email": "email-exhibitor@gmail.com",
			"createFields": [
				{
					"definitionId": "Definition_Id",
					"locale": "en_US",
					"value": "exhibitor-v"
				}
			],
			"documentsV2": {
				"ids": [
					"Document_id"
				],
				"action": "ADD"
			},
			"membersIds": [
				"User_Id"
			]
		}
	]
}
```

## Update exhibitors

Use the `upsertEventExhibitors` mutation to update existing exhibitors. In this example, the `clientId` identifies the exhibitor, and the mutation updates its name, description and other details.

| Argument | Description |
| --- | --- |
| `eventId` | The ID of the event that contains the exhibitors. |
| `exhibitors` | The data of the exhibitors to update. Each exhibitor needs at least a `name`. |

```graphql title="Mutation"
mutation upsertExhibitors($eventId: String!, $exhibitors: [ExhibitorInput!]!) {
  upsertEventExhibitors(eventId: $eventId, exhibitors: $exhibitors) {
    id
    name
    logoUrl
    websiteUrl
    description
  }
}
```

```json title="Variables"
{
  "eventId": "RXZlbnRfMQ==",
  "exhibitors": [
    {
      "name": "Test Exhibitor Update",
      "description": "This is an Updated test Exhibitor.",
      "clientId": "Exhibitor12345", 
      "categories": "Organizer",
      "logoUrl": "https://fakeimg.pl/250x100/",
      "websiteUrl": "https://test.com",
      "type": "Online Marketing "
    }
  ]
}
```

### Update members, custom fields, social networks and documents
This example uses the `clientId` to identify the exhibitor, then links it to members, custom field values, social networks, booths and documents.

| Argument | Description |
| --- | --- |
| `eventId` | The ID of the event that contains the exhibitors. |
| `exhibitors` | The data of the exhibitors to update. Each exhibitor needs at least a `name`. |

:::note
Create custom field values first with `setSelectFieldValue` (see [Custom fields](./graphql-event-api-examples-custom-fields.md)). Then send the `key` of the value in `value`, and the custom field ID in `definitionId`.
:::

```graphql title="Mutation"
mutation upsertMyExhibitors($eventId: String!, $exhibitors: [ExhibitorInput!]!) {
  upsertEventExhibitors(eventId: $eventId, exhibitors: $exhibitors) {
    id
    name
    logoUrl
    websiteUrl
    description
  }
}
```

```json title="Variables"
{
  "eventId": "RXZlbnRfMQ==",
  "exhibitors": [
    {
     "name": "Test Exhibitor Update",
      "description": "This is an Updated test Exhibitor.",
      "clientId": "Exhibitor12345", 
      "categories": "Organizer",
      "booths": [{ "name" :"test booth", "id":"12987" }],
      "logoUrl": "https://fakeimg.pl/250x100/",
      "websiteUrl": "https://test.com",
      "type": "Online Marketing ",
      "socialNetworks": [{ "profile": "test_twitter exhibitor", "type": "TWITTER"}],
      "createFields" : [{"definitionId": "RmllbGREZWZpbml0aW9uXzQ2NjEzNA==", "value": "france"}, {"definitionId": "RmllbGREZWZpbml0aW9uXzQ2NjEzNw==", "value": "hall-1"}, {"definitionId": "RmllbGREZWZpbml0aW9uXzQ2NjEzOA==", "value": "world-food"}, {"definitionId": "RmllbGREZWZpbml0aW9uXzQ2NjEzOQ==", "value": "tea"}, {"definitionId": "RmllbGREZWZpbml0aW9uXzQ2NjEzOQ==", "value": "ice-cream"}],
      "membersIds": ["RXZlbnRQZW9wbGVfMTI3OTEyMTQ="],
      "documents": [
        {
          "url":"https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
          "name" :"test2"
        }
      ]
    }
  ]
}
```

### Update an exhibitor and link products
Use the `updateExhibitor` mutation to update a single exhibitor. Unlike `upsertEventExhibitors`, it supports some special features, rights and advanced fields. In this example, the `exhibitorId` identifies the exhibitor, and the mutation updates its name, description, group, background image, website and logo, links products (`productIds`) and sets its `features`.

| Argument | Description |
| --- | --- |
| `eventId` | The ID of the event that contains the exhibitor. |
| `exhibitorId` | The Swapcard ID of the exhibitor to update. |

```graphql title="Mutation"
mutation updateExhibitor($input: UpdateExhibitorInput!) {
  updateExhibitor(input: $input) {
    errors {
      code
      input
    }
    exhibitor {
      clientIds
      createdAt
      id
    }
  }
}
```

```json title="Variables"
{
  "input" : {
    "eventId":"RXZlbnRfMQ==",
    "groupId": "RXZlbnRI=",
    "exhibitorId": "RXhoaWJpdG9yXzcxMjQ5NA==",
    "name":"Updated Exhibitor with Products",
    "logoUrl":"www.testExhibitor.png",
    "websiteUrl":"www.testExhibitor.com" ,
    "backgroundImageUrl": "www.exhibitorbackgroundimage.png",
    "productIds": ["UHJvZHVjdF82MTQwMjc=","UHJvZHVjdF97MTQwMjc=" ],
    "description": "This is a new updated Exhibitor with products linked to it",
    "features": {
    "canExportAdvertisements": true, 
    "canExportChats": true,  
    "canExportContacts": true, 
    "canExportDocuments": false, 
    "canExportExhibitorPages": false, 
    "canExportExhibitorItems": false, 
    "canExportMeetingsConfirmed": true, 
    "canExportRegistrations": false, 
    "canExportWatchedExhibitorPlannings": false, 
    "canViewVisits": true, 
    "inviteMembers": true,  
    "scanBadge": true
  }
  }
}
```

## Link two exhibitors
Link an existing exhibitor to another exhibitor of the same event. This takes two mutations: the first defines the relation, the second links the two exhibitors in the UI.

### Step 1: Create an exhibitor link

Use the `createExhibitorLink` mutation to create a link that defines the relation between the two exhibitors (the parent and child names).

```graphql title="Mutation"
mutation CreateExhibitorLink($input: CreateExhibitorLinkInput!) {
  createExhibitorLink(input: $input) {
    exhibitorLink {
      childName
      id
      parentName
    }
  }
}
```

```json title="Variables"
{
  "input": {
 "eventId": "RXZlbnRfMQ==",
 "parentName": "Parent Exhibitor", 
 "childName": "Child Exhibitor"
  }   
  }
```

The response contains the `exhibitorLink.id`: you use it in step 2.

### Step 2: Link the exhibitors

Use the `createExhibitorLinkRelation` mutation with the exhibitor link ID and the IDs of the parent and child exhibitors.

```graphql title="Mutation"
mutation CreateExhibitorLinkRelation($input: CreateExhibitorLinkRelationInput!) {
  createExhibitorLinkRelation(input: $input) {
    exhibitorLink {
      childName
      id
      parentName
    }
  }
}
```

```json title="Variables"
{
  "input": {
 "exhibitorLinkId": "RXhoaWJpGlua18xMDAx",
 "parentExhibitorId": "RXhoaWJpzc5MDE3Mg==", 
 "childExhibitorId": "RXhoaWJp4MTkyMA=="
}
}
```

## Delete exhibitors
Use the `deleteEventExhibitors` mutation to delete one or more exhibitors from an event.

| Argument | Description |
| --- | --- |
| `eventId` | The ID of the event that contains the exhibitors. |
| `exhibitorIds` | Array of the IDs of the exhibitors to delete, passed to the `exhibitorsIds` argument. |

```graphql title="Mutation"
mutation deleteExhibitors($eventId: String!, $exhibitorIds: [String!]!) {
  deleteEventExhibitors(eventId: $eventId, exhibitorsIds: $exhibitorIds) {
    id
    name
    logoUrl
    websiteUrl
    description
  }
}
```

```json title="Variables"
{
 "eventId": "RXZlbnRfMQ==",  
  "exhibitorIds": [
   "RXhoaWJpdG9yXzI=","RXhoaWJpdG7pXzI="
  ]
}
```
