Eventlayer / Start building
Issue your first ticket
Create an event, register an attendee and issue a ticket with one TypeScript script.
Build a small event for After Hours in Sydney, register Maya Chen, and issue her General Admission ticket. At the end, you will have real resource IDs and an assigned ticket in your workspace.
- 01API key
- 02Event
- 03Attendee
- 04Ticket
1. Create your API key
Create a workspace, verify your email and open Dashboard → API Keys. Create a key and copy its token when it is shown. Store it in the server environment where you will run the script:
export EVENTLAYER_KEY="sk_your_key_here"Keep this key out of browser code and source control. See authentication for other ways to configure credentials.
2. Install the SDK
In a Node.js project, install Eventlayer and a TypeScript runner:
npm install eventlayer
npm install --save-dev tsxIf you are starting in an empty directory, run npm init -y first.
3. Create the event, attendee and ticket
Save this complete example as first-ticket.ts. Each call uses the IDs returned
by the previous one. The SDK reads EVENTLAYER_KEY from your environment.
import { Eventlayer } from "eventlayer";
// Avoid automatically repeating resource creation if a response is lost.
const eventlayer = new Eventlayer(undefined, { maxRetries: 0 });
async function main() {
const { data: event, error: eventError } = await eventlayer.events.create({
name: "After Hours",
startAt: {
utc: "2026-11-07T08:00:00Z",
timezone: "Australia/Sydney",
},
location: "Machine Hall, Sydney",
});
if (eventError) throw eventError;
console.log("Event:", event.id);
const { data: attendee, error: attendeeError } =
await eventlayer.attendees.create({
eventId: event.id,
name: "Maya Chen",
email: "maya@example.com",
});
if (attendeeError) throw attendeeError;
console.log("Attendee:", attendee.id);
const { data: ticket, error: ticketError } = await eventlayer.tickets.create({
eventId: event.id,
attendeeId: attendee.id,
});
if (ticketError) throw ticketError;
console.log("Ticket:", ticket.id, ticket.status);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});Eventlayer creates a default General Admission ticket type with the event,
so this example does not need a ticketTypeId. The supplied time is 19:00 in
Sydney. See event time for UTC and timezone handling.
Run the script:
npx tsx first-ticket.ts4. Check the result
Your output will look like this, with different IDs:
Event: ev_…
Attendee: atd_…
Ticket: tkt_… assignedThis script creates new resources each time it runs. Creating an event does not publish a public event page; your website or app supplies that experience.
If a request fails
The SDK returns HTTP failures in error; network failures throw. An API error
includes a requestId to help you investigate. See errors.
The three writes are separate operations. If a later step fails, inspect the IDs already printed and resume from that step. If a request timed out, check whether the resource exists before creating it again. The registration guide covers saving progress and recovering safely in your application.