swarmtix_access_codes_create
Creates an access code that unlocks a hidden ticket type, at its normal price
swarmtix_access_codes_create
Creates an access code for a hidden ticket type and returns it. Buyers who type the code at checkout can see and buy that ticket type, at its normal price. An access code takes nothing off the price.
When you would reach for it
- A members-only or VIP ticket that should not be visible to everyone.
- A speaker or partner ticket you send to specific people.
Scope
discounts:write
Calling this twice creates two codes. It is not idempotent. Check swarmtix_discounts_list before retrying a call that timed out.
Before you start
The ticket type must have requiresAccessCode set. Set it when you create the ticket type with swarmtix_ticket_types_create, or change it with swarmtix_ticket_types_update. A hidden ticket with no access code cannot be bought by anyone, and swarmtix_event_readiness warns about it.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
event | string | Yes | - | The event's id (a GUID) or its URL slug. |
code | string | Yes | - | The code a buyer types. Letters, digits, dots, dashes and underscores, up to 100 characters. |
ticketType | string | Yes | - | The id of the hidden ticket type this code unlocks. |
endsAt | string | Yes | - | When the code stops being accepted, ISO 8601, read as UTC when no offset is given. |
startsAt | string | No | now | When the code starts being accepted. |
usesLimit | integer | No | no limit | How many times in total the code may be used. 1 to 1,000,000. |
startsAt and endsAt are read as UTC and stored in the event's local time, using the event's timezone.
Example call
{
"name": "swarmtix_access_codes_create",
"arguments": {
"event": "spring-summit-2027",
"code": "VIPLOUNGE",
"ticketType": "b7d3e5a1-92c4-4f18-8a6b-3e0f1c7d9a52",
"endsAt": "2027-11-03T12:00:00Z",
"usesLimit": 25
}
}What comes back
The code as stored, in the same shape as swarmtix_discounts_create returns, with kind set to "accessCode", amountOff and percentageOff both 0, and ticketTypeId set to the ticket type it unlocks.
Troubleshooting
"ticketType is not valid: ..."
The ticket type is not on this event, or it does not have requiresAccessCode set. Set it first.
"code is not valid: it contains " ". Expected a code of letters, digits, dots, dashes or underscores."
Use letters, digits, ., - and _ only.
"endsAt is not valid: it is not after startsAt."
The window has no length. endsAt must be after the start.
Use cases
- VIP tickets unlocked by a code you send
- Partner tickets with a usage limit