Skip to main content
View as Markdown

Integrate the Leads API

Build the two most common Leads API integrations step by step: a badge-scanning app for exhibitors, and a lead export that syncs to a CRM.
IntegrationWhat it doesSteps
Badge-scanning appLets exhibitors scan attendee badges at the event, with a rating and a note.Store the API key, pick a booth, scan badges.
Lead exportExports the leads of a booth and syncs them with a CRM or a CSV file.Store the API key, pick a booth, fetch the leads.

Code examples are available in cURL, Node.js, PHP and Python.

Before you begin​

  • An exhibitor API key, created in the Exhibitor Center. Send it as-is in the Authorization header, with no Bearer prefix. See Exhibitor authentication.
  • Every request is a POST to the Leads API endpoint: https://developer.swapcard.com/exhibitor/graphql.

Build a badge-scanning app​

Build an app that lets exhibitors scan attendee badges during events.

Step 1: Store the API key​

Implement a secure way to collect and store the API key of each of your users.

Security best practice

Never store API keys in client-side code or expose them in web applications. Always store them securely on your server.

  1. Create a settings or configuration page in your app.
  2. Provide a secure input field for the API key.
  3. Store the key encrypted in your database or secure storage.
  4. Validate the key by making a test API call, such as the { __typename } query shown in Exhibitor authentication.

Step 2: Let the user pick a booth​

Before scanning badges, users need to select the exhibitor booth they represent. Use the myExhibitors query to retrieve all the booths the user has access to. Keep the booth id (the exhibitorId) and the event id (the eventId) for the next step.

curl -X POST \
https://developer.swapcard.com/exhibitor/graphql \
-H 'Authorization: YOUR_API_KEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"query": "query myExhibitors($cursor: CursorPaginationInput) { myExhibitors(cursor: $cursor) { pageInfo { hasNextPage endCursor } nodes { id name events { nodes { id title } } } } }",
"variables": {
"cursor": {
"first": 100
}
}
}'
Response
{
"data": {
"myExhibitors": {
"pageInfo": {
"hasNextPage": false,
"endCursor": "eyJpZCI6IjEyMzQ1In0="
},
"nodes": [
{
"id": "RXhoaWJpdG9yXzU5NTIx",
"name": "Tech Solutions Booth",
"events": {
"nodes": [
{
"id": "RXZlbnRfMjg1NzM=",
"title": "Tech Conference 2025"
}
]
}
}
]
}
}
}

If pageInfo.hasNextPage is true, the user has more booths: run the query again with endCursor passed as cursor.after.

Step 3: Scan badges​

Send scanned codes with the scanBadges mutation, along with the eventId and exhibitorId from step 2. Each badge has a code, and an optional rating and note.

The mutation accepts one or several badges per call. Send one badge for each scan, or queue scans while the device is offline and send them together in one batch.

curl -X POST \
https://developer.swapcard.com/exhibitor/graphql \
-H 'Authorization: YOUR_API_KEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"query": "mutation scanBadges($input: ScanBadgesInput!) { scanBadges(input: $input) { badges { errorCode connection { id rating note target { __typename ... on EventPerson { firstName lastName jobTitle email organization } } } } } }",
"variables": {
"input": {
"eventId": "RXZlbnRfMjg1NzM=",
"exhibitorId": "RXhoaWJpdG9yXzU5NTIx",
"scanBadges": [
{
"code": "BADGE_QR_CODE_123",
"rating": 5,
"note": "Very interested in our product"
}
]
}
}
}'
Response
{
"data": {
"scanBadges": {
"badges": [
{
"errorCode": null,
"connection": {
"id": "Q29ubmVjdGlvbl8xMTYzNDE=",
"rating": 5,
"note": "Very interested in our product",
"target": {
"__typename": "EventPerson",
"firstName": "John",
"lastName": "Doe",
"jobTitle": "CTO",
"email": "john.doe@example.com",
"organization": "Tech Corp"
}
}
}
]
}
}
}

Build a lead export​

Build a tool that syncs lead data with a CRM or exports it for analysis.

Step 1: Store the API key​

Collect and store the API key the same way as in step 1 of the badge-scanning app.

Step 2: Let the user pick a booth​

Use the same myExhibitors query as in step 2 of the badge-scanning app to let users select the booths to export leads from.

Step 3: Fetch the leads​

Use the leads query to retrieve all the leads of a booth for an event. The examples also show how to map each lead to a flat record for your CRM, and how to write the records to a CSV file.

curl -X POST \
https://developer.swapcard.com/exhibitor/graphql \
-H 'Authorization: YOUR_API_KEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"query": "query myLeads($eventId: ID!, $exhibitorId: ID!) { leads(eventId: $eventId, exhibitorId: $exhibitorId) { contacts { pageInfo { endCursor hasNextPage } nodes { id connectedAtEvent { id title } connectedAt isScanned rating note owner { id email firstName lastName jobTitle organization } target { ... on Contact { id email firstName lastName jobTitle organization } ... on EventPerson { id email firstName lastName jobTitle organization } } customFields { __typename ... on SelectField { id value definition { name id } } ... on TextField { id value definition { name } } } } } } }",
"variables": {
"eventId": "RXZlbnRfMjg1NzM=",
"exhibitorId": "RXhoaWJpdG9yXzU5NTIx"
}
}'
Response
{
"data": {
"leads": {
"contacts": {
"pageInfo": {
"endCursor": "WyIyMDI1LTA5LTAzVDEzOjI4OjMzLjAwMFoiLDExNjM0MV0=",
"hasNextPage": false
},
"nodes": [
{
"id": "Q29ubmVjdGlvbl8xMTYzNDE=",
"connectedAtEvent": {
"id": "RXZlbnRfMjg1NzM=",
"title": "Tech Conference 2025"
},
"connectedAt": "2025-09-03 15:28:33",
"isScanned": true,
"rating": 5,
"note": "Very interested in our cloud solution",
"owner": {
"id": "VXNlcl8yNDExNg==",
"email": "exhibitor@techcorp.com",
"firstName": "Sarah",
"lastName": "Johnson",
"jobTitle": "Sales Manager",
"organization": "Tech Corp"
},
"target": {
"id": "VXNlcl8xNDc3MTg=",
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"jobTitle": "CTO",
"organization": "Example Inc"
},
"customFields": [
{
"__typename": "SelectField",
"id": "RmllbGRWYWx1ZV8zMzg3ODA=",
"value": "yes",
"definition": {
"name": "Interested in Cloud Solution?",
"id": "RmllbGREZWZpbml0aW9uXzI0NzYyNg=="
}
}
]
}
]
}
}
}
}

The query returns one page of leads. When pageInfo.hasNextPage is true, pass endCursor as cursor.after on contacts to get the next page. See Export leads.

Next steps​

  • See every field you can request for a lead, including all custom field types, in Export leads.
  • Handle scan errors such as CODE_NOT_FOUND: see Scan badges.
  • Check the rate limits before you sync leads in bulk.
  • Follow schema changes in the Changelog.