Building a ticketing system

Hi all!

I’m trying to build an e-commerce site that sells tickets to events, and need a little help getting over the line with Strapi.

I have two collections, one for the Events, and one for Tickets. They have a many-to-one relationship set up, and I can’t work out how to write the controller logic to allocate tickets to an event in a rising numerical order when the ticket API receives a POST from my headless e-commerce solution.

Effectively, the flow I’m trying to create is:

User selects ticket quantity and checks out → e-commerce solution sends web hook POST with checkout details (customer email, event purchased, quantity of tickets etc) → Strapi receives this, and creates the tickets.

In my head this sounds doable but I can’t figure it out. Can anyone give me a little help?