Authentication
To communicate with the APIs, you'll need an access token with the appropriate permissions.
Types of authentication
You should use the given access token if:
- You want to use the API to interact with your organization.
- Your are building a script to ingest or export the data from your organization.
- You want to use the API to programmatically automate specific actions in your own organization.
Heads up!
The access token should not be embedded in a web page.
How to get your Access Token
You can create an Access Token
, also named API key, in the Event Studio.
Heads up!
Your access token can give access to your private Swapcard data and should be treated like a password.
How to use the token
All GraphQL API queries require a valid access token.
Include your token as an Authorization
header in all API queries.
To keep the platform secure, ensure the user associated to the token has appropriate role and rights.
Only request as much data access as your app needs to work.
- cURL
- Node.JS
- PHP
curl \
-s https://developer.swapcard.com/event-admin/graphql \
-H 'Authorization: ACCESS_TOKEN_HERE' \
-H 'Accept: application/json'
const operationsDoc = `
query MyQuery {
__typename
}
`;
async function fetchGraphQL(operationsDoc, operationName, variables) {
const result = await fetch(
"https://developer.swapcard.com/event-admin/graphql",
{
method: "POST",
headers: {
"Authorization": "ACCESS_TOKEN_HERE"
}
body: JSON.stringify({
query: operationsDoc,
variables: variables,
operationName: operationName
})
}
);
return await result.json();
}
$arrHeaders = array(
'Authorization: ' . ACCESS_TOKEN_HERE,
'Content-Type: application/json'
);
$appelCurl = curl_init();
curl_setopt($appelCurl, CURLOPT_URL, 'https://developer.swapcard.com/event-admin/graphql');
curl_setopt($appelCurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($appelCurl, CURLINFO_HEADER_OUT, 1);
curl_setopt($appelCurl, CURLOPT_POST, 1);
curl_setopt($appelCurl, CURLOPT_POSTFIELDS, $strJson);
curl_setopt($appelCurl, CURLOPT_HTTPHEADER, $arrHeaders);
$curlResult = curl_exec($appelCurl);
$curlErrno = curl_errno($appelCurl);
$curlInfo = curl_getinfo($appelCurl);