Skip to main content

Your First API Call

Let's make your first API call to Ticketlayer!

Prerequisites​

  • A credential: an organisation API key (tlak_) or a staff access token. See Keys and authentication.
  • A Ticketlayer account with at least one organisation

Get Your User Profile​

The simplest API call is retrieving your own user profile. This one needs a staff token (it is a "who am I" call, so API keys are refused with 404); the organisation and event calls further down work with an API key too.

GET/meGet Current UserFull docs →

Get your user profile using the TypeScript SDK:

import { BackstageClient } from '@ticketlayer/backstage';

const client = new BackstageClient({
organisationSlug: 'your-org',
});
client.setAccessToken('YOUR_ACCESS_TOKEN');

// Get the current authenticated user
const user = await client.users.getMe();

console.log(`Hello, ${user.firstName} ${user.lastName}!`);
console.log(`Email: ${user.email}`);
console.log(`User ID: ${user.id}`);

The SDK automatically unwraps the data field from the JSend response, so you receive the inner object directly.

Get Your Organisations​

Once you have your profile, you can retrieve the list of organisations you have access to:

GET/me/organisationsGet My OrganisationsFull docs →

Get your organisations using the TypeScript SDK:

import { BackstageClient } from '@ticketlayer/backstage';

const client = new BackstageClient({
organisationSlug: 'your-org',
});
client.setAccessToken('YOUR_ACCESS_TOKEN');

// Get all organisations you have access to
const organisations = await client.users.getMyOrganisations();

for (const org of organisations) {
console.log(`${org.name} (${org.slug})`);
}

Response Format​

All API responses follow the JSend specification:

{
"status": "success",
"data": {
"user": {
"id": "usr_123abc",
"email": "your@email.com",
"firstName": "John",
"lastName": "Doe",
"createdAt": "2026-01-01T00:00:00Z"
}
}
}

Error Handling​

When things go wrong, the API returns an error response:

{
"status": "error",
"message": "Authentication required",
"code": "UNAUTHORIZED"
}

The TypeScript SDK throws typed errors you can catch:

try {
const user = await client.users.getMe();
} catch (error) {
if (error.status === 401) {
console.log('Not authenticated');
} else if (error.status === 403) {
console.log('Permission denied');
} else {
console.log('API error:', error.message);
}
}

Next Steps​

Now that you've made your first API call: