Moshtix Developer Documentation

Moshtix Developer Documentation

  • Docs
  • API Playground
  • Terms Of Use
  • Need Help?

›Getting Started

Getting Started

  • Our API
  • Authentication
  • Queries
  • Mutations
  • Dates
  • Currency
  • Images
  • Errors
  • Webhooks
  • Widgets

Mutations

Mutations

Similarly to how queries specify only the data they need to be included in a response, when mutating (making changes to) objects, you only need to provide the objects and attributes that you want to change, rather than the entire object. This means less complexity for client applications, and smaller request payloads compared to a traditional API.

The example below domonstrates how to create a GA event with some discounted tickets via offer code, plus hidden VIP tickets that can be revealed using an offer code. All tickets in this event draw from the same allocation, which matches the imaginary venue capacity.

import fetch from 'node-fetch';

const execute = async () => {
  const query = `
    mutation {
      viewer(token: "your-token-here") {
        saveEvent(event: {
          id: null,
          approved: false,
          client: {
            id: 6080
          },
          useLatestEditor: true,
          name: "Test API Event",
          teaser: "This event is only a test event.",
          description: "<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam."
          announcementDate: "2021-10-24T23:30:00.000Z",
          startDate: "2023-12-31T22:30:00.000Z",
          endDate: "2023-12-31T23:30:00.000Z",
          venue: { id: 274 },
          category: {
            id: 5
          }
          genre: null
          ticketsRequireAttendeeName: false,
          ticketsRequireAttendeeDob: false,
          ticketsRequireAttendeeEmail: false,
          ticketsRequireAttendeePhone: false,
          ticketsRequireAttendeePostcode: false,
          orderRequiresDob: false,
          orderRequiresGender: false,
          orderRequiresLocation: false,
          allocationGroupsEnabled: true,
          maxTicketsPerCustomer: 10,
          maxTicketsPerOrder: 30,
          allocationGroups: {
            items: [
              {
                id: -1,
                name: "Total venue capacity",
                quantity: 12000
              }
            ]
          }
          ticketTypes: {
            items: [
              {
                id: -1
                name: "General admission",
                ticketPrice: 30.99,
                salesStartDate: "2021-10-24T23:30:00.000Z",
                salesCloseDate: "2023-12-31T23:30:00.000Z",
                minPerOrder: 0,
                maxPerOrder: 10,
                increment: 1,
                maxPerCustomer: 30,
                allocationGroup: {
                  id: -1
                }
              },
              {
                id: -2
                name: "VIP admission",
                ticketPrice: 40.99,
                salesStartDate: "2021-10-24T23:30:00.000Z",
                salesCloseDate: "2023-12-31T23:30:00.000Z",
                minPerOrder: 0,
                maxPerOrder: 10,
                increment: 1,
                maxPerCustomer: 30,
                hidden: true,
                allocationGroup: {
                  id: -1
                }
              },
            ],
          },
          offerCodes: {
            items: [
              {
                id: -1
                offerStartDate: "2021-10-24T23:30:00.000Z",
                offerEndDate: "2023-12-31T23:30:00.000Z",
                allowEarlyPurchase: false,
                revealHiddenTicket: true,
                codes: {
                  items: [
                    {
                      name: "VIPACCESSCODE",
                      quantity: 5000
                    }
                  ]
                },
                ticketTypes: {
                  items: [
                    {
                      quantity: null
                      ticketType: {
                        id: -2
                      }
                    }
                  ]

                }
              },
              {
                id: -2
                offerStartDate: "2021-10-24T23:30:00.000Z",
                offerEndDate: "2023-12-31T23:30:00.000Z",
                discountAmount: 5.00
                allowEarlyPurchase: false,
                revealHiddenTicket: false,
                codes: {
                  items: [
                    {
                      name: "GAMATESRATES",
                      quantity: 1000
                    }
                  ]
                },
                ticketTypes: {
                  items: [
                    {
                      quantity: null
                      ticketType: {
                        id: -1
                      }
                    }
                  ]
                },
              },
            ]
          }
        }) {
          id
          previewId
          venue {
            name
            address {
              region
            }
          }
          allocationGroups {
            items {
              name
              quantity
              remaining
              used
            }
          }
          ticketTypes {
            items {
              id
              name
              ticketPrice
              ticketOnlineFee
              ticketOnlinePrice
            }
          }
          offerCodes {
            items {
              codes {
                items {
                  name
                  eventCode
                  quantity
                  remaining
                  used
                }
              }
            }
          }
        }
      }
    }
  `;

  const response = await fetch('https://api.moshtix.com/v1/graphql', {
    method: 'POST',
    body: JSON.stringify({ query }),
    headers: { 'Content-Type': 'application/json' },
  });

  console.log(JSON.stringify(await response.json()));
};

