Items
Fetch, create, update and delete the items of an event and their categories. An item can be a product, a project, a job offer and so on.
Items are products in the API: the objects are Product and ProductCategory. Each item belongs to a category, and you can link it to one or more exhibitors.
Reference: Product object, ProductCategory object
On this page you can:
- Fetch products, with pagination or filtered by ID or category.
- Create a product category and create a product.
- Update a product category and update a product.
- Delete products.
- Check the requirements and constraints to avoid errors.
Before you begin
- An API key, sent in the
Authorizationheader. The key acts with the roles and permissions of the user who created it. See Authentication. - The ID of the event (
eventId). See Events. - To create a product, the ID of its category. Create the category manually or with
createProductCategoryV2.
Fetch products
Use the event query with the products field to fetch the products of an event.
Get the first 100 products
Fetch the first 100 products of an event, together with its product categories.
| Argument | Description |
|---|---|
eventId | The ID of the event. |
cursor | Pagination. first sets how many records to fetch per page. |
query EventProducts($eventId: ID!, $cursor: CursorPaginationInput!){
event(id: $eventId) {
productCategoriesV2{
totalCount
nodes {
id
name
}
}
products(cursor: $cursor) {
nodes {
clientIds
id
name
}
}
}
}
{
"eventId": "RXZlbnRfMQ==",
"cursor": {
"first": 100
}
}
Get the next 100 products
To fetch the next page, send the query again and set cursor.after to the pageInfo.endCursor value of the previous response. Repeat while pageInfo.hasNextPage is true.
| Argument | Description |
|---|---|
eventId | The ID of the event. |
cursor | Pagination. first sets how many records to fetch per page; after is the cursor returned by the previous response. |
query EventProducts($eventId: ID!, $cursor: CursorPaginationInput!) {
event(id: $eventId) {
products(cursor: $cursor) {
nodes {
clientIds
id
name
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
{
"eventId": "RXZlbnRfMQ==",
"cursor": {
"first": 100,
"after": "INSERT_CURSOR_ID_HERE"
}
}
Get products by ID
Fetch specific products.
| Argument | Description |
|---|---|
eventId | The ID of the event. |
filter.ids | Array of the IDs of the products to fetch. |
query EventProducts($eventId: ID!, $filter: ProductFilterInput!) {
event(id: $eventId) {
products(filter: $filter) {
nodes {
clientIds
id
name
}
}
}
}
{
"eventId": "RXZlbnRfNDY1Njc4",
"filter": {
"ids":
[
"ProductID1",
"ProductID2"
]
}
}
Get products by category
Fetch the products of one or more categories.
| Argument | Description |
|---|---|
eventId | The ID of the event. |
filter.parentCategoryIds | Array of the IDs of the categories. |
query EventProducts($eventId: ID!, $filter: ProductFilterInput!) {
event(id: $eventId) {
products(filter: $filter) {
nodes {
clientIds
id
name
}
}
}
}
{
"eventId": "RXZlbnRfNDY1Njc4",
"filter": {
"parentCategoryIds":
[
"ProductCategoryID1",
"ProductCategoryID2"
]
}
}
Create a product category
Use the createProductCategoryV2 mutation to create a category, for example "Job Offers".
| Argument | Description |
|---|---|
eventId | The ID of the event where you create the category. |
name | The name of the category in the event. |
mutation createProductCategory($input: CreateProductCategoryInput!) {
createProductCategoryV2(input: $input) {
errors {
code
message
}
productCategory {
id
name
}
}
}
{
"input" : {
"name":"Job Offers",
"eventId":"RXZlbnRfMQ==",
"imageUrl":"www.test.png",
"color": "blue",
"limit": 200
}
}
Create a product
Use the createProduct mutation to create a product in a category, and optionally link it to exhibitors.
| Argument | Description |
|---|---|
eventId | The ID of the event where you create the product. |
categoryId | The ID of the category of the product. The category must already exist: create it manually or with the createProductCategoryV2 mutation. |
name | The name of the product in the event. |
clientId | Your own unique external ID for the product. |
translations | The name of the product in other languages. |
mutation createProduct($input: CreateProductInput!) {
createProduct(input: $input) {
product {
clientIds
customFields {
... on TextField {
id
locale
value
}
}
translations {
name
language
}
description
name
updatedAt
createdAt
exhibitors {
name
}
assetsUrls
}
errors {
message
}
}
}
{
"input" : {
"clientId": "Item1Id",
"name": "swapcard item",
"categoryId":"UHJvZHVjdENhdGVnb3J5XzEwMTYzOQ==" ,
"eventId":"RXZlbnRfMQ==",
"imageUrl":"www.test.png",
"description": "This is a swapcard item",
"customFields": [{
"definitionId": "RmllbGREZWZpbml==",
"text": {"language": "fr_FR", "value": "item"}
}],
"translations": [{
"name": "swapcard item",
"language": "en_US"
}],
"exhibitorIds": ["ExhibitorId"],
"assetsUrls": ["www.asset1.com", "www.asse2.com"]
}
}
Update a product category
Use the updateProductCategoryV2 mutation to update a category.
| Argument | Description |
|---|---|
productCategoryId | The ID of the category to update. |
mutation updateProductCategory($input: UpdateProductCategoryInput!) {
updateProductCategoryV2(input: $input) {
errors {
code
message
}
productCategory {
id
name
}
}
}
{
"input" : {
"name":"Job Offers New",
"imageUrl":"www.testnew.png",
"productCategoryId": "UHJvZHVjdENhdGVnb3J5XzEwMTY0MA=="
}
}
Update a product
Use the updateProduct mutation to update a product, for example to change its category, exhibitors or custom fields.
| Argument | Description |
|---|---|
productId | The Swapcard ID of the product to update. |
categoryId | The ID of the category of the product. The category must already exist: create it manually or with the createProductCategoryV2 mutation. |
mutation updateProduct($input: UpdateProductInput!) {
updateProduct(input: $input) {
errors {
code
message
}
product {
updatedAt
id
}
}
}
{
"input" : {
"productId": "UHJvZHVjdF82MTQwMjc=",
"categoryId":"UHJvZHVjdENhdGVnb3J5XzEwMTYzOQ==" ,
"exhibitorIds": ["RXhoaWJpdG9yXzY5MDUyNA=="],
"customFields": [{
"definitionId": "RmllbGREZWZpbml==",
"text": {"language": "fr_FR", "value": "Item updated"}
}]
}
}
Delete products
Use the deleteProducts mutation to delete one or more products. The response returns the IDs of the deleted products.
| Argument | Description |
|---|---|
productIds | Array of the IDs of the products to delete. |
Make sure you use the right product IDs and that you have the permission to delete these products.
mutation deleteProducts($input: DeleteProductsInput!){
deleteProducts(input: $input) {
deletedProductIds
}
}
{
"input" : {
"productIds": [
"UHJvZHVjdF82MTQwMzY=",
"UHJvZHVjdG46MTQwMzY="
]
}
}
Requirements and constraints
Check these points to avoid errors when you create or update products:
- Use the right product ID.
- You need the permission to update the product, and all the exhibitors linked to it.
- Use a valid event ID and category ID.
nameandnameTranslation: 255 characters maximum.descriptionanddescriptionTranslation: 2,000 characters maximum.- A product can have up to 20 linked images.
- Asset URLs must be valid.
- Image URLs must not use
http. - To link exhibitors, use valid exhibitor IDs.