Create an event promo code
Codes are normalized to uppercase and percentages cannot exceed 100. Omitted fields are preserved when updating. Requires the event management capability; all referenced records must belong to this event and organization.
curl --request POST \
--url https://api.gratona.com/v1/admin/events/{eventId}/promo-codes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "Example",
"type": "percent",
"value": 1,
"max_redemptions": 1,
"per_order_limit": 1,
"starts_at": "2026-12-20T18:00:00Z",
"ends_at": "2026-12-20T18:00:00Z",
"ticket_type_ids": [
1
],
"sponsor_package_ids": [
1
],
"is_active": false
}
'import requests
url = "https://api.gratona.com/v1/admin/events/{eventId}/promo-codes"
payload = {
"code": "Example",
"type": "percent",
"value": 1,
"max_redemptions": 1,
"per_order_limit": 1,
"starts_at": "2026-12-20T18:00:00Z",
"ends_at": "2026-12-20T18:00:00Z",
"ticket_type_ids": [1],
"sponsor_package_ids": [1],
"is_active": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: 'Example',
type: 'percent',
value: 1,
max_redemptions: 1,
per_order_limit: 1,
starts_at: '2026-12-20T18:00:00Z',
ends_at: '2026-12-20T18:00:00Z',
ticket_type_ids: [1],
sponsor_package_ids: [1],
is_active: false
})
};
fetch('https://api.gratona.com/v1/admin/events/{eventId}/promo-codes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gratona.com/v1/admin/events/{eventId}/promo-codes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => 'Example',
'type' => 'percent',
'value' => 1,
'max_redemptions' => 1,
'per_order_limit' => 1,
'starts_at' => '2026-12-20T18:00:00Z',
'ends_at' => '2026-12-20T18:00:00Z',
'ticket_type_ids' => [
1
],
'sponsor_package_ids' => [
1
],
'is_active' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gratona.com/v1/admin/events/{eventId}/promo-codes"
payload := strings.NewReader("{\n \"code\": \"Example\",\n \"type\": \"percent\",\n \"value\": 1,\n \"max_redemptions\": 1,\n \"per_order_limit\": 1,\n \"starts_at\": \"2026-12-20T18:00:00Z\",\n \"ends_at\": \"2026-12-20T18:00:00Z\",\n \"ticket_type_ids\": [\n 1\n ],\n \"sponsor_package_ids\": [\n 1\n ],\n \"is_active\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.gratona.com/v1/admin/events/{eventId}/promo-codes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"Example\",\n \"type\": \"percent\",\n \"value\": 1,\n \"max_redemptions\": 1,\n \"per_order_limit\": 1,\n \"starts_at\": \"2026-12-20T18:00:00Z\",\n \"ends_at\": \"2026-12-20T18:00:00Z\",\n \"ticket_type_ids\": [\n 1\n ],\n \"sponsor_package_ids\": [\n 1\n ],\n \"is_active\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gratona.com/v1/admin/events/{eventId}/promo-codes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"Example\",\n \"type\": \"percent\",\n \"value\": 1,\n \"max_redemptions\": 1,\n \"per_order_limit\": 1,\n \"starts_at\": \"2026-12-20T18:00:00Z\",\n \"ends_at\": \"2026-12-20T18:00:00Z\",\n \"ticket_type_ids\": [\n 1\n ],\n \"sponsor_package_ids\": [\n 1\n ],\n \"is_active\": false\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 1,
"client_id": 1,
"event_id": 1,
"code": "Example",
"type": "Example",
"value": "25.00",
"max_redemptions": 1,
"redemptions_count": 1,
"per_order_limit": 1,
"starts_at": "2026-10-20T12:00:00Z",
"ends_at": "2026-10-20T12:00:00Z",
"ticket_type_ids": [
1
],
"sponsor_package_ids": [
1
],
"is_active": false,
"created_at": "2026-10-20T12:00:00Z",
"updated_at": "2026-10-20T12:00:00Z",
"deleted_at": "2026-10-20T12:00:00Z"
}
}{
"message": "Something went wrong. Please try again.",
"status": "error",
"error": "invalid_request",
"code": "DONOR_NOT_FOUND"
}{
"message": "Something went wrong. Please try again.",
"status": "error",
"error": "invalid_request",
"code": "DONOR_NOT_FOUND"
}{
"message": "Not Found",
"status": "error"
}{
"errors": {},
"status": "error",
"message": "The given data was invalid."
}Authorizations
Passport bearer token authentication for legacy admin sessions.
Path Parameters
Record ID in the authenticated organization.
42
Body
Code.
80"Example"
Type.
percent, fixed, free, access, null "percent"
Value. Percent discounts cannot exceed 100 when type=percent is submitted.
x >= 01
Max redemptions.
x >= 11
Per order limit.
x >= 11
Starts at. Date without offset is interpreted in the event timezone.
"2026-12-20T18:00:00Z"
Ends at. Date without offset is interpreted in the event timezone.
"2026-12-20T18:00:00Z"
Ticket type ids.
*. Referenced record must belong to the authenticated organization and this event.
Sponsor package ids.
*. Referenced record must belong to the authenticated organization and this event.
Is active.
false
Response
Create an event promo code completed.
Show child attributes
Show child attributes
curl --request POST \
--url https://api.gratona.com/v1/admin/events/{eventId}/promo-codes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "Example",
"type": "percent",
"value": 1,
"max_redemptions": 1,
"per_order_limit": 1,
"starts_at": "2026-12-20T18:00:00Z",
"ends_at": "2026-12-20T18:00:00Z",
"ticket_type_ids": [
1
],
"sponsor_package_ids": [
1
],
"is_active": false
}
'import requests
url = "https://api.gratona.com/v1/admin/events/{eventId}/promo-codes"
payload = {
"code": "Example",
"type": "percent",
"value": 1,
"max_redemptions": 1,
"per_order_limit": 1,
"starts_at": "2026-12-20T18:00:00Z",
"ends_at": "2026-12-20T18:00:00Z",
"ticket_type_ids": [1],
"sponsor_package_ids": [1],
"is_active": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: 'Example',
type: 'percent',
value: 1,
max_redemptions: 1,
per_order_limit: 1,
starts_at: '2026-12-20T18:00:00Z',
ends_at: '2026-12-20T18:00:00Z',
ticket_type_ids: [1],
sponsor_package_ids: [1],
is_active: false
})
};
fetch('https://api.gratona.com/v1/admin/events/{eventId}/promo-codes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gratona.com/v1/admin/events/{eventId}/promo-codes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => 'Example',
'type' => 'percent',
'value' => 1,
'max_redemptions' => 1,
'per_order_limit' => 1,
'starts_at' => '2026-12-20T18:00:00Z',
'ends_at' => '2026-12-20T18:00:00Z',
'ticket_type_ids' => [
1
],
'sponsor_package_ids' => [
1
],
'is_active' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gratona.com/v1/admin/events/{eventId}/promo-codes"
payload := strings.NewReader("{\n \"code\": \"Example\",\n \"type\": \"percent\",\n \"value\": 1,\n \"max_redemptions\": 1,\n \"per_order_limit\": 1,\n \"starts_at\": \"2026-12-20T18:00:00Z\",\n \"ends_at\": \"2026-12-20T18:00:00Z\",\n \"ticket_type_ids\": [\n 1\n ],\n \"sponsor_package_ids\": [\n 1\n ],\n \"is_active\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.gratona.com/v1/admin/events/{eventId}/promo-codes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"Example\",\n \"type\": \"percent\",\n \"value\": 1,\n \"max_redemptions\": 1,\n \"per_order_limit\": 1,\n \"starts_at\": \"2026-12-20T18:00:00Z\",\n \"ends_at\": \"2026-12-20T18:00:00Z\",\n \"ticket_type_ids\": [\n 1\n ],\n \"sponsor_package_ids\": [\n 1\n ],\n \"is_active\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gratona.com/v1/admin/events/{eventId}/promo-codes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"Example\",\n \"type\": \"percent\",\n \"value\": 1,\n \"max_redemptions\": 1,\n \"per_order_limit\": 1,\n \"starts_at\": \"2026-12-20T18:00:00Z\",\n \"ends_at\": \"2026-12-20T18:00:00Z\",\n \"ticket_type_ids\": [\n 1\n ],\n \"sponsor_package_ids\": [\n 1\n ],\n \"is_active\": false\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 1,
"client_id": 1,
"event_id": 1,
"code": "Example",
"type": "Example",
"value": "25.00",
"max_redemptions": 1,
"redemptions_count": 1,
"per_order_limit": 1,
"starts_at": "2026-10-20T12:00:00Z",
"ends_at": "2026-10-20T12:00:00Z",
"ticket_type_ids": [
1
],
"sponsor_package_ids": [
1
],
"is_active": false,
"created_at": "2026-10-20T12:00:00Z",
"updated_at": "2026-10-20T12:00:00Z",
"deleted_at": "2026-10-20T12:00:00Z"
}
}{
"message": "Something went wrong. Please try again.",
"status": "error",
"error": "invalid_request",
"code": "DONOR_NOT_FOUND"
}{
"message": "Something went wrong. Please try again.",
"status": "error",
"error": "invalid_request",
"code": "DONOR_NOT_FOUND"
}{
"message": "Not Found",
"status": "error"
}{
"errors": {},
"status": "error",
"message": "The given data was invalid."
}