execute();

Note above that mutations also define a query of the object you are creating. So in one single request we are able to create the event with all of it's associated objects (i.e. ticket types, offer codes etc.) and return information about the new event (including system generated ID's).

Once the object has been created with all the required fields we can change specific fields by providing only the ID of the object we want to change, and the specific details of the fields we want to change.

The query below will rename the event, and reduce the price of the General Admission ticket, assuming you change the ID's to match the ID's for your test event.

mutation {
  viewer(token: "your-token-here") {
    saveEvent(event: {
      id: 132264,
      name: "Test API Event - Renamed",
      ticketTypes: {
        items: [
          {
            id: 360777
            ticketPrice: 20.99,
            },
        ],
      },
    }) {
      id
      name
      ticketTypes {
        items {
          id
          name
          ticketPrice
          ticketOnlineFee
          ticketOnlinePrice
        }
      }
    }
  }
}

Associated Object

Negative ID's are used to express relationships between objects that haven't been created yet.

Removing/Deleting an Object

Where it's possible to remove an object (e.g. a ticket type from an event), a 'remove' field is available, which should be set to true in a mutation if you want to remove the object.

The query below will remove the ticket type with the matching ID, so long as it hasn't sold tickets.

mutation {
  viewer(token: "your-token-here") {
    saveEvent(event: {
      id: 132264,
      ticketTypes: {
        items: [
          {
            id: 360779
            remove: true
            },
        ],
      },
    }) {
      id
      ticketTypes {
        items {
          id
          name
          ticketPrice
          ticketOnlineFee
          ticketOnlinePrice
        }
      }
    }
  }
}

Bulk Offer Codes

Moshtix can import bulk codes for a single offer, but the API cannot currently upload or interact with them. Please use the chat/message feature of this website to get in touch with our developers, contact client services using the details on the menu in the Moshtix Control Room website.

Ticket Type Fees

Moshtix fee structures are tiered based on the base price of a ticket e.g. the fees for a $10 ticket might be different to the fees to a $100 ticket, or a $500 ticket.

When setting the prices for tickets in our API, the base price must be provided, which then has fees added to it, which ultimately results in a total ticket price for customers.

It's important to note then that some total ticket prices are not possible due to the total ticket price falling within an impossible gap, where if you lower the base price, the fees take the total above your target, and if you increase the base price you tip into the upper tier, and also exceed the target total. In this scenario the solution is to choose a different target price, or negotiate with your account manager to see if there is a way to adjust the fee structure on your account to solve the problem.

There is an API method that can assist with calculating ticket type fees prior to creating tickets, which is demonstrated in the query below.

Assuming the target total ticket price is $20 you can use this method to calculate the base price that should be used when creating the ticket.

query {
  viewer(token: "your-token-here") {
    getTicketFees(clientId: 6080, ticketPrice: 20, hard: false) {
      feeTotal
      basePrice
      ticketPrice
    }
  }
}

Will produce a response much like the following:

{
  "data": {
    "viewer": {
      "getTicketFees": {
        "feeTotal": 2.02,
        "basePrice": 17.98,
        "ticketPrice": 20
      }
    }
  }
}

So in this scenario $19.98 should be used to create a ticket type that will be dispayed to the customer as $20.

← QueriesDates →
  • Mutations
  • Associated Object
  • Removing/Deleting an Object
  • Bulk Offer Codes
  • Ticket Type Fees
Copyright © 2025 Moshtix Pty Ltd