Customer Data
Use DOM Package helpers for profile, order, booking, enquiry, receipt, and company data
Customer Data
After a customer signs in, the DOM Package can call Customer API endpoints on their behalf. These helpers add the authentication headers and handle token refresh automatically.
Created and First Active
The customer returned by getUser(), authentication state callbacks, and profile create or update responses includes two read-only system timestamps in DOM Package 1.6.2 and newer:
const session = await tiquo.getUser();
const customer = session?.customer;
if (customer) {
console.log(customer.createdAt); // number | undefined
console.log(customer.firstActiveAt); // number | undefined
const created = customer.createdAt
? new Date(customer.createdAt)
: undefined;
const firstActive = customer.firstActiveAt
? new Date(customer.firstActiveAt)
: undefined;
}| Field | Type | Definition |
|---|---|---|
createdAt | readonly number | undefined | Unix timestamp in milliseconds for when the customer profile was created |
firstActiveAt | readonly number | undefined | Unix timestamp in milliseconds for the customer's first qualifying activity; absent until activity exists |
Created and First Active are separate values. Customer activity never changes or backdates createdAt. firstActiveAt is not the database insertion time, and activities performed by staff, systems, integrations, or imports do not set it.
The values are equal when a customer creates their own account and is immediately active in the same flow. An imported or staff-created profile can have a later First Active timestamp, or no value until the customer becomes active.
Both fields use Unix milliseconds and do not include a display timezone. Convert them with new Date(timestamp) and format them using the venue or customer's timezone. They cannot be changed with updateProfile(); the SDK strips both keys if untyped JavaScript supplies them dynamically.
Updating the Customer Profile
await tiquo.updateProfile({
firstName: 'John',
lastName: 'Smith',
phone: '+1234567890',
});This calls the Update Profile endpoint under the hood.
Only editable profile fields should be passed to updateProfile(). createdAt and firstActiveAt are system-managed and read-only.
Profile photos can be passed as a hosted URL, a browser File or Blob, or a data:image/... or blob:... URI.
const file = fileInput.files?.[0];
if (file) {
await tiquo.updateProfile({
profilePhoto: file,
});
}You can also upload only the profile photo:
await tiquo.uploadProfilePhoto(file);When a file or blob is provided, the SDK requests a secure upload URL, uploads the image to Tiquo storage, then saves the resulting image URL on the authenticated customer's profile.
Fetching Customer Data
The SDK provides convenience methods for the Customer API list endpoints:
// Get order history
const orders = await tiquo.getOrders();
// Get booking history
const bookings = await tiquo.getBookings();
// Get upcoming bookings only
const upcoming = await tiquo.getUpcomingBookings();
// Get enquiry history
const enquiries = await tiquo.getEnquiries();
// Get companies the customer belongs to
const companies = await tiquo.getCompanies();Creating Enquiries
Use createEnquiry() to submit an enquiry from a public website. If the visitor is already authenticated, the enquiry is linked to their customer profile. If not, Tiquo uses the public key and Website SDK website-domain configuration to accept the submission, find or create the customer by email, and attach the enquiry.
const result = await tiquo.createEnquiry({
customer: {
email: 'customer@example.com',
firstName: 'John',
lastName: 'Smith',
phone: '+44 7911 123456',
},
enquiry: {
subject: 'Private event enquiry',
message: 'I would like to book a private event for 40 guests.',
source: 'website',
},
});
console.log(result.enquiry.id);customer.email is required. The enquiry must include either enquiry.message or enquiry.subject.
Receipts
Use getReceipt() to retrieve a printable receipt payload for an order owned by the authenticated customer.
const receipt = await tiquo.getReceipt('order_123');Receipts are available for orders that have been paid, refunded, or completed. Draft and pending orders do not have customer receipts yet.
Booking Tickets
Bookings include a ticketing object when ticket settings are available for the booking's sublocation.
const { bookings } = await tiquo.getUpcomingBookings();
const booking = bookings[0];
if (booking?.ticketing.qrCodeTicketsEnabled) {
const ticketPdf = await tiquo.downloadBookingTicket(booking.id);
}When wallet tickets are enabled, the booking also includes wallet links:
const walletUrl = booking.ticketing.walletTicketUrl;
const appleWalletUrl = booking.ticketing.appleWalletTicketUrl;
const googleWalletUrl = booking.ticketing.googleWalletTicketUrl;Company Memberships
Use getCompanies() to show the authenticated customer's company memberships.
const { companies } = await tiquo.getCompanies();
for (const company of companies) {
console.log(company.name, company.membership.relationship);
}Each company includes the customer's membership details, including whether the customer is a company admin.
Company admins can call getCompanyColleagues() to retrieve basic contact-card information for colleagues in the same company.
const company = companies.find((item) => item.membership.isCompanyAdmin);
if (company) {
const { colleagues } = await tiquo.getCompanyColleagues(company.id);
console.log(colleagues);
}If the authenticated customer is not a company admin for that company, the request returns a permissions error.