curl -X POST "https://api.playground.try.be/shop/voucher-types?site_id=site_abc123" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "£50 Gift Voucher",
"description": "A £50 gift voucher to spend on any treatment or retail item at our spa.",
"product_code": "VOU-GIFT-50",
"external_id": "ext-gift-50",
"image_id": "5f1234567890abcdef123456",
"recipient_message": "<p>Enjoy your gift! Spend it on anything you like at our spa.</p>\n",
"amount_type": "cash",
"amount": 5000,
"customisable_amount": false,
"partially_redeemable": true,
"valid_weekdays": [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday"
],
"invalid_date_set_ids": [
"64a9f3b2c3d8e1f4a5b6c7d8"
],
"valid_offerings": [
{
"offering_id": "64a9f3b2c3d8e1f4a5b6c7d8",
"offering_name": "Twilight massage",
"offering_type": "appointment"
}
],
"invalid_offerings": [
{
"offering_id": "64a9f3b2c3d8e1f4a5b6c7d8",
"offering_name": "Twilight massage",
"offering_type": "appointment"
}
],
"default_validity_interval": "P1Y",
"offered_online": true,
"private": false,
"visibility": "public",
"members_only": false,
"permitted_membership_type_ids": [
"00000000-0000-0000-0000-000000000000"
],
"category_ids": [
"64a9f3b2c3d8e1f4a5b6c7d8"
],
"currency": "gbp"
}'
const response = await fetch('https://api.playground.try.be/shop/voucher-types?site_id=site_abc123', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({
"name": "£50 Gift Voucher",
"description": "A £50 gift voucher to spend on any treatment or retail item at our spa.",
"product_code": "VOU-GIFT-50",
"external_id": "ext-gift-50",
"image_id": "5f1234567890abcdef123456",
"recipient_message": "<p>Enjoy your gift! Spend it on anything you like at our spa.</p>\n",
"amount_type": "cash",
"amount": 5000,
"customisable_amount": false,
"partially_redeemable": true,
"valid_weekdays": [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday"
],
"invalid_date_set_ids": [
"64a9f3b2c3d8e1f4a5b6c7d8"
],
"valid_offerings": [
{
"offering_id": "64a9f3b2c3d8e1f4a5b6c7d8",
"offering_name": "Twilight massage",
"offering_type": "appointment"
}
],
"invalid_offerings": [
{
"offering_id": "64a9f3b2c3d8e1f4a5b6c7d8",
"offering_name": "Twilight massage",
"offering_type": "appointment"
}
],
"default_validity_interval": "P1Y",
"offered_online": true,
"private": false,
"visibility": "public",
"members_only": false,
"permitted_membership_type_ids": [
"00000000-0000-0000-0000-000000000000"
],
"category_ids": [
"64a9f3b2c3d8e1f4a5b6c7d8"
],
"currency": "gbp"
}),
})
if (!response.ok) {
throw new Error(`Trybe API ${response.status}: ${await response.text()}`)
}
const data = await response.json()
import httpx
response = httpx.post(
"https://api.playground.try.be/shop/voucher-types?site_id=site_abc123",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Accept": "application/json",
"Content-Type": "application/json",
},
json={
"name": "£50 Gift Voucher",
"description": "A £50 gift voucher to spend on any treatment or retail item at our spa.",
"product_code": "VOU-GIFT-50",
"external_id": "ext-gift-50",
"image_id": "5f1234567890abcdef123456",
"recipient_message": "<p>Enjoy your gift! Spend it on anything you like at our spa.</p>\n",
"amount_type": "cash",
"amount": 5000,
"customisable_amount": False,
"partially_redeemable": True,
"valid_weekdays": [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday"
],
"invalid_date_set_ids": [
"64a9f3b2c3d8e1f4a5b6c7d8"
],
"valid_offerings": [
{
"offering_id": "64a9f3b2c3d8e1f4a5b6c7d8",
"offering_name": "Twilight massage",
"offering_type": "appointment"
}
],
"invalid_offerings": [
{
"offering_id": "64a9f3b2c3d8e1f4a5b6c7d8",
"offering_name": "Twilight massage",
"offering_type": "appointment"
}
],
"default_validity_interval": "P1Y",
"offered_online": True,
"private": False,
"visibility": "public",
"members_only": False,
"permitted_membership_type_ids": [
"00000000-0000-0000-0000-000000000000"
],
"category_ids": [
"64a9f3b2c3d8e1f4a5b6c7d8"
],
"currency": "gbp"
},
)
response.raise_for_status()
data = response.json()
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.playground.try.be/shop/voucher-types?site_id=site_abc123', [
'headers' => [
'Authorization' => 'Bearer YOUR_API_KEY',
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'json' => [
'name' => '£50 Gift Voucher',
'description' => 'A £50 gift voucher to spend on any treatment or retail item at our spa.',
'product_code' => 'VOU-GIFT-50',
'external_id' => 'ext-gift-50',
'image_id' => '5f1234567890abcdef123456',
'recipient_message' => '<p>Enjoy your gift! Spend it on anything you like at our spa.</p>
',
'amount_type' => 'cash',
'amount' => 5000,
'customisable_amount' => false,
'partially_redeemable' => true,
'valid_weekdays' => [
'monday',
'tuesday',
'wednesday',
'thursday',
'friday'
],
'invalid_date_set_ids' => [
'64a9f3b2c3d8e1f4a5b6c7d8'
],
'valid_offerings' => [
[
'offering_id' => '64a9f3b2c3d8e1f4a5b6c7d8',
'offering_name' => 'Twilight massage',
'offering_type' => 'appointment'
]
],
'invalid_offerings' => [
[
'offering_id' => '64a9f3b2c3d8e1f4a5b6c7d8',
'offering_name' => 'Twilight massage',
'offering_type' => 'appointment'
]
],
'default_validity_interval' => 'P1Y',
'offered_online' => true,
'private' => false,
'visibility' => 'public',
'members_only' => false,
'permitted_membership_type_ids' => [
'00000000-0000-0000-0000-000000000000'
],
'category_ids' => [
'64a9f3b2c3d8e1f4a5b6c7d8'
],
'currency' => 'gbp'
],
]);
$data = json_decode($response->getBody(), true);
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
payload, _ := json.Marshal(map[string]interface{}{
"name": "£50 Gift Voucher",
"description": "A £50 gift voucher to spend on any treatment or retail item at our spa.",
"product_code": "VOU-GIFT-50",
"external_id": "ext-gift-50",
"image_id": "5f1234567890abcdef123456",
"recipient_message": "<p>Enjoy your gift! Spend it on anything you like at our spa.</p>\n",
"amount_type": "cash",
"amount": 5000,
"customisable_amount": false,
"partially_redeemable": true,
"valid_weekdays": []interface{}{
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
},
"invalid_date_set_ids": []interface{}{
"64a9f3b2c3d8e1f4a5b6c7d8",
},
"valid_offerings": []interface{}{
map[string]interface{}{
"offering_id": "64a9f3b2c3d8e1f4a5b6c7d8",
"offering_name": "Twilight massage",
"offering_type": "appointment",
},
},
"invalid_offerings": []interface{}{
map[string]interface{}{
"offering_id": "64a9f3b2c3d8e1f4a5b6c7d8",
"offering_name": "Twilight massage",
"offering_type": "appointment",
},
},
"default_validity_interval": "P1Y",
"offered_online": true,
"private": false,
"visibility": "public",
"members_only": false,
"permitted_membership_type_ids": []interface{}{
"00000000-0000-0000-0000-000000000000",
},
"category_ids": []interface{}{
"64a9f3b2c3d8e1f4a5b6c7d8",
},
"currency": "gbp",
})
req, _ := http.NewRequest("POST", "https://api.playground.try.be/shop/voucher-types?site_id=site_abc123", bytes.NewBuffer(payload))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var data map[string]interface{}
json.NewDecoder(resp.Body).Decode(&data)
}