# Scan badges

Source: https://swapcard.dev/content-api/examples/scan-badges


Send the QR or barcode codes your booth staff scan, with an optional rating and note. Each code that matches a person in the event creates a connection (a lead) for your booth.

Reference: [`scanBadges` mutation](../graphql-exhibitor-api-schema/operations/mutations/scan-badges.mdx), [`Connection` object](../graphql-exhibitor-api-schema/types/objects/connection.mdx)

## Before you begin

- An exhibitor API key created in the Exhibitor Center, sent in the `Authorization` header to `https://developer.swapcard.com/exhibitor/graphql`. See [Exhibitor authentication](/exhibitors/authentication).
- The `exhibitorId` of your booth and the `eventId` of the event. Get both with [List your booths](graphql-event-api-examples-my-exhibitors.md).

## Scan badges
Use this mutation each time a badge is scanned. You can send one code or several codes in the same call.

| Argument | Type | Description |
| --- | --- | --- |
| [`input`](../graphql-exhibitor-api-schema/types/inputs/scan-badges-input.mdx) | `ScanBadgesInput!` | Badge codes and evaluation data to process. |

`ScanBadgesInput` contains:

| Field | Type | Description |
| --- | --- | --- |
| `eventId` | `ID!` | The ID of the event. |
| `exhibitorId` | `ID!` | The ID of the exhibitor booth. |
| [`scanBadges`](../graphql-exhibitor-api-schema/types/inputs/scan-badge-input.mdx) | `[ScanBadgeInput!]!` | The scanned badges. Each one has a `code` (`String!`), and an optional `note` (`String`) and `rating` (`Float`). |

```graphql title="Mutation"
mutation scanBadges($input: ScanBadgesInput!) {
  scanBadges(input: $input) {
    badges {
      errorCode
      connection {
        id
        rating
        note
        target {
          __typename
          ... on PersonInterface {
            ...PersonFields
          }
          ... on EventPerson {
            ...EventPersonFields
          }
        }
        customFields {
          __typename
          ... on NumberField {
            id
            definition {
              id
              name
            }
            number: value
          }
          ... on UrlField {
            id
            definition {
              id
              name
            }
            value
          }
          ... on MediaField {
            id
            definition {
              id
              name
            }
            value
          }
          ... on TextField {
            id
            definition {
              id
              name
            }
            locale
            value
          }
          ... on LongTextField {
            id
            definition {
              id
              name
            }
            locale
            value
          }
          ... on SelectField {
            id
            definition {
              id
              name
            }
            translations {
              value
              language
            }
            value
          }
          ... on MultipleSelectField {
            id
            definition {
              id
              name
            }
            translations {
              value
              language
            }
            value
          }
          ... on MultipleTextField {
            id
            definition {
              id
              name
            }
            locale
            value
          }
          ... on DateField {
            id
            definition {
              id
              name
            }
            date: value
          }
        }
        connectedAt
      }
    }
    errors {
      inputId
      message
      code
    }
  }
}

fragment PersonFields on PersonInterface {
  firstName
  lastName
  jobTitle
  email
  organization
  address {
    city
    country
    place
    street
    zipCode
  }
}

fragment EventPersonFields on EventPerson {
  firstName
  lastName
  jobTitle
  email
  organization
  address {
    city
    country
    place
    street
    zipCode
  }
}
```

```json title="Variables"
{
  "input": {
    "eventId": "RXZlbnRfMjg1NzM=",
    "exhibitorId": "RXhoaWJpdG9yXzU5NTIx",
    "scanBadges": [
      {
        "code": "123456789",
        "note": "Lead to contact urgently",
        "rating": 5
      }
    ]
  }
}
```

## Handle the response
The mutation returns one entry in `badges` per scanned code. For each entry:

- `errorCode` is `null` and `connection` contains the new lead when the code matches a person.
- Otherwise `connection` is `null` and `errorCode` is one of the [`ScanBadgeErrorCodeEnum`](../graphql-exhibitor-api-schema/types/enums/scan-badge-error-code-enum.mdx) values: `CODE_NOT_FOUND`, `FEATURE_NOT_ALLOWED` or `USER_NOT_IN_EVENT`.

The scanned person is returned in `connection.target` as an `EventPerson`. See the [Changelog](../graphql-leads-api-changelog.md).

### The connection is created
```json title="Response"
{
  "data": {
    "scanBadges": {
      "badges": [
        {
          "errorCode": null,
          "connection": {
            "id": "Q29ubmVjdGlvbl8xMTYzNDE=",
            "rating": 5,
            "note": "Lead to contact urgently",
            "target": {
              "__typename": "EventPerson",
              "firstName": "John",
              "lastName": "Doe",
              "jobTitle": null,
              "email": "test@gmail.com",
              "organization": null,
              "address": null
            },
            "customFields": [
              {
                "__typename": "SelectField",
                "id": "RmllbGRWYWx1ZV8zMzg3ODA=",
                "definition": {
                  "id": "RmllbGREZWZpbml0aW9uXzI0NzYyNg==",
                  "name": "Interested by the Cloud offer ?"
                },
                "translations": [
                  {
                    "value": "Yes",
                    "language": "en_US"
                  }
                ],
                "value": "yes"
              },
              {
                "__typename": "MultipleSelectField",
                "id": "RmllbGRWYWx1ZV8zMzg3ODI=",
                "definition": {
                  "id": "RmllbGREZWZpbml0aW9uXzI0NzYyNw==",
                  "name": "Should contacted the week of ?"
                },
                "translations": [
                  {
                    "value": "1st Sept.",
                    "language": "en_US"
                  }
                ],
                "value": "1st-sept"
              }
            ],
            "connectedAt": "2025-09-03 15:28:33"
          }
        }
      ],
      "errors": []
    }
  }
}
```

### The code is not found
```json title="Response"
{
  "data": {
    "scanBadges": {
      "badges": [
        {
          "errorCode": "CODE_NOT_FOUND",
          "connection": null
        }
      ],
      "errors": []
    }
  }
}
```
